InfoSec Write-ups

A collection of write-ups from the best hackers in the world on topics ranging from bug bounties and CTFs to vulnhub machines, hardware challenges and real life encounters. Subscribe to our weekly newsletter for the coolest infosec updates: https://weekly.infosecwriteups.com/

Follow publication

Building a Virtual Security Home Lab: Part 7 - Active Directory Lab Setup - Part 2

A step-by-step guide for building your very own Cybersecurity Home Lab using VirtualBox

David Varghese
InfoSec Write-ups
Published in
20 min readJan 21, 2024

--

banner-image|640

Banner Background by logturnal on Freepik
Hacker Image by catalyststuff on Freepik

In the previous module, we installed Windows Server 2019, installed AD Domain Services, configured DHCP and set up a DNS Forwarder. In this module, we will continue building out the AD Lab by completing the Domain Controller setup and adding devices to the AD environment.

Windows Server 2019 Setup

Select Manage from the top right corner of Server Manager and then select "Add Roles and Features".

dc-28|360

Click Next till you reach the Server Roles page. Enable "Active Directory Certificate Services".

dc-107|580

Click on Add Features.

dc-108|580

Click on Next to continue.

dc-109|580

Click Next till you reach the Role Services Page. Enable "Certificate Authority". Click on Next to continue.

dc-110|580

Click on Install to start the setup.

dc-111|580

After the installation is complete the server has to be restarted. Open the Start Menu, click on the Power icon and then select Restart.

dc-119|240

Click on Continue to restart the system.

dc-120|300

After the restart once Server Manager loads. Click on the Flag icon on the top right side and select “Configure Active Directory Certificate Services”

dc-112|400

Click on Next.

dc-113|580

Enable “Certification Authority” and click on Next.

dc-114|580

Click on Next.

dc-115|580

Click on Next.

dc-116|580

Click on Next till you reach the Confirmation page. Click on Configure to save the changes.

dc-117|580

Click on Close.

dc-118|580

Open the Start menu click on “Windows Administrative Tools” and then select Active Directory Users and Computers.

dc-64|400

Right-click on the domain name (in my case ad.lab) in the sidebar. Then select New -> User.

dc-65|500

Enter the First Name, Last Name and User logon name for the new user. This user will be the Administrator for the Domain Controller.

dc-66|400

Enter the Password for the user. Uncheck all options leaving “Password never expires”. Click on Next to create the user.

dc-67|400

Expand the dropdown on the domain name from the sidebar. Click on Users. Then double-click on "Domain Admins".

dc-68|500

Go to Members -> Add.

dc-69|400

Enter the name of the user and check on Check Names.

dc-70|400

Click on OK.

dc-71|400

Click on Apply then OK to persist the changes.

dc-72|400

Open the Start menu and then click on the user logo and then select Sign out.

dc-73|400

From the login screen select “Other user”. Then enter the login name and password that was configured for your domain administrator.

Open the Start menu. Select “Windows Administrative Tools” and then choose Active Directory Users and Computers.

dc-75|400

Right-click on the domain name from the sidebar. Select New -> User.

dc-76|500

Enter the details for the user.

dc-77|400

Give the user a password. Check the “User cannot change password” and “Password never expires” options. Click Next to create a user.

dc-78|400

Follow the same steps as above to create a second AD User.

dc-76|500
dc-79|400
dc-80|400

Making AD Lab Exploitable

To make the Active Directory Lab vulnerable we need to change some settings. We will use a PowerShell script and change so and Group Policies to achieve the desired result.

You can skip this section and continue from the “Windows 10 Enterprise VM1 Setup” step if you do not plan to make your Active Directory Lab vulnerable to attacks

Right-click on the Start menu and select Windows PowerShell (Admin).

dc-91|300

Run the following command:

# Allow Execution of Scripts
Set-ExecutionPolicy -ExecutionPolicy Bypass -Force
dc-121|500
# Download and Execute Script
[System.Net.WebClient]::new().DownloadString('https://raw.githubusercontent.com/WaterExecution/vulnerable-AD-plus/master/vulnadplus.ps1') -replace 'change\.me', 'ad.lab' | Invoke-Expression

