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 IP Release and Renew via Minimized cmd During Driver Install
Malicious IIS Worker Spawning nslookup via WS_FTP Deserialization
Malicious Metasploit Reverse Shell Injection in SQL Server (via process_creation)
Suspicious Fake Crypto Wallet Installer Batch Script Staging (via file_event)
Obfuscated Encoded PowerShell Payload Deployed via Process Execution (via process_creation)
Operator Bloopers Cobalt Strike Modules
Malicious KB Document Masqueraded Executable Spawned by Script Interpreter via RoKRAT Loader (via process_creation)
Malicious SCMBanker ClickFix Payload Fetch via Curl Piped to Cmd
Malicious Payload Assembly via MZ Header Prepend and copy Concatenation (via process_creation)
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.