Detection rules › Sigma

Potential PowerShell Obfuscation Via Reversed Commands

Status
test
Severity
high
Log source
product windows, category process_creation
Author
Teymur Kheirkhabarov (idea), Vasiliy Burov (rule), oscd.community, Tim Shelton
Source
github.com/SigmaHQ/sigma

Detects the presence of reversed PowerShell commands in the CommandLine. This is often used as a method of obfuscation by attackers

MITRE ATT&CK coverage

Event coverage

ProviderEventTitle
SysmonEvent ID 1Process creation

Rule body yaml

title: Potential PowerShell Obfuscation Via Reversed Commands
id: b6b49cd1-34d6-4ead-b1bf-176e9edba9a4
status: test
description: Detects the presence of reversed PowerShell commands in the CommandLine. This is often used as a method of obfuscation by attackers
references:
    - https://2019.offzone.moscow/ru/report/hunting-for-powershell-abuses/
    - https://speakerdeck.com/heirhabarov/hunting-for-powershell-abuse?slide=66
author: Teymur Kheirkhabarov (idea), Vasiliy Burov (rule), oscd.community, Tim Shelton
date: 2020-10-11
modified: 2023-05-31
tags:
    - attack.stealth
    - attack.t1027
    - 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_cli:
        CommandLine|contains:
            - 'hctac'
            - 'kaerb'
            - 'dnammoc'
            - 'ekovn' # Also covers 'ekovni'
            - 'eliFd'
            - 'rahc'
            - 'etirw'
            - 'golon'
            - 'tninon'
            - 'eddih'
            - 'tpircS'
            - 'ssecorp'
            - 'llehsrewop'
            - 'esnopser'
            - 'daolnwod'
            - 'tneilCbeW'
            - 'tneilc'
            - 'ptth'
            - 'elifotevas'
            - '46esab'
            - 'htaPpmeTteG'
            - 'tcejbO'
            - 'maerts'
            - 'hcaerof'
            - 'retupmoc'
    filter_main_encoded_keyword:
        # We exclude usage of encoded commands as they might generate FPs as shown here:
        #   https://github.com/SigmaHQ/sigma/pull/2720
        #   https://github.com/SigmaHQ/sigma/issues/4270
        CommandLine|contains:
            - ' -EncodedCommand '
            - ' -enc '
    condition: all of selection_* and not 1 of filter_main_*
falsepositives:
    - Unlikely
level: high

Stages and Predicates

Stage 0: condition

all of selection_* and not 1 of filter_main_*

Stage 1: selection_img

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

Stage 2: selection_cli

selection_cli:
    CommandLine|contains:
        - 'hctac'
        - 'kaerb'
        - 'dnammoc'
        - 'ekovn'
        - 'eliFd'
        - 'rahc'
        - 'etirw'
        - 'golon'
        - 'tninon'
        - 'eddih'
        - 'tpircS'
        - 'ssecorp'
        - 'llehsrewop'
        - 'esnopser'
        - 'daolnwod'
        - 'tneilCbeW'
        - 'tneilc'
        - 'ptth'
        - 'elifotevas'
        - '46esab'
        - 'htaPpmeTteG'
        - 'tcejbO'
        - 'maerts'
        - 'hcaerof'
        - 'retupmoc'

Stage 3: not filter_main_encoded_keyword

filter_main_encoded_keyword:
    CommandLine|contains:
        - ' -EncodedCommand '
        - ' -enc '

Exclusions

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

FieldKindExcluded values
CommandLinematch -EncodedCommand
CommandLinematch -enc

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
  • 46esab
  • daolnwod
  • dnammoc
  • eddih
  • ekovn
  • eliFd
  • elifotevas
  • esnopser
  • etirw
  • golon
  • hcaerof
  • hctac
  • htaPpmeTteG
  • kaerb
  • llehsrewop
  • maerts
  • ptth
  • rahc
  • retupmoc
  • ssecorp
  • tcejbO
  • tneilCbeW
  • tneilc
  • tninon
  • tpircS
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)