PowerShell Directory Enumeration via MAZE Ransomware Tactics
Detection of PowerShell scripts utilizing specific cmdlets to recursively enumerate file system directories, a technique historically associated with MAZE ransomware discovery operations.
This detection brief addresses the use of PowerShell for unauthorized directory discovery and enumeration. Threat actors, specifically those associated with the MAZE ransomware, have been observed utilizing PowerShell scripts to map local and network file systems. By iterating through directories using cmdlets such as Get-ChildItem and redirecting the output to files, attackers can identify sensitive data for exfiltration or encryption. The technique is typically executed via living-off-the-land binaries to minimize footprint, making the monitoring of PowerShell Script Block Logging essential for identifying post-exploitation discovery activities in enterprise environments.
Attack Chain
- Initial access is established via phishing or exploitation of internet-facing services.
- The attacker executes a PowerShell process via a web shell or other command-line entry point.
- A script is invoked to enumerate directories to identify valuable data targets.
- The script uses 'Get-ChildItem' with 'foreach' loops to recursively scan folder structures.
- The attacker forces suppression of errors using '-ErrorAction SilentlyContinue' to prevent detection of permission issues.
- Results of the directory scan are captured and redirected to a local text file using 'Out-File -append'.
- The collected metadata is exfiltrated to the attacker's C2 server.
- The final objective is reached through the subsequent encryption of identified directories.
Impact
Successful execution of this discovery technique allows attackers to map the environment, prioritize targets for data exfiltration, and systematically prepare for the deployment of ransomware. This increases the risk of data loss and operational downtime for organizations in all sectors.
Recommendation
- Enable PowerShell Script Block Logging (Event ID 4104) across all Windows endpoints to capture the full content of executing scripts.
- Deploy the provided Sigma rule to identify common patterns of automated directory enumeration via PowerShell.
- Investigate the source of PowerShell commands that use redirection to hidden or temporary directories.
- Review and restrict execution policy for PowerShell scripts to signed or approved administrative tasks.
Immediate actions
Enable PowerShell Script Block Logging (Event ID 4104) across all endpoints
Threat Hunt
Search for high volumes of Out-File executions originating from PowerShell
Data: Event ID 4104
Mitigations
Implement Constrained Language Mode (CLM) via AppLocker or WDAC
Restricts execution of unauthorized PowerShell functions
Detection coverage 1
Detect Suspicious Directory Enumeration via PowerShell
mediumDetects PowerShell scripts that perform recursive directory enumeration and redirect output to a file, a technique used by MAZE ransomware
Detection queries are available on the platform. Get full rules →