TCP port scanning using PowerShell
Port scanning is the practice of systematically checking the open, closed, or filtered ports on a target system. Open ports represent potential entry points for attackers, while closed or filtered ports may indicate security measures in place. By conducting a port scan, penetration testers can gather crucial information about a network or system’s security posture.
Test-NetConnection
is a versatile cmdlet available in Windows PowerShell (version 4.0 and later) that primarily serves to diagnose network connectivity. However, it can be repurposed to perform port scanning in a penetration-testing context.
Single port scanning with Test-NetConnection
To perform a simple port scan on a target host using Test-NetConnection
, follow this example:
Test-NetConnection -ComputerName 192.168.1.100 -Port 80 ComputerName : 192.168.1.100 RemoteAddress ...