Detection rules › Splunk
PSexec Service Creation (Windows Event Log)
Detect creation of service for PSexec, as seen with Impackets PSexec.py or PSexec execution
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1569.002 System Services: Service Execution |
| Persistence | T1543.003 Create or Modify System Process: Windows Service |
| Privilege Escalation | T1543.003 Create or Modify System Process: Windows Service |
References
Event coverage
| Provider | Event |
|---|---|
| Service-Control-Manager | Event ID 7045 |
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.
| Field | Kind | Excluded values |
|---|---|---|
Service_Start_Type | regex_match | "4, disabled" |
Service_Name | regex_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.
| Field | Kind | Values |
|---|---|---|
EventCode | eq |
|
Service_File_Name | regex_match |
|
Service_Name | regex_match |
|
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.
| Stage | Term |
|---|---|
| 1 | TERM |
| 1 | "<EventID>7045<" |