# Windows

<figure><img src="/files/OA74eOiFjGq77MzFCoHt" alt=""><figcaption><p>The Capsulecorp-pentest environment</p></figcaption></figure>

This guide assumes you will be using `Hyper-V`.  During all of my testing, Hypver-V outperformed VirtualBox and VMware on the Windows system I used to create this guide.  If you prefer to use an alternate hypervisor, you do so without the support of this documentation.

{% hint style="info" %}
Documentation for additional hypervisors will be created in the future
{% endhint %}

{% hint style="warning" %}
It's best to use a dedicated lab machine as these VMs eat up a lot of resources
{% endhint %}

## 1. Enable Hypver-V

In order to get the best experience on a Windows machine, enable the native hypervisor Hyper-V from the Windows Features menu.  You may be required to restart your computer

1. Click on the Windows button and start typing the word "add"
2. Click on "Add or remove programs"
3. Click "Programs and Features"
4. Click Turn Windows features on or off"
5. Check the box next to "Hyper-V"
6. Click OK

<figure><img src="/files/IIaNaLkdfoFOm26ACs5X" alt=""><figcaption><p>Check the box next to "Hyper-V" and click OK</p></figcaption></figure>

## 2. Install & Configure WSL

At the end of the day, `Ansible` and `Vagrant` just work better from a Linux/UNIX environment.  You'll need to install WSL and configure a few environment variables for everything to work as it should.

{% hint style="info" %}
In this guide I make use of the "Terminal Preview" app from the Microsoft app store.  This makes it easier to switch back and forth between a Windows command prompt, PowerShell prompt and an Ubuntu bash prompt.
{% endhint %}

1. Open up an administrative command prompt by `Ctrl+Shift` clicking on the Terminal Preview app launcher
2. Run the command: `wsl --install`&#x20;
3. Restart your computer when the command finishes
4. Enter a username and password to use within your Ubuntu subsystem
5. Update the package manager with `sudo apt update`
6. Upgrade to the latest version of Ubuntu with `sudo apt dist-upgrade`

<figure><img src="/files/m5ZN790In8AJKhWXsRdH" alt=""><figcaption><p>Run the command: wsl --install</p></figcaption></figure>

## 3. Install Ansible

1. Install pip with `sudo apt install python3-pip`
2. Install ansible with pip: `pip3 install ansible --user`

{% hint style="info" %}
This will install ansible inside your `~/.local/bin` directory.  You'll need to modify your `~/.bashrc` file to contain `set PATH=~/.local/bin:$PATH` in order to use the `ansible` command
{% endhint %}

Alternatively you can install ansible with apt: `sudo apt install ansible`&#x20;

<figure><img src="/files/GwdvRlW4NCNeg9d4Pi7w" alt=""><figcaption><p>Make sure you can run ansible --version inside WSL</p></figcaption></figure>

## 4. Install Vagrant

To install Vagrant browse to <https://developer.hashicorp.com/vagrant/downloads> and select the appropriate Debian package (presumably Amd64).  Grab the URL to the download link and use wget to download the `.deb` package to a folder within your WSL environment

`wget https://releases.hashicorp.com/vagrant/[ver#]/vagrant_[ver#]_x86_64.deb`

<figure><img src="/files/TeIBprkYSxtocJ8aIQkq" alt=""><figcaption><p>Download the .deb package from hashicorp.com</p></figcaption></figure>

Install the `.dep` package using `dpkg -i` Then modify your `~/.bashrc` file to contain the following:

```bash
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
```

Don't forget to run `source ~/.bashrc` and then you should be able to run the `vagrant` command within your WSL environment.

<figure><img src="/files/kfFLxCAo4SJx3EIxb5ne" alt=""><figcaption><p>Make sure you can run vagrant --version inside WFL</p></figcaption></figure>

### 4.1. Necessary vagrant plugins

A few vagrant plugins are required to launch and provision all of the VMs.  If you below `vagrant plugin install` commands fail, open up an administrative PowerShell prompt and run the command.

```powershell
Restart-Service LxssManager
```

**References:**

* <https://github.com/hashicorp/vagrant/issues/12077>
* <https://discourse.roots.io/t/error-chmod-operation-not-permitted-chmod-internal/17632>

**Vagrant plugins:**

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

## 5. Clone Github Repo

Navigate to an appropriate folder within your WSL environment and checkout the repo from Github.

```bash
cd /mnt/c/Users/royce/
git clone https://github.com/R3dy/capsulecorp-pentest.git
cd capsulecorp-pentest
```

Familiarise yourself with the congents of the `Vagrant` file.  If you need to make any changes to the VMs such as CPU/Memory changes or pick a different base box then this is the file you'll want to edit.

**Vagrantfile**

{% embed url="<https://github.com/R3dy/capsulecorp-pentest/blob/master/Vagrantfile>" %}
master/Vagrantfile
{% endembed %}

## 6. Create Hypver-V Virtual Switch

1. Open up the Hyper-V Manager and click on the **Virtual Switch Manager** link from the Actions menu.
2. Create a New virtual network switch and name it `Capsulecorp-pentest`.  Check the External network radio button and select the appropriate network adapter from the dropdown list.

You'll specify this Virtual Switch each time you bring up a VM with `vagrant up`

<figure><img src="/files/M1IqS83BG0aY0CwzzVhj" alt=""><figcaption><p>Create a new Virtual Switch</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://realhax.gitbook.io/capsulecorp-pentest/setup/windows.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
