Building a Security Lab in VirtualBox

In this post, we we will take a look at an in-detail process of setting up an entry-level cybersecurity lab using VirtualBox

8 months ago   •   6 min read

By 0xBEN
Table of contents
Last Modified Discord Username Discord Servers
Dec. 31, 2021 0xBEN#0001 HackTheBox | TryHackMe | TheCyberMentor
Infosec Prep | Infosec Knowledge Sharing

Spam, abuse, junk, or likewise will be ignored, blocked, and/or reported

Change Log

Updated network map with optional interface covered in the section: Adding Another Interface to pfSense.

Looking for my Proxmox Guide?

Proxmox VE 7: Converting a Laptop into a Bare Metal Server
In this post, we will take a look at an in-detail process of setting up a Proxmox home lab on a bare metal server.

Honorable Mentions

  • Check out @Dewalt’s PimpMyKali script to make your Kali VMs so much better
  • gimmesystem in the HackTheBox Discord server for QA testing this guide

Usage Scenarios


You have a desktop – either your daily-use computer or backup computer – you do not want to reimage it, but would like to run some labs on your computer.


Your daily-use computer. You want to run some labs on it and would like a mobile security lab.

What We'll Build

  • Virtualized pfSense firewall as the gateway
  • Multiple subnets for different purposes
    • LAN
    • Isolated
    • Active Directory

Recommended System Specifications

  • Multithreaded CPU with Virtualization Support
  • At least 16GB RAM – 32GB would be better
  • Plenty of free disk space, preferably more than one internal disk

Enabling Virtualization in the BIOS

NOTE: This process is unique to different PC vendors. I am going to demonstrate this on a HP EliteBook 840 G3. Use Google to find the procedure for your computer model.

  1. Turn on the laptop
  2. Press the ESC key multiple times until you get to the system setup menu.

Warning: you might need to press a different key on your system to get to the BIOS menu. From my HP laptop, ESC is the key to get to the BIOS.

  1. Choose BIOS Setup
  2. Go to Advanced > System Options
  3. Enable VTx and VTd (For AMD processors, there is a different name)
  4. Save changes and exit the BIOS setup

Install VirtualBox

To download the VirtualBox installer for your host OS, navigate to their downloads page here:

Downloads – Oracle VM VirtualBox

You'll see a list of downloads based on host operating system. At the time of writing this guide, the latest version was 6.1.32.

  • If downloading for Windows, click Windows hosts
  • If downloading for Mac OS, click OS X hosts
  • If downloading for Linux, click Linux distributions and follow the instructions. You can downloading using an .rpm or .deb package, or you can install using your package manager such as yum or apt.

Install the VirtualBox Extension Pack

Once you've installed VirtualBox, I'd highly recommend you add the extension pack for better VM support.

You can download the extension pack file. Once you open the file, VirtualBox should be the default file handler and install the extension pack. You must reinstall the extension pack any time you update VirtualBox!

A Note on VirtualBox Guest Additions

What are the VirtualBox Guest Additions? As you continue to experiment with VirtualBox, you may hear this name come up. Put simply, the Guest Additions are drivers (or software) you can install inside the VM, to enable it to run more smoothly with VirtualBox.

For example, sometimes you may have VM that has a poor screen resolution, the screen doesn't resize, or some other strange issues. You may need to install the VirtualBox Guest Additions drivers to help the VM run more smoothly.

In this lab guide, we won't be using the Guest Additions much, because most of our VMs won't require it. If you use the Kali Linux VirtualBox image provided by Offensive Security, the Guest Additions already come installed.

Next Steps

Please note that all of the steps demonstrated in this lab are being done on a Windows host machine.

Building a pfSense VM for Our Cyber Range

Building a pfSense VM for Our VirtualBox Cyber Range
In this module, we will look at setting up a pfSense firewall VM in VirtualBox to segment our home lab network

Importing Kali from Offensive Security Images

Importing Kali Using the Official VirtualBox Image
In this module, we will look at the process of importing the pre-packaged Kali VM for VirtualBox directly from the official source.

Configuring the pfSense Firewall

Configuring the pfSense Firewall for Our VirtualBox Lab
In this module, we will log into the pfSense web portal and configure firewall rules for our VirtualBox lab using our Kali VM.

Adding Vulnhub VMs to the Lab

Adding Vulnhub VMs to Our VirtualBox Cyber Range
In this module, we will look at two different ways, based on file type, to import VMs from Vulnhub into our home lab.

Building the Active Directory Lab

Adding an Active Directory Forest to Our VirtualBox Lab
In this module, we will cover the steps to set up a small Active Directory forest in VirtualBox, including a domain controller and two client computers

Troubleshooting Your Lab

Troubleshooting Your VirtualBox Lab
In this module, we will take a look at some common problems you may experience in your VirtualBox lab and how to begin fixing them.

Creating a Windows 7 Buffer Overflow Practice VM

Creating a Windows 7 Buffer Overflow Practice VM in VirtualBox
In this module, we will look at creating a vulnerable Windows 7 VM in VirtualBox that will run some applications which are vulnerable to 32-bit stack-based buffer overflows

Adding Another Interface to pfSense

Adding Another Interface to pfSense in VirtualBox
In this module, we will look at the process of adding an additional interface to the pfSense VM when the VirtualBox GUI only shows four available interfaces.


Appendix A: Double NAT Diagram

Learn more about NAT here:

Spread the word

Keep reading