Detection rules › Sigma

Elevated System Shell Spawned From Uncommon Parent Location

Status
test
Severity
medium
Log source
category process_creation, product windows
Author
frack113, Tim Shelton (update fp)
Source
github.com/SigmaHQ/sigma

Detects when a shell program such as the Windows command prompt or PowerShell is launched with system privileges from a uncommon parent location.

Known false positives

  • Some legitimate applications may spawn shells from uncommon parent locations. Apply additional filters and perform an initial baseline before deploying.

MITRE ATT&CK coverage

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: Elevated System Shell Spawned From Uncommon Parent Location
id: 178e615d-e666-498b-9630-9ed363038101
related:
    - id: 61065c72-5d7d-44ef-bf41-6a36684b545f
      type: similar
status: test
description: Detects when a shell program such as the Windows command prompt or PowerShell is launched with system privileges from a uncommon parent location.
references:
    - https://github.com/Wh04m1001/SysmonEoP
author: frack113, Tim Shelton (update fp)
date: 2022-12-05
modified: 2025-03-06
tags:
    - attack.privilege-escalation
    - attack.execution
    - attack.t1059
logsource:
    product: windows
    category: process_creation
detection:
    selection_shell:
        - Image|endswith:
              - '\powershell.exe'
              - '\powershell_ise.exe'
              - '\pwsh.exe'
              - '\cmd.exe'
        - OriginalFileName:
              - 'PowerShell.EXE'
              - 'powershell_ise.EXE'
              - 'pwsh.dll'
              - 'Cmd.Exe'
    selection_user:
        User|contains: # covers many language settings
            - 'AUTHORI'
            - 'AUTORI'
        LogonId: '0x3e7'
    filter_main_generic:
        # Example 1:
        #   C:\Program Files\erl-23.2\erts-11.1.4\bin\erl.exe" -service_event ErlSrv_RabbitMQ -nohup -sname rabbit@localhost -s rabbit boot -boot start_sasl +W w +MBas ageffcbf +MHas ageffcbf +MBlmbcs 512 +MHlmbcs 512 +MMmcs 30 +P 1048576 +t 5000000 +stbt db +zdbbl 128000 +sbwt none +sbwtdcpu none +sbwtdio none -kernel inet_dist_listen_min 25672 -kernel inet_dist_listen_max 25672 -lager crash_log false -lager handlers []
        # Example 2:
        #   ParentImage: C:\Program Files (x86)\Varonis\DatAdvantage\GridCollector\VrnsRealTimeAlertsSvc.exe" /appid 000000ad-cb03-500b-9459-c46d000000ad
        #   CommandLine: C:\Windows\system32\cmd.exe /c C:\Program Files "(x86)\Varonis\DatAdvantage\GridCollector\handle_scopes.cmd C:\Collector" Working Share\VaronisWorkDirectoryCollector
        ParentImage|contains:
            - ':\Program Files (x86)\'
            - ':\Program Files\'
            - ':\ProgramData\'
            - ':\Windows\System32\'
            - ':\Windows\SysWOW64\'
            - ':\Windows\Temp\' # Installers
            - ':\Windows\WinSxS\'
    filter_optional_manageengine:
        # Example:
        #   ParentImage: C:/ManageEngine/ADManager Plus/pgsql/bin/postgres.exe" --forkarch 5380
        #   CommandLine: C:\Windows\system32\cmd.exe /c "IF EXIST archive.bat (archive.bat pg_wal\000000010000008E000000EA 000000010000008E000000EA)
        ParentImage|endswith: ':\ManageEngine\ADManager Plus\pgsql\bin\postgres.exe'
        Image|endswith: '\cmd.exe'
    filter_optional_asgard:
        CommandLine|contains: ':\WINDOWS\system32\cmd.exe /c "'
        CurrentDirectory|contains: ':\WINDOWS\Temp\asgard2-agent\'
    filter_optional_ibm_spectrumprotect:
        ParentImage|contains: ':\IBM\SpectrumProtect\webserver\scripts\'
        CommandLine|contains: ':\IBM\SpectrumProtect\webserver\scripts\'
    filter_main_parent_null:
        ParentImage: null
    filter_main_parent_empty:
        ParentImage:
            - ''
            - '-'
    condition: all of selection_* and not 1 of filter_main_* and not 1 of filter_optional_*
falsepositives:
    - Some legitimate applications may spawn shells from uncommon parent locations. Apply additional filters and perform an initial baseline before deploying.
level: medium

Stages and Predicates

Stage 0: condition

all of selection_* and not 1 of filter_main_* and not 1 of filter_optional_*

Stage 1: selection_shell

