Adding an Active Directory Forest to Our VMware Lab

In this module, we will cover the steps to set up a small Active Directory forest in VMware, including a domain controller and two client computers
Adding an Active Directory Forest to Our VMware Lab
In: VMware, VMware Cybersecurity Lab Project, Computer Networking, Active Directory, Windows, Attack
ℹ️
This page is part of a larger series on building a cybersecurity lab using VMware Workstation Pro. Click here to be taken back to the project home page.

Previous Step

Adding HackMyVM Boxes to Our VMware Cyber Range
In this module, we will look at the process to import a VM from HackMyVM into our VMware Cyber Range.



Active Directory Lab Overview

Note: if you don't want your AD lab to have Internet access, modify the firewall rules. I will not be showing you how to do this, as I've already shown you how to craft this kind of firewall rule when first configuring pfSense.

Putting Kali on the Active Directory Network

⚠️
Note: Some attacks require Kali to be on the same LAN as the targets. To change Kali's network configurations, see the steps just below...
  1. Stop the VM
  2. Go to VMware Workstation settings for Kali VM
  3. Change the network adapter to be on the cyber-range-ad-lab LAN segment
  4. Start Kali again

To put Kali back on the default LAN, just follow the steps from above, but set it to the cyber-range-LAN LAN segment.



Getting the Windows ISO Files

We will be getting the ISO files from the Microsoft Evaluation Center. Most of the ISOs you encounter here will have a lifespan of 90 -- 180 days of usage. Some say that you can extend beyond the lifespan and the VMs will still function just fine

Windows Server 2025

  • Click Download the ISO
  • Fill out your information (uncheck the box for additional communications)
  • Find your language
    • Under ISO – download
    • Click the 64-bit edition link

Windows 11 Enterprise

  • Click Download the ISO - Window 11 Enterprise
  • Fill out your information (uncheck the box for additional communications)
  • Find your language
    • Under ISO – Enterprise download
    • Click the 64-bit edition link

Windows 7

When this page was initially written, these download links — on download.microsoft.com — for Windows 7 were functional. At last check — June 23, 2023 — these links are all dead.

I am leaving the links here in case anyone reading this would like to try and look for them on the Internet Archive.

Wayback Machine



Staging the VMs

Windows Server 2025

Create a New Virtual Machine
Typical
Choose the Windows Server 2025 .iso file
Leave the product key empty, provide a username and optional password
Click "Yes"
Next
Choose "single file" > Next
Click "Customize Hardware"
Put the VM on the cyber-range-ad-lab LAN segment > Close > Finish
Give the VM 4 GB RAM, since we're running the desktop environment
⚠️
Do not start the VM yet!



Windows 11 Enterprise Template

Create a New Virtual Machine
Typical
Choose the Windows 11 Enterprise .iso file > Next
Name the VM accordingly > Next
Provide a password > Next
⚠️
Note that even though we are remembering the password, this VM is a template that we are going to clone other VMs from, so do make it a point to remember the password whenever you need to clone off this image.
Choose "single file" > Next
Choose "Customize Hardware"
Put the VM on the cyber-range-ad-lab LAN segment > Finish
⚠️
Do not start the VM yet!



Install the Operating Systems

Windows Server 2025

Power on the VM...

Be patient while the auto-installer finishes...
VMware Easy Install has completed and we are running as the username we specified earlier

Configure the Network Interface

ℹ️
Remember! We disabled the DHCP service on pfSense for the AD Lab LAN, because we want the domain controller to act as the DHCP server. Therefore, the domain controller will not be automatically configured and we will have to set it up manually.
Right-click the globe icon > Network and Internet settings
Ethernet
IP assignment > Edit
Configure accordingly > Save
ℹ️
We set the Preferred DNS to 127.0.0.1, because in a moment, when we configure the DNS service, we are going to set a conditional forwarder.

The DNS service on this server will be responsible for the ad.lab domain. Any other domain or host will be forwarded to the DNS resolver on pfSense at 10.80.80.1.



Rename the Server

Click "System" > Scroll down to "About"
Click "Rename this PC"
Enter "DC01" (or whatever your preference is) > Next > Restart Now



Take a Snapshot of the VM

ℹ️
Now that the VM has been configured with an IP and hostname, we want to take a snapshot of the VM before we install the domain services, so that we can restore the VM when we want to rebuild from scratch.
Right-click on the VM > Snapshot > Take Snapshot...
Fill out and click "Take Snapshot"



Install and Configure Domain Services

