Practice library / Active Directory and Windows attacks
Lab · Hard · 2.5 hoursFree account
AD Certificate Services (ADCS) Attacks
Find a vulnerable certificate template with Certipy, exploit ESC1 to impersonate a Domain Admin, and map the detection a defender sees.
On this page 15 sections
- ·Overview
- ·Prerequisites
- ·Lab setup
- ·Build the target
- 1Confirm your foothold credential
- 2Enumerate the CA and its templates
- Locked: Find the vulnerable templates
- Locked: Request a certificate as the Domain Admin
- Locked: Authenticate with the certificate
- Locked: Read the ESC8 relay path
- Locked: Understand certificate persistence
- Locked: Confirm the misconfiguration is fixed
- Locked: Check
- Locked: Clean-up
- Locked: Command reference
Active Directory Certificate Services issues the certificates that authenticate accounts in a domain, so a certificate for a Domain Admin is a login as that Domain Admin. One vulnerable template lets a normal user request a certificate for any account, and SpecterOps catalogued these flaws as ESC1 through ESC8. The exercises here enumerate a lab CA with Certipy, exploit ESC1 end to end, and map each step to the Windows CA audit events a defender uses.
Lab Objectives
- Enumerate an Enterprise CA and its certificate templates with Certipy
- Read a Certipy
-vulnerablereport and name the ESC class each finding belongs to - Exploit an ESC1 template to request a certificate for an account you do not control
- Turn that certificate into a TGT and an NT hash with PKINIT authentication
- Explain how ESC8 relays a machine account to the CA's web enrollment endpoint
- Map each step to the Windows CA audit events a defender uses to detect it
Overview
Active Directory Certificate Services (ADCS) is the Microsoft Public Key Infrastructure (PKI) that issues certificates inside a domain. A certificate authenticates an account the same way a password does. So a certificate that names a Domain Admin, signed by a trusted Enterprise CA, is a login as that Domain Admin.
The problem is the templates. A certificate template is a mould that decides who can enrol and what the issued certificate can say. A handful of template settings, combined, let a normal user request a certificate that names any account they choose. SpecterOps catalogued these as ESC1 through ESC8 (and later ESC9+). This lab works the most common one, ESC1, end to end, then reads ESC8, and finishes on detection.
Prerequisites
- Finish Active Directory Fundamentals first. This lab assumes you know a Domain Controller, Kerberos, an NT hash and a TGT (Ticket Granting Ticket), and goes straight to abusing the PKI that sits on top of them.
- AD Enumeration with CrackMapExec teaches the credential check this lab opens with.
- AD Enumeration with BloodHound is useful: Certipy can output a BloodHound-ingestible zip, and the certificate edges then appear in the same graph.
- Kerberos Attacks and NTLM Relay Attacks pair with this lab. The certificate you mint here becomes a Kerberos TGT; ESC8 is an NTLM relay with the CA as its target.
Lab setup
| Item | Purpose |
|---|---|
certipy-ad (v4.8 or later) | Enumerates ADCS, requests certificates and runs PKINIT authentication. Install with pipx install certipy-ad |
crackmapexec | Confirms the foothold credential works before you spend any effort on it |
impacket | Provides the Kerberos and secrets-dump tooling Certipy builds on |
| A Linux attack box | Kali, with network reach to the lab domain |
Build the target
KaliRange hosts no targets, no virtual machines and no lab files. You run this lab on your own machine, against a domain that you build. The names and 10.10.20.x addresses below are the example addresses of this lab. Replace them with the addresses of your own domain.
Your lab domain must have these parts:
| Host | Role |
|---|---|
DC01 (10.10.20.10) | Domain Controller of CORP.LOCAL, Windows Server 2022, SMB signing required |
CA01 (10.10.20.15) | Domain-joined Enterprise CA named CORP-CA01-CA, with web enrollment (/certsrv/) enabled |
| Your Kali machine | The attack box, with network access to both hosts |
- The foothold account
j.doe@CORP.LOCALwith the passwordStr0ngPass!99: a plain domain user with no admin rights. It stands in for credentials that an earlier phase already got. Use your own password and put it in the commands. - A certificate template
UserEnroll, published onCORP-CA01-CAand set up like this:Domain Userscan enrol, the enrollee supplies the subject, client authentication is allowed, manager approval is off and no authorized signatures are required (Steps 2 to 4). This is a deliberately vulnerable template. Create it only in your own lab. - The
administratoraccount inCORP.LOCAL, so that the certificate of Step 4 can name it. - For Step 8, the ability to edit the template yourself: clear "Supply in the request" on its subject-name tab.
Build such a domain from free, legal parts. Install an evaluation copy of Windows Server from the Microsoft Evaluation Center (180 days) in virtual machines on your own computer, promote one to a domain controller, join the other and add the Active Directory Certificate Services role to it. Or start from GOAD ("Game of Active Directory"), a deliberately vulnerable Active Directory lab that Orange Cyberdefense publishes on GitHub. Isolate it from the internet. Its names differ from CORP.LOCAL, so change the names in the commands. Take a snapshot of each virtual machine before Step 1.
Authorized-lab only. Run every command in this lab against 10.10.20.10 and 10.10.20.15, only against a domain that you own or have written permission to test, inside your isolated lab domain, and nowhere else. Requesting a certificate that impersonates another account on a domain you do not own is unauthorized access and forgery in most countries. Minting a Domain Admin certificate outside a lab is a real intrusion, not a test.
Step 1: Confirm your foothold credential
Test the j.doe credential against the Domain Controller
Check that the credential of your own j.doe account authenticates before you build any tooling around it. A failed enrollment is hard to read; a failed login is not.
crackmapexec smb 10.10.20.10 -u j.doe -p 'Str0ngPass!99'Example output:
SMB 10.10.20.10 445 DC01 [*] Windows Server 2022 Build 20348 x64 (name:DC01) (domain:corp.local) (signing:True) (SMBv1:False)
SMB 10.10.20.10 445 DC01 [+] corp.local\j.doe:Str0ngPass!99The [+] line confirms the password is correct and the account is not locked. You now hold a valid, low-privilege domain user. That is all an ESC1 attack needs.
What a defender would see. One SMB authentication, Event ID 4624 with logon type 3 on DC01. By itself this is routine. It becomes evidence only once the later certificate requests tie back to this same source account and IP.
Step 2: Enumerate the CA and its templates
Run certipy find to inventory the PKI
Collect every CA, every published template and every enrollment permission the domain exposes. Certipy reads this over LDAP and the certificate enrollment RPC, using the credential from Step 1.
certipy find -u 'j.doe@corp.local' -p 'Str0ngPass!99' -dc-ip 10.10.20.10 -stdoutExample output (trimmed to one CA and one template):
Certificate Authorities
0
CA Name : CORP-CA01-CA
DNS Name : CA01.corp.local
Certificate Subject : CN=CORP-CA01-CA, DC=corp, DC=local
Web Enrollment : Enabled
User Specified SAN : Disabled
Certificate Templates
12
Template Name : UserEnroll
Enabled : True
Client Authentication : True
Enrollee Supplies Subject : True
Requires Manager Approval : False
Authorized Signatures Required : 0
Enrollment Rights : CORP.LOCAL\Domain UsersCertipy writes the full result to a timestamped _Certipy.txt, a .json and a BloodHound .zip in the working directory. Enrollee Supplies Subject : True is the line that matters: it means the person asking for the certificate chooses the name on it.
What a defender would see. A burst of LDAP reads against the Public Key Services container, plus enrollment-service RPC calls, from one normal user. ADCS enumeration has no routine business reason. Event ID 4662 (object access) across PKI objects in one short window, from one account, is the signal, the same correlation pattern BloodHound collection produces.
Sign in to continue
9 more sections are for signed-in members. It is free: sign in with Google.