HackTheBoxActiveDirectoryWindowsVulnLabs

BabyTwo

Guest SMB exposes users; credential spray finds username=password accounts; write access to SYSVOL logon script delivers a shell as Amelia.Griffiths; ACL abuse resets GPOADM's password; pyGPOAbuse on

Target: 10.129.234.72 Domain: baby2.vl Difficulty: Medium Category: Active Directory / Windows


Overview

Baby2 is an Active Directory machine hosted on VulnLab. The attack path chains together several common misconfigurations: anonymous/guest SMB enumeration, username-as-password credential spraying, write access to a domain logon script, privilege escalation via ACL abuse (WriteDacl/WriteOwner), and finally full domain compromise via GPO abuse with pyGPOAbuse.


1. Reconnaissance

Nmap Port Scan

The scan reveals a standard Windows Server 2022 Domain Controller

Key findings from the scan:

  • Domain: baby2.vl

  • Hostname: dc.baby2.vl

  • OS: Windows Server 2022 Build 20348

  • SMB message signing is enabled and required (rules out relay attacks directly)


2. SMB Enumeration — Guest/Null Session

The homes share being world-writable is a notable finding worth revisiting after credential access.


3. User Enumeration via SMB

With guest/null LDAP or SMB access, a list of domain usernames was gathered, producing users.txt containing accounts such as:

  • Administrator

  • Guest

  • krbtgt

  • gpoadm

  • Joan.Jennings

  • Mohammed.Harris

  • Harry.Shaw

  • Carl.Moore

  • Ryan.Jenkins

  • Kieran.Mitchell

  • Nicola.Lamb

  • Lynda.Bailey

  • Joel.Hurst

  • Amelia.Griffiths

  • library


4. Credential Spraying — Username as Password

A common misconfiguration in AD environments is users whose password matches their username. NetExec's --no-brute flag tests each user's name as their own password without triggering lockout policies:


5. Expanding Access with Carl.Moore

Checking share permissions as Carl.Moore reveals expanded access:

The apps and docs shares are now writable. More critically, investigating SYSVOL/NETLOGON reveals a logon script (login.vbs) that is executed automatically every time a user logs in. This is the key to achieving initial code execution on the domain controller.


6. Logon Script Hijacking — Initial Foothold

Understanding the Attack Vector

The login.vbs script is stored in the SYSVOL scripts folder and mapped as the domain logon script via Group Policy. Because an automation runs this script on every user login, replacing it with a malicious version will trigger a reverse shell as the next user who authenticates.

Step 1 — Generate Encoded PowerShell Reverse Shell Payload

A standard PowerShell TCP reverse shell is base64-encoded (UTF-16LE) to avoid character escaping issues when embedded inside VBScript:

Step 2 — Craft the Malicious VBScript

The malicious login.vbs preserves the original drive mapping functionality (to avoid detection/disruption) and appends a GetShell() subroutine that launches the encoded PowerShell payload silently:

Step 3 — Deploy the Malicious Script via SMB

Connecting to the SYSVOL scripts folder using the library:library credentials (which have write access to NETLOGON), the original script is renamed and the malicious version uploaded:

Step 4 — Catch the Shell

When the next user logs in and the script executes, a reverse shell connects back:

The shell is running as Amelia.Griffiths. who has WriteDacl & WriteOwner on GPOADM user and GPO-MANAGEMENT


7. Privilege Escalation — ACL Abuse & GPO Abuse

Enumerating Privileges (BloodHound)

Running BloodHound reveals a compelling privilege chain:

and GPOADM has GenericWrite on these two Policies tho we only need Default Domain Policy to exploit

and from here we'll get its GPO-ID .

The attack path is:

  1. Abuse WriteDacl/WriteOwner on GPOADM to grant ourselves full control

  2. Reset GPOADM's password

  3. Use GPOADM's GenericAll on the Default Domain Policy GPO to inject a malicious scheduled task via pyGPOAbuse

  4. Trigger a gpupdate to execute the task as SYSTEM

Step 1 — Grant Full Control Over GPOADM

From Amelia's shell (PowerView is transferred):

This leverages the WriteDacl permission Amelia holds on GPOADM via the LEGACY group to grant herself GenericAll rights over the GPOADM account.

Step 2 — Reset GPOADM's Password

Verify the new credentials work:

Step 3 — Identify the Default Domain Policy GPO ID

From BloodHound, the Default Domain Policy object information shows:

  • Object ID: 16398B5E-3BC4-4CD2-A9CB-33B690E6A6AD

  • GPO ID (CN): 31B2F340-016D-11D2-945F-00C04FB984F9

  • Gpcpath: \BABY2.VL\SYSVOL\BABY2.VL\POLICIES\{31B2F340-016D-11D2-945F-00C04FB984F9}

  • Affected Objects: 27 (includes all domain computers and users)

This GPO applies domain-wide, making it perfect for a SYSTEM-level payload.

Step 4 — Generate Second Reverse Shell Payloa

A new encoded PowerShell payload is generated, this time calling back on port 9001:

Step 5 — Inject Malicious Scheduled Task via pyGPOAbuse

pyGPOAbuse is a Python tool that abuses GenericAll/GenericWrite rights on a GPO to inject a scheduled task that runs as SYSTEM:

Step 6 — Force GPO Update to Trigger Execution

From Amelia's existing shell, force an immediate Group Policy refresh:

Step 7 — Catch SYSTEM Shell


8. Attack Chain Summary


9. Tools Used

Tool
Purpose

nmap

Port and service enumeration

NetExec (nxc)

SMB auth, share enum, credential spraying

smbclient

SMB share interaction, file upload

BloodHound

AD privilege path analysis

PowerView

In-memory AD enumeration and ACL manipulation

pyGPOAbuse

GPO-based code execution as SYSTEM

netcat

Reverse shell listener


10. Key Takeaways & Mitigations

Finding
Mitigation

Null/guest SMB session exposes usernames

Disable null session access; restrict guest account

Username == password for multiple accounts

Enforce strong password policy; audit weak credentials with BloodHound or similar

Write access to SYSVOL logon scripts for low-priv users

Restrict SYSVOL script write access to Domain Admins only

Excessive ACLs: WriteDacl/WriteOwner on privileged accounts

Audit and remove unnecessary ACE entries; implement AD tiering

GenericAll on Default Domain Policy

Restrict GPO modification rights; monitor GPO changes via SIEM

gpupdate force-able by standard users

Consider restricting or monitoring gpupdate /force usage

Last updated