Netcat

Chat

Client (initiating)		Listener (receiving)
nc 10.0.0.2 1234 ------> nc -lp 1234

File Content Transfer

Client (sending)		    Listener (receiving)
nc 10.0.0.2 1234 < file.txt ------> nc -lp 1234 > file.txt

Listener (sending)	       Client (receiving)
nc -lp 1234 < file.txt ------> nc 10.0.0.1 1234 > file.txt

Send Text

Can send text too (this example is sent to localhost):

echo "text" | nc localhost 10000

Using SSH Tunnels (Edit this)

Listener (sending)

nc -l -p 9876 < file.txt

Receiver

ssh -L 1111:10.0.0.3:22 [email protected] -NT
ssh -L 2222:10.0.0.4:9876 -p 1111 user2@localhost -NT
nc localhost 2222 > file.txt

Last updated

Was this helpful?