> Purpose and scope. This article provides a comprehensive map of WMI Event Subscription-based persistence for authorized penetration testing, red/purple team exercises, and
> defense (SOC/DFIR) teams: how it works → how to detect it → how to prevent it. Content
> is intended for educational and defensive purposes; detailed attack setup commands are in the Lab Appendix and
> must only be used in environments with explicit written authorization.
>
> Scope: This article covers WMI Event Subscription persistence in Windows endpoint and server (including on-prem and hybrid) environments.
> Azure/cloud-native WMI surface, macOS/Linux WMI equivalents, and non-WMI COM-based persistence (T1546.015) are outside the scope of this article.
Executive Summary
Windows Management Instrumentation (WMI) is a powerful infrastructure that has existed since Windows 98,
designed to manage the operating system and remote systems. It is a legitimate tool for administrators and developers; however, the same flexibility
offers attackers a persistence and execution mechanism that is by design.
WMI's event infrastructure allows linking a trigger to an action.
By persistently writing three components into the WMI repository (CIM repository — Common Information Model repository),
an attacker can establish a backdoor that survives even system restarts, runs with SYSTEM privileges,
and leaves no traditional "autorun" trace on disk:
__EventFilter— trigger condition (WQL query). E.g., "~1200 seconds after startup".__EventConsumer— the action to execute when triggered (command line or script).__FilterToConsumerBinding— the record that binds the filter to the consumer.
This technique is classified in MITRE ATT&CK as T1546.003 (Event Triggered Execution: WMI Event Subscription —
Event Triggered Execution: WMI Event Subscription) and appears under both Persistence and
Privilege Escalation tactics. WMI is also used for **remote command execution and lateral
movement** (T1047); this article focuses primarily on persistence and secondarily on
execution/lateral movement.
> Core thesis. WMI persistence evades signature-centric detection that relies on scanning
> executables on disk or registry ASEPs. Reliable detection depends on the behavioral layer
> (process tree, consumer anomaly, WMI telemetry correlation) and the
> signature layer (Sysmon EID 19/20/21, WMI-Activity EID 5861) working together.
> Without Sysmon or when the WMI-Activity log is not flowing to the SIEM, this technique remains largely
> invisible.
Creating a persistent __FilterToConsumerBinding requires local administrator (local admin) privileges;
therefore the least privilege principle is an important layer — but once admin is obtained, the detection and hunting layers come into play.
WMI Architecture
Understanding the attack requires clarifying WMI's layered structure.
- CIM repository. WMI conforms to the CIM (Common Information Model)
industry standard; CIM is developed by DMTF. The repository holds queryable static
data that persists across restarts — which is exactly what makes it interesting to attackers.
- Providers and classes. The Win32 provider offers rich information about the system via classes such as
Win32_Process(process),
Win32_Service (service), Win32_LogonSession (session), Win32_Account.
- WQL (WMI Query Language). Events are filtered with WQL; WQL is a
subset of SQL. Event queries define triggers using the SELECT * FROM ... WITHIN n WHERE ... pattern.
#### Intrinsic and extrinsic events
WMI produces two types of events:
- Intrinsic events are created by a change in the WMI model —
__InstanceCreationEventwhen a class instance
is created, __InstanceModificationEvent when modified.
Intrinsic events require polling; this is why the WITHIN n (poll every n seconds) clause
appears in WQL.
- Extrinsic events are events that cannot be directly bound to changes in repository objects —
for example, RegistryKeyChangeEvent notifies when a registry key changes.
The most commonly seen pattern in attack scenarios is an intrinsic event based on system uptime:
-- Defense analysis reference — pattern triggered when system has been up ~1200 seconds
SELECT * FROM __InstanceModificationEvent WITHIN 5
WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System'
AND TargetInstance.SystemUpTime >= 1200
Why is this pattern common? Because the payload silently executes shortly after every restart —
no user interaction required. An attacker may also write the trigger to unusual namespaces such as
root\Default to reduce the detection footprint.
The Three Components of a Subscription — T1546.003
| Component | WMI class | Role |
|---|---|---|
| Event filter | __EventFilter | Trigger — WQL query defining the event of interest |
| Event consumer | __EventConsumer (subclasses) | Action — the command/script to execute when triggered |
| Binding | __FilterToConsumerBinding | The record that binds the filter to the consumer |
The binding answers: "On which Windows event (filter) should I run which program (consumer)?"
These three objects are typically written to the root\subscription namespace.
Installation can be done via a PowerShell Set-WmiInstance call, compiling a MOF file with
mofcomp.exe, or directly via WMI COM interfaces. Full command examples are in the Lab Appendix.
#### Consumer types
WMI has five standard consumer classes: CommandLineEventConsumer,
ActiveScriptEventConsumer, LogFileEventConsumer, NTEventLogEventConsumer,
SMTPEventConsumer. In real attacks the first two dominate:
CommandLineEventConsumer— spawns a process when triggered. TheCommandLineTemplate
property specifies the command to run, ExecutablePath specifies the absolute path. Typical payload:
a directly executable binary or rundll32.exe / powershell.exe with encoded script
parameters. Microsoft Learn approved source: Wbemcons.dll.
ActiveScriptEventConsumer— executes via a script path on disk or directly via script text
(ScriptText). Only VBScript or JScript is supported (PowerShell
is not supported). When it runs, it spawns the rarely seen scrcons.exe process (official Microsoft
name: "WMI Standard Event Consumer - Scripting Application").
> SYSTEM privileges. WMI consumers run in the SYSTEM context. This means the technique carries
> an Admin-to-SYSTEM escalation effect in addition to persistence.
#### Evasion methods
Attackers use various evasion approaches to complicate detection:
- Using the
root\Defaultnamespace instead of the standardroot\subscription. - Choosing names similar to legitimate consumer names — for example, a name resembling the real "SCM Event Log Consumer"
(a general TTP documented in security community research reports;
claims tied to specific malware must be verified from primary sources).
- Preferring PowerShell WMI cmdlets over monitored tools (
wmic.exe). - Direct WMI COM calls that leave less trace than
CreateInstance.
#### Historical context: Stuxnet and beyond
WMI event subscription-based persistence is a mature technique. Stuxnet (approx. 2010)
is cited by researchers as one of the early examples of WMI event consumers being used for persistence in the wild; the campaign is reported to have used a winsta.exe payload and a MOF file named sysnullevnt.mof
to create a WMI subscription (source:
Matt Graeber, Black Hat 2015 WMI research paper and ESET "Stuxnet Under the Microscope").
In subsequent years, numerous malware families including ransomware and crypto-worms
have been documented by researchers as having adopted this pattern.
#### Remote execution and lateral movement via WMI — T1047
WMI is used not only for persistence but also for remote command execution and lateral movement (T1047).
The Win32_Process.Create method can start processes on remote systems. The core process for remote WMI
actions is WmiPrvSE.exe; WmiPrvSE.exe spawning powershell.exe
is a typical attack signature. Publicly available tools: Impacket wmiexec,
PowerShell WMI cmdlets (Invoke-WmiMethod), wmic.
Lab Appendix (authorized test environment only)
> This section is for explicitly authorized lab/penetration testing environments only.
# Authorized test environment — PowerShell subscription setup flow (inspired by ired.team example)
$ns = 'root\subscription'
# 1) Filter (trigger)
$Filter = Set-WmiInstance -Namespace $ns -Class __EventFilter -Arguments @{
Name = 'backdoor'
EventNamespace = 'root\CIMV2'
QueryLanguage = 'WQL'
Query = "SELECT * FROM __InstanceModificationEvent WITHIN 5 " +
"WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System' " +
"AND TargetInstance.SystemUpTime >= 1200"
}
# 2) Consumer (action)
$Consumer = Set-WmiInstance -Namespace $ns -Class CommandLineEventConsumer -Arguments @{
Name = 'backdoor'
ExecutablePath = 'C:\test\backdoor.exe'
}
# 3) Binding
Set-WmiInstance -Namespace $ns -Class __FilterToConsumerBinding -Arguments @{
Filter = $Filter
Consumer = $Consumer
}
// Authorized test environment — conceptual MOF skeleton (root\subscription)
#PRAGMA NAMESPACE("\\\\.\\root\\subscription")
instance of __EventFilter as $Filter {
Name = "GenericFilter";
QueryLanguage = "WQL";
Query = "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE ...";
};
instance of CommandLineEventConsumer as $Consumer {
Name = "GenericConsumer";
CommandLineTemplate = "C:\\Windows\\test.exe";
};
instance of __FilterToConsumerBinding {
Filter = $Filter;
Consumer = $Consumer;
};