Suspicious Encoded PowerShell Command Line
Last updated on:
In this page
Rule name | Rule type | Log sources | MITRE ATT&CK tags | Severity |
Suspicious Encoded PowerShell Command Line | Standard | Windows | Execution: Command and Scripting Interpreter - PowerShell (T1059.001) | Critical |
About the rule
Rule Type
Standard
Rule Description
This rule detects PowerShell processes that use base64-encoded commands, often seen in malware campaigns like Emotet. Attackers use encoded strings to obfuscate their intent, hiding malicious scripts from traditional command-line monitoring tools and security software.
Severity
Trouble
Rule journey
Attack chain scenario
Initial access via malicious Office document → Triggers hidden PowerShell with -enc flag → Decodes and executes base64 command to fetch malware → Installs backdoor → Lateral movement
Impact
- Data theft
- Ransomware deployment
- Backdoor creation
Rule Requirement
Prerequisites
Process Creation Auditing
Via Windows Event Viewer (GPO)
- Open GPMC (gpmc.msc) using a domain admin account.
- Navigate to:
Computer Configuration > Policies > Windows Settings > Security Settings > Advanced Audit Policy Configuration > Audit Policies > Detailed Tracking - Enable:
- Audit Process Creation
- Audit Process Termination
(Check “Success” box for both)
- For command-line logging:
Go to:
Computer Configuration > Administrative Templates > System > Audit Process Creation
→ Enable “Include command line in process creation events.” - 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 notcontains "ExecutionPolicy Remotesigned" AND PROCESSNAME endswith "powershell.exe" AND (COMMANDLINE contains "-e" OR COMMANDLINE contains "-en" OR COMMANDLINE contains "-enc" OR COMMANDLINE contains "-w hidden -e")) 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 PowerShell executions (e.g., powershell.exe or pwsh.exe) with -enc or -e flag followed by suspicious base64 strings. This enables you to disable or restrict PowerShell usage where not needed.
Author
Florian Roth (Nextron Systems), Markus Neis, Jonhnathan Ribeiro, Daniil Yugoslavskiy, Anton Kutepov, oscd.community
Future actions
Known False Positives
This rule might be triggered due to some IT automation tools and scripts that use encoding legitimately.
Next Steps
When this rule is triggered, the following measures can be implemented:
- Identification: Identify if the flagged event is a new incident or part of an existing incident.
- Analysis: Analyze the impact and extent of the incident to comprehend the severity of the attack using the Incident Workbench.
- Response: Respond promptly by initiating an automated workflow to interrupt the network connections and cease the malicious process.
- Audit PowerShell activities: Monitor PowerShell invocations with encoded commands.
Mitigation
Mitigation ID | Mitigation Name | Mitigation description |
M1049 | Implement antivirus or antimalware scanning to isolate suspicious files. | |
M1045 | Configure policies that allow PowerShell to execute only signed scripts. | |
M1042 | Restrict or disable PowerShell on systems where it is not required. | |
M1038 | Restrict the execution of scripts that contain sensitive language elements i.e., malicious codes using the PowerShell Constrained Language mode. | |
M1026 | Restrict privileges to execute PowerShell scripts to administrators and enforce limitations on the commands that can be executed via remote PowerShell sessions. |


