PowerShell Sensitive File Discovery Technique
Adversaries utilize PowerShell commands to recursively search for sensitive file extensions such as .pass and .kdbx to identify credentials or keys stored on disk.
This technique involves the use of PowerShell cmdlets to perform recursive directory searches specifically targeting sensitive file extensions associated with password managers and credential stores. Adversaries often execute these commands post-compromise to locate, exfiltrate, or harvest credentials necessary for privilege escalation or lateral movement. By leveraging cmdlets such as Get-ChildItem with recursion enabled, attackers can efficiently identify high-value targets across diverse directory structures on a compromised Windows host. Detection of this activity relies on monitoring PowerShell Script Block Logging, as these commands are frequently executed within volatile memory or via one-liners that bypass traditional file-system logging.
Attack Chain
- Initial access is established through spearphishing or exploit delivery on the target system.
- The attacker gains execution of a PowerShell instance or interactive shell.
- The attacker identifies the current user context and file system structure.
- The attacker executes a recursive search command (e.g., Get-ChildItem -Recurse) targeting specific patterns like ".kdbx" or ".pass".
- The search identifies the absolute path to credential-related files on the disk.
- The attacker reads or exfiltrates the discovered sensitive files to a C2-controlled endpoint.
Impact
Successful discovery of sensitive files can lead to the compromise of password databases and plain-text credential files, significantly increasing the risk of full account takeover, lateral movement across the network, and long-term persistence through harvested authentication tokens.
Recommendation
- Enable PowerShell Script Block Logging (Event ID 4104) across all Windows endpoints to ensure the visibility of script execution.
- Deploy the provided Sigma rule to detect recursive file searches targeting known credential file extensions.
- Perform threat hunting for common PowerShell enumeration patterns and investigate high-frequency recursive search activity from unauthorized user accounts.
Immediate actions
Enable PowerShell Script Block Logging (Event ID 4104) across all endpoints
Threat Hunt
Search for high-frequency use of recursive search flags in PowerShell logs
Data: PowerShell Operational Logs (Event 4104)
Mitigations
Implement strict access controls on directories containing sensitive credential files
Discovery of credentials
Detection coverage 1
Detect Sensitive File Discovery via PowerShell
mediumDetects the use of PowerShell cmdlets to recursively search for sensitive file extensions such as .pass, .kdbx, or .kdb
Detection queries are available on the platform. Get full rules →