MultiPotato: get SYSTEM via SeImpersonate privileges
This is just another Potato to get SYSTEM via SeImpersonate privileges. But this one is different in terms of
- It doesn’t contain any SYSTEM auth trigger for weaponization. Instead, the code can be used to integrate your favorite trigger by yourself.
- It’s not only using CreateProcessWithTokenW to spawn a new process. Instead, you can choose between CreateProcessWithTokenW, CreateProcessAsUserW, CreateUser and BindShell.
So this project is able to open up a NamedPipe Server, impersonates any user connecting to it, and afterward does one of the options mentioned above. If any new SYSTEM auth triggers are published in the future this tool can still be used to elevate privileges – you just need to use another Pipe-Name in this case.
- CreateUser with modified PetitPotam trigger:
c:\temp\MultiPotato> MultiPotato.exe -t CreateUser
You have by default value 60 seconds (changeable via THEAD_TIMEOUT) to let the SYSTEM account or any other account authenticate. This can be done for example via an unpatched MS-EFSRPC function. By default, MultiPotato listens on the pipename \\.\pipe\pwned/pipe/srvsvc which is meant to be used in combination with MS-EFSRPC. For other SYSTEM auth triggers, you can adjust this value via the -p parameter.
c:\temp\MultiPotato> PetitPotamModified.exe localhost/pipe/pwned localhost
Using PetitPotam.py as a trigger from a remote system with a valid low privileged user is of course also possible.
- CreateProcessAsUserW with SpoolSample trigger:
c:\temp\MultiPotato> MultiPotato.exe -t CreateProcessAsUserW -p “pwned\pipe\spoolss” -e “C:\temp\stage2.exe”
And trigger it via
c:\temp\MultiPotato>MS-RPRN.exe \188.8.131.52 \184.108.40.206/pipe/pwned
Important: In my testings for MS-RPRN I could not use localhost or 127.0.0.1 as a target, this has to be the network IP-Adress or FQDN. In addition, the Printer Service needs to be enabled for this to work.
- BindShell with SpoolSample PipeName
c:\temp\MultiPotato> MultiPotato.exe -t BindShell -p "pwned\pipe\spoolss"
I recently had a penetration test, where I was able to pwn an MSSQL Server via SQL-Injection and XP_CMDShell. But all public Potatoes failed on this target system to elevate privileges from service-account to SYSTEM. The System auth trigger was not the problem – instead, CreateProcessWithTokenW failed all the time with NTSTATUS Code 5 – access is forbidden. This didn’t really make sense for me and may be an edge case. One reason for that could be the local endpoint protection which may have blocked the process creation after impersonating SYSTEM.
Therefore I searched for alternatives – and asked some people on Twitter about it. Again Credit to @splinter_code for explaining to me how to do it via CreateProcessAsUserW which worked fine on the pwned MSSQL server to get a SYSTEM C2-Callback.
Copyright (C) 2021