Recursive directory listing issued from a Windows shell
AN1040's real discriminator is MITRE's TimeWindow knob — more than fifty directory queries inside thirty seconds — which a single Sigma event cannot count, so this rule instead matches the command forms that ask for a whole tree in one call: `dir /s`, `tree /f`, `forfiles /s`, and PowerShell's `Get-ChildItem -Recurse` and its aliases. Each form is matched with a regex that requires the command word at a token boundary with its recursion flag following it, because an unordered substring pair ('dir' plus '/s') also matches unrelated command lines — a robocopy job against a folder named "Source Dir" run with /s, or a silent installer whose /s flag shares a line with any path containing 'dir'. That is a narrower slice of MITRE's CommandLineRegex knob than "any enumeration command", because a single non-recursive `dir` is indistinguishable from routine shell use and would swamp this rule. UserContext is not encoded — the brief calls for scoping standard versus service accounts, which needs an identity join this event does not carry — and a hand-rolled recursion loop or a compiled enumerator that never shells out to these four commands produces no match at all. UNVERIFIED AS AUTHORED — derived from MITRE ATT&CK DET0370, not hand-written and not tested by its author. Any lab result is on this rule's own page.Full descriptionShow less
The detection
The 3 SIEM queries below are previews produced by Siemphony’s own translator, not pySigma, and none has been executed against a real backend — review before you deploy.
detection.yml
Sentinel · KQL
Run this as a search.
DeviceProcessEvents| where ((FolderPath endswith "\\cmd.exe" or FolderPath endswith "\\powershell.exe" or FolderPath endswith "\\pwsh.exe") and (ProcessCommandLine matches regex "(?i)(?:^|[\\s&|(\"])dir(?:\\s+[^&|;]+)?\\s+/s(?:[\\s\"]|$)" or ProcessCommandLine matches regex "(?i)(?:^|[\\s&|(\"])tree(?:\\.com)?(?:\\s+[^&|;]+)?\\s+/f(?:[\\s\"]|$)" or ProcessCommandLine matches regex "(?i)forfiles(?:\\.exe)?(?:\\s+[^&|;]+)?\\s+/s(?:[\\s\"]|$)" or ProcessCommandLine matches regex "(?i)(?:^|[\\s;|({\"])(?:get-childitem|gci|ls|dir)(?:\\s+[^;|]+)?\\s+-(?:r|re|rec|recu|recur|recurs|recurse)(?:[\\s\"]|$)"))
Splunk · SPL
Run this as a search.
index=* | where ((match(Image, "(?i)\\\\cmd\\.exe$") OR match(Image, "(?i)\\\\powershell\\.exe$") OR match(Image, "(?i)\\\\pwsh\\.exe$")) AND (match(CommandLine, "(?:^|[\\s&|(\"])dir(?:\\s+[^&|;]+)?\\s+/s(?:[\\s\"]|$)") OR match(CommandLine, "(?:^|[\\s&|(\"])tree(?:\\.com)?(?:\\s+[^&|;]+)?\\s+/f(?:[\\s\"]|$)") OR match(CommandLine, "forfiles(?:\\.exe)?(?:\\s+[^&|;]+)?\\s+/s(?:[\\s\"]|$)") OR match(CommandLine, "(?:^|[\\s;|({\"])(?:get-childitem|gci|ls|dir)(?:\\s+[^;|]+)?\\s+-(?:r|re|rec|recu|recur|recurs|recurse)(?:[\\s\"]|$)")))Wazuh · XML rule
Deploy to your manager — this is a rule, not a search.
<group name="sigma,windows,process_creation,"> <!-- Rule ids must be unique on your manager; 100000+ is the user range. --> <rule id="100000" level="5"> <!-- Set <if_sid> to the decoder/base rule for windows so this only evaluates relevant events. --> <field name="Image" type="pcre2">(?i)(\\cmd\.exe$|\\powershell\.exe$|\\pwsh\.exe$)</field> <field name="CommandLine" type="pcre2">(?i)((?:^|[\s&|("])dir(?:\s+[^&|;]+)?\s+/s(?:[\s"]|$)|(?:^|[\s&|("])tree(?:\.com)?(?:\s+[^&|;]+)?\s+/f(?:[\s"]|$)|forfiles(?:\.exe)?(?:\s+[^&|;]+)?\s+/s(?:[\s"]|$)|(?:^|[\s;|({"])(?:get-childitem|gci|ls|dir)(?:\s+[^;|]+)?\s+-(?:r|re|rec|recu|recur|recurs|recurse)(?:[\s"]|$))</field> <description>Recursive directory listing issued from a Windows shell</description> <mitre> <id>T1083</id> </mitre> </rule></group>
Elastic · ES|QL
Run this as a search.
Elastic cannot express this construct. ES|QL RLIKE uses Lucene regexp syntax, which has no case-insensitive flag, and Sigma regexes are case-insensitive. Use |contains/|startswith/|endswith, or write the ES|QL by hand. The Sigma source is on the first tab, unchanged.
Verdicts · reactions · comments
Community
Verdicts from engineers who actually deployed it, and the conversation around it.
Nobody has run this in a real environment and said what happened.
Verdicts from engineers who deployed it
0 castNo verdicts reported yet. The first one is worth more than the tenth — say what you ran it against.
Log in to report a verdict.
Log in to join the discussion.
No comments yet. Someone who deploys this will have something to say about it.