This cheat sheet is designed to briefly reference among the mostly used Netcat instructions, together with a quick description and sensible examples for instance their use. Whether or not you’re a seasoned skilled seeking to brush up in your command-line abilities or a newcomer desperate to discover the chances of networking via Netcat, you’ll discover beneficial insights and shortcuts right here.
Set up:
Distribution | Command |
---|---|
Debian, Ubuntu | sudo apt-get set up netcat |
CentOS/Fedora/Purple Hat | sudo dnf set up nc |
NixOS | nix-shell -p netcat-gnu for a brief set up setting. |
Utilization:
Job | Command |
---|---|
Hear on a port | nc -l 1234 |
Hook up with a port | nc instance.com 1234 |
Switch information (Receiver) | nc -l 1234 > file.txt |
Switch information (Sender) | nc instance.com 1234 |
Chat server | nc -l 1234 |
Chat consumer | nc instance.com 1234 |
Port scanning | nc -zv instance.com 20-30 |
File switch with tar (Sender) | tar cf - . | nc -w 3 instance.com 1234 |
File switch with tar (Receiver) | nc -l 1234 | tar x |
Execute command upon connection | nc -l 1234 -e /bin/bash |
Join by way of UDP | nc -u instance.com 1234 |
Verbose output | nc -v instance.com 1234 |
Hear with particular supply IP | nc -l 1234 -s 10.0.0.1 |
Ship a textual content message to a port | nc -lk 1234 |
Use with IPv6 | nc -6 instance.com 1234 |
Bind to a particular native port (consumer) | nc -p 8080 instance.com 1234 |
Switch listing with tar and netcat (Sender) | tar czf - listing/ | nc -w 3 instance.com 1234 |
Switch listing with tar and netcat (Receiver) | nc -l 1234 | tar xzf - |
Take a look at if the port is open | echo "Good day World" | nc instance.com 1234 |
Obtain file and print on console | nc -l 1234 > /dev/stdout |
Take a look at if port is open | echo -n | nc -w 1 instance.com 1234 |
Use customized timeout | nc -w 10 instance.com 1234 |
Proxy with Netcat | nc -l 1234 | nc instance.com 5678 |
Create a easy HTTP server | echo -e "HTTP/1.1 200 OKrnrnHello World" | nc -l 1234 |
Ship file with UDP (Sender) | nc -u instance.com 1234 |
Obtain file with UDP (Receiver) | nc -ul 1234 > file.txt |
Verify mail server (SMTP) interplay | nc -C instance.com 25 |
Echo service emulation | nc -l 1234 -c 'xargs -n1 echo' |
Hear on a number of ports (utilizing -k for persistent listening and a loop) | echo -n "instance.com" | nc 8.8.8.8 53 |
Take a look at if the port is open | whereas true; do nc -lk 1234; accomplished |
This Netcat cheat sheet has highlighted the instrument’s flexibility and energy for all the things from easy duties to superior operations. Mastering Netcat can considerably enhance your networking abilities. Maintain practising, exploring additional sources, and share your findings to deepen your understanding and contribute to the group’s collective data.