Windows CMD for /f Tokens= with Recursive Dir Listing

Flags cmd.exe for /f loops using tokens= with recursive dir enumeration in the command line and parent.

FreeReviewedSigma · Medium · v1
Product
windows
Category
process_creation
Author
Joseliyo Sanchez, @Joseliyo_Jstnk (SigmaHQ), DRL 1.1
Published
2025-11-12
Updated
2026-07-30

ATT&CK techniques

Execution → Defense Evasion
  1. Recon

  2. Resource Dev

  3. Initial Access

  4. Persistence

  5. Priv Esc

  6. Cred Access

  7. Discovery

  8. Lateral Movement

  9. Collection

  10. C2

  11. Exfiltration

  12. Impact

What it detects

This rule flags process creation events where cmd.exe command lines include a for /f loop with tokens= and an in ( dir ... ) style recursive directory listing pattern. Such command-line composition can be used to dynamically enumerate files and drive subsequent actions, which is a common step in stealthy execution chains. The detection relies on Windows process creation telemetry capturing the full command line for both the process and its parent.

Related detections9 linkedT1059.003 — drag to rearrange
Suspicious Doenerium Host Fingerprinting via cmd.exe
Suspicious Scheduled Task Creation Referencing dllFake Batch Scripts (via process_creation)
Suspicious Backup Exec Remote Agent Spawning Command Shell via Process Creation (via process_creation)
Suspicious ClickFix Command Execution via RunMRU Registry Key
Suspicious LampoRAT Command Dispatcher via Cmd Delayed Expansion Flags (via process_creation)
Malicious WSUS Service Spawning Command Shell via CVE-2025-59287 (via process_creation)
Malicious SharePoint w3wp Spawning Command Shell and PowerShell
Suspicious extrac32 CAB Extraction Abuse
Suspicious curl Spawning Script Host for Latrodectus Delivery
Windows CMD for /f Tokens= with Recursive Dir Listing
Pivot detection · T1059.003 · 9 related

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.