Suspicious Mofcomp Utility Execution
Detection logic for the abuse of the Windows mofcomp utility, which is frequently leveraged by attackers to compile malicious Managed Object Format (MOF) files for WMI event subscription persistence.
The mofcomp.exe utility is a native Windows component responsible for parsing Managed Object Format (MOF) files and integrating them into the WMI repository. Attackers abuse this utility to establish persistence or facilitate privilege escalation by registering malicious WMI event consumers. When executed from suspicious locations (such as temporary directories) or spawned by common shell and scripting interpreters (cmd.exe, powershell.exe, wscript.exe), mofcomp execution often indicates an attempt to subvert system monitoring or maintain backdoors. This brief provides detection engineering guidance to monitor for these patterns while filtering out legitimate administrative activity, such as legitimate WMI repository maintenance performed by SCCM or system services.
Attack Chain
- Attacker establishes initial access via spearphishing or exploit.
- Attacker downloads a malicious MOF file to a user-writable directory (e.g., %TEMP% or C:\Users\Public).
- Attacker executes a staging script or shell (e.g., cmd.exe or powershell.exe) to initiate the payload.
- The script calls 'mofcomp.exe' pointing to the malicious MOF file located in a staging directory.
- The mofcomp utility parses the file and registers the malicious WMI event consumer in the CIM repository.
- The WMI event subscription triggers the malicious payload upon a system event (e.g., system startup or specific time interval).
- Final objective is achieved: persistent, elevated execution of arbitrary code via WMI service.
Impact
Successful abuse of mofcomp allows attackers to maintain persistence that survives system reboots and often bypasses basic file-based security controls by executing code within the context of the WMI service. This technique is commonly associated with cryptominers, remote access trojans (RATs), and various persistence mechanisms across enterprise environments.
Recommendation
Deploy the provided Sigma rule to monitor process creation events for suspicious mofcomp.exe invocations. Ensure Sysmon or native Windows process auditing (Event ID 4688 with command-line auditing enabled) is active. Filter out known administrative workflows, such as Configuration Manager components, to reduce noise. Investigate any alerts originating from unexpected parent processes or unauthorized paths.
Immediate actions
Deploy the Sigma rule to monitor for mofcomp process creation.
Threat Hunt
Search for historical process creation events involving mofcomp.exe from non-standard system directories.
Data: Process creation logs
Detection coverage 1
Potentially Suspicious Mofcomp Execution
highDetects execution of mofcomp.exe as a child of shell/script interpreters or from suspicious working directories.
Detection queries are available on the platform. Get full rules →