Post

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

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

Domain Configuration

Certificate Service Installation

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

dc-28

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

dc-107

Click on Add Features.

dc-108

Click on Next to continue.

dc-109

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

dc-110

Click on Install to start the setup.

dc-111

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

Click on Continue to restart the system.

dc-120

Certificate Service Configuration

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

Click on Next.

dc-113

Enable “Certification Authority” and click on Next.

dc-114

Click on Next.

dc-115

Click on Next.

dc-116

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

dc-117

Click on Close.

dc-118

User Configuration

AD Admin Setup

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

dc-64

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

dc-65

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

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

dc-67

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

dc-68

Go to Members -> Add.

dc-69

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

dc-70

Click on OK.

dc-71

Click on Apply then OK to persist the changes.

dc-72

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

dc-73

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

dc-74

AD User 1 Setup

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

dc-75

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

dc-76

Enter the details for the user.

dc-77

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

dc-78

AD User 2 Setup

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

dc-76

dc-79

dc-80

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

Running Vulnerable AD Script

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

dc-91

Run the following command:

1
2
# Allow Execution of Scripts
Set-ExecutionPolicy -ExecutionPolicy Bypass -Force

dc-121

1
2
# 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

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

dc-123

Group Policy Configuration

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

dc-81

Expand “Forest” and then expand “Domains”.

dc-102

Disable Windows Defender and Firewall

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

dc-82

Give the GPO the name Disable Protections.

dc-83

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

dc-84

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

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

dc-86

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

dc-87

Double-click on Real-time Protection.

dc-104

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

dc-105

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

dc-106

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

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

dc-89

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

dc-90

Enable Remote Login for Local Admins

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

dc-124

Give the GPO the name Local Admin Remote Login.

dc-125

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

dc-126

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

dc-127

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

dc-128

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

dc-129

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

Enable WinRM Server

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

dc-124

Give the GPO the name Enable WinRM Server.

dc-131

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

dc-132

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

dc-133

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

dc-134

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

dc-135

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

dc-136

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

dc-137

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

dc-138

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

dc-139

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

dc-140

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

dc-141

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

dc-142

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

dc-143

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

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

dc-145

Enable RDP (Remote Desktop Protocol)

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

dc-124

Give the GPO the name Enable RDP.

dc-146

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

dc-147

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

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

dc-149

Enable RPC (Remote Procedure Call)

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

dc-124

Give the GPO the name Enable RPC.

dc-150

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

dc-151

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

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

dc-153

Enforce the Domain Policies

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

dc-91

In the terminal enter the following:

1
gpupdate /force

dc-92

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

OS Installation

Click on Next.

user-1

Click on Install now.

user-2

Accept the agreement and then click on Next.

user-3

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

user-4

Select Disk 0 and then click on Next.

user-5

The VM will reboot multiple times during the installation.

user-6

Select your Region and Keyboard Layout.

user-7

user-8

Click on Skip.

user-9

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

user-10

Enter a username and click on Next.

user-11

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

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

user-13

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

user-14

Select Not now.

user-15

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

user-16

Guest Additions Installation

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

Click on Devices -> Insert Guest Additions CD image.

user-18

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

user-19

Click Next.

user-20

Click Next.

user-21

Click on Install to start the installation.

user-22

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

user-23

Login into the system.

user-24

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

user-25

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.

Adding VM1 to Domain

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

Click on Advanced system settings.

user-27

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

user-28

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

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

user-30

Click on OK.

user-31

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

user-32

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

user-33

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

user-34

Click on “Restart Now”.

user-35

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.

user-36

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

user-37

Windows 10 Enterprise VM2 Setup

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

user-46

OS Installation

user-1

user-2

user-4

user-5

user-6

user-7

user-10

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

user-38

user-12

user-13

user-14

user-15

user-16

Guest Additions Installation

user-17

user-18

user-19

user-20

user-22

user-23

user-39

user-25

Adding VM2 to Domain

user-26

user-27

user-28

user-40

user-44

user-41

user-32

user-33

user-34

user-35

Login using the AD credentials of the second AD user.

user-42

user-43

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.

DNS & DHCP Verification

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

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

misc-2

Taking VM Snapshots

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

Click on Take from the toolbar.

misc-8

Give the snapshot a descriptive name and click on OK.

misc-4

This will create a new Snapshot from the VM.

misc-5

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

misc-6

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

misc-7

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

Alternative AD Setup

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

Hacking AD Lab

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.

Part 7 - Malware Analysis Lab Setup

This post is licensed under CC BY 4.0 by the author.