Today we will teach you how to perform port scanning with the TCP/IP Swiss Army Knife tool, netcat.
What is Netcat?
nc, also known as the TCP/IP swiss army knife is a feature rich network utility which can be used to read and write data to network connections using TCP or UDP. But, since you are here to learn how to use netcat as a port scanner, I think you already know about this amazing tool.
What is portscanning?
PortScanning is the act of systematically scanning a computer's ports.
Use netcat As A Port Scanner Tool?
Ok, open a new terminal (CTRL+ALT+T in Ubuntu) and run the following command to perform a TCP port scan.
nc -v -z 127.0.0.1 25
Can you explain the options used in this demonstration to us? Yes, I can! The -v option is used to run netcat in verbose mode so the user can see what is happening and -z option tells netcat to not make a full connection since we are only interested to know the state of the port.
You can also scan a range of ports with the following command.
nc -v -z host port-range
If you want to learn more about netcat tips, read our article on how to create a chat with netcat.