| ID | Technique | Tactic |
|---|---|---|
| T1047 | Windows Management Instrumentation | Execution |
Detection: Windows WMI Impersonate Token
Description
The following analytic detects WMI token impersonation by identifying wmiprvse.exe requesting the query, VM, and duplicate-handle rights associated with WMI process access.
It leverages Sysmon EventCode 10 and checks for access masks that combine PROCESS_QUERY_INFORMATION (0x400), PROCESS_QUERY_LIMITED_INFORMATION (0x1000), PROCESS_VM_OPERATION (0x8), PROCESS_VM_READ (0x10), PROCESS_VM_WRITE (0x20), PROCESS_DUP_HANDLE (0x40), and PROCESS_ALL_ACCESS (0x1f3fff).
Search
1`sysmon`
2EventCode=10
3SourceImage="*\\wmiprvse.exe"
The 0x1478 mask combines query, VM, and duplicate-handle rights; The 0x1fffff mas is full process access. Additional requested rights are allowed.
1
2| eval g_access_decimal = tonumber(replace(GrantedAccess,"0x",""),16)
3
4| eval PROCESS_QUERY_INFORMATION = 1024
5
6| eval PROCESS_QUERY_LIMITED_INFORMATION = 4096
7
8| eval PROCESS_VM_OPERATION = 8
9
10| eval PROCESS_VM_READ = 16
11
12| eval PROCESS_VM_WRITE = 32
13
14| eval PROCESS_DUP_HANDLE = 64
15
16| eval WMI_REQUIRED_ACCESS = PROCESS_QUERY_INFORMATION + PROCESS_QUERY_LIMITED_INFORMATION + PROCESS_VM_OPERATION + PROCESS_VM_READ + PROCESS_VM_WRITE + PROCESS_DUP_HANDLE
17
18| eval PROCESS_ALL_ACCESS = 2097151
19
20| eval wmi_access_set = bit_and(g_access_decimal, WMI_REQUIRED_ACCESS)
21
22| eval full_access_set = bit_and(g_access_decimal, PROCESS_ALL_ACCESS)
23
24| where wmi_access_set == WMI_REQUIRED_ACCESS
25 OR full_access_set == PROCESS_ALL_ACCESS
26
27
28| stats count min(_time) as firstTime
29 max(_time) as lastTime
30 BY user_id dest
31 signature_id signature granted_access Opcode
32 SourceImage SourceProcessGUID SourceProcessId
33 TargetImage TargetProcessGUID TargetProcessId
34 CallTrace vendor_product
35
36
37| eval CallTrace=split(CallTrace, "
38|")
39
40
41| `security_content_ctime(firstTime)`
42
43| `security_content_ctime(lastTime)`
44
45| `windows_wmi_impersonate_token_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| Sysmon EventID 10 | 'XmlWinEventLog' |
'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational' |
Macros Used
| Name | Value |
|---|---|
| security_content_ctime | convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$) |
| windows_wmi_impersonate_token_filter | search * |
windows_wmi_impersonate_token_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
Default Configuration
This detection is configured by default in Splunk Enterprise Security to run with the following settings:
| Setting | Value |
|---|---|
| Disabled | true |
| Cron Schedule | 0 * * * * |
| Earliest Time | -70m@m |
| Latest Time | -10m@m |
| Schedule Window | auto |
| Creates Finding (Notable) | No |
| Creates Intermediate Finding (Risk Event) | Yes |
Implementation
This search requires Sysmon Logs and a Sysmon configuration, which includes EventCode 10. This search uses an input macro named sysmon. We strongly recommend that you specify your environment-specific configurations (index, source, sourcetype, etc.) for Windows Sysmon logs. Replace the macro definition with configurations for your Splunk environment. The search also uses a post-filter macro designed to filter out known false positives.
Known False Positives
administrator may execute impersonate wmi object script for auditing. Filter is needed.
Associated Analytic Story
Intermediate Findings
| Message | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| The [$SourceImage$] requested the access mask [$granted_access$] from [$TargetImage$] on [$dest$]. This may indicate WMI token impersonation. | dest | system | 20 |
Threat Objects
| Field | Type |
|---|---|
| SourceImage | file_path |
References
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | XmlWinEventLog:Microsoft-Windows-Sysmon/Operational |
XmlWinEventLog |
| Integration | ✅ Passing | Dataset | XmlWinEventLog:Microsoft-Windows-Sysmon/Operational |
XmlWinEventLog |
Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI.
Alternatively you can replay a dataset into a Splunk Attack Range
Source: GitHub |
Version: 11