netcat
is the swiss army knife.
- start server and client - test firewall
start server
nc -l -p 8080
nc -u -l -p 8080 # start udp server
start client connect to server
nc localhost 8080
nc -u localhost 8080 # connect to udp server
- File transfer
start server
nc -l -p 8080 > 1.txt
start client to copy the file
nc -N localhost 8080 < 1.txt
-N
means stop the connection after transfer
- Scan port
nc -z -v -n 127.0.0.1 21-25
- Retriev banner infomation from port
nc -v 127.0.0.1 22
- Remote shell:
server side
mkfifo /tmp/p # create pipe(fifo) file, purpose to collect comand from client side to /tmp/p file
cat /tmp/p | /bin/bash 2>&1 |nc -l -p 8080 > /tmp/p
# cat read /tmp/p content and send to /bin/bah
# bash run the command and pipe the result back to netcat (nc)
# netcat send output to client
client side
nc -n 127.0.0.1 8080