Replace ad.lab with the name you have used for your Active Directory Domain before running the above command.

The above command constants of the following steps: [System.Net.WebClient]::new().DownloadString(): Downloads the Script
-replace: Change string present in the script
Invoke-Expression: Execute the Script

dc-122|600

Once the script reaches the end. It will wait for 30 seconds and then restart the system.

dc-123|600

After the system restarts open the Start menu and click on “Windows Administrative Tools” then choose Group Policy Management.

dc-81|400

Expand “Forest” and then expand “Domains”.

dc-102|400

Right-click on the domain name. Select “Create a GPO in the domain and link here”.

dc-82|500

Give the GPO the name Disable Protections.

dc-83|400

Expand the domain name. Right-click on “Disable Protections” and choose Edit.

dc-84|600

This will open the Group Policy Management Editor. From the sidebar go to the following folder: Computer Configuration -> Policies -> Administrative Templates -> Windows Components -> Windows Defender Antivirus.

dc-85|600

Select “Windows Defender Antivirus”. From the right side select “Turn off Windows Defender Antivirus” and click on Edit policy setting.

dc-86|600

Set it to Enabled. Click on Apply then OK to save the changes.

dc-87|600

Double-click on Real-time Protection.

dc-104|600

Select “Turn off real-time protection” and then click on “Edit policy settings”

dc-105|600

Set it to Enabled. Click on Apply then OK to save the changes.

dc-106|500

Expand the sidebar folders to the following: Computer Configuration -> Policies -> Administrative Templates -> Network -> Network Connections -> Windows Defender Firewall -> Domain Profile.

Select “Windows Defender Firewall: Protect all network connections”. Click on “Edit policy settings”.

dc-88|600

Set it to Disabled. Click on Apply then OK to save the changes.

dc-89|600

Close Group Policy Management Editor. From the sidebar of Group Policy Management right-click on “Disable Protections” and choose “Enforced”.

dc-90|600

Right-click on the domain name. Select “Create a GPO in the domain and link here”.

dc-124|360

Give the GPO the name Local Admin Remote Login.

dc-125|400

Right-click on “Local Admin Remote Login” and choose Edit.

dc-126|340

Using the sidebar descend into Computer Configuration -> Preferences -> Windows Settings -> Registry. Then, right-click Registry and choose New -> Registry Item.

dc-127|400

For the Hive field select HKEY_LOCAL_MACHINE. To fill the value in the "Key Path" field click on the ... button.

dc-128|400

In the window that opens up navigate to the following directory: SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

dc-129|420

Enter the following for the remaining fields:
Value name: LocalAccountTokenFilterPolicy
Value type: REG_DWORD
Value data: 1

Click on Apply then OK. Close Group Policy Management Editor.

dc-130|400

Right-click on the domain name. Select “Create a GPO in the domain and link here”.

dc-124|360

Give the GPO the name Enable WinRM Server.

dc-131|400

Right-click on “Enable WinRM Server” and choose Edit.

dc-132|340

Using the sidebar go to the following folder: Computer Configuration -> Policies -> Administrative Templates -> Windows Components -> Windows Remote Management (WinRM) -> WinRM Service.

dc-133|600

Select “Allow remote server management through WinRM” and then click on “Edit policy settings”.

dc-134|560

Set the policy to Enabled. In the IPv4 filter field enter *. Click on Apply then OK.

dc-135|500

Select “Allow Basic authentication” and click on “Edit policy settings”.

dc-136|560

Set the policy to Enabled. Click on Apply and then OK.

dc-137|500

Select “Allow unencrypted traffic” and click on “Edit policy settings”.

dc-138|560

Set the policy to Enabled. Click on Apply then OK.

dc-139|500

In the sidebar navigate to: Computer Configuration -> Preferences -> Control Panel Settings. Right-click on Services and select New -> Service.

dc-140|560

Select Startup to Automatic. Use the ... button to select the Server name.

dc-141|400

Select “Windows Remote Management (WS-Management)” and click on Select.

dc-142|420

For Service action select Start service. Click on Apply then OK.

dc-143|400

Using the sidebar navigate to the following location: Computer Configuration -> Policies -> Administrative Templates -> Windows Components -> Windows Remote Shell

