Artifact Analysis: Windows Management Instrumentation (WMI)
1. WMI Architectural Overview
Section intitulée « 1. WMI Architectural Overview »To hunt for WMI abuse, analysts must understand its underlying architecture. WMI is not a single executable; it is a complex framework.
- The WMI Repository: A central database (
C:\Windows\System32\wbem\Repository) storing the definitions of all manageable system objects. - WMI Providers: Dynamic-Link Libraries (DLLs) that act as intermediaries between the WMI service and the actual OS components (e.g., a provider for processes, one for the registry, one for event logs).
- WMI Consumers: The interfaces or scripts that query the providers. Historically, the command-line tool
wmic.exewas heavily used. However, with Microsoft deprecatingwmicin modern Windows builds, threat actors have shifted almost entirely to PowerShell cmdlets (Get-WmiObject,Invoke-WmiMethod, and the newer CIM cmdlets likeGet-CimInstance).
2. Adversarial Abuse of WMI (TTPs)
Section intitulée « 2. Adversarial Abuse of WMI (TTPs) »Adversaries leverage WMI’s legitimate administrative capabilities across three distinct phases of the kill chain.
A. Reconnaissance (Discovery)
Section intitulée « A. Reconnaissance (Discovery) »WMI allows an attacker to map a system or a network without dropping any custom scanning tools.
wmic product get name,version(Enumerates installed software/antivirus).wmic process list brief(Lists running processes).wmic qfe get hotfixid(Identifies installed security patches to find missing CVEs).
B. Lateral Movement (Execution)
Section intitulée « B. Lateral Movement (Execution) »WMI is the stealthiest alternative to PsExec and SMB-based lateral movement. If an attacker possesses local administrator credentials for a target machine, they can use WMI to remotely spawn a process.
- The Attack:
wmic /node:"TARGET-PC" process call create "cmd.exe /c powershell.exe -enc <payload>" - Forensic Implication: Unlike PsExec, which drops a highly visible service (
PSEXESVC), WMI remote execution leverages the native WMI Provider Host (WmiPrvSE.exe).
C. Fileless Persistence (Event Subscriptions)
Section intitulée « C. Fileless Persistence (Event Subscriptions) »This is WMI’s most dangerous capability. Attackers can configure WMI to act as an autonomous trigger for malicious code, creating persistence that survives reboots without touching traditional registry run keys or Startup folders.
This technique requires the creation of the WMI Trio:
- Event Filter: The trigger condition (e.g., “Wait until system uptime is 5 minutes” or “Wait until user Admin logs in”).
- Event Consumer: The action to take when the filter triggers. Attackers typically use the
CommandLineEventConsumer(to run a script) or theActiveScriptEventConsumer(to execute VBScript/JScript entirely in memory). - FilterToConsumerBinding: The logical link connecting the trigger (Filter) to the action (Consumer).
3. DFIR Investigation & Telemetry
Section intitulée « 3. DFIR Investigation & Telemetry »Because WMI is a trusted system component, distinguishing administrative IT activity from malicious exploitation requires granular behavioral analysis.
A. Process Lineage Anomalies (Event 4688)
Section intitulée « A. Process Lineage Anomalies (Event 4688) »When an attacker uses WMI for lateral movement or persistence execution, the payload is spawned by the WMI Provider Host.
- Suspicious Lineage:
WmiPrvSE.exe→cmd.exeorpowershell.exe. - Legitimate IT management tools (like SCCM) may produce similar lineage, so analysts must scrutinize the
CommandLinearguments for obfuscation or anomalous network callbacks.
B. Sysmon Telemetry (The Ultimate Defense)
Section intitulée « B. Sysmon Telemetry (The Ultimate Defense) »Microsoft explicitly designed Sysmon Event IDs 19, 20, and 21 to combat fileless WMI persistence. In a standard workstation environment, the creation of custom WMI event consumers is exceedingly rare.
- Event ID 19:
WmiEventFilter activity detected - Event ID 20:
WmiEventConsumer activity detected - Event ID 21:
WmiEventConsumerToFilter activity detected(The Binding)
C. Native WMI-Activity Logs
Section intitulée « C. Native WMI-Activity Logs »If Sysmon is not deployed, analysts must rely on the native WMI-Activity/Operational event log, which must be explicitly enabled and forwarded via GPO.
- Event ID 5861: Logs the creation of a WMI binding. This is the closest native equivalent to Sysmon ID 21 and a critical indicator of persistence establishment.
4. Threat Hunting Queries
Section intitulée « 4. Threat Hunting Queries »// Detects anomalous child processes spawned by the WMI Provider Host// indicating potential remote execution or persistence triggering.DeviceProcessEvents| where InitiatingProcessFileName =~ "wmiprvse.exe"// Target command shells and scripting engines| where FileName in~ ("cmd.exe", "powershell.exe", "pwsh.exe", "wscript.exe", "cscript.exe")// Filter out known IT management noise (Customize for your environment)| where ProcessCommandLine !contains "ccmsetup"| project TimeGenerated, DeviceName, InitiatingProcessAccountName, InitiatingProcessFileName, FileName, ProcessCommandLine| sort by TimeGenerated desctitle: WMI Fileless Persistence (Sysmon 21)id: 1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6dstatus: stabledescription: Detects the creation of a WmiEventConsumerToFilter binding, the final step in establishing WMI-based fileless persistence.logsource: product: windows category: wmi_eventdetection: selection: # Sysmon Event ID 21 EventID: 21 # Focus on common malicious consumer types Destination|contains: - 'CommandLineEventConsumer' - 'ActiveScriptEventConsumer' condition: selectionlevel: criticaltags: - attack.persistence - attack.privilege_escalation - attack.t1546.003References & Further Reading
Section intitulée « References & Further Reading »- MITRE ATT&CK: Event Triggered Execution: WMI Event Subscription (T1546.003)
- FireEye / Mandiant: WMI vs. WMI: Monitoring for Malicious Activity
- Related Playbook: Hunting for Persistence
- Related Artifact: Event ID 4688 (Process Creation)
- Related Artifact: Sysmon Telemetry