Deploying Metasploitable

What is Metasploitable?

So I want to start learning cybersecurity. How do I do it? Do I just try pwning my own devices or start attempting SQL injection into Facebook’s login portal? That would be a terrible idea. We need a safe environment to practice hacking techniques while staying out of trouble. The goal is to learn, not cause chaos.

There are several great resources available online that can help you build your skills, such as Hack The Box, PortSwigger, TryHackMe, OverTheWire, and many more.

However, one fun and educational approach is to set up your own testing lab completely for free. This also provides an opportunity to learn about virtualization, networking, server management, and automation along the way. Why not give it a try?

Meet Metasploitable, created by the Rapid7 Metasploit team. Rapid7 is a well-known security company that develops the Metasploit Framework, a popular tool for penetration testing and developing exploits. Metasploitable was specifically designed to be used as a target for testing Metasploit Framework exploits and other security tools and techniques. Let’s set it up.

Virtual Networks

A virtual network is a software-based network that exists within a physical network. Virtual networks are created by virtualization software such as VirtualBox or VMware and allow virtual machines to communicate with each other and with the host machine. These networks are isolated from your physical (home) network, making them safe for practicing and testing.

I’m using VirtualBox here. If you’re using VMware or another virtualization tool, the steps may differ. I recommend using VirtualBox — it’s free and user-friendly.

Let’s start by creating a DHCP server for the 10.10.10.0/24 network. I’ll call this network hackinet, but any memorable name will do. This network will be used for our vulnerable machines.

Open a windows terminal and run:

# Navigate to the VirtualBox installation directory where the required executable is located
PS> cd 'C:\Program Files\Oracle\VirtualBox\'

# Create a DHCP server with an IP address of 10.10.10.1 which will assign IPs in the range 
# 10.10.10.10 - 10.10.10.20 to VMs connected to the network 
PS> .\VBoxManage.exe dhcpserver add --network=hackinet --server-ip=10.10.10.1 --lower-ip=10.10.10.10 --upper-ip=10.10.10.20 --netmask=255.255.255.0 --enable

# Verify the details of the DHCP server you just created
PS> .\VBoxManage.exe list dhcpservers

We now have a working virtual network. All VMs connected to this network can communicate with one another and will be isolated from your physical network.

Metasploitable 2

Next, Let’s deploy our first vulnerable machine, Metasploitable 2.

  1. Download the metasploitable-linux-2.0.0.zip file here.
  2. Once downloaded, extract its contents to the location where your other virtual machines reside, in my case it would be C:\Users\raf8\VirtualBox VMs
  3. Open VirtualBox and click on New to create a new virtual machine. Use the following settings to create the virtual environment:
    • Name: Metasploitable 2
    • Type: Linux
    • Version: Other Linux (64-bit)
    • Base Memory: 512 MB
    • Processors: 1
    • Hard disk: Use an existing virtual hard disk file and select the Metasploitable.vmdk file from the files we extracted earlier
  4. Click “Finish”

Network settings

Next, we have to configure the network settings for the virtual machine.

  1. Right-click on the newly created virtual machine and select Settings.
  2. Click on Network and select Adapter 1.
  3. Enable the adapter and select “Internal Network” from the “Attached to” dropdown menu.
  4. Use hackinet as the name of the internal network. This is the virtual network we created earlier.
  5. Click “OK” to save the settings.

We are now ready to start the virtual machine. The login credentials are msfadmin for the user and password. We can use the ifconfig command to check its IP address. The IP address should be in the 10.10.10.10 - 10.10.10.20 range that we configured for the DHCP server. The virtual machine is now ready to be hacked. If you are unsure about where to start, you can check its exploitability guide.

Metasploitable 3

We are now going to deploy the 2 versions of Metasploitable 3, one running Windows and the other running Linux. Metasploitable 3 is the latest available version for the Metasploitable series. We’ll use Vagrant — a tool for building and managing virtual machine environments via a simple configuration file. When I discovered Vagrant, I fell in love with it, nowadays I mostly deploy virtual machines using this tool. Running vagrant up and having a fresh VM deployed before you can finish making a coffee, it’s just amazing. I highly recommend you explore Vagrant further.

  1. Install Vagrant
  2. With Vagrant installed, let’s open a terminal and use the following commands to install Vagrant Reload and vbguest plugins:
    PS> vagrant plugin install vagrant-reload
    PS> vagrant plugin install vagrant-vbguest
    
  3. The following commands will create a new local metasploitable workspace, download the required Vagrantfile and deploy both versions of Metasploitable 3 (Windows and Linux)
    PS> mkdir metasploitable3-workspace
    PS> cd metasploitable3-workspace
    PS> iwr "https://raw.githubusercontent.com/rapid7/metasploitable3/master/Vagrantfile" -outfile Vagrantfile
    PS> vagrant up
    
  4. After the last command completed, both virtual machines will be up and running. Power off both VMs and change the network settings as we did with the Metasploitable 2 machine.
  5. Disable additional network adapters, they aren’t needed
  6. We can now power the VMs and login using vagrant as the user and password. The Administrator password for the windows machine is also vagrant

Now go ahead and start practicing! Again, if you don’t know where to start, check out the vulnerability guide.

But wait, how are we suppossed to attack this vulnerable machines we just deployed? We need to deploy Kali and connect it to our virtual network in order to launch our attacks. Let’s use Vagrant to create a Kali machine so that we can start hacking.

Remember to manually connect your deployed Kali machine to the virtual network we created earlier so that it can communicate with the Metasploitable VMs.

If you find trouble getting more than one network adapter to work on your attack host, this post will help you solve the issue.