Select “Allow Remote Shell Access” and click on “Edit policy setting”.

dc-144|600

Set the policy to Enabled. Click on Apply then OK. Close the Group Policy Management Editor.

dc-145|500

Right-click on the domain name. Select “Create a GPO in the domain and link here”.

dc-124|360

Give the GPO the name Enable RDP.

dc-146|400

Right-click on “Enable RDP” and select Edit.

dc-147|340

Using the sidebar navigate to the following folder: Computer Configuration -> Policies -> Administrative Templates -> Windows Components -> Remote Desktop Services -> Remote Desktop Session Host -> Connections.

Select “Allow users to connect remotely using Remote Desktop Services” and click on “Edit policy settings”.

dc-148|600

Set the policy to Enabled. Click on Apply then OK. Close Group Policy Management Editor.

dc-149|500

Right-click on the domain name. Select “Create a GPO in the domain and link here”.

dc-124|360

Give the GPO the name Enable RPC.

dc-150|400

Right-click on “Enable RPC” and select Edit.

dc-151|340

Using the sidebar navigate to the following folder: Computer Configuration -> Administrative Templates -> System -> Remote Procedure Call.

Select “Enable RPC Endpoint Mapper Client Authentication” and click on “Edit policy settings”.

dc-152|600

Set the policy to Enabled. Click on Apply then OK. Close Group Policy Management Editor.

dc-153|500

Right-click on the Start menu and select Windows PowerShell (Admin).

dc-91|300

In the terminal enter the following:

gpupdate /force
dc-92|440

Now whenever a new device joins our AD environment the Group Policies that apply to all the devices will automatically be applied to them. With this, we have completed the Domain Controller setup.

For the rest of the module the DC VM should be left powered on. To use the AD lab DC should be the first VM that is launched.

Windows 10 Enterprise VM1 Setup

Select Windows 10 Enterprise VM1 from the sidebar then click on Start.

user-45|540

Click on Next.

user-1|540

Click on Install now.

user-2|540

Accept the agreement and then click on Next.

user-3|540

Select “Custom: Install Windows only (advanced)”.

user-4|540

Select Disk 0 and then click on Next.

user-5|540

The VM will reboot multiple times during the installation.

user-6|540

Select your Region and Keyboard Layout.

user-7|540
user-8|540

Click on Skip.

user-9|540

Select “Domain join instead”. This will allow us to configure a local account.

user-10|540

Enter a username and click on Next.

user-11|540

You can provide any username in this step but to avoid confusion I would recommend using the First Name of one of the non-admin users that was created in AD. In my case the two AD users are John Doe and Jane Doe. For this VM I have choose John, when i configure the 2nd VM I will use Jane.

Enter a password and click on Next.

This password can be different from the password that was configured in Active Directory.

user-12|540

Configure the “Security Questions” for the user. Remember to note down these details in a secure location.

user-13|540

Disable all the features that are shown. Then click on Accept.

user-14|540

Select Not now.

user-15|540

Once on the desktop a prompt to allow internet access should show up click on Yes.

user-16|540

Similar to the Windows 2019 Server VM we need to install Guest Additions to enable Fullscreen mode. From the VM toolbar select Devices -> Remove disk for virtual drive. This will remove the Windows 10 image.

user-17|500

Click on Devices -> Insert Guest Additions CD image.

user-18|380

Open File Explorer. Once the disk has loaded from the sidebar select the disk drive. Double-click VBoxWindowsAdditions to start the installer.

user-19|540

Click Next.

user-20|400

Click Next.

user-21|400

Click on Install to start the installation.

user-22|400

Select “Reboot now” and then click on Finish. The VM will reboot.

user-23|400

Login into the system.

user-24|540

From the toolbar select Optical Devices -> Remove disk from virtual drive to remove the Guest Additions image.

user-25|400

Use the shortcut Right Ctrl+F to enter Fullscreen mode. Use the same key to exit Fullscreen. The VM should automatically scale to fit the window size.

Now we can add this device to the AD domain and log in as an AD user.

Click on the Search Bar and search for “This PC”. Right-click on it and select Properties.

