Detection rules › Splunk

Command-Line Interface Execution (PowerShell)

Group by
_time, host
Source
github.com/anvilogic-forge/armory

Detects when a Command-Line Interface executes on a host

MITRE ATT&CK coverage

References

Event coverage

Rule body yaml

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

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.

FieldKindValues
EventCodeeq
  • 4103 corpus 105 (splunk 105)
processmatch
  • "(?i)powershell\.exe" corpus 2 (splunk 2)
  • "(i?)cmd\.exe" corpus 2 (splunk 2)

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.

StageTerm
1"powershell.exe"
1"cmd.exe"