Install Active Directory Domain Services

Manage > Add Roles and Features

Click Next > Next > Next until you reach the Server Roles tab...

Click Active Directory Domain Services > Add Features
Click DNS Server > Add Features

Click Next > Next > Next > Next ...

Check the box to allow automatic restarts during installation > Click Install



Configure Domain Services

If you checked the box to automatically reboot during installation, you should now be sitting at the Server Manager dashboard.

Click the ⚠️ icon
Click "Promote this server to a domain controller"
Add a new forest > ad.lab
ℹ️
I chose the .lab top-level domain (TLD), as this is not likely to have any collisions with real domains at more common TLDs such as .com, .org, .net, etc. Using the .local domain is not recommended, as this can interfere with multicast traffic.
Set a password for "restore mode"
Leave unchecked > Next

Click Next > Next > Next ...

If you see the screenshot below, this is most likely because the VMware Easy Installer does not set a password for the local "Administrator" account...

Right-click the "Start Button" and click "Terminal (Admin)"
net user Administrator 'P@$$word123!'
Set a "complex" password on the local Administrator account
Click "Rerun prerequisites check"
✅ and now we're good to go. Click "Install".
ℹ️
The system will reboot during the installation, be patient while everything completes



Configure Active Directory Certificate Services

Manage > Add Roles and Features

Click Next > Next > Next until you reach the Server Roles tab...

Click Active Directory Certificate Services > Add Features

Click Next > Next > Next...

Choose "Certificate Authority"

Click Next > Install. When the installation is complete, it's time to configure the service.

Click "Configure Active Directory Certificate Services ..."
Next
"Certificate Authority"

We're just going to accept all of the default options in the next steps. Click Next > Next > Next > Next > Next > Next > Next > Configure.



Configure DNS Service

The DNS server running on the domain controller will act as a resolver for the ad.lab domain (or whichever local domain you chose). We need a forwarder for any DNS query for which the DNS server does not know the answer.

We can use the pfSense default gateway as a downstream DNS server that the domain controller can pass queries to for any unknown hostnames.

Open up the Start Menu and search for DNS.
DC01 > Double-click "Forwarders"
Click the "Edit" button
Click "OK"
We can reach the Internet now that DNS is properly configured to forward to pfSense



Configure DHCP Server

Manage > Add Roles and Features

Click Next > Next > Next until you reach the Server Roles tab...

Click "DHCP Server" > Add Features

Click Next > Next > Next > Install...

Click "Complete DHCP configuration"
Next
Click "Specify"
Enter the "Administrator" credential we used from before > Commit > Close
Open the "Start Menu" > Search "DHCP"
Right-click "IPv4" > New Scope ...
Fill in the form accordingly
Next
No exclusions needed. Next ...
A 2 day lease is reasonable. Next ...
Next
Enter 10.80.80.1 > Add > Next
Next
No WINS servers. Next ...
Yes > Next > Finish



Create User Accounts

Domain Administrator

Start Menu > Active Directory Users and Computers
Right-click ad.lab > New > User
ad.lab > Users > double-click Domain Admins > click "Add"
Enter the username, domain.admin > Click "OK"



Domain Users

John Doe
Right-click ad.lab > New > User
Next
Next > Finish

Jane Doe
Right-click ad.lab > New > User
Next
Next > Finish



Windows 11 Enterprise Template

Install Windows 11 Enterprise

ℹ️
If it wasn't already clear, this is going to be a template VM from which to clone other Windows 11 Enterprise boxes off of. We will do some baseline configurations on the VM and prepare it to be a cloneable image.

Power on the VM ...

Act quickly here to boot from the .iso file, use CTRL + ALT to free your mouse
Choose your language settings
Next > Accept the EULA
Create Partition > Apply (and wait for it to complete) > Next > Install
Choose your country / regional / keyboard settings
Click "Sign-in options"
Domain join instead
Enter a username and password, then set security questions
Go through and disable all of these settings, then wait for Windows Update...



Sysprep the Template

💡
We want to run sysprep to create a template VM, so that when we clone the VM, the Windows systems will always have a unique SID when joining to the domain.

The installation process should now be complete and you should be able to log in using the username and password you set during the installation.

Logged in and waiting for initial setup to complete...
Right-click on the Start Menu > click "Windows PowerShell (Admin)"
C:\Windows\System32\Sysprep\sysprep.exe
Click "OK" and let the sysprep process complete until the VM shuts down
ℹ️
If you get this error when running sysprep, use notepad to view the file setupact.log and find what's causing the issue.
notepad C:\Windows\System32\Sysprep\Panther\setupact.log

