Detection rules › Splunk
Executable Create Script Process (PowerShell)
A BAT file is a DOS batch file used to execute commands with the Windows Command Prompt (cmd.exe), this usecase will detect common scripting type like bat, sh, and ps1 with an executable parent
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1059.003 Command and Scripting Interpreter: Windows Command Shell |
| Collection | T1119 Automated Collection |
| Exfiltration | T1020 Automated Exfiltration |
References
Event coverage
| Provider | Event | Title |
|---|---|---|
| PowerShell | Event ID 4104 | Creating Scriptblock text (MessageNumber of MessageTotal). |
Rule body yaml
id: '1116.1228'
title: Executable Create Script Process
description: 'A BAT file is a DOS batch file used to execute commands with the Windows
Command Prompt (cmd.exe), this usecase will detect common scripting type like bat,
sh, and ps1 with an executable parent. -- Threat Actor Association: APT28 (aka.Fancy
Bear, Fighting Ursa, Forest Blizzard, Pawn Storm, TA422, STRONTIUM), APT29/Nobelium/Cozy
Bear, APT31, APT35/Phosphorus/Magic Hound, APT41, APT43, Blind Eagle/APT-C-36, FIN8,
Gamaredon Group/Shuckworm, GoldenJackal, Karakurt, Mustang Panda (aka. Stately Taurus//Earth
Preta/BRONZE PRESIDENT/TA416/RedDelta), Redfly, TA413, UAC-0057 (GhostWriter), Vice
Society, Volt Typhoon, Winter Vivern, Witchetty, Wizard Spider -- Software Association:
ALPHV/BlackCat, AvosLocker, Bazarloader, BianLian, Black Basta, Blackbyte, Clop,
Conti, Dharma, Emotet, Hive, LV, Prestige, PYSA/Mespinoza, Quantum, Rhysida, Royal,
Snatch, Vice Society, TargetCompany, Trigona, XingLocker, Zloader - Atomics T1547.001
Test#6 - #TrendingThreat #Russia #Ukraine'
logic_format: Splunk
logic: ' `get_endpoint_data` `get_endpoint_data_powershell` ( signature_id=4104 AND
(".bat" OR ".ps1" OR ".sh") ) | rex field=process mode=sed max_match=0 "s/(?mi)^(Path.+)|^(ScriptBlock
ID.+)|^(Creating Scriptblock.+)//g"| rex field=process mode=sed "s/([\n\r]+)|(\s\s+)//g"|
regex process="(?i)\w+\.(bat|ps1|sh)" | table _time, host, user, signature_id, process,
process_name, parent_process_name | bin span=1s | stats values(*) as * by _time,
host '
techniques:
- execution:command and scripting interpreter
- exfiltration:automated exfiltration
- execution:command and scripting interpreter:windows command shell
- collection:automated collection
technique_id:
- T1059
- T1020
- T1059.003
- T1119
data_category:
- PowerShell logs
- Process command-line parameters
references:
- https://www.fireeye.com/blog/threat-research/2016/05/targeted_attacksaga.html
Stages and Predicates
Stage 1: search
`get_endpoint_data` `get_endpoint_data_powershell` ( signature_id=4104 AND (".bat" OR ".ps1" OR ".sh") )
Stage 2: eval
| rex field=process mode=sed max_match=0 "s/(?mi)^(Path.+)|^(ScriptBlock ID.+)|^(Creating Scriptblock.+)//g"
Stage 3: eval
| rex field=process mode=sed "s/([\n\r]+)|(\s\s+)//g"
Stage 4: regex
| regex process="(?i)\w+\.(bat|ps1|sh)"
Stage 5: table
| table _time, host, user, signature_id, process, process_name, parent_process_name
Stage 6: bucket
| bin span=1s
Stage 7: 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 |
|---|---|---|
process | regex_match |
|
signature_id | 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 | ".bat" |
| 1 | ".ps1" |
| 1 | ".sh" |