Detection rules › Sigma

Potentially Suspicious Mofcomp Execution

Status
test
Severity
high
Log source
category process_creation, product windows
Author
Nasreddine Bencherchali (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects execution of the "mofcomp" utility as a child of a suspicious shell or script running utility or by having a suspicious path in the commandline. The "mofcomp" utility parses a file containing MOF statements and adds the classes and class instances defined in the file to the WMI repository. Attackers abuse this utility to install malicious MOF scripts

MITRE ATT&CK coverage

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: Potentially Suspicious Mofcomp Execution
id: 1dd05363-104e-4b4a-b963-196a534b03a1
status: test
description: |
    Detects execution of the "mofcomp" utility as a child of a suspicious shell or script running utility or by having a suspicious path in the commandline.
    The "mofcomp" utility parses a file containing MOF statements and adds the classes and class instances defined in the file to the WMI repository.
    Attackers abuse this utility to install malicious MOF scripts
references:
    - https://thedfirreport.com/2022/07/11/select-xmrig-from-sqlserver/
    - https://github.com/The-DFIR-Report/Sigma-Rules/blob/75260568a7ffe61b2458ca05f6f25914efb44337/win_mofcomp_execution.yml
    - https://learn.microsoft.com/en-us/windows/win32/wmisdk/mofcomp
author: Nasreddine Bencherchali (Nextron Systems)
date: 2022-07-12
modified: 2026-08-06
tags:
    - attack.stealth
    - attack.t1218
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - Image|endswith: '\mofcomp.exe'
        - OriginalFileName: 'mofcomp.exe'
    selection_case:
        - ParentImage|endswith:
              - '\cmd.exe'
              - '\powershell.exe'
              - '\pwsh.exe'
              - '\wsl.exe'
              - '\wscript.exe'
              - '\cscript.exe'
        - CommandLine|contains:
              - '\AppData\Local\Temp'
              - '\Contacts\'
              - '\Favorites\'
              - '\Favourites\'
              - '\Music\'
              - '\Pictures\'
              - '\Users\Public\'
              - '\Videos\'
              - '\WINDOWS\Temp\'
              - '%appdata%'
              - '%temp%'
              - '%tmp%'
    filter_main_wmiprvse:
        ParentImage: 'C:\Windows\System32\wbem\WmiPrvSE.exe'
        CommandLine|contains: 'C:\Windows\TEMP\'
        CommandLine|endswith: '.mof'
    filter_main_installutil:
        ParentCommandLine|endswith: '\InstallUtil.exe /Uninstall C:\Windows\CCM\Microsoft.ConfigurationManager.SVProvider.dll'
        ParentImage|endswith: '\InstallUtil.exe'
        CommandLine|contains|all:
            - 'C:\Windows\TEMP'
            - '.tmp'
    filter_optional_null_parent:
        ParentCommandLine: null
    condition: all of selection_* and not 1 of filter_main_* and not 1 of filter_optional_*
falsepositives:
    - Unknown
level: high

Stages and Predicates

Stage 0: condition

all of selection_* and not 1 of filter_main_* and not 1 of filter_optional_*

Stage 1: selection_img

selection_img:
    - Image|endswith: '\mofcomp.exe'
    - OriginalFileName: 'mofcomp.exe'

Stage 2: selection_case

selection_case:
    - ParentImage|endswith:
          - '\cmd.exe'
          - '\powershell.exe'
          - '\pwsh.exe'
          - '\wsl.exe'
          - '\wscript.exe'
          - '\cscript.exe'
    - CommandLine|contains:
          - '\AppData\Local\Temp'
          - '\Contacts\'
          - '\Favorites\'
          - '\Favourites\'
          - '\Music\'
          - '\Pictures\'
          - '\Users\Public\'
          - '\Videos\'
          - '\WINDOWS\Temp\'
          - '%appdata%'
          - '%temp%'
          - '%tmp%'

Stage 3: not filter_main_*

filter_main_wmiprvse:
    ParentImage: 'C:\Windows\System32\wbem\WmiPrvSE.exe'
    CommandLine|contains: 'C:\Windows\TEMP\'
    CommandLine|endswith: '.mof'
filter_main_installutil:
    ParentCommandLine|endswith: '\InstallUtil.exe /Uninstall C:\Windows\CCM\Microsoft.ConfigurationManager.SVProvider.dll'
    ParentImage|endswith: '\InstallUtil.exe'
    CommandLine|contains|all:
        - 'C:\Windows\TEMP'
        - '.tmp'

Stage 4: not filter_optional_null_parent

filter_optional_null_parent:
    ParentCommandLine: null

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
CommandLineends_with.mofexcludes:CommandLine field:"CommandLine" value:".mof"
CommandLinematchC:\Windows\TEMP\excludes:CommandLine field:"CommandLine" value:"C:\Windows\TEMP\"
ParentImageeqC:\Windows\System32\wbem\WmiPrvSE.exeexcludes:ParentImage field:"ParentImage" value:"C:\Windows\System32\wbem\WmiPrvSE.exe"
CommandLinematch.tmpexcludes:CommandLine field:"CommandLine" value:".tmp"
CommandLinematchC:\Windows\TEMPexcludes:CommandLine field:"CommandLine" value:"C:\Windows\TEMP"
ParentCommandLineends_with\InstallUtil.exe /Uninstall C:\Windows\CCM\Microsoft.ConfigurationManager.SVProvider.dllexcludes:ParentCommandLine field:"ParentCommandLine" value:"\InstallUtil.exe /Uninstall C:\Windows\CCM\Microsoft.ConfigurationManager.SVProvider.dll"
ParentImageends_with\InstallUtil.exeexcludes:ParentImage field:"ParentImage" value:"\InstallUtil.exe"
ParentCommandLineis_null(no value, null check)excludes:ParentCommandLine

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CommandLinematch
  • %appdata% corpus 13 (sigma 11, chronicle 2)
  • %temp% corpus 16 (sigma 13, chronicle 2, kusto 1)
  • %tmp% corpus 15 (sigma 13, chronicle 2)
  • \AppData\Local\Temp corpus 8 (sigma 8)
  • \Contacts\ corpus 7 (sigma 7)
  • \Favorites\ corpus 7 (sigma 7)
  • \Favourites\ corpus 7 (sigma 7)
  • \Music\ corpus 4 (sigma 4)
  • \Pictures\ corpus 5 (sigma 5)
  • \Users\Public\ corpus 18 (sigma 17, elastic 1)
  • \Videos\ corpus 4 (sigma 4)
  • \WINDOWS\Temp\ corpus 13 (sigma 12, elastic 1)
field:"CommandLine" kind:match
Imageends_with
  • \mofcomp.exe
field:"Image" kind:ends_with value:"\mofcomp.exe"
OriginalFileNameeq
  • mofcomp.exe
field:"OriginalFileName" kind:eq value:"mofcomp.exe"
ParentImageends_with
  • \cmd.exe corpus 20 (sigma 20)
  • \cscript.exe corpus 17 (sigma 17)
  • \powershell.exe corpus 24 (sigma 24)
  • \pwsh.exe corpus 21 (sigma 21)
  • \wscript.exe corpus 19 (sigma 19)
  • \wsl.exe corpus 4 (sigma 4)
field:"ParentImage" kind:ends_with