Netcat - Cheat Sheet
Netcat - Cheat Sheet
Enjoy this cheat sheet at its fullest within Dash, the macOS documentation browser.
Usage
Normal syntax
nc [options] [host] [port]
General Options
nc -4 [options] [host] [port] Use IPv4 addressing only
Server Examples
netcat -l 5050 Listen for TCP connections (port 5050). Data received is directed to STDOUT . Data is captured and
transmitted from STDOUT .
Simple Proxy
mknod backpipe p ; nc -l [proxy port] < backpipe | nc [destination host] [destination port] > pipe
Create a named pipe. Setup an a listener on proxy port. Forward requests from listener to a client which in-turn sends them onto the
destination host. The client redirects the response from the destination host into the named pipe. The listener picks up the response from the
named pipe and returns it. The named pipe thus allows the proxy to transmit data bi-directionally.
Port Scanning
nc -zv hostname.com 80 Scan a single TCP port
nc -zv hostname.com 80-84 Scan a range of ports
Notes
Thanks to biscuitNinja and the Netcat Cheat Sheet.