The Hacker Recipes
GitHubTwitterExegolTools
  • Introduction
  • Active Directory
    • Reconnaissance
      • DHCP
      • DNS
      • NBT-NS
      • Responder ⚙️
      • Port scanning
      • LDAP
      • BloodHound ⚙️
      • MS-RPC
      • enum4linux ⚙️
      • Password policy
    • Movement
      • Credentials
        • Dumping
          • SAM & LSA secrets
          • DPAPI secrets
          • NTDS secrets
          • LSASS secrets
          • DCSync
          • Group Policy Preferences
          • Network shares
          • Network protocols
          • Web browsers
          • In-memory secrets
          • Kerberos key list
          • 🛠️Cached Kerberos tickets
          • 🛠️Windows Credential Manager
          • 🛠️Local files
          • 🛠️Password managers
        • Cracking
        • Bruteforcing
          • Guessing
          • Spraying
          • Stuffing
        • Shuffling
        • Impersonation
      • MITM and coerced auths
        • ARP poisoning
        • DNS spoofing
        • DHCP poisoning
        • DHCPv6 spoofing
        • WSUS spoofing
        • LLMNR, NBT-NS, mDNS spoofing
        • ADIDNS poisoning
        • WPAD spoofing
        • MS-EFSR abuse (PetitPotam)
        • MS-RPRN abuse (PrinterBug)
        • MS-FSRVP abuse (ShadowCoerce)
        • MS-DFSNM abuse (DFSCoerce)
        • PushSubscription abuse
        • WebClient abuse (WebDAV)
        • 🛠️NBT Name Overwrite
        • 🛠️ICMP Redirect
        • 🛠️Living off the land
      • NTLM
        • Capture
        • Relay
        • Pass the hash
      • Kerberos
        • Pre-auth bruteforce
        • Pass the key
        • Overpass the hash
        • Pass the ticket
        • Pass the cache
        • Forged tickets
          • Silver tickets
          • Golden tickets
          • Diamond tickets
          • Sapphire tickets
          • RODC Golden tickets
          • MS14-068
        • ASREQroast
        • ASREProast
        • Kerberoast
        • Delegations
          • (KUD) Unconstrained
          • (KCD) Constrained
          • (RBCD) Resource-based constrained
          • S4U2self abuse
          • Bronze Bit
        • Shadow Credentials
        • UnPAC the hash
        • Pass the Certificate
        • sAMAccountName spoofing
        • SPN-jacking
      • DACL abuse
        • AddMember
        • ForceChangePassword
        • Targeted Kerberoasting
        • ReadLAPSPassword
        • ReadGMSAPassword
        • Grant ownership
        • Grant rights
        • Logon script
        • Rights on RODC object
      • Group policies
      • Trusts
      • Netlogon
        • ZeroLogon
      • Certificate Services (AD-CS)
        • Certificate templates
        • Certificate authority
        • Access controls
        • Unsigned endpoints
        • Certifried
      • SCCM / MECM
        • Privilege escalation
        • Post-exploitation
      • Exchange services
        • 🛠️PrivExchange
        • 🛠️ProxyLogon
        • 🛠️ProxyShell
      • Print Spooler Service
        • PrinterBug
        • PrintNightmare
      • Schannel
        • Pass the Certificate
      • Built-ins & settings
        • Security groups
        • MachineAccountQuota
        • Pre-Windows 2000 computers
        • RODC
    • Persistence
      • DC Shadow
      • SID History
      • Skeleton key
      • GoldenGMSA
      • AdminSDHolder
      • Kerberos
        • Forged tickets
        • Delegation to KRBTGT
      • Certificate Services (AD-CS)
        • Certificate authority
        • Access controls
        • Golden certificate
      • 🛠️DACL abuse
      • Shadow Principals (PAM)
  • Web services
    • Reconnaissance
      • HTTP response headers
      • Comments and metadata
      • Error messages
      • Site crawling
      • Directory fuzzing
      • Subdomains enumeration
      • Subdomain & vhost fuzzing
      • Web Application Firewall (WAF)
      • Content Management System (CMS)
      • Other technologies
      • Known vulnerabilities
    • Configuration
      • Default credentials
      • HTTP methods
      • HTTP security headers
        • Clickjacking
        • MIME type sniffing
        • 🛠️CORS (Cross-Origin Resource Sharing)
        • 🛠️CSP (Content Security Policy)
      • HTTP request smuggling
      • HTTP response splitting
      • Insecure Cookies
      • Denial of Service (DoS)
      • Identity and Access Management
        • 🛠️OAuth 2.0
    • Accounts and sessions
      • Security policies
      • Password change
      • 🛠️Password reset
      • Account creation
      • 🛠️Account deletion
      • 🛠️Logging in
    • User inputs
      • File inclusion
        • LFI to RCE
          • logs poisoning
          • phpinfo
          • file upload
          • PHP wrappers and streams
          • PHP session
          • /proc
        • RFI to RCE
      • Unrestricted file upload
      • SQL injection
      • XSS (Cross-Site Scripting)
      • CSRF (Cross-Site Request Forgery)
      • SSRF (Server-Side Request Forgery)
      • IDOR (Insecure Direct Object Reference)
      • ORED Open redirect
      • Content-Type juggling
      • XXE injection
      • Insecure JSON Web Tokens
      • 🛠️HTTP parameter pollution
      • 🛠️SSTI (Server-Side Template Injection)
      • 🛠️Insecure deserialization
      • 🛠️CRLF injection
      • 🛠️Arbitrary file download
      • 🛠️Directory traversal
      • 🛠️Null-byte injection
  • Systems & services
    • Reconnaissance
      • 🛠️Hosts discovery
      • Port scanning
    • Initial access (protocols)
      • 🛠️FTP
      • 🛠️SSH
      • 🛠️Telnet
      • 🛠️DNS
      • 🛠️HTTP
      • 🛠️Kerberos
      • 🛠️LDAP
      • 🛠️SMB
      • 🛠️RTSP
      • 🛠️MSSQL
      • 🛠️NFS
      • 🛠️MySQL
      • 🛠️RDP
      • 🛠️WinRM
    • Initial access (phishing)
    • Privilege escalation
      • Windows
        • 🛠️Credential dumping
        • 🛠️Unquoted path
        • 🛠️Scheduled tasks
        • 🛠️Weak service permissions
        • 🛠️Vulnerable drivers
        • 🛠️Account privileges
        • 🛠️Kernel exploitation
        • 🛠️Windows Subsystem for Linux
        • 🛠️Runas saved creds
        • Unattend files
        • 🛠️Network secrets
        • 🛠️Living off the land
      • UNIX-like
        • SUDO
        • SUID/SGID binaries
        • 🛠️Capabilities
        • 🛠️Network secrets
        • 🛠️Living off the land
    • Pivoting
      • 🛠️Port forwarding
      • 🛠️SOCKS proxy
  • Evasion
    • (AV) Anti-Virus
      • 🛠️Loader
      • 🛠️Dropper
      • 🛠️Obfuscation
      • 🛠️Process injection
      • 🛠️Stealth with C2
    • 🛠️(EDR) Endpoint Detection and Response
  • 🛠️Physical
    • Locks
    • Networking
      • Network Access Control
    • Machines
      • HID injection
      • Keylogging
      • BIOS security
      • Encryption
      • Airstrike attack
    • Super secret zones
      • 🍌Banana & chocolate cake
      • 🍳Omelette du fromage
      • 🍔Burger du seigneur
      • 🥞The Pancakes of Heaven
  • 🛠️Intelligence gathering
    • CYBINT
      • Emails
      • Web infrastructure
    • OSINT
    • GEOINT
  • 🛠️RADIO
    • RFID
      • Mifare Classic
        • Default keys
        • Darkside
        • Nested
    • Bluetooth
    • Wi-Fi
      • 🛠️WEP
      • 🛠️WPA2
      • 🛠️WPS
    • Wireless keyboard/mouse
  • 🛠️mobile apps
    • Android
      • Android Debug Bridge ⚙️
      • APK transform
      • Magisk
    • iOS
      • Certificate pinning
