0xc4t Notes

Web Security & Active Directory Security


ESC2 ADCS Misconfigurations exploitation — Active Directory Pentesting

ESC2 (Escalation Path 2) is a vulnerability in Active Directory Certificate Services where a certificate template allows low-privileged users to enroll and include dangerous Extended Key Usages (EKUs)

Examples include the following:

This attack abuses a misconfiguration in the Extended Key Usages (EKUs) of certificate templates — specifically templates that allow “Client Authentication” or “Any Purpose” — and together this enables Kerberos authentication via PKINIT.

For enumeration and exploitation we can use built-in Kali Linux tools:

Evil-WinRM, Impacket, Certipy-AD, Metasploit ESC2 does not require password cracking or stealing password hashes, nor brute force; an attacker can easily enroll a certificate and log in without going through MFA or the domain’s password complexity policies.

ESC2 also does not require a high-privilege account — because the certificate template is misconfigured with access for Authenticated Users or “Any Purpose”, a normal domain user account is sufficient; an attacker can exploit this misconfiguration.

Lab setup To create an ESC2 lab, we need a Primary Domain Controller, so a child Domain Controller will not work. and make sure you have installed Active Directory Certificate Services (ADCS).

alt text

Open the Certificate Template Console by pressing WIN + R certtmpl.msc and right-click on the template named “Code Signing,” then duplicate the template and select the General tab. Name the new template, for example, “ESC2.”


alt text

alt text

alt text

Select the Extensions tab, then Application Policies -> Edit, select Code Signing and remove it, then add Any Purpose and click OK.


alt text

alt text

alt text

Open the Security tab, click Add -> Domain User and OK. Select the domain user and grant Enroll permission.


alt text

alt text

After configuration, we must first enable the Certificate Template that we just created in the “Certification Authority.” Follow these steps!


alt text

alt text

alt text

And we successfully created a Certificate template that is vulnerable to ESC2! Let’s try to exploit this misconfiguration.


Enumeration and Exploitation

Certipy is one of the tools that can be used for enumeration on ADCS to find vulnerable certificate templates.

To perform enumeration or identify vulnerable templates, we must obtain a domain user account through any initial access technique, as long as there are valid credentials to log in as a Domain User.

certipy-ad find -u 'elena.doe@sandbox.local' -p P@ssw0rd -dc-ip 10.100.150.10 -vulnerable -enabled

alt text

alt text

alt text

Request Certificate for Administrator

certipy-ad req -u 'elena.doe@sandbox.local' -p 'P@ssw0rd' -dc-ip 10.100.150.10 -ca sandbox-DC01-CA -target 'sandbox.local' -template 'ESC2'

alt text

If successful, we will obtain an Administrator Certificate without credentials.

alt text

Use the certificate from the administrator to dump NTLM hashes from the DC or Domain Controller.

alt text

We successfully obtained the NTLM hash from the administrator and can use it for Pass The Hash to services on the Domain Controller such as winrm, rdp, samba, and other services.

Thank you for reading from start to finish. That concludes this article. Love you all!

Reference