Detection rules › Splunk

Impacket Lateral Movement Activity (Windows Event Log)

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

Rule body

id: '33319.58975'
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_winevent` (TERM(EventCode=4688) OR
  "<EventID>4688<" OR Type=Process) ("&1" OR "&1") (("wmiprvse.exe" OR "mmc.exe"
  OR "explorer.exe" OR "services.exe") (("cmd.exe" OR "powershell.exe" OR "pwsh.exe")
  ("/Q" "/c") OR ("-c" OR "-command"))) OR ("svchost" ("cmd" OR "powershell" OR "pwsh")
  ("/C" OR -c" OR -command") "Windows\\Temp") | where ((match(parent_process_name,
  "(?i)(wmiprvse|mmc|explorer|services)\.exe") and match(process, "(?i)(cmd|powershell|pwsh)\.exe\s(\/Q)?\s(\/|-)c(ommand)?\s"))
  or (match(parent_process_name, "(?i)svchost\.exe") and match(process, "(?i)(powershell|pwsh|cmd)\.exe\s(\/|-)c(ommand)?\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:
- Process command-line parameters
- Windows event logs
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_winevent` (TERM(EventCode=4688) OR "<EventID>4688<" OR Type=Process) ("&1" OR "&1") (("wmiprvse.exe" OR "mmc.exe" OR "explorer.exe" OR "services.exe") (("cmd.exe" OR "powershell.exe" OR "pwsh.exe") ("/Q" "/c") OR ("-c" OR "-command"))) OR ("svchost" ("cmd" OR "powershell" OR "pwsh") ("/C" OR -c" OR -command") "Windows\\Temp")

Stage 2: where

| where ((match(parent_process_name, "(?i)(wmiprvse|mmc|explorer|services)\.exe") and match(process, "(?i)(cmd|powershell|pwsh)\.exe\s(\/Q)?\s(\/|-)c(ommand)?\s")) or (match(parent_process_name, "(?i)svchost\.exe") and match(process, "(?i)(powershell|pwsh|cmd)\.exe\s(\/|-)c(ommand)?\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
  • 4688 corpus 317 (splunk 283, kusto 33, elastic 1)
field:"EventID" kind:eq value:"4688"
parent_process_nameregex_match
  • "(?i)(wmiprvse|mmc|explorer|services).exe" corpus 2 (splunk 2)
  • "(?i)svchost.exe"
field:"parent_process_name" kind:regex_match
processregex_match
  • "(?i)(cmd|powershell|pwsh).exe\s(\/Q)?\s(\/|-)c(ommand)?\s"
  • "(?i)(powershell|pwsh|cmd).exe\s(\/|-)c(ommand)?\s.+Windows\x5cTemp\x5c"
field:"CommandLine" kind:regex_match

Search terms

These SPL tokens match against raw event text.

StageTerm
1"<EventID>4688<"
1"&1"
1"&1"
1"wmiprvse.exe"
1"mmc.exe"
1"explorer.exe"
1"services.exe"
1"cmd.exe"
1"powershell.exe"
1"pwsh.exe"
1"/Q"
1"/c"
1"-c"
1"-command"
1"svchost"
1"cmd"
1"powershell"
1"pwsh"
1"/C"
1-c"
1-command"
1"Windows\\Temp"