The Netcat Command – How To Use In Kali Linux? 

The Netcat Command – How To Use In Kali Linux? 

June 22, 2023 Off By Das

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:
install natcat

Netcat Examples

To scan ports on the remote host use the nc -vz (host IP/hostname) (port range)

netcat -vz scan

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): 

netcat scan

the -u is for UDP ports only. 

To use netcat listening mode use nc -l (port)

netcat -l scan

Netcat allow to transfer files between hosts on the network. On the receiving machine, set up listen mode on a specific port and specify the file in order to direct the incoming data to a file:
netcat send file
This command tells Netcat to listen on port 1234 and save the incoming data to a file named ‘file_to_send’.

On the sending machine, specify the file, host’s IP address and the specified port in order to get the file from the sender:

netcat recieve file

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.


Conclusion

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.