Detection rules › Sigma

Suspicious PowerShell Encoded Command Patterns

Status
test
Severity
high
Log source
product windows, category process_creation
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

MITRE ATT&CK coverage

Event coverage

ProviderEventTitle
SysmonEvent ID 1Process creation

Rule body yaml

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

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

FieldKindExcluded values
ParentImagematchC:\Packages\Plugins\Microsoft.GuestConfiguration.ConfigurationforWindows\
ParentImagematch\gc_worker.exe

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
CommandLinematch
  • -e corpus 14 (sigma 14)
  • -en corpus 3 (sigma 3)
  • -enc corpus 6 (sigma 6)
  • -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)
Imageends_with
  • \powershell.exe corpus 182 (sigma 182)
  • \pwsh.exe corpus 168 (sigma 168)
OriginalFileNameeq
  • PowerShell.Exe corpus 120 (sigma 84, splunk 30, elastic 6)
  • pwsh.dll corpus 112 (sigma 79, splunk 30, elastic 3)