Add WinRM PowerShell session support#21402
Open
karanabe wants to merge 1 commit intorapid7:masterfrom
Open
Conversation
Add a WinRM PowerShell session option to winrm_login while keeping the existing cmd session behavior as the default. Use a Rex-safe PowerShell shell wrapper to avoid upstream finalizers during Rex HTTP cleanup, and narrow cmd fallback handling so only CreateShell access denied triggers the auto PowerShell fallback.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a
SessionTypeoption toauxiliary/scanner/winrm/winrm_loginso successful WinRM logins can create either the existing cmd-backed shell, a PSRP-backed PowerShell session, or automatically fall back to PowerShell when cmd shell creation is denied.The default remains
cmd, so existing behavior is preserved unless the user opts intopowershellorauto.The PowerShell path uses a Rex-safe WinRM PowerShell shell wrapper to avoid upstream finalizers during Rex HTTP cleanup. The
autopath only falls back for cmd CreateShell /cmd.exeaccess denied errors.Verification
List the steps needed to make sure this thing works
msfconsoleuse scanner/winrm/winrm_loginTesting
SessionType=cmd (Default)
SessionType=powershell
SessionType=auto
WinRM PowerShell session interaction after login
WinRM PowerShell session upgrade
Code Testing
RSpec output
Rubocop output