Detection rules › Splunk
Command-Line Interface Execution (PowerShell)
Detects when a Command-Line Interface executes on a host
MITRE ATT&CK coverage
References
Telemetry coverage
| Provider | Record / event type |
|---|---|
| PowerShell | Event ID 4103: Payload Context: ContextInfo User Data: UserData. |
Rule body
id: '1036.1046'
title: Command-Line Interface Execution
description: 'Detects when a Command-Line Interface executes on a host. -- Threat
Actor Association: APT29/Nobelium/Cozy Bear, APT31, APT35/Phosphorus/Magic Hound,
APT36, APT37, APT41, Carbanak, FamousSparrow, FIN6, FIN7, FIN8, Kimsuky, MalKamak,
MuddyWater, Night Spider, TA,505, TA551, Prophet Spider, Wizard Spider, WIRTE --
Software Association: Astaroth, BadHatch, Bazar, Conti, Cring, Emotet, GhostShell,
Hafnium, Hancitor, Harvester, Hive, IcedID, MINEBRIDGE, MirrorBlast, MysterySnail,
Nefilim, PowerShortShell, Prometheus / Spook, QakBot, Ransom Cartel, RATDispenser,
Remcos, Ryuk, Sodinokibi/REvil, SquirrelWaffle, Trickbot, XingLocker, Zloader, Zumkong'
logic_format: Splunk
logic: ' `get_endpoint_data` `get_endpoint_data_powershell` EventCode=4103 ("powershell.exe"
OR "cmd.exe") | table _time, host, user client, event_id, eventtype, host, index,
parameters, process, process_name, process_path, shell, signature_id, source, sourcetype,
tag, user, user_id | bin span=60s | stats values(*) as * by _time, host | where
match(process,"(?i)powershell\.exe") OR match(process,"(i?)cmd\.exe") | fields -
process '
techniques:
- execution:command and scripting interpreter:powershell
- execution:command and scripting interpreter:windows command shell
technique_id:
- T1059.001
- T1059.003
data_category:
- PowerShell logs
- Process command-line parameters
references:
- https://securityintelligence.com/an-increase-in-powershell-attacks-observations-from-ibm-x-force-iris/
- https://www.trendmicro.com/vinfo/us/security/news/cybercrime-and-digital-threats/tracking-detecting-and-thwarting-powershell-based-malware-and-attacks
Stages and Predicates
Stage 1: search
`get_endpoint_data` `get_endpoint_data_powershell` EventCode=4103 ("powershell.exe" OR "cmd.exe")
Stage 2: table
| table _time, host, user client, event_id, eventtype, host, index, parameters, process, process_name, process_path, shell, signature_id, source, sourcetype, tag, user, user_id
Stage 3: bucket
| bin span=60s
Stage 4: stats
| stats values(*) as * by _time, host
Stage 5: where
| where match(process,"(?i)powershell\.exe") OR match(process,"(i?)cmd\.exe")
Stage 6: fields
| fields - process
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
EventCode | eq |
| field:"EventID" kind:eq value:"4103" |
process | regex_match |
| field:"CommandLine" kind:regex_match |
Search terms
These SPL tokens match against raw event text.
| Stage | Term |
|---|---|
| 1 | "powershell.exe" |
| 1 | "cmd.exe" |