Detection rules › Sigma

PipeShell exfiltration over named pipes

Status
experimental
Severity
medium
Time window
5m
Log source
product windows, category ['ps_module', 'ps_classic_script', 'ps_script']
Author
mdecrevoisier
Source
github.com/mdecrevoisier/SIGMA-detection-rules

Detects scenarios where an attacker establishes "PipeShell" connection(s) between a server and client(s) in order to move laterally or exfiltrate data. The server side will trigger "ServerStream" IOCs meanwhile the client side will trigger "ClientStream" IOCs. The rule works based on this condition, where at least 2 hosts need to trigger one of the condition.

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: PipeShell exfiltration over named pipes
description: Detects scenarios where an attacker establishes "PipeShell" connection(s) between a server and client(s) in order to move laterally or exfiltrate data. The server side will trigger "ServerStream" IOCs meanwhile the client side will trigger "ClientStream" IOCs. The rule works based on this condition, where at least 2 hosts need to trigger one of the condition.
references:
- https://github.com/mdecrevoisier/EVTX-to-MITRE-Attack/tree/master/TA0002-Execution/T1059.001-PowerShell
- https://github.com/threatexpress/invoke-pipeshell
- https://github.com/p3nt4/Invoke-Piper/blob/master/Invoke-Piper.psm1
- https://sudonull.com/post/25207-Using-Pipes-for-Pivoting
- https://codewhitesec.blogspot.com/2020/01/cve-2019-19470-rumble-in-pipe.html
- https://decoder.cloud/2019/03/06/windows-named-pipes-impersonation/
- https://www.powershellgallery.com/packages/PSNamedPipe/1.0.0.19/Content/Public%5CNew-PSNamedPipeServer.ps1
tags:
- attack.execution
- attack.t1059.001
- attack.exfiltration
author: mdecrevoisier
status: experimental
logsource:
  product: windows
  category:
    - ps_module
    - ps_classic_script
    - ps_script
detection:
  SERVER_powershell_native:
    EventID: 800
    EventData|contains: 'System.IO.Pipes.NamedPipeServerStream'
  SERVER_powershell_modern:
    EventID: 4103
    Payload|contains: 'System.IO.Pipes.NamedPipeServerStream'
  SERVER_powershell_block:
    EventID: 4104
    ScriptBlockText|contains: 'System.IO.Pipes.NamedPipeServerStream'

  CLIENT_powershell_native:
    EventID: 800
    EventData|contains: 'System.IO.Pipes.NamedPipeClientStream'
  CLIENT_spowershell_modern:
    EventID: 4103
    Payload|contains: 'System.IO.Pipes.NamedPipeClientStream'
  CLIENT_powershell_block:
    EventID: 4104
    ScriptBlockText|contains: 'System.IO.Pipes.NamedPipeClientStream'

  condition: (1 of SERVER*) AND (1 of CLIENT*) | count(Computer) > 2
  timeframe: 5m
falsepositives:
- packet manager
level: medium

Stages and Predicates

Stage 0: condition

(1 of SERVER*) AND (1 of CLIENT*) | count(Computer) > 2

Stage 1: SERVER_powershell_native

SERVER_powershell_native:
  EventID: 800
  EventData|contains: 'System.IO.Pipes.NamedPipeServerStream'
Threshold
> 2

Stage 2: SERVER_powershell_modern

SERVER_powershell_modern:
  EventID: 4103
  Payload|contains: 'System.IO.Pipes.NamedPipeServerStream'

Stage 3: SERVER_powershell_block

SERVER_powershell_block:
  EventID: 4104
  ScriptBlockText|contains: 'System.IO.Pipes.NamedPipeServerStream'

Stage 4: CLIENT_powershell_native

CLIENT_powershell_native:
  EventID: 800
  EventData|contains: 'System.IO.Pipes.NamedPipeClientStream'

Stage 5: CLIENT_spowershell_modern

CLIENT_spowershell_modern:
  EventID: 4103
  Payload|contains: 'System.IO.Pipes.NamedPipeClientStream'

Stage 6: CLIENT_powershell_block

CLIENT_powershell_block:
  EventID: 4104
  ScriptBlockText|contains: 'System.IO.Pipes.NamedPipeClientStream'

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
EventDatamatch
  • System.IO.Pipes.NamedPipeClientStream
  • System.IO.Pipes.NamedPipeServerStream
Payloadmatch
  • System.IO.Pipes.NamedPipeClientStream
  • System.IO.Pipes.NamedPipeServerStream
ScriptBlockTextmatch
  • System.IO.Pipes.NamedPipeClientStream
  • System.IO.Pipes.NamedPipeServerStream