Skip to content

Windows Setup Guide

Royce Davis edited this page Oct 15, 2020 · 2 revisions

1. VirtualBox

For now VirtualBox is the supported vagrant provider. If you absolutly have to use something else you'll simply need to go through the process of converting the baseboxes found here https://app.vagrantup.com/royce and convert export/import them into VMware. Then follow Vagrant's documentation for packaging VMware base boxes/

1.1 Install the latest VirtualBox

  1. Open up a browser and navigate to the following link: https://www.virtualbox.org/wiki/Downloads

  2. Click the "Windows hosts" link to save the VirtualBox installer

  3. Run the .exe installer accepting the default options

  4. Restart Windows.

2. Windows Subsystem for Linux (WSL)

It's also possible to use Cygwin to run Ansible+Vagrant on Windows. I haven't worked through that process yet but plan to in the future.

2.1 Enable WSL with Powershell

  1. open up administrative command prompt. Right+click run as administrator.

  2. Type powershell

  3. Run this powershell command Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

  4. Restart Windows.

2.2 Install Ubuntu 20.04

  1. Open up the Microsoft Store App

  2. type Ubuntu 20.04 in the search box

  3. Click on the Ubuntu 20.04 LTS app

  4. Click the blue Get button to install it.

  5. Open up an Ubuntu terminal either by clicking "Launch" from the Microsoft Store or from the Windows Start menu

  6. Create a new username and password to use within your Ubuntu environment

3. Ansible

3.1 Install pip in Ubuntu 20.04

  1. open up ubuntu terminal and type cd ~
  2. run the command sudo apt update
  3. run the command sudo apt dist-upgrade -y
  4. run the command sudo apt install python
  5. create a directory for the pip installer mkdir pipinstaller
  6. download the pip installer curl https://bootstrap.pypa.io/get-pip.py -o pipinstaller/get-pip.py
  7. install pip python pipinstaller/get-pip.py --user
  8. Make pip executable from your path echo 'export PATH="${PATH}:/home/pentest/.local/bin"' >> ~/.bashrc

3.2 Install Ansible in Ubuntu 20.04

  1. Open up a new bash prompt (or resource the ~/.bashrc file)
  2. Install ansible using pip pip install ansible --user

4. Vagrant

4.1 Install Vagrant in Ubuntu

  1. Install with apt sudo apt install vagrant
  2. run echo 'export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"' >> ~/.bashrc
  3. run echo 'export PATH="${PATH}:/mnt/c/Program Files/Oracle/VirtualBox"' >> ~/.bashrc
  4. run source ~/.bashrc

4.2 Vagrant plugins

These may or may not be required for you but I ran into some errors and while troubleshooting I found various error messages regarding these plugins and installing them removed the error messages.

  1. vagrant plugin install winrm
  2. vagrant plugin install winrm-fs
  3. vagrant plugin install winrm-elevated

5. CapsuleCorp

  1. Change to Windows file system cd /mnt/c
  2. Download the repository git clone https://github.com/R3dy/capsulecorp-pentest.git

You should be all set now, follow the VM documentation for provisioning the VMs in the correct order.

5.1 SSH Keys for Pentest VM

When you try to run vagrant up pentest you'll notice an error about the permissions for the ssh keys used to authenticate to the VM. If you try and set them with chmod 0600 ssh/capsulecorp_id_rsa as the error message suggests you'll notice that permissions don't change. This is because by design, chmod within WSL does not modify the Windows ACLs for files/folders within the /mnt/c (a.k.a C:) path.

Simply copy ssh/capsulecorp_id_rsa to /home/[username]/ssh/capsulecorp_id_rsa and then modify your Vagrantfile to point to that file.

For Example:

 config.vm.define "pentest" do |box|
    box.vm.box = "royce/capsulecorp-pentest"
    box.vm.box_version ="0.0.4-alpha"
    box.vm.network "private_network", ip: "172.28.128.200"
    box.vm.network :forwarded_port, guest: 3389, host: 3389, auto_correct: true
    box.ssh.username = "pentest"
    box.ssh.private_key_path = "/home/pentest/ssh/capsulecorp_id_rsa"
    box.vm.provision "ansible" do |ansible|
      ansible.playbook = "pentest.yml"
    end
  end