PowerShell Base64 Encoded IEX Cmdlet

Last updated on:

Rule name

Rule type

Log sources

MITRE ATT&CK tags

Severity

PowerShell Base64 Encoded IEX Cmdlet

Standard

Windows

Execution: Command and Scripting Interpreter - PowerShell (T1059.001)

Trouble

About the rule

Rule Type

Standard

Rule Description

This detection focuses on identifying obfuscated PowerShell commands where the Invoke-Expression (IEX) cmdlet is hidden using base64 encoding. IEX is commonly used by attackers to evaluate and execute arbitrary code, especially in fileless malware attacks. Encoding the command with base64 allows adversaries to bypass basic string-based detection mechanisms.

Severity

Trouble

Rule journey

Attack chain scenario

Malicious document upload → Macro execution → PowerShell script launch → Base64-encoded IEX fetch → Remote access established

Impact

  • Ransomware deployment
  • Defense evasion
  • Fileless-acttacks

Rule Requirement

Prerequisites

Process Creation Auditing

Via Windows Event Viewer (GPO)

  1. Open GPMC (gpmc.msc) using a domain admin account.
  2. Navigate to:
    Computer Configuration > Policies > Windows Settings > Security Settings > Advanced Audit Policy Configuration > Audit Policies > Detailed Tracking
  3. Enable:
    • Audit Process Creation
    • Audit Process Termination
      (Check “Success” box for both)
  4. For command-line logging:
    Go to:
    Computer Configuration > Administrative Templates > System > Audit Process Creation
    → Enable “Include command line in process creation events.”
  5. Create registry key (if missing):
    Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Microsoft-Windows-Security-Auditing/Operational

Using Sysmon

To set up process creation monitoring with Sysmon:

1.Download and install Sysmon from Microsoft Sysinternals.

2. Open a Command Prompt with administrator privileges.

3. Create or download a Sysmon configuration file that includes process creation monitoring. A basic example for capturing all process creations is:

<Sysmon>
<EventFiltering>
<ProcessCreate onmatch="exclude"/>
</EventFiltering>
</Sysmon>

4. Install Sysmon with your configuration file using the command:

sysmon.exe -i [configfile.xml] (Replace [configfile.xml] with your file's path and name).

5. Ensure a new registry key named "Microsoft-Windows-Sysmon/Operational" exists in the directory Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\. If not, create it.

Criteria

Action1: actionname = "Process started" AND (COMMANDLINE contains "SUVYIChb,lFWCAoW,JRVggKF" OR COMMANDLINE contains "aWV4IChb,lleCAoW,pZXggKF" OR COMMANDLINE contains "aWV4IChOZX,lleCAoTmV3,pZXggKE5ld" OR COMMANDLINE contains "SUVYIChOZX,lFWCAoTmV3,JRVggKE5ld" OR COMMANDLINE contains "SUVYKF,lFWChb,JRVgoW" OR COMMANDLINE contains "aWV4KF,lleChb,pZXgoW" OR COMMANDLINE contains "aWV4KE5ld,lleChOZX,pZXgoTmV3" OR COMMANDLINE contains "SUVYKE5ld,lFWChOZX,JRVgoTmV3" OR COMMANDLINE contains "SUVYKCgn,lFWCgoJ,JRVgoKC" OR COMMANDLINE contains "aWV4KCgn,lleCgoJ,pZXgoKC") OR COMMANDLINE contains "SQBFAFgAIAAoAFsA,kARQBYACAAKABbA,JAEUAWAAgACgAWw,aQBlAHgAIAAoAFsA,kAZQB4ACAAKABbA,pAGUAeAAgACgAWw,aQBlAHgAIAAoAE4AZQB3A,kAZQB4ACAAKABOAGUAdw,pAGUAeAAgACgATgBlAHcA,SQBFAFgAIAAoAE4AZQB3A,kARQBYACAAKABOAGUAdw,JAEUAWAAgACgATgBlAHcA" select Action1.HOSTNAME,Action1.MESSAGE,Action1.COMMANDLINE,Action1.FILE_NAME,Action1.PROCESSNAME,Action1.USERNAME,Action1.PARENTPROCESSNAME

Detection

Execution Mode

realtime

Log Sources

Windows

MITRE ATT&CK

Execution: Command and Scripting Interpreter - PowerShell (T1059.001)

Security Standards

Enabling this rule will help you meet the security standard's requirement listed below:

NIST CSF DE.CM-1: Network and physical activities are monitored to detect anomalous events.

When this rule is triggered, you're notified of attempts to execute encoded PowerShell commands containing the dangerous IEX cmdlet. This enables you to disable or restrict PowerShell usage for non-admin users.

Author

Florian Roth (Nextron Systems)

Future actions

Known False Positives

This rule might be triggered by some legitimate administrative scripts.

Next Steps

When this rule is triggered, the following measures can be implemented:

  1. Identification: Identify if the flagged event is a new incident or part of an existing incident.
  2. Analysis: Analyze the impact and extent of the incident to comprehend the severity of the attack using the Incident Workbench.
  3. Response: Respond promptly by initiating an automated workflow to interrupt the network connections and cease the malicious process.
  4. Enable PoweShell logging: Enable script block and module logging in PowerShell.

Mitigation

Mitigation ID

Mitigation Name

Mitigation description

M1049

Antivirus/Antimalware

Implement antivirus or antimalware scanning to isolate suspicious files.

M1045

Code Signing

Configure policies that allow PowerShell to execute only signed scripts.

M1042

Disable or Remove Feature or Program

Restrict or disable PowerShell on systems where it is not required.

M1038

Execution Prevention

Restrict the execution of scripts that contain sensitive language elements i.e., malicious codes using the PowerShell Constrained Language mode.

M1026

Privileged Account Management

Restrict privileges to execute PowerShell scripts to administrators and enforce limitations on the commands that can be executed via remote PowerShell sessions.