Detection rules › Sigma

Suspicious PowerShell Encoded Command Patterns

Status
test
Severity
high
Log source
category process_creation, product windows
Author
Florian Roth (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects PowerShell command line patterns in combincation with encoded commands that often appear in malware infection chains

Known false positives

  • Other tools that work with encoded scripts in the command line instead of script files

MITRE ATT&CK coverage

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: Suspicious PowerShell Encoded Command Patterns
id: b9d9cc83-380b-4ba3-8d8f-60c0e7e2930c
status: test
description: Detects PowerShell command line patterns in combincation with encoded commands that often appear in malware infection chains
references:
    - https://app.any.run/tasks/b9040c63-c140-479b-ad59-f1bb56ce7a97/
author: Florian Roth (Nextron Systems)
date: 2022-05-24
modified: 2023-01-05
tags:
    - attack.execution
    - attack.t1059.001
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - Image|endswith:
              - '\powershell.exe'
              - '\pwsh.exe'
        - OriginalFileName:
              - 'PowerShell.Exe'
              - 'pwsh.dll'
    selection_flags:
        CommandLine|contains:
            - ' -e '
            - ' -en '
            - ' -enc '
            - ' -enco'
    selection_encoded:
        CommandLine|contains:
            - ' JAB'
            - ' SUVYI'
            - ' SQBFAFgA'
            - ' aWV4I'
            - ' IAB'
            - ' PAA'
            - ' aQBlAHgA'
    filter_gcworker:
        ParentImage|contains:
            - 'C:\Packages\Plugins\Microsoft.GuestConfiguration.ConfigurationforWindows\'
            - '\gc_worker.exe'
    condition: all of selection_* and not 1 of filter_*
falsepositives:
    - Other tools that work with encoded scripts in the command line instead of script files
level: high

Stages and Predicates

Stage 0: condition

all of selection_* and not 1 of filter_*

Stage 1: selection_img

selection_img:
    - Image|endswith:
          - '\powershell.exe'
          - '\pwsh.exe'
    - OriginalFileName:
          - 'PowerShell.Exe'
          - 'pwsh.dll'

Stage 2: selection_flags

selection_flags:
    CommandLine|contains:
        - ' -e '
        - ' -en '
        - ' -enc '
        - ' -enco'

Stage 3: selection_encoded

selection_encoded:
    CommandLine|contains:
        - ' JAB'
        - ' SUVYI'
        - ' SQBFAFgA'
        - ' aWV4I'
        - ' IAB'
        - ' PAA'
        - ' aQBlAHgA'

Stage 4: not filter_gcworker

filter_gcworker:
    ParentImage|contains:
        - 'C:\Packages\Plugins\Microsoft.GuestConfiguration.ConfigurationforWindows\'
        - '\gc_worker.exe'

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
ParentImagematchC:\Packages\Plugins\Microsoft.GuestConfiguration.ConfigurationforWindows\excludes:ParentImage field:"ParentImage" value:"C:\Packages\Plugins\Microsoft.GuestConfiguration.ConfigurationforWindows\"
ParentImagematch\gc_worker.exeexcludes:ParentImage field:"ParentImage" value:"\gc_worker.exe"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CommandLinematch
  • -e corpus 17 (sigma 14, elastic 3)
  • -en corpus 5 (sigma 3, elastic 2)
  • -enc corpus 8 (sigma 6, elastic 2)
  • -enco corpus 2 (sigma 2)
  • IAB corpus 2 (sigma 2)
  • JAB corpus 2 (sigma 2)
  • PAA
  • SQBFAFgA corpus 2 (sigma 2)
  • SUVYI corpus 2 (sigma 2)
  • aQBlAHgA corpus 2 (sigma 2)
  • aWV4I corpus 2 (sigma 2)
field:"CommandLine" kind:match
Imageends_with
  • \powershell.exe corpus 179 (sigma 178, kusto 1)
  • \pwsh.exe corpus 165 (sigma 164, kusto 1)
field:"Image" kind:ends_with
OriginalFileNameeq
  • PowerShell.Exe corpus 138 (sigma 84, splunk 30, elastic 24)
  • pwsh.dll corpus 112 (sigma 79, splunk 30, elastic 3)
field:"OriginalFileName" kind:eq