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 | |
| Persistence | |
| Privilege Escalation |
References
Telemetry coverage
| Provider | Record / event type |
|---|---|
| Service-Control-Manager | Event ID 7045: A service was installed in the system. |
Rule body
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
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
Service_Start_Type | regex_match | "4, disabled" | excludes:Service_Start_Type |
Service_Name | regex_match | "\s+, [\_\/\x5c]" | excludes:Service_Name |
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
EventCode | eq |
| field:"EventID" kind:eq value:"7045" |
Service_File_Name | regex_match |
| field:"Service_File_Name" kind:regex_match |
Service_Name | regex_match |
| field:"Service_Name" kind:regex_match |
Search terms
These SPL tokens match against raw event text.
| Stage | Term |
|---|---|
| 1 | "<EventID>7045<" |