Skip to content
Threat Feed
medium advisory

Detection of Non-Standard Network Port Usage via PowerShell

This brief documents a detection capability for identifying potential command-and-control activity where adversaries use PowerShell to test network connectivity over non-standard, uncommon ports.

Adversaries frequently employ techniques to evade network monitoring by utilizing protocols and port pairings that are not traditionally associated with specific traffic types. By establishing command-and-control (C2) channels over non-standard ports, such as 8088 or 587, attackers attempt to blend in with authorized traffic and bypass static firewall rules or simple inspection policies. The PowerShell cmdlet Test-NetConnection is often misused by attackers during the post-exploitation reconnaissance phase to verify reachability and ensure that a target host can communicate with external C2 infrastructure over these unconventional ports. This brief focuses on the detection of such reconnaissance activity using PowerShell Script Block Logging, which provides visibility into the parameters passed to network diagnostic commands.

Impact

Successful exploitation of non-standard port communication allows attackers to maintain persistent, covert C2 channels, potentially leading to unauthorized data exfiltration, lateral movement, or long-term remote administration of compromised endpoints. Detecting this activity early in the network reconnaissance phase is critical to preventing the establishment of a stable C2 infrastructure and mitigating further compromise within the target environment.

Recommendation

Detection engineering teams should focus on identifying suspicious usage of network connectivity tools in scripting environments.

  • Enable PowerShell Script Block Logging (Event ID 4104) across all Windows endpoints to capture the command-line arguments used in administrative tools.
  • Deploy the Sigma rule provided below to the SIEM and tune the filter list to exclude known administrative or monitoring tools specific to the local network environment.
  • Monitor logs for instances of Test-NetConnection where the destination port does not align with standardized port assignments (e.g., ports other than 80, 443).

Immediate actions

Enable PowerShell Script Block Logging (Event ID 4104) across all endpoints.

IT Operations 72h

Deploy the Sigma detection rule to the production SIEM.

Detection Engineering 72h

Mitigations

Enforce network egress filtering to prevent unauthorized connections to non-standard ports.

medium_term Network Security

T1571

Detection coverage 1

Detect Use of Test-NetConnection with Uncommon Ports

medium

Detects the use of Test-NetConnection to query ports other than standard HTTP/HTTPS (80/443), which may indicate reconnaissance for C2 setup.

sigma tactics: command_and_control techniques: T1571 sources: ps_script, windows

Detection queries are available on the platform. Get full rules →