user-26|500

Click on Advanced system settings.

user-27|540

Select the “Computer Name” tab and click on Change.

user-28|360

In the Computer name field enter a name that can be used to easily identify this VM. In the Member of section select Domain and enter the name of the AD domain (in my case ad.lab). Then click on More.

user-29|360

In the “Primary DNS suffix of this computer” field enter the domain name. Click on OK.

user-30|360

Click on OK.

user-31|360

Now a popup should appear. Enter the login name and password of the Domain Admin and click on OK.

user-32|300

The device will be added to the AD environment. Click on OK.

user-33|260

The device needs to be rebooted to apply the domain-specific settings. Click on OK to continue.

user-34|300

Click on “Restart Now”.

user-35|300

Once on the login screen. Click on “Other user”. Enter the login name and password of the AD user that will use this device and press Enter.

Now we are logged into the system as the AD user. To confirm this we can open PowerShell and run whoami.

user-37|540

Windows 10 Enterprise VM2 Setup

Follow the same steps as above to configure the VM for the second user.

user-46|540
user-1|540
user-2|540
user-4|540
user-5|540
user-6|540
user-7|540
user-10|540

Use the First Name of the second user that was configured in AD.

user-38|540
user-12|540
user-13|540
user-14|540
user-15|540
user-16|540
user-17|500
user-18|380
user-19|540
user-20|400
user-22|400
user-23|400
user-39|540
user-25|400
user-26|500
user-27|540
user-28|360
user-40|360
user-44|360
user-41|360
user-32|300
user-33|260
user-34|300
user-35|300

Login using the AD credentials of the second AD user.

user-43|540

Appendix

With this, we have completed the setup of the Active Directory lab. To wrap up, in this module we set up 3 VMs. The 1st VM (Windows Server 2019) was configured to be the Domain Controller and the other 2 VMs (Windows 10 Enterprise) were configured as client devices. Additionally, on the DC VM, we enabled DHCP, set up DNS Forwarder, enabled AD Certificate Services and configured Policies to be applied to all devices that are part of the AD environment.

You can delete the Windows Server 2019 ISO file if you do not want to store it for future use. Do not delete the Windows 10 Enterprise ISO just yet as we will require it to setup FlareVM.

To verify that the client VMs are indeed connected to the AD environment you can open DHCP Manager and compare the IP address shown with the IP address that has been assigned to the VM.

misc-1|600

Similarly, we can use DNS Manager to confirm that new DNS entries have been added for the client devices.

misc-2|600

Snapshots can be taken with the VM in a running state but sometimes doing so can cause the VM to behave erratically. So I recommend “Powering off” all the VM before taking its Snapshot.

Select the Windows Server 2019 VM. Click on the “Hamburger menu” and select Snapshots from the dropdown menu.

misc-3|540

Click on Take from the toolbar.

misc-8|540

Give the snapshot a descriptive name and click on OK.

misc-4|400

This will create a new Snapshot from the VM.

misc-5|540

Select the Windows 10 Enterprise VM1 from the sidebar and follow the above steps to create a Snapshot.

misc-6|540

Follow the same steps to create Snapshot for Windows 10 Enterprise VM2.

misc-7|540

Right-click on the hamburger menu and select “Details” to return to the VM configuration page.

Many other features and services can enabled on the DC. Refer to the below links for variations on the installation process.

There any numerous attacks that can be performed against an AD environment. Refer to the below links to see some of the commonly used hacks.

In the next module, we will begin the setup of the Malware Analysis Lab.

If you liked what you just read consider:

  • Clapping for the article (can clap up to 50 times)
  • Drop a comment showing your support
  • Sharing the article with others who will find it useful
  • Follow me on Medium, LinkedIn and GitHub
  • View my posts on Source Code

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Published in InfoSec Write-ups

A collection of write-ups from the best hackers in the world on topics ranging from bug bounties and CTFs to vulnhub machines, hardware challenges and real life encounters. Subscribe to our weekly newsletter for the coolest infosec updates: https://weekly.infosecwriteups.com/

Written by David Varghese

Cybersecurity Student | Digital Forensics | Security Analyst | Software Engineering | davidvarghese.net