Skip to content

Commit a339415

Browse files
authored
Merge pull request #3276 from nterl0k/nterl0k-t1059-malicious-powershell-strings
Nterl0k - T1059 - Generic Malicious Powershell Strings + Lookup
2 parents ebe37bb + f0d6c48 commit a339415

File tree

4 files changed

+342
-0
lines changed

4 files changed

+342
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Windows PowerShell Process With Malicious String
2+
id: 5df35d50-e1a3-4a52-a337-92e69d9b1b8a
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 through the process execution datamodel. This method captures commands given directly to powershell.exe, 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+
- Windows Security Event ID 4688
11+
- Sysmon Event ID 1
12+
- CrowdStrike ProcessRollup2
13+
search: |-
14+
| tstats `security_content_summariesonly` count values(Processes.original_file_name) as original_file_name values(Processes.process) as process values(Processes.parent_process) as parent_process min(_time) as firstTime max(_time) as lastTime from datamodel=Endpoint.Processes where `process_powershell` by Processes.user Processes.dest Processes.process_name Processes.parent_process_name Processes.process
15+
| `drop_dm_object_name(Processes)`
16+
| `security_content_ctime(firstTime)`
17+
| `security_content_ctime(lastTime)`
18+
| lookup malicious_powershell_strings command as process
19+
| where isnotnull(match)
20+
| `windows_powershell_process_with_malicious_string_filter`
21+
how_to_implement: The detection is based on data that originates from Endpoint Detection and Response (EDR) agents. These agents are designed to provide security-related telemetry from the endpoints where the agent is installed. To implement this search, you must ingest logs that contain the process GUID, process name, and parent process. Additionally, you must ingest complete command-line executions. These logs must be processed using the appropriate Splunk Technology Add-ons that are specific to the EDR product. The logs must also be mapped to the `Processes` node of the `Endpoint` data model. Use the Splunk Common Information Model (CIM) to normalize the field names and speed up the data modeling process.
22+
known_false_positives: Unknown, possible usage by internal red team or powershell commands with overlap.
23+
references:
24+
- https://attack.mitre.org/techniques/T1059/001/
25+
- https://github.com/PowerShellMafia/PowerSploit
26+
- https://github.com/PowerShellEmpire/
27+
- https://github.com/S3cur3Th1sSh1t/PowerSharpPack
28+
drilldown_searches:
29+
- name: View the detection results for - "$dest$" and "$user$"
30+
search: '%original_detection_search% | search dest = "$dest$" AND user = "$user$"'
31+
earliest_offset: $info_min_time$
32+
latest_offset: $info_max_time$
33+
- name: View risk events for the last 7 days for - "$dest$" and "$user$"
34+
search: '| from datamodel Risk.All_Risk | search normalized_risk_object IN ("$dest$","$user$") 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)`'
35+
earliest_offset: $info_min_time$
36+
latest_offset: $info_max_time$
37+
- name: Investigate PowerShell on $dest$
38+
search: '| from datamodel:Endpoint.Processes | search dest=$dest|s$ process_name=$process_name$ "*$match$*"'
39+
earliest_offset: $info_min_time$
40+
latest_offset: $info_max_time$
41+
rba:
42+
message: The user $user$ ran a known malicious PowerShell string matching *$match$* on $dest$
43+
risk_objects:
44+
- field: user
45+
type: user
46+
score: 70
47+
- field: dest
48+
type: system
49+
score: 70
50+
threat_objects:
51+
- field: process_name
52+
type: process_name
53+
tags:
54+
analytic_story:
55+
- Malicious PowerShell
56+
asset_type: Endpoint
57+
mitre_attack_id:
58+
- T1059.001
59+
product:
60+
- Splunk Enterprise
61+
- Splunk Enterprise Security
62+
- Splunk Cloud
63+
security_domain: threat
64+
tests:
65+
- name: True Positive Test
66+
attack_data:
67+
- data: https://media.githubusercontent.com/media/splunk/attack_data/master/datasets/attack_techniques/T1087.002/AD_discovery/windows-sysmon.log
68+
source: XmlWinEventLog:Microsoft-Windows-Sysmon/Operational
69+
sourcetype: XmlWinEventLog
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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

Comments
 (0)