Make and Impersonate Token
Adversaries may make new tokens and impersonate users to escalate privileges and bypass access controls. If an adversary has a username and password but the user is not logged onto the system, the adversary can create a logon session for the user using the LogonUser function. The function returns a copy of the new session's access token, which the adversary can use with SetThreadToken to assign to a thread. This is distinct from Token Impersonation/Theft (T1134.001) because it creates a new user token rather than stealing or duplicating an existing one. Real-world threat actors including Cobalt Strike operators (make_token), FIN13 (Incognito V2), BlackByte, SILENTTRINITY, and the Mafalda implant use this technique to escalate privileges or move laterally using known credentials without spawning a new interactive session visible to the target user.
// Branch 1: NewCredentials logon type (LogonType=9) — primary indicator of LogonUser API usage
// LogonType 9 is specifically generated when LogonUser() is called with LOGON32_LOGON_NEW_CREDENTIALS
let SuspiciousCallers = dynamic(["cmd.exe", "powershell.exe", "pwsh.exe", "mshta.exe", "wscript.exe", "cscript.exe", "rundll32.exe", "regsvr32.exe", "msbuild.exe"]);
let TokenTools = dynamic(["incognito", "make_token", "invoke-tokenmanipulation", "logonuserw", "logonusera", "tokenvator", "LOGON32_LOGON_NEW_CREDENTIALS", "SetThreadToken", "ImpersonateLoggedOnUser"]);
SecurityEvent
| where TimeGenerated > ago(24h)
| where EventID == 4624
| where LogonType == 9
| where AccountName !in ("", "-", "ANONYMOUS LOGON")
| where not(ProcessName has_any ("lsass.exe", "winlogon.exe", "services.exe", "svchost.exe"))
| where not(AccountName endswith "$") // Exclude machine accounts
| extend SuspiciousProcess = ProcessName has_any (SuspiciousCallers)
| extend LogonTypeName = "NewCredentials (Type 9) — LogonUser API"
| project TimeGenerated, Computer, EventID, LogonTypeName, AccountName, AccountDomain,
SubjectUserName, SubjectDomainName, ProcessName, IpAddress, IpPort,
LogonGuid, SuspiciousProcess
| union (
// Branch 2: Explicit credential logon (Event 4648) from interactive/scripting processes
SecurityEvent
| where TimeGenerated > ago(24h)
| where EventID == 4648
| where ProcessName has_any (SuspiciousCallers)
| where TargetUserName !in ("", "-")
| where not(SubjectUserName endswith "$") // Exclude machine accounts
| project TimeGenerated, Computer, EventID,
LogonTypeName = "Explicit Credentials (4648)",
AccountName = TargetUserName, AccountDomain = TargetDomainName,
SubjectUserName, SubjectDomainName,
ProcessName, IpAddress = TargetServerName, IpPort = "",
LogonGuid = TargetInfo, SuspiciousProcess = true
)
| union (
// Branch 3: Process creation with known token manipulation tool names or API call patterns
DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has_any (TokenTools)
or FileName has_any (["incognito.exe", "tokenvator.exe"])
| project TimeGenerated = Timestamp, Computer = DeviceName, EventID = 1,
LogonTypeName = "Token Manipulation Tool Execution",
AccountName, AccountDomain = "",
SubjectUserName = InitiatingProcessAccountName, SubjectDomainName = "",
ProcessName = FileName, IpAddress = "", IpPort = "",
LogonGuid = "", SuspiciousProcess = true
)
| sort by TimeGenerated desc Data Sources
Required Tables
False Positives
- runas /netonly used by IT administrators to run administrative tools under alternate domain credentials generates LogonType 9 events with ProcessName=runas.exe
- Password managers and enterprise SSO solutions that call LogonUser internally to validate credentials against Active Directory
- SCCM/ConfigMgr, Intune, or BigFix deployment agents that impersonate service account credentials when installing software
- Virtualization and remote desktop session brokers (Citrix Virtual Apps, VMware Horizon) that create logon sessions for session routing using stored credentials
- Custom line-of-business applications with embedded credential logic using SSPI/LogonUser for application-layer AD authentication
References (10)
- https://attack.mitre.org/techniques/T1134/003/
- https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-logonuserw
- https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreadtoken
- https://learn.microsoft.com/en-us/windows/win32/secauthz/access-tokens
- https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4624
- https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4648
- https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventid=4624
- https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-TokenManipulation.ps1
- https://www.cobaltstrike.com/blog/windows-access-tokens-and-alternate-credentials
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1134.003/T1134.003.md
Unlock Pro Content
Get the full detection package for T1134.003 including response playbook, investigation guide, and atomic red team tests.