Detection rules › Sigma

Metasploit Or Impacket Service Installation Via SMB PsExec

Status
test
Severity
high
Log source
product windows, service security
Author
Bartlomiej Czyz, Relativity
Source
github.com/SigmaHQ/sigma

Detects usage of Metasploit SMB PsExec (exploit/windows/smb/psexec) and Impacket psexec.py by triggering on specific service installation

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: Metasploit Or Impacket Service Installation Via SMB PsExec
id: 6fb63b40-e02a-403e-9ffd-3bcc1d749442
related:
    - id: 1a17ce75-ff0d-4f02-9709-2b7bb5618cf0
      type: derived
status: test
description: Detects usage of Metasploit SMB PsExec (exploit/windows/smb/psexec) and Impacket psexec.py by triggering on specific service installation
references:
    - https://bczyz1.github.io/2021/01/30/psexec.html
author: Bartlomiej Czyz, Relativity
date: 2021-01-21
modified: 2022-10-05
tags:
    - attack.lateral-movement
    - attack.t1021.002
    - attack.t1570
    - attack.execution
    - attack.t1569.002
logsource:
    product: windows
    service: security
    definition: The 'System Security Extension' audit subcategory need to be enabled to log the EID 4697
detection:
    selection:
        EventID: 4697
        ServiceFileName|re: '^%systemroot%\\[a-zA-Z]{8}\.exe$'
        ServiceName|re: '(^[a-zA-Z]{4}$)|(^[a-zA-Z]{8}$)|(^[a-zA-Z]{16}$)'
        ServiceStartType: 3  # on-demand start, see https://www.ultimatewindowssecurity.com/securitylog/encyclopedia/event.aspx?eventID=4697
        ServiceType: '0x10'
    filter:
        ServiceName: 'PSEXESVC'
    condition: selection and not filter
falsepositives:
    - Possible, different agents with a 8 character binary and a 4, 8 or 16 character service name
level: high

Stages and Predicates

Stage 0: condition

selection and not filter

Stage 1: selection

selection:
    EventID: 4697
    ServiceFileName|re: '^%systemroot%\\[a-zA-Z]{8}\.exe$'
    ServiceName|re: '(^[a-zA-Z]{4}$)|(^[a-zA-Z]{8}$)|(^[a-zA-Z]{16}$)'
    ServiceStartType: 3
    ServiceType: '0x10'

Stage 2: not filter

filter:
    ServiceName: 'PSEXESVC'

Exclusions

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

FieldKindExcluded values
ServiceNameeqPSEXESVC

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
ServiceFileNameregex_match
  • ^%systemroot%\[a-zA-Z]{8}.exe$
ServiceNameregex_match
    • (^[a-zA-Z]{4}$)
    • (^[a-zA-Z]{8}$)
    • (^[a-zA-Z]{16}$)
ServiceStartTypeeq
  • 3
ServiceTypeeq
  • 0x10