Detection rules › Sigma

Potential Suspicious Mofcomp Execution

Status
test
Severity
high
Log source
product windows, category process_creation
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

Event coverage

ProviderEventTitle
SysmonEvent ID 1Process creation

Rule body yaml

title: Potential 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: 2023-04-11
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'
              - '\Users\Public\'
              - '\WINDOWS\Temp\'
              - '%temp%'
              - '%tmp%'
              - '%appdata%'
    filter_main_wmiprvse:
        ParentImage: 'C:\Windows\System32\wbem\WmiPrvSE.exe'
        CommandLine|contains: 'C:\Windows\TEMP\'
        CommandLine|endswith: '.mof'
    filter_optional_null_parent:
        # Sometimes the parent information isn't available from the Microsoft-Windows-Security-Auditing provider.
        CommandLine|contains: 'C:\Windows\TEMP\'
        CommandLine|endswith: '.mof'
    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'
          - '\Users\Public\'
          - '\WINDOWS\Temp\'
          - '%temp%'
          - '%tmp%'
          - '%appdata%'

Stage 3: not filter_main_wmiprvse

filter_main_wmiprvse:
    ParentImage: 'C:\Windows\System32\wbem\WmiPrvSE.exe'
    CommandLine|contains: 'C:\Windows\TEMP\'
    CommandLine|endswith: '.mof'

Stage 4: not filter_optional_null_parent

filter_optional_null_parent:
    CommandLine|contains: 'C:\Windows\TEMP\'
    CommandLine|endswith: '.mof'

Exclusions

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
CommandLineends_with.mof
CommandLinematchC:\Windows\TEMP\
ParentImageeqC:\Windows\System32\wbem\WmiPrvSE.exe
CommandLineends_with.mof
CommandLinematchC:\Windows\TEMP\

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
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)
  • \Users\Public\ corpus 17 (sigma 17)
  • \WINDOWS\Temp\ corpus 12 (sigma 12)
Imageends_with
  • \mofcomp.exe
OriginalFileNameeq
  • 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)