Vagrant Logo


Cactuscon 9 occured last weekend. For those that missed the 2021 talks, their currently available on this channel:

One of the talks caught our eye: CC9 Learn Offensive Security with Project V^3. Last year we talked about using Virtualbox, Vagrant and Anisble to quickly provision Virtual Machines (VMs) for challenges, self-learning or possibly CTF’s or sharing within the team. A link to our previous blog post is here:

V^3 is currently a small but ambitious project where they have converted publically available Vulnhub VMs to the virtualbox format, for ease of download and execution. In their github repository they have also included one VM from outside of Vulnhub a previous Cactuscon CTF image. We like their idea and use-cases as this could be expanded to include VMs from other platforms like HacktheBox or even retired Offensive Security VMs. For more details the project can be found here:

So in this post we talk more about Vagrant and how to manage it with virtualbox!


Initial Commands

We covered these two commands previosly but as a quick catch up the two most used commands are likely:

Start a VM

vagrant up

Remove a VM

vagrant destroy

More Vagrant Commands

We didn’t really cover these last time, but you may also want to know these commands:

Stop a VM (rather than remove/destroy)

vagrant halt

or even suspend an image

vagrant suspend

Alternatiely to resume an image

vagrant resume

If for some reason, the provisioning failed, or you messed up a VM in some fashion, you can reload and reprovision a VM:

vagrant reload
vagrant provision

When you use the vagrant destroy command, it deletes the Virtualbox image, but still stores a cached VM image in ~/.vagrant. If you are short on disk space you will probably want to permently delete these cached images:

List boxs:

vagrant box list


vagrant box list
RedHatAugust/Star-Wars-CTF-1 (virtualbox, 0.01)
kalilinux/rolling            (virtualbox, 2020.4.0)
ubuntu/bionic64              (virtualbox, 20210112.0.0)
ubuntu/trusty64              (virtualbox, 20190514.0.0)

If you then want to delete a box the command is

vagrant box remove <vm name>

Other Helpful Additions

Add a Kali Image

The project was missing a Kali Linux vagrant build (I think they left this intentionally open for people to use their own pentest builds), so attached is our Kali-Linux vagrant-file; Simply create a directory, and copy the following into Vagrantfile

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|

  base_network = "192.168.99" = "kalilinux/rolling"
  # config.vm.box_check_update = false
  # "forwarded_port", guest: 80, host: 8080 :private_network, ip: "#{base_network}.10" :private_network, type: "dhcp", virtualbox__intnet: "haymarketers", adapter: "2"

  # config.vm.synced_folder "../data", "/vagrant_data"

  # All below is default, but you may want to tailor it for your personal systems
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #   vb.memory = "2048"
  #   vb.cpus = 2
  # end
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2

You may want to adjust the networking for your Virtualbox setup, but remember in Virtualbox the 1st interface is always natted, and this is the interface Vagrant SSH/provising will use in an attempt to perfrom any additional setup steps you may require.

Darwin Setup Script

The V^3 project currently has helper setup scripts for Windows in Powershell but not for Linux or OSX. Below is a small shell script we created for our junior team members on OSX; All the script does is use vboxmanage to setup the same haymarketers network like the powershell scripts in the repository:


if [ $# -eq 0 ]; then
    echo "Usage:"
    echo "-----"
    echo "$0 install - install haymarketers network"
    echo "$0 uninstall - uninstall haymarketers network"
    exit 1

OSTYPE=$(uname -s)
VBOX=$(which VBoxManage)

if [[ "$VBOX" == '' ]]; then
  echo "Error: VBoxManage not found in PATH!\nExiting!"
  exit 1

install() {
  if [[ "$OSTYPE" == 'Darwin' ]]; then
    echo "Darwin Setup"
    VBoxManage dhcpserver add --netname haymarketers --ip --netmask --lowerip --upperip --enable    
    echo "Added haymarketers network"
  elif [[ "$OSTYPE" == 'Linux' ]]; then
    echo "todo..."
    echo "unknown platform"

uninstall() {
  if [[ "$OSTYPE" == 'Darwin' ]]; then
    echo "Darwin Setup detected..."
    VBoxManage dhcpserver remove --network haymarketers
    echo "Removed Haymarketers Network"
  elif [[ "$OSTYPE" == 'Linux' ]]; then
    echo "todo..."
    echo "unknown platform"



Images were sourced from Vagrant HashiCorp.

Share on: