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_silentcleanup: meterpreter payloads don't work when the selected architecture isn't correct #12665

Closed
cnotin opened this issue Dec 5, 2019 · 0 comments

Comments

@cnotin
Copy link
Contributor

cnotin commented Dec 5, 2019

Steps to reproduce

  1. Obtain a x64 meterpreter session on a x64 Windows 10 host under an admin user but in a non-elevated context (because we want to bypass UAC)
  2. Use bypassuac_silentcleanup module with commands:
use exploits/windows/local/bypassuac_silentcleanup
set session 1
run

As we didn't select a payload, windows/meterpreter/reverse_tcp (-> x86) will be selected by default

Expected behavior

We get an elevated session. It should work even if the architecture is incorrect because the generated Powershell begins with an architecture detection gadget:

if([IntPtr]::Size -eq 4){$b='powershell.exe'}else{$b=$env:windir+'\syswow64\WindowsPowerShell\v1.0\powershell.exe'};

See https://github.com/rapid7/rex-powershell/blob/3e79abf73709c9be2e6796da29927aaa171e1405/lib/rex/powershell/command.rb#L238-L244

Current behavior

We don't get any elevated session because this UAC exploit messes with the %WINDIR% env variable (that's its goal!), so the architecture detection gadget fails to launch a new powershell.exe with the correct architecture for the payload, as it uses %WINDIR% in its path:

$env:windir+'\syswow64\WindowsPowerShell\v1.0\powershell.exe

Alternative solution: choosing the correct payload:

set payload windows/x64/meterpreter/reverse_tcp

System stuff

Metasploit version

Framework: 5.0.62-dev
Console : 5.0.62-dev

I installed Metasploit with:

Kali package

OS

Kali

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

No branches or pull requests

2 participants