Detection rules › Sigma

Potential Powershell ReverseShell Connection

Status
stable
Severity
high
Log source
category process_creation, product windows
Author
FPT.EagleEye, wagga, Nasreddine Bencherchali (Nextron Systems)
Source
github.com/SigmaHQ/sigma

Detects usage of the "TcpClient" class. Which can be abused to establish remote connections and reverse-shells. As seen used by the Nishang "Invoke-PowerShellTcpOneLine" reverse shell and other.

Known false positives

  • In rare administrative cases, this function might be used to check network connectivity

MITRE ATT&CK coverage

Telemetry coverage

ProviderRecord / event type
SysmonEvent ID 1: Process creation

Rule body

title: Potential Powershell ReverseShell Connection
id: edc2f8ae-2412-4dfd-b9d5-0c57727e70be
status: stable
description: Detects usage of the "TcpClient" class. Which can be abused to establish remote connections and reverse-shells. As seen used by the Nishang "Invoke-PowerShellTcpOneLine" reverse shell and other.
references:
    - https://www.volexity.com/blog/2021/03/02/active-exploitation-of-microsoft-exchange-zero-day-vulnerabilities/
    - https://www.microsoft.com/security/blog/2021/03/02/hafnium-targeting-exchange-servers/
    - https://github.com/samratashok/nishang/blob/414ee1104526d7057f9adaeee196d91ae447283e/Shells/Invoke-PowerShellTcpOneLine.ps1
author: FPT.EagleEye, wagga, Nasreddine Bencherchali (Nextron Systems)
date: 2021-03-03
modified: 2023-04-05
tags:
    - attack.execution
    - attack.t1059.001
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - OriginalFileName:
              - 'PowerShell.EXE'
              - 'pwsh.dll'
        - Image|endswith:
              - '\powershell.exe'
              - '\pwsh.exe'
    selection_cli:
        CommandLine|contains|all:
            - ' Net.Sockets.TCPClient'
            - '.GetStream('
            - '.Write('
    condition: all of selection_*
falsepositives:
    - In rare administrative cases, this function might be used to check network connectivity
level: high

Stages and Predicates

Stage 0: condition

all of selection_*

Stage 1: selection_img

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

Stage 2: selection_cli

selection_cli:
    CommandLine|contains|all:
        - ' Net.Sockets.TCPClient'
        - '.GetStream('
        - '.Write('

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
CommandLinematch
  • Net.Sockets.TCPClient
  • .GetStream(
  • .Write(
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