Skip to content
Threat Feed
high advisory

Suspicious PowerShell Base64 Encoded Command Lines

Detection of malicious PowerShell execution patterns involving Base64 encoded commands, frequently utilized by malware families such as Emotet for obfuscated payload delivery.

This brief addresses a common technique used by attackers to execute obfuscated PowerShell scripts on Windows systems. By utilizing Base64 encoding for command-line arguments, attackers attempt to bypass static analysis tools and signature-based security controls. This method is a hallmark of various malware families, most notably Emotet, which leverages PowerShell to bootstrap secondary payloads, establish persistence, or perform reconnaissance. Attackers typically use the -EncodedCommand or shorthand -e switches to pass malicious scripts that are reconstructed in memory at runtime. Given the ubiquity of PowerShell in administrative environments, detection must focus on common encoding patterns and indicators of shell reconstruction to distinguish malicious activity from standard system maintenance tasks.

Attack Chain

  1. Initial infection (e.g., via phishing document) triggers an external process, often mshta.exe or wscript.exe.
  2. The initial process executes a command-line string containing a Base64 encoded PowerShell script.
  3. The operating system spawns a new PowerShell (powershell.exe) or PowerShell Core (pwsh.exe) process.
  4. The process ingest the encoded argument, often hidden with flags to prevent user notification.
  5. The PowerShell engine decodes the Base64 input buffer into executable code.
  6. The decoded script performs environment checks, C2 connection establishment, or privilege escalation.
  7. The final stage executes the primary payload (e.g., banking trojan or credential harvester) in memory.

Impact

Successful execution of these encoded commands often results in full system compromise, providing attackers with a foothold for credential theft, lateral movement, and data exfiltration. Because the malicious logic is decoded directly in memory, it poses a significant challenge for traditional file-based antivirus solutions that do not perform behavioral memory analysis.

Recommendation

  • Deploy the provided Sigma rule to detect PowerShell processes launching with known Base64 command-line patterns.
  • Enable PowerShell Script Block Logging (Event ID 4104) to capture the de-obfuscated script content, providing visibility into the decoded logic even when the initial command line is encoded.
  • Review environments for high-frequency PowerShell usage from non-administrative service accounts to refine the baseline for detection tuning.

Immediate actions

Deploy the encoded PowerShell detection rule to the SIEM

Detection Engineering 48h

Threat Hunt

Search for processes spawned by non-interactive service accounts using -enc or -e switches

T1059.001 medium medium confidence hunt now

Data: Process creation telemetry

Detection coverage 1

Detect Suspicious Encoded PowerShell Command Line

high

Detects PowerShell process starts with Base64 encoded commands often associated with malware such as Emotet.

sigma tactics: execution techniques: T1059.001 sources: process_creation, windows

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