Detection rules › Sigma

File And SubFolder Enumeration Via Dir Command

Status
test
Severity
low
Log source
category process_creation, product windows
Author
frack113
Source
github.com/SigmaHQ/sigma

Detects usage of the "dir" command part of Windows CMD with the "/S" command line flag in order to enumerate files in a specified directory and all subdirectories.

Known false positives

  • Likely

MITRE ATT&CK coverage

TacticTechniques
Discovery

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: File And SubFolder Enumeration Via Dir Command
id: 7c9340a9-e2ee-4e43-94c5-c54ebbea1006
status: test
description: |
    Detects usage of the "dir" command part of Windows CMD with the "/S" command line flag in order to enumerate files in a specified directory and all subdirectories.
references:
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1217/T1217.md
author: frack113
date: 2021-12-13
modified: 2026-05-18
tags:
    - attack.discovery
    - attack.t1217
logsource:
    category: process_creation
    product: windows
detection:
    selection_cmd:
        - Image|endswith: '\cmd.exe'
        - OriginalFileName: Cmd.Exe
    selection_cli:
        CommandLine|contains|windash: '-s'
        CommandLine|contains: 'dir '
    filter_main_rmdir:
        CommandLine|contains: 'rmdir'
    condition: all of selection_* and not 1 of filter_main_*
falsepositives:
    - Likely
level: low
regression_tests_path: regression_data/rules/windows/process_creation/proc_creation_win_cmd_dir_execution/info.yml
simulation:
    - type: atomic-red-team
      name: List Internet Explorer Bookmarks using the command prompt
      technique: T1217
      atomic_guid: 727dbcdb-e495-4ab1-a6c4-80c7f77aef85

Stages and Predicates

Stage 0: condition

all of selection_* and not 1 of filter_main_*

Stage 1: selection_cmd

selection_cmd:
    - Image|endswith: '\cmd.exe'
    - OriginalFileName: Cmd.Exe

Stage 2: selection_cli

selection_cli:
    CommandLine|contains|windash: '-s'
    CommandLine|contains: 'dir '

Stage 3: not filter_main_rmdir

filter_main_rmdir:
    CommandLine|contains: 'rmdir'

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
CommandLinematchrmdirexcludes:CommandLine field:"CommandLine" value:"rmdir"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CommandLinematch
  • -s transforms: windash corpus 10 (sigma 4, kusto 4, elastic 1, splunk 1)
  • dir corpus 8 (sigma 5, splunk 2, chronicle 1)
field:"CommandLine" kind:match
Imageends_with
  • \cmd.exe corpus 130 (sigma 130)
field:"Image" kind:ends_with value:"\cmd.exe"
OriginalFileNameeq
  • Cmd.Exe corpus 81 (sigma 43, elastic 21, splunk 17)
field:"OriginalFileName" kind:eq value:"Cmd.Exe"