Windows PowerShell Scripts Testing Uncommon Port Connectivity via Test-NetConnection

Detects PowerShell scripts using Test-NetConnection to reach a target on non-443/80 ports.

FreeReviewedSigma · Medium · v2
Product
windows
Category
ps_script
Author
frack113 (SigmaHQ), DRL 1.1
Published
2022-01-23
Updated
2026-07-31

ATT&CK techniques

C2
  1. Recon

  2. Resource Dev

  3. Initial Access

  4. Execution

  5. Persistence

  6. Priv Esc

  7. Defense Evasion

  8. Cred Access

  9. Discovery

  10. Lateral Movement

  11. Collection

  12. Exfiltration

  13. Impact

What it detects

This rule flags PowerShell script blocks that call Test-NetConnection with both a ComputerName and a port argument, specifically when the target port is uncommon (not 443 or 80). Using nonstandard ports for application-layer connectivity can help adversaries blend command-and-control traffic or application traffic away from expected defaults. It relies on Script Block Logging telemetry capturing the contents of the PowerShell script block text, including the Test-NetConnection parameters.

Related detections7 linkedT1571 — drag to rearrange
Suspicious Outbound Connection To MoonPeak C2 High Ports
Possible Remcos C2 Connection from eilowutil Process
Malicious UNC4841 SSH Backdoor Persistence via Non-Standard Port and AllowUsers Restriction (via process_creation)
Malicious Reverse Shell via socat
Linux network connections to known malware callback ports
Windows Network Connections to Known Malware Callback Ports (Suspicious Destination Ports)
Windows Network Connections to Uncommon Ports (8080, 8888)
Windows PowerShell Scripts Testing Uncommon Port Connectivity via Test-NetConnection
Pivot detection · T1571 · 7 related

Changelog

v2
  1. v2
    Candidate ingested via manual entry.2026-07-31
  2. v1
    No changelog recorded for this version.2026-07-30

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.