Detection rules › Sigma

Unusually Long PowerShell CommandLine

Status
test
Severity
low
Log source
category process_creation, product windows
Author
oscd.community, Natalia Shornikova
Source
github.com/SigmaHQ/sigma

Detects unusually long PowerShell command lines with a length of 1000 characters or more

MITRE ATT&CK coverage

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: Unusually Long PowerShell CommandLine
id: d0d28567-4b9a-45e2-8bbc-fb1b66a1f7f6
status: test
description: Detects unusually long PowerShell command lines with a length of 1000 characters or more
references:
    - https://speakerdeck.com/heirhabarov/hunting-for-powershell-abuse
author: oscd.community, Natalia Shornikova
date: 2020-10-06
modified: 2023-04-14
tags:
    - attack.execution
    - attack.t1059.001
    - detection.threat-hunting
logsource:
    category: process_creation
    product: windows
detection:
    selection_powershell:
        - Image|endswith:
              - '\powershell.exe'
              - '\pwsh.exe'
        - OriginalFileName:
              - 'PowerShell.EXE'
              - 'pwsh.dll'
        - Description: 'Windows Powershell'
        - Product: 'PowerShell Core 6'
    selection_length:
        CommandLine|re: '.{1000,}'
    condition: all of selection_*
falsepositives:
    - Unknown
level: low

Stages and Predicates

Stage 0: condition

all of selection_*

Stage 1: selection_powershell

selection_powershell:
    - Image|endswith:
          - '\powershell.exe'
          - '\pwsh.exe'
    - OriginalFileName:
          - 'PowerShell.EXE'
          - 'pwsh.dll'
    - Description: 'Windows Powershell'
    - Product: 'PowerShell Core 6'

Stage 2: selection_length

selection_length:
    CommandLine|re: '.{1000,}'

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CommandLineregex_match
  • .{1000,}
field:"CommandLine" kind:regex_match value:".{1000,}"
Descriptioneq
  • Windows Powershell corpus 3 (sigma 3)
field:"Description" kind:eq value:"Windows Powershell"
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
Producteq
  • PowerShell Core 6 corpus 3 (sigma 3)
field:"Product" kind:eq value:"PowerShell Core 6"