Powered by GitBook
On this page
  • Theory
  • Practice
  • Escalation techniques
  • Terminology
  • Recon
  • Abuse
  • Resources

Was this helpful?

  1. Active Directory
  2. Movement

Certificate Services (AD-CS)

PreviousZeroLogonNextCertificate templates

Last updated 12 months ago

Was this helpful?

Theory

AD CS is Microsoft’s PKI implementation that provides everything from encrypting file systems, to digital signatures, to user authentication (a large focus of our research), and more. While AD CS is not installed by default for Active Directory environments, from our experience in enterprise environments it is widely deployed, and the security ramifications of misconfigured certificate service instances are enormous. ()

In , and shared their research on AD CS and identified multiple theft, escalation and persistence vectors.

  • Credential theft (dubbed THEFT1 to THEFT5)

  • Account persistence (dubbed PERSIST1 to PERSIST3)

  • Domain escalation (dubbed ESC1 to ESC14)

    • based on

    • based on

    • related to access control vulnerabilities

    • based on an NTLM relay vulnerability related to the

  • Domain persistence (dubbed DPERSIST1 to DPERSIST3)

    • by

    • by trusting rogue CA certificates

    • by

Practice

Escalation techniques

Certifried

Terminology

  • PKI (Public Key Infrastructure) — a system to manage certificates/public key encryption

  • AD CS (Active Directory Certificate Services) — Microsoft’s PKI implementation

  • CA (Certificate Authority) — PKI server that issues certificates

  • Enterprise CA — CA integrated with AD (as opposed to a standalone CA), offers certificate templates

  • Certificate Template — a collection of settings and policies that defines the contents of a certificate issued by an enterprise CA

  • CSR (Certificate Signing Request) — a message sent to a CA to request a signed certificate

  • EKU (Extended/Enhanced Key Usage) — one or more object identifiers (OIDs) that define how a certificate can be used

