netcat

BSD netcat (nc) Cheatsheet #

netcat, or nc, is a versatile networking tool used for reading from and writing to network connections using TCP or UDP on BSD systems.

Basic Usage #

Command/OptionExampleDescription
nc -l -p portnc -l -p 1234Listen on port 1234
nc host portnc example.com 80Connect to port 80 on example.com
nc -u host portnc -u example.com 1234Use UDP to connect to port 1234 on example.com

Advanced Usage #

Command/OptionExampleDescription
nc -z -v host port1-port2nc -z -v example.com 20-80Scan ports 20 through 80 on example.com
nc -l -p port -e /path/to/programnc -l -p 1234 -e /bin/shBind a shell to port 1234
nc -l -p port -c 'command'nc -l -p 1234 -c 'ls -la'Execute ls -la and send output over port 1234

Security and Monitoring #

Command/OptionExampleDescription
nc -v -w 5 host portnc -v -w 5 example.com 80Connect to example.com on port 80 with a 5-second timeout
nc -l -p port -knc -l -p 1234 -kKeep listening for connections after handling one

This cheatsheet covers essential netcat (nc) commands and options for BSD systems.

netcat

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.