|
| 1 | +name: Windows PowerShell Script Block With Malicious String |
| 2 | +id: 0f09cedd-10f1-4b9f-bdea-7a8b06ea575d |
| 3 | +version: 1 |
| 4 | +date: '2024-12-19' |
| 5 | +author: Steven Dick |
| 6 | +status: production |
| 7 | +type: TTP |
| 8 | +description: The following analytic detects the execution of multiple offensive toolkits and commands by leveraging PowerShell Script Block Logging (EventCode=4104). This method captures and logs the full command sent to PowerShell, allowing for the identification of suspicious activities including several well-known tools used for credential theft, lateral movement, and persistence. If confirmed malicious, this could lead to unauthorized access, privilege escalation, and potential compromise of sensitive information within the environment. |
| 9 | +data_source: |
| 10 | +- Powershell Script Block Logging 4104 |
| 11 | +search: |- |
| 12 | + `powershell` ScriptBlockText EventCode=4104 |
| 13 | + | stats count min(_time) as firstTime max(_time) as lastTime list(ScriptBlockText) as command Values(OpCode) as reason values(Path) as file_name values(UserID) as user by ActivityID, Computer, EventCode |
| 14 | + | eval command = mvjoin(command,"\n"), dest = Computer, signature = EventCode, signature_id = ActivityID |
| 15 | + | lookup malicious_powershell_strings command |
| 16 | + | where isnotnull(match) |
| 17 | + | `security_content_ctime(firstTime)` |
| 18 | + | `security_content_ctime(lastTime)` |
| 19 | + | `windows_powershell_script_block_with_malicious_string_filter` |
| 20 | +how_to_implement: The following analytic requires PowerShell operational logs to be imported. Modify the powershell macro as needed to match the sourcetype or add index. This analytic is specific to 4104, or PowerShell Script Block Logging. |
| 21 | +known_false_positives: Unknown, possible usage by internal red team or powershell commands with overlap. |
| 22 | +references: |
| 23 | +- https://attack.mitre.org/techniques/T1059/001/ |
| 24 | +- https://github.com/PowerShellMafia/PowerSploit |
| 25 | +- https://github.com/PowerShellEmpire/ |
| 26 | +- https://github.com/S3cur3Th1sSh1t/PowerSharpPack |
| 27 | +drilldown_searches: |
| 28 | +- name: View the detection results for - "$dest$" |
| 29 | + search: '%original_detection_search% | search dest = "$dest$"' |
| 30 | + earliest_offset: $info_min_time$ |
| 31 | + latest_offset: $info_max_time$ |
| 32 | +- name: View risk events for the last 7 days for - "$dest$" |
| 33 | + search: '| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$dest$") starthoursago=168 | stats count min(_time) as firstTime max(_time) as lastTime values(search_name) as "Search Name" values(risk_message) as "Risk Message" values(analyticstories) as "Analytic Stories" values(annotations._all) as "Annotations" values(annotations.mitre_attack.mitre_tactic) as "ATT&CK Tactics" by normalized_risk_object | `security_content_ctime(firstTime)` | `security_content_ctime(lastTime)`' |
| 34 | + earliest_offset: $info_min_time$ |
| 35 | + latest_offset: $info_max_time$ |
| 36 | +- name: Investigate PowerShell on $dest$ |
| 37 | + search: '`powershell` ScriptBlockText EventCode=4104 Computer=$dest|s$ "*$match$*"' |
| 38 | + earliest_offset: $info_min_time$ |
| 39 | + latest_offset: $info_max_time$ |
| 40 | +rba: |
| 41 | + message: The user $user$ ran a known malicious PowerShell string matching *$match$* on $dest$ |
| 42 | + risk_objects: |
| 43 | + - field: user |
| 44 | + type: user |
| 45 | + score: 70 |
| 46 | + - field: dest |
| 47 | + type: system |
| 48 | + score: 70 |
| 49 | + threat_objects: |
| 50 | + - field: signature_id |
| 51 | + type: signature |
| 52 | +tags: |
| 53 | + analytic_story: |
| 54 | + - Malicious PowerShell |
| 55 | + asset_type: Endpoint |
| 56 | + mitre_attack_id: |
| 57 | + - T1059.001 |
| 58 | + product: |
| 59 | + - Splunk Enterprise |
| 60 | + - Splunk Enterprise Security |
| 61 | + - Splunk Cloud |
| 62 | + security_domain: threat |
| 63 | +tests: |
| 64 | +- name: True Positive Test |
| 65 | + attack_data: |
| 66 | + - data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1552.006/powershell_gpp_discovery/win-powershell.log |
| 67 | + source: XmlWinEventLog:Microsoft-Windows-PowerShell/Operational |
| 68 | + sourcetype: XmlWinEventLog |
0 commit comments