Skip to content
Threat Feed
medium threat

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

  1. Initial access is established via phishing or exploitation of internet-facing services.
  2. The attacker executes a PowerShell process via a web shell or other command-line entry point.
  3. A script is invoked to enumerate directories to identify valuable data targets.
  4. The script uses 'Get-ChildItem' with 'foreach' loops to recursively scan folder structures.
  5. The attacker forces suppression of errors using '-ErrorAction SilentlyContinue' to prevent detection of permission issues.
  6. Results of the directory scan are captured and redirected to a local text file using 'Out-File -append'.
  7. The collected metadata is exfiltrated to the attacker's C2 server.
  8. 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

IT Operations 48h

Threat Hunt

Search for high volumes of Out-File executions originating from PowerShell

T1083 medium medium confidence hunt now

Data: Event ID 4104

Mitigations

Implement Constrained Language Mode (CLM) via AppLocker or WDAC

medium_term IT Operations

Restricts execution of unauthorized PowerShell functions

Detection coverage 1

Detect Suspicious Directory Enumeration via PowerShell

medium

Detects PowerShell scripts that perform recursive directory enumeration and redirect output to a file, a technique used by MAZE ransomware

sigma tactics: discovery techniques: T1083 sources: ps_script, windows

Detection queries are available on the platform. Get full rules →