Detection of Automated PowerShell Data Collection
Adversaries utilize automated PowerShell scripts to locate and gather sensitive documents across local file systems for subsequent exfiltration.
Adversaries often perform automated data collection to identify valuable information after gaining initial access to a compromised environment. By leveraging the built-in PowerShell capability 'Get-ChildItem', attackers can recursively search directories for specific file extensions associated with documents, such as .docx, .xlsx, .pdf, or .rtf. This technique allows for rapid discovery and staging of data without the need for manual browsing. Defenders should monitor for PowerShell scripts that combine recursive directory traversal with file-type filtering, as this pattern is a common indicator of automated reconnaissance and collection activity preceding exfiltration.
Attack Chain
- Initial access is established on the Windows host via spearphishing or exploit.
- The attacker opens a PowerShell session to execute discovery commands.
- The adversary identifies a target directory for data harvesting.
- The Get-ChildItem cmdlet is invoked with -Recurse and -Include parameters.
- The command filters the search for specific document extensions (e.g., .docx, .pdf).
- The system iterates through subdirectories to collect a list of target files.
- Results are piped or redirected to a temporary staging file on the disk.
- Collected files are compressed or prepared for exfiltration to an external C2 server.
Impact
Successful execution of automated collection allows an attacker to gain visibility into an organization's proprietary data, intellectual property, and sensitive user documentation. This stage is a prerequisite for data theft, which can lead to significant business disruption, regulatory penalties, and loss of competitive advantage.
Recommendation
- Enable PowerShell Script Block Logging (Event ID 4104) across all endpoints to capture full command execution history.
- Deploy the provided Sigma rule to detect recursive file searches targeting document extensions.
- Investigate any PowerShell processes triggered by unexpected parent processes (e.g., web server services or document editors).
- Review generated PowerShell logs for attempts to copy or move large volumes of files identified during the collection process.
Immediate actions
Enable PowerShell Script Block Logging (Event ID 4104)
Threat Hunt
Search for high-frequency Get-ChildItem calls with recursive flags in logs
Data: PowerShell Operational Event Log
Mitigations
Implement strict Execution Policy and AppLocker/WDAC rules
Restricts execution of unauthorized PowerShell scripts
Detection coverage 1
Detect Automated PowerShell Data Collection
mediumDetects the use of PowerShell to recursively search for common document file types, an indicator of automated data collection.
Detection queries are available on the platform. Get full rules →