selection_shell:
    - Image|endswith:
          - '\powershell.exe'
          - '\powershell_ise.exe'
          - '\pwsh.exe'
          - '\cmd.exe'
    - OriginalFileName:
          - 'PowerShell.EXE'
          - 'powershell_ise.EXE'
          - 'pwsh.dll'
          - 'Cmd.Exe'

Stage 2: selection_user

selection_user:
    User|contains:
        - 'AUTHORI'
        - 'AUTORI'
    LogonId: '0x3e7'

Stage 3: not filter_main_*

filter_main_generic:
    ParentImage|contains:
        - ':\Program Files (x86)\'
        - ':\Program Files\'
        - ':\ProgramData\'
        - ':\Windows\System32\'
        - ':\Windows\SysWOW64\'
        - ':\Windows\Temp\'
        - ':\Windows\WinSxS\'
filter_main_parent_null:
    ParentImage: null
filter_main_parent_empty:
    ParentImage:
        - ''
        - '-'

Stage 4: not filter_optional_*

filter_optional_manageengine:
    ParentImage|endswith: ':\ManageEngine\ADManager Plus\pgsql\bin\postgres.exe'
    Image|endswith: '\cmd.exe'
filter_optional_asgard:
    CommandLine|contains: ':\WINDOWS\system32\cmd.exe /c "'
    CurrentDirectory|contains: ':\WINDOWS\Temp\asgard2-agent\'
filter_optional_ibm_spectrumprotect:
    ParentImage|contains: ':\IBM\SpectrumProtect\webserver\scripts\'
    CommandLine|contains: ':\IBM\SpectrumProtect\webserver\scripts\'

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
ParentImageeq-excludes:ParentImage field:"ParentImage" value:"-"
ParentImageis_null(no value, null check)excludes:ParentImage
ParentImagematch:\Program Files (x86)\excludes:ParentImage field:"ParentImage" value:":\Program Files (x86)\"
ParentImagematch:\Program Files\excludes:ParentImage field:"ParentImage" value:":\Program Files\"
ParentImagematch:\ProgramData\excludes:ParentImage field:"ParentImage" value:":\ProgramData\"
ParentImagematch:\Windows\SysWOW64\excludes:ParentImage field:"ParentImage" value:":\Windows\SysWOW64\"
ParentImagematch:\Windows\System32\excludes:ParentImage field:"ParentImage" value:":\Windows\System32\"
ParentImagematch:\Windows\Temp\excludes:ParentImage field:"ParentImage" value:":\Windows\Temp\"
ParentImagematch:\Windows\WinSxS\excludes:ParentImage field:"ParentImage" value:":\Windows\WinSxS\"
CommandLinematch:\IBM\SpectrumProtect\webserver\scripts\excludes:CommandLine field:"CommandLine" value:":\IBM\SpectrumProtect\webserver\scripts\"
ParentImagematch:\IBM\SpectrumProtect\webserver\scripts\excludes:ParentImage field:"ParentImage" value:":\IBM\SpectrumProtect\webserver\scripts\"
CommandLinematch:\WINDOWS\system32\cmd.exe /c "excludes:CommandLine
CurrentDirectorymatch:\WINDOWS\Temp\asgard2-agent\excludes:CurrentDirectory field:"CurrentDirectory" value:":\WINDOWS\Temp\asgard2-agent\"
Imageends_with\cmd.exeexcludes:Image field:"Image" value:"\cmd.exe"
ParentImageends_with:\ManageEngine\ADManager Plus\pgsql\bin\postgres.exeexcludes:ParentImage field:"ParentImage" value:":\ManageEngine\ADManager Plus\pgsql\bin\postgres.exe"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
Imageends_with
  • \cmd.exe corpus 130 (sigma 130)
  • \powershell.exe corpus 179 (sigma 178, kusto 1)
  • \powershell_ise.exe corpus 41 (sigma 41)
  • \pwsh.exe corpus 165 (sigma 164, kusto 1)
field:"Image" kind:ends_with
LogonIdeq
  • 0x3e7 corpus 2 (sigma 2)
field:"LogonId" kind:eq value:"0x3e7"
OriginalFileNameeq
  • Cmd.Exe corpus 81 (sigma 43, elastic 21, splunk 17)
  • PowerShell.EXE corpus 138 (sigma 84, splunk 30, elastic 24)
  • powershell_ise.EXE corpus 51 (splunk 30, sigma 18, elastic 3)
  • pwsh.dll corpus 112 (sigma 79, splunk 30, elastic 3)
field:"OriginalFileName" kind:eq
Usermatch
  • AUTHORI corpus 14 (sigma 14)
  • AUTORI corpus 14 (sigma 14)
field:"user" kind:match