Netcat is a Linux networking tool used for reading from and writing to network connections using TCP or UDP. In other words, the tool allows us to connect and run commands on remote machine. The tool also allows port scanning on remote machine.
Installation
The tool is uaually installed in linux distributions. if not from some reason you can install it by using ‘sudo apt-get install netcat‘ command:
Netcat Examples
To scan ports on the remote host use the ‘nc -vz (host IP/hostname) (port range)‘:
The –v is for verbose mode and the -z is for not establishing connection.
You can also connect to a remote machine. In order to do that you need to specify the IP/hostname and Port/service name (ssh,telnet,https, etc):
the -u is for UDP ports only.
To use netcat listening mode use ‘nc -l (port)‘:
This command tells Netcat to get the file from the sender in IP 192.168.124.4 on port 1234. It will get the file ‘file_to_send’ from the sender and save it as ‘file_recieved’. Notice that you specify the same port on the sender and reciever hosts and that the port is not blockes by ACL or Firewall.
Netcat is a powerful and flexible networking tool that can be used for a variety of tasks such as port scanning, file transfers, creating chat servers, and more. Its versatility makes it an essential tool for system administrators and cybersecurity professionals.