Port Scanning
While not as feature-rich as dedicated port scanners like Nmap, Netcat can perform basic port scanning to identify open ports and services on a target host.
Basic Port Scanning
Use the -z flag for zero-I/O mode (scan only, no data transfer) and -v for verbose output to see which ports are open.
Scan a Single Port
Check if a specific port is open:
Output shows connection succeeded if port is open
Scan Multiple Ports
Check several specific ports:
Scan a Port Range
Scan a range of ports using hyphen notation:
UDP Port Scanning
UDP scanning is less reliable than TCP scanning because UDP is connectionless and doesn't guarantee responses. However, Netcat can still attempt UDP scans.
UDP Scan
Scan UDP ports (less reliable):
No response might mean open, filtered, or no service
Service Banner Grabbing
After identifying an open port, you can connect to grab the service banner to identify what's running:
Grab HTTP Banner
Connect and manually send an HTTP request:
Grab SSH Banner
SSH services often send a banner immediately upon connection:
Look for the SSH version string in the output