Netcat(nc) is helpful to open TCP connections, send UDP packets, listen on arbitrary TCP and UDP ports, scanning of ports .This part of the blog is dedicated to Linux and Unix-like commands that can be used from Information Security Administrators and Penetration Testers.
1.To Bind Shell:
nc –lvp -e – Running in windows box
nc–v – Run in Linux/Unix-like box
-> Launching a listening shell in windows
-> Binding from linux
Launching a listening shell in Linux/Unix-like and binding from Windows:
-> nc -lvp -e /bin/sh – Running in Linux/Unix-like box
– Run in Windows box
2. Using Netcat to transfer files
In Unix/Linux using echo command create sample.txt with content ‘abcdefghijkl’
echo ‘abcdefghijkl’ >sample.txt
NOTE:Here , –n parameter here prevents DNS lookup, -z -> makes nc not receive any data from the server and -w 1 -> makes the connection timeout after 1 second of inactivity. The commands above will scan from port 1 to 1000.
4. Client/Server Model
It is very easy to create client/server model using nc command. There are some steps as follows: