Detection rules › Splunk

PSexec Service Creation (Windows Event Log)

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

Detect creation of service for PSexec, as seen with Impackets PSexec.py or PSexec execution

MITRE ATT&CK coverage

References

Event coverage

Rule body yaml

id: '5399.5499'
title: PSexec Service Creation
description: 'Detect creation of service for PSexec, as seen with Impackets PSexec.py
  or PSexec execution. -- Threat Actor Association: APT29, APT31, BlackMatter, DarkSide,
  Fox Kitten, Hello Kitty / Five Hands, Whisper Spider, UNC2628 -- Software Association:
  Akira, Conti, LockBit, Nefilim, Play, Rhysida, SamSam'
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=7045) OR
  "<EventID>7045<")| regex Service_Start_Type!="4|disabled"| regex Service_Name!="\s+|[\_\/\x5c]"|
  regex Service_Name="(\w{4}|execsvc)$"| regex Service_File_Name="\x5c.{8}\.exe$"
  | eval service_name=Service_File_Name | table _time, host, user signature_id, user,
  dest_host, process_id, process_name, process_path, process, parent_process_id, parent_process_name,
  parent_process_path, event_id, src, service_name | bin span=1s | stats values(*)
  as * by _time, host '
techniques:
- persistence:create or modify system process:windows service
- execution:system services:service execution
technique_id:
- T1543.003
- T1569.002
data_category:
- Windows event logs
references:
- https://github.com/SecureAuthCorp/impacket/blob/master/examples/psexec.py
- https://ashwinrayaprolu.wordpress.com/2011/04/12/xcmd-an-alternative-to-psexec/
- https://github.com/kavika13/RemCom
- https://github.com/malcomvetter/CSExec/tree/master/csexecsvc

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=7045) OR "<EventID>7045<")

Stage 2: regex

| regex Service_Start_Type!="4|disabled"

Stage 3: regex

| regex Service_Name!="\s+|[\_\/\x5c]"

Stage 4: regex

| regex Service_Name="(\w{4}|execsvc)$"

Stage 5: regex

| regex Service_File_Name="\x5c.{8}\.exe$"

Stage 6: eval

| eval service_name=Service_File_Name

Stage 7: table

| table _time, host, user signature_id, user, dest_host, process_id, process_name, process_path, process, parent_process_id, parent_process_name, parent_process_path, event_id, src, service_name

Stage 8: bucket

| bin span=1s

Stage 9: stats

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

Exclusions

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
Service_Start_Typeregex_match"4, disabled"
Service_Nameregex_match"\s+, [\_\/\x5c]"

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
  • 7045 corpus 20 (splunk 18, chronicle 1, kusto 1)
Service_File_Nameregex_match
  • "\x5c.{8}.exe$"
Service_Nameregex_match
  • "(\w{4}|execsvc)$"

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
1TERM
1"<EventID>7045<"