Detection rules › Splunk

Impacket Lateral Movement Activity (Sysmon)

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

Impacket is a collection of Python classes for working with network protocols, primarily focused on providing tools and scripts that facilitate the interaction with network services and protocols commonly used in network penetration testing and red teaming. wmiexec, smbexec, and dcomexec are specific tools within the Impacket suite that use various protocols to execute commands on remote systems. This use case detects specific behavior patterns associated with Impacket tools wmiexec, smbexec, and dcomexec.

MITRE ATT&CK coverage

References

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

id: '33319.58976'
title: Impacket Lateral Movement Activity
description: Impacket is a collection of Python classes for working with network protocols,
  primarily focused on providing tools and scripts that facilitate the interaction
  with network services and protocols commonly used in network penetration testing
  and red teaming. wmiexec, smbexec, and dcomexec are specific tools within the Impacket
  suite that use various protocols to execute commands on remote systems. This use
  case detects specific behavior patterns associated with Impacket tools wmiexec,
  smbexec, and dcomexec.
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_sysmon` (TERM(EventCode=1) OR "<EventID>1<")
  ("&1" OR "&1") (("wmiprvse.exe" OR "mmc.exe" OR "explorer.exe" OR "services.exe")
  ("cmd.exe" "/Q" "/c")) OR ("svchost" "-k" "netsvcs" "taskeng.exe" "cmd" "/C" "Windows\\Temp")
  | where (match(parent_process_name, "(?i)(wmiprvse|mmc|explorer|services)\.exe")
  and match(process, "(?i)cmd\.exe\s\/Q\s\/c\s")) or (match(parent_process, "(?i)svchost\.exe\s-k\snetsvcs.+taskeng\.exe")
  and match(process, "(?i)cmd\.exe\s\/c\s.+Windows\x5cTemp\x5c")) | table _time, host,
  user, parent_*, process, process_* | bin span=1s | stats values(*) as * by _time,
  host '
techniques:
- lateral-movement:remote services:smb/windows admin shares
- lateral-movement:exploitation of remote services
technique_id:
- T1021.002
- T1210
data_category:
- Windows Sysmon
references:
- https://attack.mitre.org/techniques/T1047/
- https://attack.mitre.org/techniques/T1021/003/
- https://detection.fyi/sigmahq/sigma/windows/process_creation/proc_creation_win_hktl_impacket_lateral_movement/?query=10c14723-61c7-4c75-92ca-9af245723ad2
- https://github.com/fortra/impacket/tree/master

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_sysmon` (TERM(EventCode=1) OR "<EventID>1<") ("&1" OR "&1") (("wmiprvse.exe" OR "mmc.exe" OR "explorer.exe" OR "services.exe") ("cmd.exe" "/Q" "/c")) OR ("svchost" "-k" "netsvcs" "taskeng.exe" "cmd" "/C" "Windows\\Temp")

Stage 2: where

| where (match(parent_process_name, "(?i)(wmiprvse|mmc|explorer|services)\.exe") and match(process, "(?i)cmd\.exe\s\/Q\s\/c\s")) or (match(parent_process, "(?i)svchost\.exe\s-k\snetsvcs.+taskeng\.exe") and match(process, "(?i)cmd\.exe\s\/c\s.+Windows\x5cTemp\x5c"))

Stage 3: table

| table _time, host, user, parent_*, process, process_*

Stage 4: bucket

| bin span=1s

Stage 5: stats

| stats values(*) as * by _time, host

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
EventCodeeq
  • 1 corpus 241 (splunk 225, kusto 15, elastic 1)
field:"EventID" kind:eq value:"1"
parent_processregex_match
  • "(?i)svchost.exe\s-k\snetsvcs.+taskeng.exe"
field:"ParentCommandLine" kind:regex_match
parent_process_nameregex_match
  • "(?i)(wmiprvse|mmc|explorer|services).exe" corpus 2 (splunk 2)
field:"parent_process_name" kind:regex_match
processregex_match
  • "(?i)cmd.exe\s\/Q\s\/c\s"
  • "(?i)cmd.exe\s\/c\s.+Windows\x5cTemp\x5c"
field:"CommandLine" kind:regex_match

Search terms

These SPL tokens match against raw event text.

StageTerm
1"<EventID>1<"
1"&1"
1"&1"
1"wmiprvse.exe"
1"mmc.exe"
1"explorer.exe"
1"services.exe"
1"cmd.exe"
1"/Q"
1"/c"
1"svchost"
1"-k"
1"netsvcs"
1"taskeng.exe"
1"cmd"
1"/C"
1"Windows\\Temp"