Detection rules › Sigma

Forfiles.EXE Child Process Masquerading

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

Detects the execution of "forfiles" from a non-default location, in order to potentially spawn a custom "cmd.exe" from the current working directory.

MITRE ATT&CK coverage

TacticTechniques
StealthT1036 Masquerading

Event coverage

ProviderEventTitle
SysmonEvent ID 1Process creation

Rule body yaml

title: Forfiles.EXE Child Process Masquerading
id: f53714ec-5077-420e-ad20-907ff9bb2958
status: test
description: |
    Detects the execution of "forfiles" from a non-default location, in order to potentially spawn a custom "cmd.exe" from the current working directory.
references:
    - https://www.hexacorn.com/blog/2023/12/31/1-little-known-secret-of-forfiles-exe/
author: Nasreddine Bencherchali (Nextron Systems), Anish Bogati
date: 2024-01-05
tags:
    - attack.stealth
    - attack.t1036
logsource:
    category: process_creation
    product: windows
detection:
    selection:
        # Notes:
        #   - The parent must not have CLI options
        #   - The Child Image must be named "cmd" as its hardcoded in the "forfiles" binary
        #   - The Child CLI will always contains "/c echo" as its hardcoded in the original "forfiles" binary
        ParentCommandLine|endswith:
            - '.exe'
            - '.exe"'
        Image|endswith: '\cmd.exe'
        CommandLine|startswith: '/c echo "'
    filter_main_parent_not_sys:
        ParentImage|contains:
            - ':\Windows\System32\'
            - ':\Windows\SysWOW64\'
        ParentImage|endswith: '\forfiles.exe'
        Image|contains:
            - ':\Windows\System32\'
            - ':\Windows\SysWOW64\'
        Image|endswith: '\cmd.exe'
    condition: selection and not 1 of filter_main_*
falsepositives:
    - Unknown
level: high

Stages and Predicates

Stage 0: condition

selection and not 1 of filter_main_*

Stage 1: selection

selection:
    ParentCommandLine|endswith:
        - '.exe'
        - '.exe"'
    Image|endswith: '\cmd.exe'
    CommandLine|startswith: '/c echo "'

Stage 2: not filter_main_parent_not_sys

filter_main_parent_not_sys:
    ParentImage|contains:
        - ':\Windows\System32\'
        - ':\Windows\SysWOW64\'
    ParentImage|endswith: '\forfiles.exe'
    Image|contains:
        - ':\Windows\System32\'
        - ':\Windows\SysWOW64\'
    Image|endswith: '\cmd.exe'

Exclusions

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

FieldKindExcluded values
Imagematch:\Windows\SysWOW64\
Imagematch:\Windows\System32\
ParentImagematch:\Windows\SysWOW64\
ParentImagematch:\Windows\System32\
Imageends_with\cmd.exe
ParentImageends_with\forfiles.exe

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
CommandLinestarts_with
  • /c echo "
Imageends_with
  • \cmd.exe corpus 130 (sigma 130)
ParentCommandLineends_with
  • .exe corpus 2 (sigma 2)
  • .exe"