Detection rules › Sigma

Potential Shellcode Injection

Status
test
Severity
medium
Log source
category process_access, product windows
Author
Bhabesh Raj
Source
github.com/SigmaHQ/sigma

Detects potential shellcode injection as seen used by tools such as Metasploit's migrate and Empire's psinject.

MITRE ATT&CK coverage

TacticTechniques
Privilege Escalation
Stealth

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 10: ProcessAccess

Rule body

title: Potential Shellcode Injection
id: 250ae82f-736e-4844-a68b-0b5e8cc887da
status: test
description: Detects potential shellcode injection as seen used by tools such as Metasploit's migrate and Empire's psinject.
references:
    - https://github.com/EmpireProject/PSInject
author: Bhabesh Raj
date: 2022-03-11
modified: 2024-07-02
tags:
    - attack.privilege-escalation
    - attack.stealth
    - attack.t1055
    - detection.threat-hunting
logsource:
    category: process_access
    product: windows
detection:
    selection:
        GrantedAccess:
            - '0x147a'
            - '0x1f3fff'
        CallTrace|contains: 'UNKNOWN'
    filter_main_wmiprvse:
        SourceImage: 'C:\Windows\System32\Wbem\Wmiprvse.exe'
        TargetImage: 'C:\Windows\system32\lsass.exe'
    filter_optional_dell_folders:
        # If dell software is installed we get matches like these
        # Example 1:
        #   SourceImage: C:\Program Files\Dell\SupportAssistAgent\bin\SupportAssistAgent.exe
        #   TargetImage: C:\Program Files\Dell\TechHub\Dell.TechHub.exe
        #   GrantedAccess: 0x1F3FFF
        # Example 2:
        #   SourceImage: C:\Program Files (x86)\Dell\UpdateService\DCF\Dell.DCF.UA.Bradbury.API.SubAgent.exe
        #   TargetImage: C:\Program Files\Dell\TechHub\Dell.TechHub.exe
        #   GrantedAccess: 0x1F3FFF
        # Example 3:
        #   SourceImage: C:\Program Files\Dell\TechHub\Dell.TechHub.exe
        #   TargetImage: C:\Program Files (x86)\Dell\UpdateService\DCF\Dell.DCF.UA.Bradbury.API.SubAgent.exe
        #   GrantedAccess: 0x1F3FFF
        SourceImage|startswith:
            - 'C:\Program Files\Dell\'
            - 'C:\Program Files (x86)\Dell\'
        TargetImage|startswith:
            - 'C:\Program Files\Dell\'
            - 'C:\Program Files (x86)\Dell\'
    filter_optional_dell_specifc:
        SourceImage: 'C:\Program Files (x86)\Dell\UpdateService\ServiceShell.exe'
        TargetImage: 'C:\Windows\Explorer.EXE'
    filter_optional_visual_studio:
        SourceImage|startswith: 'C:\Program Files\Microsoft Visual Studio\'
        TargetImage|startswith: 'C:\Program Files\Microsoft Visual Studio\'
    condition: selection and not 1 of filter_main_* and not 1 of filter_optional_*
falsepositives:
    - Unknown
level: medium

Stages and Predicates

Stage 0: condition

selection and not 1 of filter_main_* and not 1 of filter_optional_*

Stage 1: selection

selection:
    GrantedAccess:
        - '0x147a'
        - '0x1f3fff'
    CallTrace|contains: 'UNKNOWN'

Stage 2: not filter_main_wmiprvse

filter_main_wmiprvse:
    SourceImage: 'C:\Windows\System32\Wbem\Wmiprvse.exe'
    TargetImage: 'C:\Windows\system32\lsass.exe'

Stage 3: not filter_optional_*

filter_optional_dell_folders:
    SourceImage|startswith:
        - 'C:\Program Files\Dell\'
        - 'C:\Program Files (x86)\Dell\'
    TargetImage|startswith:
        - 'C:\Program Files\Dell\'
        - 'C:\Program Files (x86)\Dell\'
filter_optional_dell_specifc:
    SourceImage: 'C:\Program Files (x86)\Dell\UpdateService\ServiceShell.exe'
    TargetImage: 'C:\Windows\Explorer.EXE'
filter_optional_visual_studio:
    SourceImage|startswith: 'C:\Program Files\Microsoft Visual Studio\'
    TargetImage|startswith: 'C:\Program Files\Microsoft Visual Studio\'

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
SourceImageeqC:\Windows\System32\Wbem\Wmiprvse.exeexcludes:SourceImage field:"SourceImage" value:"C:\Windows\System32\Wbem\Wmiprvse.exe"
TargetImageeqC:\Windows\system32\lsass.exeexcludes:TargetImage field:"TargetImage" value:"C:\Windows\system32\lsass.exe"
SourceImagestarts_withC:\Program Files (x86)\Dell\excludes:SourceImage field:"SourceImage" value:"C:\Program Files (x86)\Dell\"
SourceImagestarts_withC:\Program Files\Dell\excludes:SourceImage field:"SourceImage" value:"C:\Program Files\Dell\"
TargetImagestarts_withC:\Program Files (x86)\Dell\excludes:TargetImage field:"TargetImage" value:"C:\Program Files (x86)\Dell\"
TargetImagestarts_withC:\Program Files\Dell\excludes:TargetImage field:"TargetImage" value:"C:\Program Files\Dell\"
SourceImageeqC:\Program Files (x86)\Dell\UpdateService\ServiceShell.exeexcludes:SourceImage field:"SourceImage" value:"C:\Program Files (x86)\Dell\UpdateService\ServiceShell.exe"
TargetImageeqC:\Windows\Explorer.EXEexcludes:TargetImage field:"TargetImage" value:"C:\Windows\Explorer.EXE"
SourceImagestarts_withC:\Program Files\Microsoft Visual Studio\excludes:SourceImage field:"SourceImage" value:"C:\Program Files\Microsoft Visual Studio\"
TargetImagestarts_withC:\Program Files\Microsoft Visual Studio\excludes:TargetImage field:"TargetImage" value:"C:\Program Files\Microsoft Visual Studio\"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CallTracematch
  • UNKNOWN corpus 5 (sigma 3, elastic 2)
field:"CallTrace" kind:match value:"UNKNOWN"
GrantedAccesseq
  • 0x147a
  • 0x1f3fff corpus 3 (sigma 2, splunk 1)
field:"GrantedAccess" kind:eq