Detection rules › Splunk
PowerShell Download Activity (PowerShell)
This use case detects PowerShell commands used to download files or strings, indicating possible attempts to execute a script hosted on the internet
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1059.001 Command and Scripting Interpreter: PowerShell |
| Command & Control | T1105 Ingress Tool Transfer |
References
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-7.3
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3
- https://blog.talosintelligence.com/prometei-botnet-improves/
- https://blog.talosintelligence.com/lazarus-three-rats/
Event coverage
| Provider | Event | Title |
|---|---|---|
| PowerShell | Event ID 4103 | Payload Context: ContextInfo User Data: UserData. |
| PowerShell | Event ID 4104 | Creating Scriptblock text (MessageNumber of MessageTotal). |
Rule body yaml
id: '17159.27778'
title: PowerShell Download Activity
description: 'This use case detects PowerShell commands used to download files or
strings, indicating possible attempts to execute a script hosted on the internet.
-- Threat Actor Association: Alloy Taurus/Gallium, APT28 (aka.Fancy Bear, Fighting
Ursa, Forest Blizzard, Pawn Storm, TA422, STRONTIUM), APT29, APT40, FIN7, FIN8,
FIN11, Gamaredon Group/Shuckworm, Turla (akaSecret Blizzard, KRYPTON, and UAC-0003),
Sandworm Team - Software Association: ALPHV/Blackcat, Clop, LockBit, Quantum, Raspberry
Robin, Remcos RAT, TargetCompany, Ursnif, Vice Society -- Atomics T1087.002 Test
#15 Atomics T1135 Test #8 Atomics T1518 Test #4 Atomics T1518 Test #5 Atomics T1518
Test #6'
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_powershell` (TERM(EventCode=4103) OR
"<EventID>4103<" OR TERM(EventCode=4104) OR "<EventID>4104<") ((TERM(Invoke-Expression)
OR TERM(iex)) AND (TERM(Invoke-WebRequest) OR TERM(iwr))) OR ("New-Object" "Net.Webclient"
"Download") | table _time, host, user, user, process | bin span=1s | stats values(*)
as * by _time, host '
techniques:
- execution:command and scripting interpreter:powershell
- execution:command and scripting interpreter
- command-and-control:ingress tool transfer
technique_id:
- T1059.001
- T1059
- T1105
data_category:
- PowerShell logs
references:
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-7.3
- https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-7.3
- https://blog.talosintelligence.com/prometei-botnet-improves/
- https://blog.talosintelligence.com/lazarus-three-rats/
Stages and Predicates
Stage 1: search
`get_endpoint_data` `get_endpoint_data_powershell` (TERM(EventCode=4103) OR "<EventID>4103<" OR TERM(EventCode=4104) OR "<EventID>4104<") ((TERM(Invoke-Expression) OR TERM(iex)) AND (TERM(Invoke-WebRequest) OR TERM(iwr))) OR ("New-Object" "Net.Webclient" "Download")
Stage 2: table
| table _time, host, user, user, process
Stage 3: bucket
| bin span=1s
Stage 4: stats
| stats values(*) as * by _time, host
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
EventCode | eq |
|
Search terms
Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.
| Stage | Term |
|---|---|
| 1 | TERM |
| 1 | "<EventID>4103<" |
| 1 | TERM |
| 1 | "<EventID>4104<" |
| 1 | "Invoke-Expression" |
| 1 | TERM |
| 1 | iex |
| 1 | "Invoke-WebRequest" |
| 1 | TERM |
| 1 | iwr |
| 1 | "New-Object" |
| 1 | "Net.Webclient" |
| 1 | "Download" |