netcat
Netcat Relays on Windows
Start by entering a temp dir where we can create files
cd C:\tempListener to Client Relay
This creates a relay that sends packets from the local port to a netcat client connected to the target ip address on the target port
echo nc [TargetIPAddr] [port] > relay.bat
nc -l -p [LocalPort] -e relay.batListener to Listener Relay
echo nc -l -p [Local_Port_2] > relay.bat
nc -l -p [Local_Port_1] -e relay.batThis creates a relay that will send packets from any connection on
Local_Port_1to any connection onLocal_Port_2
Client to Client Relay
echo nc [NextHopIPAddr] [port2] > relay.bat
nc [PreviousHopIPAddr] [port] -e relay.batThis creates a relay that will send packets from the connection to
PreviousHopIPAddronportto a netcat client connected toNextHopIPAddronport2
Netcat Command Flags
-lListen mode-LListen harder, only supported on windows versions of netcat. This option makes netcat persistently listen which will listen again after client disconnect.-uUDP mode-pLocal Port. In listen mode this is the port listened on, in client mode this is the source port for all packets sent-eProgram the execute after connection occurs, connecting STDIN and STDOUT of the program-nDont perform DNS look up on names of machines on the other side-zZero I/O mode. Dont send any data, just emit a packet with out a payload-wNTimeout of connections. Wait N seconds after closure of STDIN. If connection doesnt happen after N seconds netcat will stop listening-v-vvBe verbose, be very verbose respectively
TCP Banner Grabs
echo "" | nc -v -n -w1 [TargetIP] [start_port]-[end_port]Grab the banner of any TCP service running on an IP from a linux machine
-rAdd this flag to randomize destination ports within the range-padd this flag to specify a source port for the connection
Netcat Relays on Linux
Move to tmp dir and create a FIFO
cd /tmp
mknod backpipe pListener to Client Relay
nc -l -p [Local_Port] 0<backpipe | nc [Target_IP_Addr] [port] | tee backpipeCreate a relay that sends packets from the
Local_Portto a netcat client connected toTarget_IP_Addronport
Listener to Listener Relay
nc -l -p [Local_Port_1] 0<backpipe | nc -l -p [Local_Port_2] | tee backpipeCreate a relay that sends packets from any connection on
Local_Port_1to any connection onLocal_Port_2
Client to Client Relay
nc [PreviousHopIPAddr] [port] 0<backpipe | nc [NextHopIPAddr] [port2] | tee backpipeCreate a relay that sends packets from the connection to
PreviousHopIPAddronportto a netcat client connected toNextHopIPAddronport2
Last updated