Windows PowerShell TcpClient reverse-shell connection attempt via Net.Sockets
Alerts on PowerShell processes launching with .NET TcpClient stream/write patterns consistent with reverse TCP connectivity.
FreeUnreviewedSigmahighv1
windows-powershell-tcpclient-reverse-shell-connection-attempt-via-net-sockets-edc2f8ae
title: Windows PowerShell TcpClient reverse-shell connection attempt via Net.Sockets
id: 01f752df-5c99-46a7-b76f-a4d11b0d2670
status: stable
description: This rule flags process executions of PowerShell (powershell.exe or pwsh.exe) where the command line contains indicators of .NET Net.Sockets.TcpClient usage along with stream and write operations. Such patterns are commonly used to establish remote TCP connections and transmit data, which can support reverse-shell behavior. It relies on Windows process creation telemetry and matches the PowerShell image name and specific substrings in the command line.
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
- https://github.com/SigmaHQ/sigma/blob/master/rules/windows/process_creation/proc_creation_win_powershell_reverse_shell_connection.yml
author: FPT.EagleEye, wagga, Nasreddine Bencherchali (Nextron Systems), Huntrule Team
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
license: DRL-1.1
related:
- id: edc2f8ae-2412-4dfd-b9d5-0c57727e70be
type: derived
What it detects
This rule flags process executions of PowerShell (powershell.exe or pwsh.exe) where the command line contains indicators of .NET Net.Sockets.TcpClient usage along with stream and write operations. Such patterns are commonly used to establish remote TCP connections and transmit data, which can support reverse-shell behavior. It relies on Windows process creation telemetry and matches the PowerShell image name and specific substrings in the command line.
Known false positives
- In rare administrative cases, this function might be used to check network connectivity
Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.