Detect File and Directory Discovery in Google Chronicle
Adversaries may enumerate files and directories or search specific filesystem locations to gather information about a host or network share. This discovery technique helps adversaries identify sensitive files, understand the environment, and shape follow-on behavior such as targeted exfiltration or lateral movement. Common tools include dir, tree, ls, find, locate, and forfiles. Adversaries may also search for credential files, configuration files, or documents with specific extensions using recursive enumeration patterns.
MITRE ATT&CK
- Tactic
- Discovery
- Technique
- T1083 File and Directory Discovery
- Canonical reference
- https://attack.mitre.org/techniques/T1083/
YARA-L Detection Query
rule t1083_file_directory_discovery {
meta:
author = "Argus Detection Engineering"
description = "Detects T1083 File and Directory Discovery via recursive enumeration using Windows CMD, PowerShell, find.exe, or where.exe targeting sensitive paths or credential files"
mitre_attack_tactic = "Discovery"
mitre_attack_technique = "T1083"
severity = "MEDIUM"
confidence = "HIGH"
version = "1.0"
events:
$e.metadata.event_type = "PROCESS_LAUNCH"
$e.principal.process.file.full_path = /(?i)(cmd\.exe|powershell\.exe|pwsh\.exe|find\.exe|where\.exe)$/
(
$e.principal.process.command_line = /(?i)(dir\s|tree\s|forfiles|get-childitem|\bgci\b|get-item)/
or $e.principal.process.command_line = /(?i)(find\s|where\s)/
)
(
// Recursive flag present
$e.principal.process.command_line = /(?i)(\/s\b|\/S\b|-[Rr]ecurse|-r\s|--recursive|-R\s)/
or
// Credential file targeting
$e.principal.process.command_line = /(?i)(\.key|\.pem|\.pfx|\.p12|\.kdbx|id_rsa|authorized_keys|\.ppk|password|passwd|credential|secret|\.aws|web\.config|appsettings)/
or
// Suspicious parent
$e.principal.process.parent_process.file.full_path = /(?i)(winword\.exe|excel\.exe|powerpnt\.exe|outlook\.exe|mshta\.exe|wscript\.exe|cscript\.exe|regsvr32\.exe|rundll32\.exe|msiexec\.exe|msedge\.exe|chrome\.exe|firefox\.exe)$/
)
(
// Also require either sensitive path OR credential hunt to reduce noise
$e.principal.process.command_line = /(?i)(\\users\\|\\appdata\\|\\documents\\|\\desktop\\|\\temp\\|\\ssh\\|\.aws|\.config|inetpub|wwwroot)/
or
$e.principal.process.command_line = /(?i)(\.key|\.pem|\.pfx|\.p12|\.kdbx|id_rsa|authorized_keys|\.ppk|password|passwd|credential|secret)/
)
condition:
$e
} Chronicle YARA-L 2.0 rule detecting T1083 File and Directory Discovery. Matches process launch events where Windows discovery utilities (cmd.exe, PowerShell, find.exe, where.exe) are used with recursive flags against sensitive file system paths or credential-related file extensions. Optionally correlates suspicious parent processes such as Office applications or script interpreters as a high-confidence escalation signal.
Data Sources
Required Tables
False Positives & Tuning
- Enterprise deployment orchestration tools (Puppet, Chef, SaltStack) executing PowerShell Get-ChildItem to verify file state during runs
- IT operations runbooks that search for log files, temp files, or config artifacts using dir /s during routine maintenance windows
- Developers using terminal emulators or IDEs that spawn cmd.exe or PowerShell with recursive find operations during build or test cycles
Other platforms for T1083
Testing Methodology
Validate this detection against 5 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Recursive Directory Listing via CMD
Expected signal: Sysmon Event ID 1: Process Create with Image=cmd.exe, CommandLine containing 'dir /s /b C:\Users'. Security Event ID 4688 (if command line auditing enabled). Sysmon Event ID 11: File Create for %TEMP%\df00tech-dir-test.txt. Parent process will be the shell or test runner invoking the command.
- Test 2Credential File Search via PowerShell
Expected signal: Sysmon Event ID 1: Process Create with Image=powershell.exe, CommandLine containing 'Get-ChildItem', '-Recurse', '-Force', and credential extensions (.key, .pem, .pfx, id_rsa, .kdbx). Sysmon Event ID 11: File Create for the output file. PowerShell ScriptBlock Log Event ID 4104 with full script.
- Test 3File Search via Windows where.exe for Executable Targets
Expected signal: Sysmon Event ID 1: Process Create with Image=where.exe, CommandLine containing '/r C:\Program Files *.exe'. Security Event ID 4688 with same details if command line auditing is enabled. Sysmon Event ID 11 for the output file creation.
- Test 4Tree Command for Full Filesystem Enumeration
Expected signal: Sysmon Event ID 1: Process Create with Image=cmd.exe, CommandLine containing 'tree /f /a C:\Users'. Security Event ID 4688 if command line auditing is enabled. Sysmon Event ID 11 for the output file creation in TEMP.
- Test 5Linux Credential File Discovery via find
Expected signal: Linux auditd EXECVE records showing find command with -name patterns for credential files. Syslog entries if process accounting is enabled. On systems with Sysmon for Linux: Event ID 1 (Process Create) with CommandLine showing find with credential extension patterns.
References (7)
- https://attack.mitre.org/techniques/T1083/
- https://blogs.jpcert.or.jp/en/2016/01/windows-commands-abused-by-attackers.html
- https://www.us-cert.gov/ncas/alerts/TA18-106A
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1083/T1083.md
- https://learn.microsoft.com/en-us/defender-endpoint/advanced-hunting-deviceprocessevents-table
- https://docs.splunk.com/Documentation/SplunkCloud/latest/SearchReference/CommonStatsFunctions
- https://github.com/SigmaHQ/sigma/tree/master/rules/windows/process_creation
Unlock Pro Content
Get the full detection package for T1083 including response playbook, investigation guide, and atomic red team tests.