We can see the "ERROR" logs at this particular point of the file. sysprep was unable to remove a package during the process and terminated. Let's see if we can manually remove it and try again.

Get-AppxPackage -AllUsers -Name 'Microsoft.Ink.Handwriting.Main*' | % {Remove-AppxPackage -Package $_.Name -AllUsers}
And now, sysprep has no problems generalizing the image and the VM shuts down when complete
Right-click the template VM > Snapshot > Take Snapshot ...
Fill out the form and click "Take Snapshot"



Joining Windows 11 PCs to the Domain

Create the Cloned VMs

Windows Enterprise 11 VM 1

Right-click the Template > Manage > Clone
Do a full clone off the snapshot taken before
Click "Finish" and wait while the clone finishes

Windows Enterprise 11 VM 2

Repeat the process shown above and create one more clone....



Keeping Things Organized

Now's as good a time as any to begin categorizing our VMs to keep things tidy. We can use the VMware Workstation "folders" feature to sort things out.



Join the PCs to the Domain

⚠️
I am only going to demonstrate this process on one of the VMs. Follow along and repeat this process on any other clients you want to join to the domain.

Windows 11 Enterprise VM 1

ℹ️
Because we selected the Out-of-Box-Experience (OOBE) when running sysprep on the template — which is the correct choice — we are required to run the through the Windows setup again as a newly issued computer.

This is essentially the same thing as receiving a newly imaged Windows computer from your employer and joining it to the local domain.

Go ahead and power on the VM ...

Like you did with the template, make your selections:

  • Language
  • Region
  • Keyboard
Click "Sign-in options" > Domain join instead
Specify a username and password, as well as security questions

Then, as done previously, disable the selections in the privacy settings. Finally, wait for Windows Updates to finish and you should be directed to the Windows desktop.

Open the Start Menu > Settings app
System > scroll down and click "About"
Sroll down and click "Advanced system settings"
Under "Computer Name" tab, click "Change..."
Choose "More..."
Fill out accordingly and click "OK"
Fill out and press "OK"
Enter the domain.admin credentials created before to approve the domain join
It may take a moment, but you should receive a welcome message, proceed to reboot the VM

Windows 11 Enterprise VM 2

Follow along with the procedure demonstrated just above to join the second Windows 11 Enterprise VM to the domain.



Test Domain User Login

Click "Other User" and enter your login details created earlier
Showing current user, IP configuration, and AD domain context



Active Directory Setup Complete

Congratulations! You now have a small Active Directory forest consisting of one domain controller and two Windows 11 Enterprise clients joined to the domain.

If things seem a little sluggish on any of the VMs, you may need to increase the RAM and / or CPU resources.

ℹ️
REMEMBER! You enabled the DNS service on the Domain Controller. It is now the Start of Authority (SOA) for the ad.lab local domain. If you are having trouble resolving computer hostnames to IP addresses, compare what is in DNS with what is in the DHCP pool.
ad.lab Forward Lookup Zone in DNS app on DC01 shows A records for domain-joined hosts
DHCP app shows current leases for domain-joined hosts



Starting with a Clean Slate

If you want to roll back your Active Directory lab to the very beginning, run these steps in this order:

  1. Power off the Windows Server 2025VM and both Windows 11 Enterprise VMs
  2. Delete both Windows 11 Enterprise VMs
  3. Roll back to the pre-domain snapshot of the domain controller we took before
  4. Follow the steps to re-provision the ad.lab domain, the DNS server, and the DHCP server
  5. Clone the Windows 11 Enterprise Template as many times as needed
  6. Join your clients to the domain



Next Step

A lot of the attacks you'll see in this next section have a lot of overlap with what's in TheCyberMentor's "Practical Ethical Hacking" course. Just bear in mind that your environment and his environment will have different domain names, usernames, etc. But, the substance is in the methodology.

Hack Your VMware AD Lab
In this module we will look at using a publicly available script to make our Active Directory domain susceptible to multiple vulnerabilities.
Comments
More from 0xBEN
Building a Security Lab in VMware Workstation Pro
VMware

Building a Security Lab in VMware Workstation Pro

In this project, broken up into multiple modules, you will build a comprehensive cybersecurity home lab using VMware Workstation Pro. Upon completion, you will have an environment where you can safely practice penetration testing against a wide variety of targets, as well as detection in your SIEM.
Table of Contents
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to 0xBEN.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.