Recon

While AD CS offers attackers a wide range of exploitation and persistence scenarios, this set of services is not always installed, and when it is, it is a requirement to identify its different parts in the domain.

Cert Publishers

An initial indicator is the "Cert Publishers" built-in group whose members usually are the servers where AD CS is installed (i.e. PKI/CA).

  • From UNIX-like systems: rpc net group members "Cert Publishers" -U "DOMAIN"/"User"%"Password" -S "DomainController"

  • From Windows systems: net group "Cert Publishers" /domain

pKIEnrollmentService objects

Alternatively, information like the PKI's CA and DNS names can be gathered through LDAP.

netexec ldap 'domaincontroller' -d 'domain' -u 'user' -p 'password' -M adcs
windapsearch -m custom --filter '(objectCategory=pKIEnrollmentService)' --base 'CN=Configuration,DC=domain,DC=local' --attrs dn,dnshostname --dc 'domaincontroller' -d 'domain.local' -u 'user' -p 'password'
ntlmrelayx -t "ldap://domaincontroller" --dump-adcs

Attack paths

# enumerate and save text, json and bloodhound (original) outputs
certipy find -u 'user@domain.local' -p 'password' -dc-ip 'DC_IP' -old-bloodhound

# quickly spot vulnerable elements
certipy find -u 'user@domain.local' -p 'password' -dc-ip 'DC_IP' -vulnerable -stdout

The tool also supports multiple output types (text, json, stdout).

By default, Certipy uses LDAPS, which is not always supported by the domain controllers. The -scheme flag can be used to set whether to use LDAP or LDAPS.

Certify.exe cas

Abuse

The different domain escalation scenarios are detailed in the following parts.

Techniques dubbed ESC1 to ESC3, ESC9, ESC10, ESC13 and ESC14

Techniques dubbed ESC6 and ESC12

Techniques dubbed ESC4, ESC5 & ESC7

Technique dubbed ESC8, ESC11

Resources

()

's module (Python) can be used to find PKI enrollment services in AD.

(Python) can be used to manually to the LDAP query.

With 's (Python), thanks to (), it is possible to gather information regarding ADCS like the name and host of the CA, the certificate templates enrollment rights for those allowing client authentication and not requiring manager approval, etc. With ntlmrelayx, these information can be gathered through a relayed LDAP session.

(Python) and (C#) can also identify the PKI enrollment services and potential attack paths.

From UNIX-like systems, the (Python) tool can be used to operate multiple attacks and enumeration operations.

Certipy also supports BloodHound. With the -old-bloodhound option, the data will be exported for the original version of . With the -bloodhound option, the data will be exported for the modified version of BloodHound, by Certipy's (default output when no flag is set).

From Windows systems, the (C#) tool can be used to operate multiple attacks and enumeration operations.

specterops.io
netexec
adcs
windapsearch
Impacket
ntlmrelayx
SAERXCIT
PR#1214
Certipy
Certify
Certipy
BloodHound
forked
author
Certify
Certificate templates
Certificate authority
Unsigned endpoints
specterops.io
their research papers
Will Schroeder
Lee Christensen
misconfigured certificate templates
dangerous CA configuration
web and RPC endpoints of AD CS
maliciously creating vulnerable access controls
https://posts.specterops.io/certified-pre-owned-d95910965cd2posts.specterops.io
Microsoft ADCS – Abusing PKI in Active Directory Environment - RiskInsightRiskInsight
Web endpoint (ESC8)
RPC endpoint (ESC11)
AD CS - What Can Be Misconfigured? - HTTP418 InfoSecHTTP418 InfoSec
Logo
AD CS - The 'Certified Pre-Owned' Attacks - HTTP418 InfoSecHTTP418 InfoSec
Logo
Certipy 2.0: BloodHound, New Escalations, Shadow Credentials, Golden Certificates, and more!Medium
Logo
Logo
Template allows SAN (ESC1)
Any purpose EKU (ESC2)
Certificate Agent EKU (ESC3)
No security extension (ESC9)
Weak certificate mapping (ESC10)
Issuance policiy with privileged group linked (ESC13)
Weak explicit mapping (ESC14)
EDITF_ATTRIBUTESUBJECTALTNAME2 (ESC6)
Shell access to ADCS CA with YubiHSM (ESC12)
forging certificates with a stolen CA certificates