Token Manipulation
This walkthrough covers the full Windows token workflow - from identifying a target identity to stealing its token, using it for operations, and reverting cleanly. Token-based impersonation avoids passing plaintext credentials and leaves a smaller footprint than run-as.
Prerequisites
- An active agent on a Windows machine
- A process running under the target identity is already present on the machine (for
token-steal) - OR valid credentials for the target user (for
token-make)
How Token Storage Works
The agent maintains an internal token store - a numbered list of Windows tokens it has collected or created. Commands that support impersonation (including lateral movement commands) use the currently applied token.
Workflow A - Steal a token from a running process
Step 1 - Find a process running as the target identity
Output:
Identify a process owned by CORP\Administrator - here PID 6240.
Step 2 - Enable SeDebugPrivilege (commercial payload only)
Stealing tokens from processes owned by other users requires elevated privileges. If running as a local admin but SeDebugPrivilege is not yet active:
Output:
Step 3 - Steal the token (it's automatically selected also)
Output:
Step 4 - Operate as the impersonated user
All subsequent commands now run under CORP\Administrator:
Output:
Step 5 - Revert to the original token
When done, restore the agent's default identity:
Workflow B - Create a token from credentials
Use this when you have plaintext credentials but no process running as that user is present on the machine.
Step 1 - Create the token
Output:
Info
netonly: true creates a token where the credentials are only used for network authentication - the local process identity stays unchanged. This is equivalent to runas /netonly and is useful for accessing network resources (SMB, LDAP, WinRM) without fully impersonating the user locally.
Cleanup
Remove tokens that are no longer needed:
Or clear the entire store:
Using Tokens with Lateral Movement
The jump-wmi, jump-service, and jump-winrm commands all respect the currently applied token. Instead of passing --username and --password, apply the token first:
See the Lateral Movement use case for a full walkthrough of this pattern.