Try in Splunk Security Cloud


The following analytic identifies suspicious PowerShell script execution via EventCode 4104 that is processing cryptography namespace library. This technique was seen in several powershell malware, loader, downloader and stager that will decrypt or decode the next malicious stager or the actual payload. This Anomaly detection can be a good indicator that a powershell process to decrypt code. We recommend to further check the parent_process_name, the file or data it tries to decrypt, network connection and user who execute the script.

  • Type: Anomaly
  • Product: Splunk Enterprise, Splunk Enterprise Security, Splunk Cloud
  • Datamodel: Endpoint
  • Last Updated: 2023-01-26
  • Author: Teoderick Contreras, Splunk
  • ID: f8b482f4-6d62-49fa-a905-dfa15698317b




ID Technique Tactic
T1059.001 PowerShell Execution
T1059 Command and Scripting Interpreter Execution
Kill Chain Phase
  • Exploitation
  • DE.CM
  • CIS 3
  • CIS 5
  • CIS 16
`powershell` EventCode=4104 ScriptBlockText = "*System.Security.Cryptography*" AND NOT(ScriptBlockText IN ("*SHA*", "*MD5*", "*DeriveBytes*")) 
| stats count min(_time) as firstTime max(_time) as lastTime by EventCode ScriptBlockText Computer UserID 
| `security_content_ctime(firstTime)` 
| `security_content_ctime(lastTime)` 
| `windows_powershell_cryptography_namespace_filter`


The SPL above uses the following Macros:

:information_source: windows_powershell_cryptography_namespace_filter is a empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Required fields

List of fields required to use this analytic.

  • _time
  • ScriptBlockText
  • Opcode
  • Computer
  • UserID
  • EventCodes

How To Implement

To successfully implement this analytic, you will need to enable PowerShell Script Block Logging on some or all endpoints. Additional setup here

Known False Positives

False positives should be limited. Filter as needed.

Associated Analytic Story


Risk Score Impact Confidence Message
25.0 50 50 A suspicious powershell script contains cryptography command in $ScriptBlockText$ with EventCode $EventCode$ in host $Computer$

:information_source: The Risk Score is calculated by the following formula: Risk Score = (Impact * Confidence/100). Initial Confidence and Impact is set by the analytic author.


Test Dataset

Replay any dataset to Splunk Enterprise by using our tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range

source | version: 1