Linux netcat

In this Linux lesson, we will focus on a Linux network utility which is also named as “Swiss army knife” of developers. Here, we will focus on linux netcat command. In Linux, netcat utility is a multi-functional tool. It allows security audits and network investigation for ethical hackers. It can be used for also port scanning, file transfers, backdoor creating etc. It is a good Linux tool for an ethical hacker. Netcat basically reads and writes data on TCP and UDP ports.

 


 

What is Netcat?

Netcat is basically a tool used by developers and ethical hackers for security audits and network investigation. Netcat allows us to listen a specific port of a connection. Or it allows us to connect to a remote device. With this Linux utility, we can find the exploits in a system.

 


 

Linux Netcat Examples

A wide range network tasks can be done with the help of this command. Below, we have given different examples of these tasks.

 


 

Establishing Connection

If you would like to establish a connection with another host over a port, we use netcat command. By doing this without any option, by default, we start a TCP connection to the mentioned port. Below you can find an example command which starts a connection to TCP port 23 towards host 192.168.5.2.

 

root@kali:/home/kali# nc 192.168.5.2 23

 

By default, this command tries a TCP connection. If you would like to do this with UDP, you should use nc -u option.

 


 

Sending Files With netcat

We can also send files from one host to another with netcat. Here, netcat build a client/server model to do this. One side becomes a client and the other side becomes a server.

 

 


 

Port Scanning With netcat

Port scanning is one of the important tasks for a penetration tester or an ethical hacker. With different Linux commands we can do port scanning. The main role of netcat is not port scanning but we can use netcat for port scanning. We can do this port scanning for both TCP and UDP ports. For this action, we use netcat -z option.

 

 

We can check a specific port range with netcat to check if are there any open port between these ports. To do this, we use the below command with nc -z option for port scan and -v option for verbose mode for detail information.

 

root@kali:/home/kali# nc -zv www.google.com 20-25

 

By default, only TCP ports are scanned. But we can scan UDP ports insdead of TCP ports. To du this, we use nc -u option.

 

root@kali:/home/kali# nc -zvu www.google.com 20-25

 

 

We can do port scan also for a specific port. For example, if you would like to check if are there any DNS Server which uses default UDP port 53 at the remote device.

 

root@kali:/home/kali# nc -zvu www.google.com 53

DNS fwd/rev mismatch: www.google.com != sof02s31-in-f4.1e100.net

www.google.com [172.217.169.100] 53 (domain) open

Back to: Kali Linux Course

Leave a Reply

Your email address will not be published. Required fields are marked *