Detection rules › Splunk
Common Reconnaissance Commands (PowerShell)
These are reconnaissance commands that are most commonly used by attackers in order to collect information after gaining a access to the machine
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | |
| Discovery |
References
Telemetry coverage
| Provider | Record / event type |
|---|---|
| PowerShell | Event ID 4104: Creating Scriptblock text (MessageNumber of MessageTotal). |
Rule body
id: '1035.1043'
title: Common Reconnaissance Commands
description: 'These are reconnaissance commands that are most commonly used by attackers
in order to collect information after gaining a access to the machine. -- Threat
Actor Association: AbcBot, Alloy Taurus/Gallium, Andariel, APT27/Emissary Panda,
APT28 (aka.Fancy Bear, Fighting Ursa, Forest Blizzard, Pawn Storm, TA422, STRONTIUM),
APT29/Nobelium/Cozy Bear, APT33, APT35/Phosphorus/Magic Hound, APT36, APT43, Carbanak,
FamousSparrow, FIN6, FIN7, FIN8, FIN12, FIN13, Gorgon Group, Kimsuky, MuddyWater,
OilRig, SaintBear (aka UAC-0056, UNC2589, TA471), TA428, TA2541, TRAVELING SPIDER,
UAC-0056, Volt Typhoon (Bronze Silhouette, Vanguard Panda), Winter Vivern, Wizard
Spider -- Software Association: AvosLocker, BadHatch, Bazarloader, BianLian, Black
Basta, Blackcat/ALPHV, Clop, Conti, Cyclops Blink, Emotet, GhostShell, Hancitor,
Havex, IcedID, Insekt, Lockbit, NanoCore, Nefilim, PowerShortShell, Prometheus /
Spook, PYSA/Mespinoza, QakBot, Remcos, Ryuk, Snatch, Sodinokibi/REvil, Trickbot,
Vice Society, XingLocker -- Atomics T1007 Test#1 Atomics T1007 Test#2 Atomics T1016
Test#1 Atomics T1016 Test#2 Atomics T1016 Test#3 Atomics T1016 Test#4 Atomics T1016
Test#7 Atomics T1018 Test#1 Atomics T1018 Test#2 Atomics T1018 Test#3 Atomics T1018
Test#5 Atomics T1018 Test#6 Atomics T1018 Test#8 Atomics T1518.001 Test#1 Atomics
T1571 Test#1 Atomics T1033 Test #1 Atomics T1087.001 Test #4 Atomics T1087.001 Test
#5 Atomics T1087.001 Test #6 Atomics T1087.001 Test #7 Atomics T1087.001 Test #8
Atomics T1087.001 Test #9 Atomics T1087.001 Test #10 Atomics T1201 Test #5 Atomics
T1201 Test #6'
logic_format: Splunk
logic: ' `get_endpoint_data` `get_endpoint_data_powershell` EventCode=4104 ("whoami"
OR "dir" OR "systeminfo" OR "HOSTNAME" OR "ipconfig" OR "route" OR "arp" OR "netstat"
OR "netsh" OR "schtasks" OR "tasklist" OR "driverquery" OR "qprocess" OR "nslookup"
OR "tracert" OR "query" OR "cmdkey" OR ("net" AND ("localgroup" OR "group" OR "config"
OR "share" OR "use" OR "user"))) | 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"|
table _time, host, user dvc, dvc_nt_host, event_id, eventtype, host, index, parameters,
process, process_id, process_name, process_path, shell, signature_id, source, sourcetype,
src_user, tag, user, user_id | bin span=60s | stats values(*) as * by _time, host
| where match(process,"(?i)((whoami)|(dir)|(hostname)|(hostname)|(systeminfo)|(ipconfig)|(route)|(arp)|(cmdkey))($|\s)")
OR match(process,"(?i)((netstat)|(netsh)|(schtasks)|(tasklist)|(driverquery)|(qprocess)|(nslookup))($|\s)")
OR match(process,"(?i)((tracert)|(query)|(net\s+((localgroup)|(group)|(config)|(share)|(use)|(user)|(view))))($|\s)")
`hec_collect`'
techniques:
- discovery:system owner/user discovery
- execution:command and scripting interpreter
- discovery:account discovery:local account
- discovery:process discovery
- discovery:system information discovery
- discovery:system service discovery
- execution:command and scripting interpreter:unix shell
- execution:command and scripting interpreter:windows command shell
technique_id:
- T1033
- T1059
- T1087.001
- T1057
- T1082
- T1007
- T1059.003
- T1059.004
data_category:
- PowerShell logs
- Process command-line parameters
references:
- https://capec.mitre.org/data/definitions/577.html
- https://www.programmersought.com/article/71384528057/
Stages and Predicates
Stage 1: search
`get_endpoint_data` `get_endpoint_data_powershell` EventCode=4104 ("whoami" OR "dir" OR "systeminfo" OR "HOSTNAME" OR "ipconfig" OR "route" OR "arp" OR "netstat" OR "netsh" OR "schtasks" OR "tasklist" OR "driverquery" OR "qprocess" OR "nslookup" OR "tracert" OR "query" OR "cmdkey" OR ("net" AND ("localgroup" OR "group" OR "config" OR "share" OR "use" OR "user")))
Stage 2: rex
| rex field=process mode=sed max_match=0 "s/(?mi)^(Path.+)|^(ScriptBlock ID.+)|^(Creating Scriptblock.+)//g"
Stage 3: rex
| rex field=process mode=sed "s/([\n\r]+)|(\s\s+)//g"
Stage 4: table
| table _time, host, user dvc, dvc_nt_host, event_id, eventtype, host, index, parameters, process, process_id, process_name, process_path, shell, signature_id, source, sourcetype, src_user, tag, user, user_id
Stage 5: bucket
| bin span=60s
Stage 6: stats
| stats values(*) as * by _time, host
Stage 7: where
| where match(process,"(?i)((whoami)|(dir)|(hostname)|(hostname)|(systeminfo)|(ipconfig)|(route)|(arp)|(cmdkey))($|\s)") OR match(process,"(?i)((netstat)|(netsh)|(schtasks)|(tasklist)|(driverquery)|(qprocess)|(nslookup))($|\s)") OR match(process,"(?i)((tracert)|(query)|(net\s+((localgroup)|(group)|(config)|(share)|(use)|(user)|(view))))($|\s)") `hec_collect`
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
EventCode | eq |
| field:"EventID" kind:eq value:"4104" |
process | regex_match |
| field:"CommandLine" kind:regex_match |
Search terms
These SPL tokens match against raw event text.
| Stage | Term |
|---|---|
| 1 | "whoami" |
| 1 | "dir" |
| 1 | "systeminfo" |
| 1 | "HOSTNAME" |
| 1 | "ipconfig" |
| 1 | "route" |
| 1 | "arp" |
| 1 | "netstat" |
| 1 | "netsh" |
| 1 | "schtasks" |
| 1 | "tasklist" |
| 1 | "driverquery" |
| 1 | "qprocess" |
| 1 | "nslookup" |
| 1 | "tracert" |
| 1 | "query" |
| 1 | "cmdkey" |
| 1 | "net" |
| 1 | "localgroup" |
| 1 | "group" |
| 1 | "config" |
| 1 | "share" |
| 1 | "use" |
| 1 | "user" |