> For the complete documentation index, see [llms.txt](https://longholdpham.gitbook.io/longs-cybersecurity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://longholdpham.gitbook.io/longs-cybersecurity/homelabs/metasploitable-3-for-virtualbox.md).

# Metasploitable 3 for VirtualBox

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FONPVWlofNWKo0JChXiBG%2Fvirtualbox-maquina-virtual.jpg?alt=media&amp;token=6dd6a141-ed16-4dcf-bed7-9708b8c576f5" alt=""><figcaption></figcaption></figure>

Similar to [Getting Metasploitable 3 for VMware Workstation](/longs-cybersecurity/homelabs/metasploitable-3-for-vmware-workstation.md) but with fewer steps and minor differences.

## Installations

* [Packer](#1.-installing-packer)
* [Vagrant](#2.-installing-vagrant)
* [Vagrant plugins](#4.-installing-vagrant-plugins)
* [Metasploitable 3's vulnerable Linux box, ub1404](https://app.vagrantup.com/rapid7/boxes/metasploitable3-ub1404)
* [Metasploitable 3's vulnerable Windows Server 2008 box, win2k8](https://app.vagrantup.com/rapid7/boxes/metasploitable3-win2k8)

## Prerequisite

Before proceeding to the below installation steps, disable **Windows Defender**'s **Real-time protection** and **Cloud-delivered protection**. Turn these back on after installing the metasploitable boxes.&#x20;

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2Ft9ik6PgAYNlheZaJ1Oz6%2Fimage.png?alt=media&amp;token=0b0b0c27-6d52-4458-890e-f8823d54fd93" alt=""><figcaption></figcaption></figure>

## 1. Installing Packer

Download Packer AMD64 (64-bit) version at <https://www.packer.io/downloads>

Go to **C:\Program Files\\** and create a new folder named **Packer**

Extract the **packer.exe** to the newly created folder

Launch the **Run** app, by pressing the **Windows key ⊞ + R**, then type **SystemPropertiesAdvanced**\ <img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FzlRtkX8HM8o2Hu0nXbV9%2Fimage.png?alt=media&amp;token=86f9cc66-2dba-49d0-afce-c6f6c2bbeeba" alt="" data-size="original">

Click **Environment Variables...**\
![](https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FstmXoGTzC0oa0pmiKulZ%2Fimage.png?alt=media\&token=a9693307-c1ba-407d-9c6a-720c25faca9f)

Look at the **System Variables** portion then double click on **Path**

![](https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FrLN8hisn7rFMeFO3CqTT%2Fimage.png?alt=media\&token=73b8e12d-6fdc-4dfc-b831-3e0b6d0f33b9)

Then click **New** and paste the directory path **C:\Program Files\Packer** then press **OK**\
![](https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2Flp2dA0pQcXlSDO3MgScF%2Fimage.png?alt=media\&token=14a17d09-547f-49b8-a61b-d82f0b8da2e6)

Check if Packer is configured correctly, type and run  `packer` in PowerShell. The result should look like this

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FQjQvEIGKwPND8wAqjstt%2Fimage.png?alt=media&amp;token=8f2f66c1-a39b-470a-a6fa-7cdd1e3b68dc" alt=""><figcaption></figcaption></figure>

## 2. Installing Vagrant

Download and install Vagrant from <https://www.vagrantup.com/downloads>

After rebooting when Vagrant's installation is done, check if Vagrant is installed correctly by typing `vagrant` in PowerShel&#x6C;*.* The result should look like this

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FttqjOs4IOQSGOUzOVQr1%2Fimage.png?alt=media&amp;token=b03221fc-b38a-4b84-9cb3-5b44b7118434" alt=""><figcaption></figcaption></figure>

## 3. Installing Vagrant plugins

Launch **PowerShell**

Install **vagrant-reload** plugin, type and run

```
vagrant plugin install vagrant-reload
```

Check if the plugins are installed by typing `vagrant plugin list`. The result should look like this<br>

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2F8yOI1bgSDuS0d7mmUo0V%2Fimage.png?alt=media&amp;token=26238830-a976-49f7-9492-190e0293d59c" alt=""><figcaption></figcaption></figure>

## 4. Installing the metasploitable boxes

Go to the directory **C:\\** and make a new folder named **metasploitable3-workspace**&#x20;

Open up **PowerShell** and traverse to the newly created folder **C:\metasploitable3-workspace**

Type and run&#x20;

```
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/rapid7/metasploitable3/master/Vagrantfile" -OutFile "Vagrantfile"
```

There should now exist a file named [**Vagrantfile**](https://www.vagrantup.com/docs/vagrantfile) in the directory

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FWbFQszK5nv4lkrAjxhMg%2Fimage.png?alt=media&amp;token=f57ddb6b-bc8c-489b-94ad-4005c749e333" alt=""><figcaption></figcaption></figure>

At the same directory location, type and run the below code on PowerShell

```
vagrant box add rapid7/metasploitable3-ub1404 --provider virtualbox
```

This will download the prebuilt metasploitable Linux box for VirtualBox. The result should look like this

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2Fx204HlsYaCC4ffuMec9V%2Fimage.png?alt=media&amp;token=efb21c0b-a94d-4ec5-a777-059c3e3089e0" alt=""><figcaption></figcaption></figure>

Back on PowerShel&#x6C;**,** type and run the below code

```
vagrant box add rapid7/metasploitable3-win2k8 --provider virtualbox
```

This will download the prebuilt metasploitable Windows Server 2008 box for VirtualBox. The result should look like this \
\
\*Note: The win2k8 box size is huge (\~6.5 GB) so the download will take a while\*

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2Fq9lM8x2WuLBwCTVZS3hb%2Fimage.png?alt=media&amp;token=6e0ea960-790f-4a66-8933-1390664915fd" alt=""><figcaption></figcaption></figure>

To check if the two boxes are downloaded successfully, type and run `vagrant box list` on PowerShel&#x6C;**.** The result should look like this

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FajNYwhOh6CmmcqNLGjxe%2Fimage.png?alt=media&amp;token=2439f5e9-725b-49f1-b2f5-4af7cd65a817" alt=""><figcaption></figcaption></figure>

To deploy these two boxes, type and run&#x20;

```
vagrant up --provider=virtualbox
```

The boxes deployment process should look similar to below<br>

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FNkFRwpxG2IqZnR7lXQim%2Fimage.png?alt=media&amp;token=2ac8986f-da1d-4e6a-a984-b331ccb21a6b" alt=""><figcaption></figcaption></figure>

Once vagrant finished the deployment, launch VirtualBox and the metasploitable 3 boxes are automically added and ready. If not, open the boxes up in VirtualBox's default machine folders (I have mine at **C:\Users\longp\VirtualBox VMs**)<br>

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2Fa0zNtJbB1Ey6A65wfgfF%2Fimage.png?alt=media&amp;token=2a6a201a-02d2-4519-89f5-4c92f253b691" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FjUukIZI8TCAVRdz22okl%2Fimage.png?alt=media&amp;token=d7b1bd80-38ea-483f-9dbe-c7b777bf06b0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2FKkKV8A57ENWalKK16XMt%2Fimage.png?alt=media&amp;token=cc02d68a-b5a6-44d4-b602-74cbf3e97702" alt=""><figcaption></figcaption></figure>

## Renewing Windows Server 2008 license&#x20;

On the metasploitable Windows Server 2008 box, launch PowerShell, type and run

```
slmgr /rearm
```

The result should look like this

<figure><img src="https://3434970178-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfqAQxvrn9WtYkym6kNcr%2Fuploads%2Fhnwf6TWYE55zvjum45gp%2Fimage.png?alt=media&amp;token=8772ba03-88d1-4a42-ac12-2cf66f77792d" alt=""><figcaption></figcaption></figure>
