# Windows Server VM

I usually go with a [Windows Server 2022](https://www.microsoft.com/en-us/evalcenter/evaluate-windows-server-2022) VM with [VMWare](https://support.broadcom.com/group/ecx/productdownloads?subfamily=VMware+Workstation+Pro) or [Virtualbox](https://www.virtualbox.org/). I have VMWare Workstation Pro as Broadcom bought out VMWare and made it free, you just need an account with them. You can go with either VMWare or Virtualbox, both work and it just comes down to personal preference on the application and what you're use to.

Obviously your setup may differ depending on your system specs. I typically go with 4GB(4096 MB) of RAM per VM, 2 processors and 2 cores per processor but I am running with 32GB of RAM and an Intel i7-10750H.

If you need to, you can start with 4 or 8GB of RAM and 2 processors and 2 core per processor, for the install so it goes faster then drop it down to 2 or 4GB of RAM and 2 processors and 1 core per processor for the victim machines.

## VMWare Setup

Starting with typical setup

<figure><img src="/files/PV31spTD5ufDIlcanVaE" alt=""><figcaption></figcaption></figure>

I add the .iso after

<figure><img src="/files/8qgXdHS5RcZNcRs0KOMx" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/VxPiL6b8akPNE9VGxeTz" alt=""><figcaption></figcaption></figure>

Name the VM and where it's stored

<figure><img src="/files/dsHqYDmcIMwooIzzmnoG" alt=""><figcaption></figcaption></figure>

How much space you want the VM to have. Note that this is not how much space it will take up unless it ends up using all 100GB. I also keep mine as a single file as I keep this on one machine rather than multiple.

<figure><img src="/files/Cs44iN3u21JwfSObkZEB" alt=""><figcaption></figcaption></figure>

Now we can customize the hardware for it.

<figure><img src="/files/Ypq27uVuDOrJG8FvLPqV" alt=""><figcaption></figcaption></figure>

For install purposes, I up it to 8GB of ram and 4 Processors. Also add in the .iso file now.

<figure><img src="/files/t3b97UuJns09UlGaNsqc" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/KqjuXQG85jG3eiUB9R3F" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/FXL8TwqBfC9kFjaNd9mP" alt=""><figcaption></figcaption></figure>

When finished, click close > finish > turn on the VM. Be sure to click into the VM to press a button when it starts.&#x20;

### Installing Windows Server 2022

this section is all just defaults of clicking Next

<figure><img src="/files/5UYCsPkq8gyRNgTtIbxR" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Nsn0WRfLWE8f4LsbAkD9" alt=""><figcaption></figcaption></figure>

I select the option with a Desktop Environment.

<figure><img src="/files/D6DyL4eusyBsD1cw2C4J" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/73m7DECcajubNhen6Itu" alt=""><figcaption></figcaption></figure>

I go with the custom installation option.

<figure><img src="/files/rw1MjowD9ibul4SlgORu" alt=""><figcaption></figcaption></figure>

Select the hard drive and click next

<figure><img src="/files/lmOySVGK01BrHGUwPhlK" alt=""><figcaption></figcaption></figure>

Wait for the install process to finish and restart

<figure><img src="/files/ZHCBmIdzfFGQ4xCX89d5" alt=""><figcaption></figcaption></figure>

### Setting up the Server

When it restarts it will ask you for your Administrator password, use whatever you'd like, just remember this is for a lab environment, so it should be something simple/crackable.

<figure><img src="/files/bTOAMFk2QxhnOZT8IV7o" alt=""><figcaption></figcaption></figure>

Log in with the password you just set. Select "Yes" when asked to have the PC discoverable.

<figure><img src="/files/W4u2R7FxTTFBoWieve04" alt=""><figcaption></figcaption></figure>

I usually start with installing VMWare tools and renaming the PC. When it comes to Installing VMWare tools, I do the complete installation and choose "no" to restarting as we will restart after we rename the PC. To rename the PC, open the start menu and type in "rename".

<figure><img src="/files/JHcLciHIB0DNIIJ04ADK" alt=""><figcaption></figcaption></figure>

Select "Rename this PC" and give it a new name. Remember this is your Domain Controller(DC).

<figure><img src="/files/DVcbKQhtd3MWKwIC1fMZ" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/GrTnYlRJpHtUCmlYkBC5" alt=""><figcaption></figcaption></figure>

It will prompt you to restart your PC. Restart it, log back in and we will turn this into our DC. With the Server Manager open, click manage in the top right and select "Add Roles and Features".

<figure><img src="/files/stPrz64YwmUEC5JRFEao" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/L8z5Q9meSNHBW8aHGsXc" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/MLzn0br91wT1UVhPV29v" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/ORc0Xr2NP4ywsyFhg20l" alt=""><figcaption></figcaption></figure>

From here, select "Active Directory Domain Services". Then click "Add Features".

<figure><img src="/files/gjIlj4RMQyT8rpk61vBy" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/GOobw8eQRzsQYBUnazrn" alt=""><figcaption></figcaption></figure>

Now click "Next" until the end, then click "Install". Once it installs, select close, and we promote it to a DC. In the Server manager, in the top right, it will be a flag with a yellow exclamation mark. Select it, then click where it says "Promote the server to a domain controller".

<figure><img src="/files/EUsz2WJIidFemjlgvuUu" alt=""><figcaption></figcaption></figure>

Add a new forest and give it a name, be sure to add ".local" to the end of it.

<figure><img src="/files/L1PenwWICxsChCfwMut7" alt=""><figcaption></figcaption></figure>

It will ask for a password, I give it the same password as the Administrator user. This is not a secure practice, but this is for our lab environment.

<figure><img src="/files/1JJkX2bMaUhMWfdJaGvq" alt=""><figcaption></figcaption></figure>

From here, click "next" until we can install it and it will restart the machine. Once it restarts, the login screen will show the domain name\user account, indicating your logging into the domain with the user.

<figure><img src="/files/mFCvTd02Gq7fTXQ4Fhrp" alt=""><figcaption></figcaption></figure>

Now lets add another feature, Active Directory Certificate Services. We go through the same process as adding the last feature till we can select it.

<figure><img src="/files/bFO4wFDxIMJm4fI3yZUD" alt=""><figcaption></figcaption></figure>

From here, it will again be, next till we can install it. Once installed, we will have another notification by the flag in the server manager.

<figure><img src="/files/iBYBNWJfo7JavXB0a6QC" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/DUd7UYubkz59AA35fFnt" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/zGQQwfSshk3J4iHtjpTc" alt=""><figcaption></figcaption></figure>

It will be another simple, next till the end from here. Select Configure in the bottom right, and we're set!

<figure><img src="/files/H5PnW7jrulmQbEwHlz3S" alt=""><figcaption></figcaption></figure>

### Adding users

Now lets add some users to our Domain. Make a .csv file with firstname, lastname, username, password, and ou.

<figure><img src="/files/tCAEHsoShRaaF2sg9iRV" alt=""><figcaption></figcaption></figure>

Copy that to the server and open it with notepad.

<figure><img src="/files/2msQ5m4VMHc9U7nQvFwV" alt=""><figcaption></figcaption></figure>

Now open Powershell ISE, make a new file paste in the following code, editing your DC name.

```powershell
Import-Module activedirectory

#Point to csv file containing users!
$UserFile = Import-csv C:\Users\Administrator\Desktop\users.csv

#Change this to your domain
$Domain = 'GIBSON.local'

foreach ($User in $UserFile)
{
        
    $Username 	= $User.username
    $Password 	= $User.password
    $Firstname 	= $User.firstname
    $Lastname 	= $User.lastname
    $OU 		= $User.ou

    #Check user does not exist
    if (Get-ADUser -F {SamAccountName -eq $Username})
    {
         #If user exists...
         Write-Warning "Error! $Username already exists."
    }
    else
    {
        #Otherwise...	
        New-ADUser `
            -SamAccountName $Username `
            -UserPrincipalName "$Username@$Domain" `
            -Name "$Firstname $Lastname" `
            -GivenName $Firstname `
            -Surname $Lastname `
            -Enabled $True `
            -DisplayName "$Lastname, $Firstname" `
            -Path $OU `
            -AccountPassword (convertto-securestring $Password -AsPlainText -Force) -ChangePasswordAtLogon $False -PasswordNeverExpires $True
            
    }
}
```

<figure><img src="/files/Fn0feMoUlSJX7w0dycad" alt=""><figcaption></figcaption></figure>

Click the green button in the top bar.

<figure><img src="/files/BzZShh5A36Vi69SPjKBf" alt=""><figcaption></figcaption></figure>

Now in the server manager, select Tools > Active Directory Users and Computers.

<figure><img src="/files/VsmDhKBkvgq3BBvslZuP" alt=""><figcaption></figcaption></figure>

Going to 'Users' we should see our list of users.&#x20;

<figure><img src="/files/2ZCsZPuoZ86IAQ7BbVpV" alt=""><figcaption></figcaption></figure>

But we should also add a service account. So in the users and computers area, right click on a blank spot and select \`Add User\`.

<figure><img src="/files/IOZZPxuWJLpWZzXw7tQP" alt=""><figcaption></figcaption></figure>

Name it SQL-SVC and give it a weak/crackable password, like `P4ssw0rd123!`. Then in an Admin command prompt run the following, ensuring that you choose an arbitrarily large port, not a common one. This will change the account to a service account by assigning it an SPN.

```
setspn -a GIBSON/SQL-SVC.GIBSON.local:55555 GIBSON\SQL-SVC
```

<figure><img src="/files/V4p8DCRFCqvTpfxcxOEe" alt=""><figcaption></figcaption></figure>

Now also, give the SQL-SVC user a description by right clicking on it, and selecting properties.

<figure><img src="/files/Qji1uxS3wSCX8TqptLUZ" alt=""><figcaption></figcaption></figure>

### Creating a Network Share

From the Server Manager, on the left hand side, select 'File and Storage services', then select Shares

<figure><img src="/files/ApolmVhmJGjaYFZiXZV0" alt=""><figcaption></figcaption></figure>

In the top section, select Tasks, New Share. In the new Window, select SMB Share - Quick.

<figure><img src="/files/MdjiM96LsGBXxr6ecVZQ" alt=""><figcaption></figcaption></figure>

Click next till you get to give it a share name, then next till you create it.

<figure><img src="/files/TyBmqKqVV6kVER3tcogu" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/ND9zeT2Ci3CbK8MH3jXZ" alt=""><figcaption></figcaption></figure>

Now is when you will want to shut down the VM and adjust RAM and Processors if needed. Drop it for 2GB or 4GB of RAM and 1 or 2 processors.

![](/files/iihICVmfSrDTBkzV6oFn)

### Setting a Static IP

I recommend setting a static IP for the server so it doesn't change when turned on. Open the Control Panel from the Start Menu, in the top right, change Category to Large or Small Icons, your choice. Then select Network and Sharing Center.

<figure><img src="/files/VOj8Jn0db3oKxxyvMq46" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/Qm4RQbIFNuEwWzjUPfFD" alt=""><figcaption></figcaption></figure>

In the left panel, select Change Adapter Settings, then right click on the adapter and select properties.

<figure><img src="/files/fM24Ejt3GD1EYKgKGEhz" alt=""><figcaption></figcaption></figure>

Select Internet Protocol Version 4 (TCP/IPv4), and select properties.

<figure><img src="/files/UV6aKA3gE3Zvt9lthht7" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/V1pQJl9YLnwGKl2JGyou" alt=""><figcaption></figcaption></figure>

Now open command prompt and run ipconfig

<figure><img src="/files/qcHS9gmM78eSF5KKZZm3" alt=""><figcaption></figcaption></figure>

In the Properties window, change it to be either the same IP or something very close.

<figure><img src="/files/RsiFZx64ZxGxj2vGyXP0" alt=""><figcaption></figcaption></figure>

### Template Mode

I **HIGHLY** recommend creating a snapshot after you have this done and setup so that way you can always revert back to that snapshot if needed if something breaks or you just need to clean things up.

Now I am going to take this tip from John Hammond. After you create the Snap Shot, I recommend going into the VMs options, changing the name to Some form of Template and Options and enabling Template mode. So clone the VM choosing the Snapshot when we want to make a VM using this one so we don't have to re-create the VM from scratch every time.

![](/files/B2IQr80c6V1Xqxjv44Lr)

### Optional: Disable Windows Defender

IF you want the other VMs that will join this Domain to have Windows Defender disabled, I recommend doing this for simplicity sake, IF you are pentesting against this and having another VM setup with Defender Enabled to test things against that.

Start Menu > Group Policy > Right Click and Run as Admin

![](/files/PfqlW8Lc00Kr8n6fLeNS)

![](/files/X2DckUZugN1nu6ooIFLB)

Right click on out domain and Create a new Group Policy in this domain (Top option).

![](/files/XH601I5nVRxKIZCVJaTu)

Name this "Disable Windows Defender"

![](/files/QlVWNB2vjTtGu4y1UgbM)

Right click on newly added "Disable Windows Defender" GPO on the left and Edit it

![](/files/Pwq35XbhEy0AVP9wlFir)

Drill Down: Computer Configuration > Policies > Administrative Templates > Windows Components > Windows Defender Antivirus

![](/files/isMnIn09xNZNmMhsFKI0)

![](/files/n8I7MXFmx56T2Gl9XAfM)

Double click on the "Turn off Windows Defender Antivirus" > Enabled > Apply > Ok

![](/files/11VHMtQdSdyFaUuiR7ZN)

Close out of the Group Policy Management Editor and on the Group Policy Management Window, with the Disable Windows Defender selected, if 'Enforced' says no, right click on it, and enforce it

![](/files/X4ybwKlqTrRNp9ZApQzv)

Now we are done!

Again, I **HIGHLY** recommend creating a snapshot after you have this done and setup so that way you can always revert back to that snapshot if needed if something breaks or you just need to clean things up.


---

# 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://cybersec.th4ntis.com/lab-setup/windows-server-vm.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.
