Sigma rule: Suspicious Usage of For Loop with Recursive Directory Search in CMD

A detection rule from the SigmaHQ repository, shown as its author published it. Dataset version ref-d6e502cdf245, updated 2025-11-12T00:00:00.000Z.

Rule

Title
Suspicious Usage of For Loop with Recursive Directory Search in CMD
Status
experimental
Level
medium
Author
Joseliyo Sanchez, @Joseliyo_Jstnk
Date
2025-11-12
File
rules/windows/process_creation/proc_creation_win_susp_cmd_for_loop_execution_with_recursive_directory_search.yml
Commit
ccbb0369507f796db0b0ae6854c8a2be471b9d84

Detects suspicious usage of the cmd.exe 'for /f' loop combined with the 'tokens=' parameter and a recursive directory listing.
This pattern may indicate an attempt to discover and execute system binaries dynamically, for example powershell, a technique sometimes used by attackers to evade detection.
This behavior has been observed in various malicious lnk files.

Log source

product
windows
category
process_creation

Detection

selection_tokens:
    CommandLine|contains|all:
        - 'for /f'
        - 'tokens='
        - 'in ('
        - 'dir'
selection_tokens_parent:
    ParentCommandLine|contains|all:
        - 'for /f'
        - 'tokens='
        - 'in ('
        - 'dir'
condition: 1 of selection_*

False positives (as the rule lists them)

  • Unknown

Tags

  • attack.execution
  • attack.stealth
  • attack.t1059.003
  • attack.t1027.010

MITRE ATT&CK ids this rule names

References

Read on 2026-11-03T00:58:21.399Z under licence sigma-drl-1.1@d5f4c36a from https://github.com/SigmaHQ/sigma/blob/ccbb0369507f796db0b0ae6854c8a2be471b9d84/rules/windows/process_creation/proc_creation_win_susp_cmd_for_loop_execution_with_recursive_directory_search.yml

Sources and licences

  • SigmaHQ

    "Suspicious Usage of For Loop with Recursive Directory Search in CMD" by Joseliyo Sanchez, @Joseliyo_Jstnk (SigmaHQ). Rule: https://github.com/SigmaHQ/sigma/blob/ccbb0369507f796db0b0ae6854c8a2be471b9d84/rules/windows/process_creation/proc_creation_win_susp_cmd_for_loop_execution_with_recursive_directory_search.yml.
    Licensed under the Detection Rule License (DRL) 1.1: https://github.com/SigmaHQ/Detection-Rule-License

    Detection Rule License (DRL) 1.1

Cite this page

Dragons Eye Ransomware Tracker, "Sigma rule: Suspicious Usage of For Loop with Recursive Directory Search in CMD",
entity page, dataset version ref-d6e502cdf245, updated 2025-11-12T00:00:00.000Z,
https://ransomware-tracker.com/detections/sigma/2782fbd8-b662-4eb5-9962-5bfbfb671e7b (accessed 2026-11-03).
Underlying source: SigmaHQ rule 2782fbd8-b662-4eb5-9962-5bfbfb671e7b, commit ccbb0369507f796db0b0ae6854c8a2be471b9d84.

Pages change. The dataset version identifies the data, but no archive of old versions is kept, so this citation cannot be replayed later.