Skip to content
Threat Feed
high advisory

PowerShell Obfuscation via Concatenated Dynamic Command Invocation

This rule detects PowerShell scripts that build commands from concatenated string literals within dynamic invocation constructs, a technique used by attackers to obscure execution intent, bypass keyword-based detections, and evade AMSI.

This detection rule identifies PowerShell scripts employing concatenated string literals within dynamic invocation constructs like &() or .(). This obfuscation technique allows attackers to construct commands dynamically, making it harder to detect their malicious intent based on static analysis or keyword matching. By breaking commands into smaller, concatenated strings, attackers aim to bypass traditional signature-based detections and evade AMSI (Anti-Malware Scan Interface). This technique has been observed in various campaigns where threat actors attempt to execute malicious code while minimizing the chances of detection. This activity is particularly concerning for defenders, as it highlights a common method to bypass security measures.

Attack Chain

  1. An attacker gains initial access to a system (e.g., through phishing or exploiting a vulnerability).
  2. The attacker executes a PowerShell script on the compromised system.
  3. The PowerShell script uses string concatenation to build malicious commands dynamically.
  4. Dynamic invocation constructs like &() or .() are used to execute the concatenated commands.
  5. The obfuscated commands bypass keyword-based detections and AMSI.
  6. The attacker performs malicious activities, such as downloading additional payloads.
  7. The attacker executes the downloaded payloads to establish persistence or exfiltrate data.
  8. The attacker achieves their final objective, such as stealing sensitive information or deploying ransomware.

Impact

Successful exploitation can lead to complete system compromise, data theft, and potential ransomware deployment. Attackers can leverage this technique to evade security controls and execute malicious commands undetected. The impact is high because it allows attackers to bypass common defenses and maintain persistence on the system, affecting potentially hundreds or thousands of systems across an organization.

Recommendation

  • Enable PowerShell Script Block Logging to capture the events necessary for this detection, as indicated in the setup instructions linked in the source material.
  • Deploy the Sigma rule Detect PowerShell Obfuscation via String Concatenation to your SIEM and tune for your environment to detect the use of concatenated strings in PowerShell commands.
  • Investigate alerts generated by the Sigma rule, focusing on the reconstructed PowerShell commands and the processes that launched them, as outlined in the triage and analysis section of the source material.
  • Monitor for follow-on activities, such as child processes, file modifications, and network connections originating from PowerShell processes exhibiting obfuscation techniques.

Detection coverage 2

Detect PowerShell Obfuscation via String Concatenation

high

Detects PowerShell scripts that build commands using concatenated strings, a technique used for defense evasion.

sigma tactics: defense_evasion techniques: T1027 sources: powershell, windows

Detect Dynamic Invocation of Concatenated Strings in PowerShell

high

This rule identifies PowerShell scripts that construct commands from concatenated string literals and execute them using dynamic invocation constructs like &() or .().

sigma tactics: defense_evasion techniques: T1027 sources: powershell, windows

Detection queries are kept inside the platform. Get full rules →