Detecting wmi persistence

From AgentFlocks/flocks · View interactive version

Detecting wmi persistence is an AI agent skill from the GitHub repository AgentFlocks/flocks. Detect WMI event subscription persistence by analyzing Sysmon Event IDs 19, 20, and 21 for malicious EventFilter, EventConsumer, and FilterToConsumerBinding creation.

How to use this skill

Skill file

Detecting WMI Persistence

When to Use

Prerequisites

Workflow

  1. Collect Telemetry: Parse Sysmon Event IDs 19 (WmiEventFilter), 20 (WmiEventConsumer), 21 (WmiEventConsumerToFilter).
  2. Identify Suspicious Consumers: Flag CommandLineEventConsumer and ActiveScriptEventConsumer types executing code.
  3. Analyze Event Filters: Examine WQL queries in EventFilters for process start triggers or timer-based execution.
  4. Correlate Bindings: Match FilterToConsumerBindings linking suspicious filters to consumers.
  5. Check Persistence Locations: Query WMI namespaces root\subscription and root\default for active subscriptions.
  6. Validate Findings: Cross-reference with known-good WMI subscriptions (SCCM, AV products).
  7. Document and Remediate: Remove malicious subscriptions and update detection rules.

Key Concepts

| Concept | Description |

|---------|-------------|

| Sysmon Event 19 | WmiEventFilter creation detected |

| Sysmon Event 20 | WmiEventConsumer creation detected |

| Sysmon Event 21 | WmiEventConsumerToFilter binding detected |

| T1546.003 | Event Triggered Execution: WMI Event Subscription |

| CommandLineEventConsumer | Executes system commands when filter triggers |

| ActiveScriptEventConsumer | Runs VBScript/JScript when filter triggers |

Tools & Systems

| Tool | Purpose |

|------|---------|

| Sysmon | Windows event monitoring for WMI activity |

| WMI Explorer | GUI tool for browsing WMI namespaces |

| Autoruns | Sysinternals tool listing persistence mechanisms |

| PowerShell Get-WMIObject | Enumerate WMI event subscriptions |

| Splunk | SIEM analysis of Sysmon WMI events |

| Velociraptor | Endpoint WMI artifact collection |

Output Format

Hunt ID: TH-WMI-[DATE]-[SEQ]
Technique: T1546.003
Host: [Hostname]
Event Type: [EventFilter|EventConsumer|Binding]
Consumer Type: [CommandLine|ActiveScript]
WQL Query: [Filter query text]
Command: [Executed command or script]
Risk Level: [Critical/High/Medium/Low]
Recommended Action: [Remove subscription, investigate lateral movement]
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.