Files
splunk-security_content/detections/endpoint/powershell_script_block_with_url_chain.yml
2024-06-26 14:41:53 +00:00

81 lines
3.3 KiB
YAML

name: PowerShell Script Block With URL Chain
id: 4a3f2a7d-6402-4e64-a76a-869588ec3b57
version: 2
date: '2024-05-30'
author: Steven Dick
status: production
type: TTP
description: The following analytic identifies suspicious PowerShell script execution
via EventCode 4104 that contains multiple URLs within a function or array. It leverages
PowerShell operational logs to detect script blocks with embedded URLs, often indicative
of obfuscated scripts or those attempting to download secondary payloads. This activity
is significant as it may signal an attempt to execute malicious code or download
additional malware. If confirmed malicious, this could lead to code execution, further
system compromise, or data exfiltration. Review parallel processes and the full
script block for additional context and related artifacts.
data_source:
- Powershell Script Block Logging 4104
search: '`powershell` EventCode=4104 ScriptBlockText IN ("*http:*","*https:*") | regex
ScriptBlockText="(\"?(https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))\"?(?:,|\))?){2,}"
| rex max_match=20 field=ScriptBlockText "(?<url>https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*))"
| eval Path = case(isnotnull(Path),Path,true(),"unknown") | stats count min(_time)
as firstTime max(_time) as lastTime list(ScriptBlockText) as command values(Path)
as file_name values(UserID) as user values(url) as url dc(url) as url_count by ActivityID,
Computer, EventCode | rename Computer as dest, EventCode as signature_id | `security_content_ctime(firstTime)`
| `security_content_ctime(lastTime)` | `powershell_script_block_with_url_chain_filter`'
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.
known_false_positives: Unknown, possible custom scripting.
references:
- https://www.mandiant.com/resources/blog/tracking-evolution-gootloader-operations
- https://thedfirreport.com/2022/05/09/seo-poisoning-a-gootloader-story/
- https://attack.mitre.org/techniques/T1059/001/
tags:
analytic_story:
- Malicious PowerShell
asset_type: Endpoint
confidence: 80
impact: 100
message: A suspicious powershell script used by $user$ on host $dest$ contains $url_count$
URLs in an array, this is commonly used for malware.
mitre_attack_id:
- T1059.001
- T1105
observable:
- name: dest
type: Endpoint
role:
- Victim
- name: user
type: User
role:
- Victim
- name: file_name
type: File Name
role:
- Attacker
- name: url
type: URL String
role:
- Attacker
product:
- Splunk Enterprise
- Splunk Enterprise Security
- Splunk Cloud
required_fields:
- _time
- EventCode
- ActivityID
- Computer
- ScriptBlockText
risk_score: 80
security_domain: endpoint
tests:
- name: True Positive Test
attack_data:
- data:
https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/malware/gootloader/partial_ttps/windows-powershell-xml.log
source: XmlWinEventLog:Microsoft-Windows-PowerShell/Operational
sourcetype: XmlWinEventLog