What is AD CS?
Active Directory Certificate Services, also known as AD CS, is an Active Directory tool for letting administrators issue and manage public key certificates that can be used to connect to various services and principals on the domain. It is often used to provide certificates that can be used in place of credentials for logging into a network, or to provide certificates that can be used to sign and verify the authenticity of data.
The main guarantees that AD CS aims to provide are:
- Confidentiality via encryption
- Integrity via digital signatures
- Authentication by associating certificate keys with computers, users, or device accounts on a computer network.
Given that AD CS often holds highly sensitive keys and access credentials for a corporate network, this makes it a prime target for attackers.
Required Ports for AD CS
Active Directory requires the following TCP ports be open on all domain controllers, which heavily overlaps with the ports required for AD CS:
- TCP/UDP port 53: DNS
- TCP/UDP port 88: Kerberos authentication
- TCP/UDP port 135: RPC
- TCP/UDP port 137-138: NetBIOS
- TCP/UDP port 389: LDAP
- TCP/UDP port 445: SMB
- TCP/UDP port 464: Kerberos password change
- TCP/UDP port 636: LDAP SSL
- TCP/UDP port 3268-3269: Global catalog
AD CS additionally has the following requirements for Certificate Authorities:
- TCP random port above 1023: RPC dynamic port allocation
The following ports are optional depending on services used, and tend to apply to Certificate Enrollment Web Services:
- TCP port 80: HTTP
- TCP port 443: HTTPS
- TCP port 445: SMB
If using Active Directory Federation Services (ADFS) for single sign on the following ports are also required:
- TCP port 80: HTTP
- TCP port 443: HTTPS
- TCP port 49443: ADFS
Core Concepts
Microsoft provides a very useful training module that covers the fundamentals of AD CS and as well as examples which cover the management of certificate enrollment, certificate revocation and certificate trusts.
Setting up A Vulnerable AD CS Server
The following steps assume that you have installed an AD CS on either a new or existing domain controller.
Installing AD CS
- Open the Server Manager
- Select Add roles and features
- Select “Active Directory Certificate Services” under the “Server Roles” section
- When prompted add all of the features and management tools
- On the AD CS “Role Services” tab, leave the default selection of only “Certificate Authority”
- Completion the installation and reboot the server
- Reopen the Server Manager
- Go to the AD CS tab and where it says “Configuration Required”, hit “More” then “Configure Active Directory Certificate…”
- Select “Certificate Authority” in the Role Services tab
- Select “Enterprise CA” in the “Setup Type” tab (the user must be a Domain Administrator for this option to be available)
- Keep all of the default settings, noting the value of the “Common name for this CA” on the “CA Name” tab (this value corresponds to the
CA
datastore option) - Accept the rest of the default settings and complete the configuration
Setting up a ESC1 Vulnerable Certificate Template
- Open up the run prompt and type in
certsrv
. - In the window that appears you should see your list of certification authorities under
Certification Authority (Local)
. Right click on the folder in the drop down markedCertificate Templates
and then clickManage
. - Scroll down to the
User
certificate. Right click on it and selectDuplicate Template
. - From here you can refer to the following Active-Directory-Certificate-Services-abuse documentation for screenshots.
- Select the
General
tab and rename this to something meaningful likeESC1-Template
, then click theApply
button. - In the
Subject Name
tab, selectSupply in the request
and clickOk
on the security warning that appears. Then click theApply
button. - Scroll to the
Extensions
tab and underApplication Policies
ensure thatClient Authentication
,Server Authentication
,KDC Authentication
, orSmart Card Logon
is listed. Then click theApply
button. - Under the
Security
tab make sure thatDomain Users
group listed and theEnroll
permissions is marked as allowed for this group. - Under
Issuance Requirements
tab, ensure that underRequire the following for enrollment
that theCA certificate manager approval
box is unticked, as is theThis number of authorized signatures
box. - Click
Apply
and thenOk
- Go back to the
certsrv
screen and right click on theCertificate Templates
folder. Then clickNew
followed byCertificate Template to Issue
. - Scroll down and select the
ESC1-Template
certificate, or whatever you named the ESC1 template you created, and selectOK
. The certificate should now be available to be issued by the CA server.
Setting up a ESC2 Vulnerable Certificate Template
- Open up
certsrv
- Scroll down to
Certificate Templates
folder, right click on it and selectManage
. - Find the
ESC1
certificate template you created earlier and right click on that, then selectDuplicate Template
. - Select the
General
tab, and then name the templateESC2-Template
. Then clickApply
. - Go to the
Subject Name
tab and selectBuild from this Active Directory Information
and selectFully distinguished name
under theSubject Name Format
. The main idea of setting this option is to prevent being able to supply the subject name in the request as this is more what makes the certificate vulnerable to ESC1. The specific options here I don’t think will matter so much so long as theSupply in the request
option isn’t ticked. Then clickApply
. - Go the to
Extensions
tab and click onApplication Policies
. Then click onEdit
. - Delete all the existing application policies by clicking on them one by one and clicking the
Remove
button. - Click the
Add
button and selectAny Purpose
from the list that appears. Then click theOK
button. - Click the
Apply
button, and thenOK
. The certificate should now be created. - Go back to the
certsrv
screen and right click on theCertificate Templates
folder. Then clickNew
followed byCertificate Template to Issue
. - Scroll down and select the
ESC2-Template
certificate, or whatever you named the ESC2 template you created, and selectOK
. The certificate should now be available to be issued by the CA server.
Setting up a ESC3 Template 1 Vulnerable Certificate Template
- Follow the instructions above to duplicate the ESC2 template and name it
ESC3-Template1
, then clickApply
. - Go to the
Extensions
tab, click the Application Policies entry, click theEdit
button, and remove theAny Purpose
policy and replace it withCertificate Request Agent
, then clickOK
. - Click
Apply
. - Go to
Issuance Requirements
tab and double check that bothCA certificate manager approval
andThis number of authorized signatures
are unchecked. - Click
Apply
if any changes were made or the button is not grey’d out, then clickOK
to create the certificate. - Go back to the
certsrv
screen and right click on theCertificate Templates
folder. Then clickNew
followed byCertificate Template to Issue
. - Scroll down and select the
ESC3-Template1
certificate, or whatever you named the ESC3 template number 1 template you just created, and selectOK
. The certificate should now be available to be issued by the CA server.
Setting up a ESC3 Template 2 Vulnerable Certificate Template
- Follow the instructions above to duplicate the ESC2 template and name it
ESC3-Template2
, then clickApply
. - Go to the
Extensions
tab, click the Application Policies entry, click theEdit
button, and remove theAny Purpose
policy and replace it withClient Authentication
, then clickOK
. - Click
Apply
. - Go to
Issuance Requirements
tab and double check that bothCA certificate manager approval
is unchecked. - Check the
This number of authorized signatures
checkbox and ensure the value specified is 1, and that thePolicy type required in signature
is set toApplication Policy
, and that theApplication policy
value isCertificate Request Agent
. - Click
Apply
and then clickOK
to issue the certificate. - Go back to the
certsrv
screen and right click on theCertificate Templates
folder. Then clickNew
followed byCertificate Template to Issue
. - Scroll down and select the
ESC3-Template2
certificate, or whatever you named the ESC3 template number 2 template you just created, and selectOK
. The certificate should now be available to be issued by the CA server.
Setting up a ESC8 Vulnerable Host
- Follow instructions for creating an AD CS enabled server
- Select Add Roles and Features
- Under “Select Server Roles” expand Active Directory Certificate Services and add
Certificate Enrollment Policy Web Service
,Certificate Enrollment Web Service
, andCertificate Authority Web Enrollment
. - For each selection, accept the default for any pop-up.
- Accept the default features and install.
- When the installation is complete, click on the warning in the Dashboard for post-deployment configuration.
- Under Credentials, accept the default
- Under Role Services, select
Certificate Authority Web Enrollment
,Certificate Enrollment Web Service
, andCertificate Enrollment Policy Web Service
- In CA for CES, accept the defaults
- In Authentication Types, accept the default integrated authentication
- In Service account for CES, select
Use built-in application pool identity
- Accept default integrated authentication for CEP
- Select the domain certificate in Server Certificate (the one that starts with the domain name by default) if more than one appears.
- Accept the remaining defaults.