Detecting PowerShell Command Line Obfuscation Techniques
Detection logic for identifying PowerShell execution utilizing excessive special characters for command line obfuscation to bypass security monitoring.
Adversaries frequently employ obfuscation techniques within PowerShell command lines to evade detection by security monitoring tools. By leveraging excessive special characters, such as backticks (`), carets (^), curly braces ({), or concatenation operators (+), attackers can break up keywords and command structure, rendering simple string-matching detection rules ineffective. This approach is commonly used in malicious scripts to hide the nature of the executed code from defenders. The detection logic provided focuses on identifying repetitive patterns of these special characters in the command line arguments of powershell.exe and pwsh.exe. Defenders should baseline their environment to account for legitimate automation scripts that may occasionally utilize obfuscated or complex command structures.
Impact
Successful obfuscation allows attackers to execute malicious scripts, download secondary payloads, or perform reconnaissance without triggering standard signature-based alerts. This increases the attacker's dwell time and ability to move laterally within a compromised environment.
Recommendation
- Deploy the provided Sigma rule to identify command lines exhibiting excessive special character usage.
- Baseline execution logs to identify legitimate software or system administration scripts that may trigger this rule, and add them to the filter block.
- Enable Sysmon or Windows Event Log 4688 with command line auditing to ensure the visibility required for this detection.
Immediate actions
Deploy Sigma detection to SIEM and set to monitor-only/logging mode.
Threat Hunt
Search historical process logs for high frequencies of backticks or carets in PowerShell command lines.
Data: Process creation events
Mitigations
Enforce script block logging (PowerShell Event ID 4104) to capture de-obfuscated script content.
T1027
Detection coverage 1
Detect Suspicious PowerShell Command Line Obfuscation
mediumDetects PowerShell execution containing high densities of special characters used for obfuscation, such as backticks, carets, concatenation operators, or braces.
Detection queries are available on the platform. Get full rules →