Token Impersonation and Potato Attacks

What are Tokens?

Tokens are temporary keys that allow you access to a system/network without having to provide credentials each time you access a file. Think cookies for computers.

There are two types of tokens:

  • Delegate

    • Created for logging into a machine or using Remote Desktop

    • Commmon

  • Impersonate

    • "Non-interactive" such as attaching a network drive or a domain logon script

    • Less common

Enumeration

Check user privilege:

whoami /priv

If SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege is enabled, then the victim machine is vulnerable to token impersonation and Potato attack. For example:

SeImpersonatePrivilege enabled
  • Service accounts usually have SeImpersonatePrivilege / SeAssignPrimaryTokenPrivilege enabled.

  • User accounts usually have SeImpersonatePrivilege / SeAssignPrimaryTokenPrivilege disabled.

Token Impersonation (Meterpreter)

If we get a Meterpreter session, use the following commands to get SYSTEM shell:

Cheat Code: Potato Attacks

Many Windows machines are vulnerable to Potato Attacks, so I call this attack the "cheat code" in Windows privilege escalation.

For potato attacks, I recommend Lovely Potato which is an automated version of Juicy Potato. Here is the Github repo of Lovely Potato:

Lovely Potato

Setup:

Open Invoke-LovelyPotato.ps1 in text editor and modify these two variables:

In the directory /usr/share/windows-resources/Lovely-Potato/, create a msfvenom reverse shell payload:

Start a web server:

Start a listener:

On the Windows client, start a PowerShell and run Invoke-LovelyPotato.ps1 remotely via the DownloadString method:

For completeness, here is the content of the PowerShell script:

We can do this manually as well. On Kali, make sure your current working directory has the following files:

  • JuicyPotato-Static.exe

  • test_clsid.bat

  • meterpreter.exe

Now start a HTTP server on this directory. On Windows, transfer these three files:

Enumerate CLSIDs:

Find system CLSIDs:

Wait 10 minutes. Launch Juicy Potato:

Now we should get a SYSTEM reverse shell on Kali.

Last updated

Was this helpful?