CheatSheetsPentesting
Netcat Cheatsheet
CheatSheet
Netcat (
nc
) is a powerful networking tool used for various tasks, including port scanning, banner grabbing, file transfers, and creating backdoor shells. This cheat sheet covers essential commands and techniques.Basic Syntax
[TargetIPaddr]
: The IP address or domain name of the target. Required in client mode, optional in listen mode.
Common Options
-l
: Listen mode (default is client mode).-L
: Listen harder (Windows only). Makes Netcat a persistent listener that restarts after a client disconnects.-u
: UDP mode (default is TCP).-p
: Local port (In listen mode, the port Netcat listens on. In client mode, the source port for outgoing packets).-e
: Program to execute after connection, linking STDIN and STDOUT to the program.-n
: Avoid DNS lookups.-z
: Zero-I/O mode. No data is sent; only a connection attempt is made.-wN
: Timeout for connects. WaitsN
seconds after closure of STDIN.-v
: Verbose mode. Prints messages on STDERR.-vv
: Very verbose mode. Prints even more details.
Fundamental Commands
Netcat Client
Connect to a specific port on a target IP address:
Netcat Listener
Create a listener on a specific local port:
Port Scanning
Perform a port scan on a target IP address:
-v
: Verbose output.-n
: No DNS resolution.-z
: Zero-I/O mode.-w1
: 1-second timeout.
TCP Banner Grabbing
Grab the banner of a TCP service:
Add -r
to randomize ports within a range or -p [port]
to specify a source port.
File Transfers
Push a File from Client to Listener
On the listener:
On the client:
Pull a File from Listener Back to Client
On the listener:
On the client:
Backdoor Shells
Listening Backdoor Shell on Linux
Listening Backdoor Shell on Windows
Reverse Backdoor Shell on Linux
Reverse Backdoor Shell on Windows
Relays
Listener-to-Client Relay (Windows)
Listener-to-Listener Relay (Linux)
Create a FIFO named pipe called backpipe
:
Then, use: