Suspicious PowerShell Reconnaissance and Data Export
Adversaries utilize automated PowerShell reconnaissance commands combined with redirection to temporary files to collect and stage system information for exfiltration.
Adversaries often perform automated reconnaissance to gather environment-specific data after gaining initial access to a Windows system. A common technique involves executing native PowerShell cmdlets to enumerate services, running processes, or file system contents and redirecting the output into text files within the user's temporary directory. This behavior facilitates the staging of sensitive internal system information for later exfiltration. Defenders should focus on monitoring PowerShell Script Block logs (Event ID 4104) for suspicious combinations of enumeration commands and redirection operators pointing to standard temporary file paths.
Attack Chain
- Attacker gains initial access to the target host through phishing or exploit.
- Attacker launches PowerShell to perform discovery of local assets.
- PowerShell cmdlets (Get-Service, Get-ChildItem, Get-Process) are executed to map system state.
- Output is piped or redirected using the '>' operator into a file in $env:TEMP.
- The attacker verifies the content of the staged text file.
- The staged data is exfiltrated to attacker-controlled infrastructure.
Impact
Successful reconnaissance allows an attacker to map the victim environment, identify security software, find sensitive data locations, and prepare for lateral movement or data exfiltration. If left undetected, this activity significantly increases the success rate of subsequent phases of an attack.
Recommendation
Deploy the provided Sigma rule to detect suspicious PowerShell enumeration patterns and enable PowerShell Script Block Logging (Event ID 4104) across all endpoints to ensure visibility.
Immediate actions
Enable PowerShell Script Block Logging (Event ID 4104)
Threat Hunt
Search for script block logs containing both enumeration cmdlets and redirection operators
Data: Event ID 4104
Detection coverage 1
Detect Recon Information for Export with PowerShell
mediumDetects reconnaissance commands that redirect output to the temp directory
Detection queries are available on the platform. Get full rules →