.. | ||
account-persistence.md | ||
certificate-theft.md | ||
domain-escalation.md | ||
domain-persistence.md | ||
README.md |
AD Certificates
{% hint style="success" %}
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Support HackTricks
- Check the subscription plans!
- Join the ЁЯТм Discord group or the telegram group or follow us on Twitter ЁЯРж @hacktricks_live.
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
Introduction
Components of a Certificate
- The Subject of the certificate denotes its owner.
- A Public Key is paired with a privately held key to link the certificate to its rightful owner.
- The Validity Period, defined by NotBefore and NotAfter dates, marks the certificate's effective duration.
- A unique Serial Number, provided by the Certificate Authority (CA), identifies each certificate.
- The Issuer refers to the CA that has issued the certificate.
- SubjectAlternativeName allows for additional names for the subject, enhancing identification flexibility.
- Basic Constraints identify if the certificate is for a CA or an end entity and define usage restrictions.
- Extended Key Usages (EKUs) delineate the certificate's specific purposes, like code signing or email encryption, through Object Identifiers (OIDs).
- The Signature Algorithm specifies the method for signing the certificate.
- The Signature, created with the issuer's private key, guarantees the certificate's authenticity.
Special Considerations
- Subject Alternative Names (SANs) expand a certificate's applicability to multiple identities, crucial for servers with multiple domains. Secure issuance processes are vital to avoid impersonation risks by attackers manipulating the SAN specification.
Certificate Authorities (CAs) in Active Directory (AD)
AD CS acknowledges CA certificates in an AD forest through designated containers, each serving unique roles:
- Certification Authorities container holds trusted root CA certificates.
- Enrolment Services container details Enterprise CAs and their certificate templates.
- NTAuthCertificates object includes CA certificates authorized for AD authentication.
- AIA (Authority Information Access) container facilitates certificate chain validation with intermediate and cross CA certificates.
Certificate Acquisition: Client Certificate Request Flow
- The request process begins with clients finding an Enterprise CA.
- A CSR is created, containing a public key and other details, after generating a public-private key pair.
- The CA assesses the CSR against available certificate templates, issuing the certificate based on the template's permissions.
- Upon approval, the CA signs the certificate with its private key and returns it to the client.
Certificate Templates
Defined within AD, these templates outline the settings and permissions for issuing certificates, including permitted EKUs and enrollment or modification rights, critical for managing access to certificate services.
Certificate Enrollment
The enrollment process for certificates is initiated by an administrator who creates a certificate template, which is then published by an Enterprise Certificate Authority (CA). This makes the template available for client enrollment, a step achieved by adding the template's name to the certificatetemplates
field of an Active Directory object.
For a client to request a certificate, enrollment rights must be granted. These rights are defined by security descriptors on the certificate template and the Enterprise CA itself. Permissions must be granted in both locations for a request to be successful.
Template Enrollment Rights
These rights are specified through Access Control Entries (ACEs), detailing permissions like:
- Certificate-Enrollment and Certificate-AutoEnrollment rights, each associated with specific GUIDs.
- ExtendedRights, allowing all extended permissions.
- FullControl/GenericAll, providing complete control over the template.
Enterprise CA Enrollment Rights
The CA's rights are outlined in its security descriptor, accessible via the Certificate Authority management console. Some settings even allow low-privileged users remote access, which could be a security concern.
Additional Issuance Controls
Certain controls may apply, such as:
- Manager Approval: Places requests in a pending state until approved by a certificate manager.
- Enrolment Agents and Authorized Signatures: Specify the number of required signatures on a CSR and the necessary Application Policy OIDs.
Methods to Request Certificates
Certificates can be requested through:
- Windows Client Certificate Enrollment Protocol (MS-WCCE), using DCOM interfaces.
- ICertPassage Remote Protocol (MS-ICPR), through named pipes or TCP/IP.
- The certificate enrollment web interface, with the Certificate Authority Web Enrollment role installed.
- The Certificate Enrollment Service (CES), in conjunction with the Certificate Enrollment Policy (CEP) service.
- The Network Device Enrollment Service (NDES) for network devices, using the Simple Certificate Enrollment Protocol (SCEP).
Windows users can also request certificates via the GUI (certmgr.msc
or certlm.msc
) or command-line tools (certreq.exe
or PowerShell's Get-Certificate
command).
# Example of requesting a certificate using PowerShell
Get-Certificate -Template "User" -CertStoreLocation "cert:\\CurrentUser\\My"
Certificate Authentication
Active Directory (AD) рдкреНрд░рдорд╛рдгрдкрддреНрд░ рдкреНрд░рдорд╛рдгреАрдХрд░рдг рдХрд╛ рд╕рдорд░реНрдерди рдХрд░рддрд╛ рд╣реИ, рдореБрдЦреНрдп рд░реВрдк рд╕реЗ Kerberos рдФрд░ Secure Channel (Schannel) рдкреНрд░реЛрдЯреЛрдХреЙрд▓ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рддреЗ рд╣реБрдПред
Kerberos Authentication Process
Kerberos рдкреНрд░рдорд╛рдгреАрдХрд░рдг рдкреНрд░рдХреНрд░рд┐рдпрд╛ рдореЗрдВ, рдПрдХ рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛ рдХреЗ Ticket Granting Ticket (TGT) рдХреЗ рд▓рд┐рдП рдЕрдиреБрд░реЛрдз рдХреЛ рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛ рдХреЗ рдкреНрд░рдорд╛рдгрдкрддреНрд░ рдХреА рдирд┐рдЬреА рдХреБрдВрдЬреА рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдХреЗ рд╣рд╕реНрддрд╛рдХреНрд╖рд░рд┐рдд рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред рдпрд╣ рдЕрдиреБрд░реЛрдз рдбреЛрдореЗрди рдирд┐рдпрдВрддреНрд░рдХ рджреНрд╡рд╛рд░рд╛ рдХрдИ рдорд╛рдиреНрдпрддрд╛рдУрдВ рд╕реЗ рдЧреБрдЬрд░рддрд╛ рд╣реИ, рдЬрд┐рд╕рдореЗрдВ рдкреНрд░рдорд╛рдгрдкрддреНрд░ рдХреА рд╡реИрдзрддрд╛, рдкрде, рдФрд░ рд░рджреНрджреАрдХрд░рдг рд╕реНрдерд┐рддрд┐ рд╢рд╛рдорд┐рд▓ рд╣реИрдВред рдорд╛рдиреНрдпрддрд╛рдУрдВ рдореЗрдВ рдпрд╣ рднреА рд╢рд╛рдорд┐рд▓ рд╣реИ рдХрд┐ рдкреНрд░рдорд╛рдгрдкрддреНрд░ рдПрдХ рд╡рд┐рд╢реНрд╡рд╕рдиреАрдп рд╕реНрд░реЛрдд рд╕реЗ рдЖрддрд╛ рд╣реИ рдФрд░ NTAUTH рдкреНрд░рдорд╛рдгрдкрддреНрд░ рд╕реНрдЯреЛрд░ рдореЗрдВ рдЬрд╛рд░реАрдХрд░реНрддрд╛ рдХреА рдЙрдкрд╕реНрдерд┐рддрд┐ рдХреА рдкреБрд╖реНрдЯрд┐ рдХрд░рдирд╛ред рд╕рдлрд▓ рдорд╛рдиреНрдпрддрд╛рдУрдВ рдХреЗ рдкрд░рд┐рдгрд╛рдорд╕реНрд╡рд░реВрдк рдПрдХ TGT рдЬрд╛рд░реА рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред AD рдореЗрдВ NTAuthCertificates
рдСрдмреНрдЬреЗрдХреНрдЯ, рдЬреЛ рдХрд┐:
CN=NTAuthCertificates,CN=Public Key Services,CN=Services,CN=Configuration,DC=<domain>,DC=<com>
is рдкреНрд░рдорд╛рдгрдкрддреНрд░ рдкреНрд░рдорд╛рдгреАрдХрд░рдг рдХреЗ рд▓рд┐рдП рд╡рд┐рд╢реНрд╡рд╛рд╕ рд╕реНрдерд╛рдкрд┐рдд рдХрд░рдиреЗ рдореЗрдВ рдХреЗрдВрджреНрд░реАрдп рд╣реИред
рд╕реБрд░рдХреНрд╖рд┐рдд рдЪреИрдирд▓ (Schannel) рдкреНрд░рдорд╛рдгреАрдХрд░рдг
Schannel рд╕реБрд░рдХреНрд╖рд┐рдд TLS/SSL рдХрдиреЗрдХреНрд╢рдиреЛрдВ рдХреЛ рд╕реБрд╡рд┐рдзрд╛рдЬрдирдХ рдмрдирд╛рддрд╛ рд╣реИ, рдЬрд╣рд╛рдБ рдПрдХ рд╣реИрдВрдбрд╢реЗрдХ рдХреЗ рджреМрд░рд╛рди, рдХреНрд▓рд╛рдЗрдВрдЯ рдПрдХ рдкреНрд░рдорд╛рдгрдкрддреНрд░ рдкреНрд░рд╕реНрддреБрдд рдХрд░рддрд╛ рд╣реИ рдЬреЛ, рдпрджрд┐ рд╕рдлрд▓рддрд╛рдкреВрд░реНрд╡рдХ рдорд╛рдиреНрдп рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИ, рддреЛ рдкрд╣реБрдБрдЪ рдЕрдзрд┐рдХреГрдд рдХрд░рддрд╛ рд╣реИред рдПрдХ рдкреНрд░рдорд╛рдгрдкрддреНрд░ рдХреЛ AD рдЦрд╛рддреЗ рд╕реЗ рдореИрдк рдХрд░рдиреЗ рдореЗрдВ Kerberos рдХрд╛ S4U2Self рдлрд╝рдВрдХреНрд╢рди рдпрд╛ рдкреНрд░рдорд╛рдгрдкрддреНрд░ рдХрд╛ рд╡рд┐рд╖рдп рд╡реИрдХрд▓реНрдкрд┐рдХ рдирд╛рдо (SAN) рд╢рд╛рдорд┐рд▓ рд╣реЛ рд╕рдХрддрд╛ рд╣реИ, рдЕрдиреНрдп рддрд░реАрдХреЛрдВ рдХреЗ рдмреАрдЪред
AD рдкреНрд░рдорд╛рдгрдкрддреНрд░ рд╕реЗрд╡рд╛рдУрдВ рдХреА рдЧрдгрдирд╛
AD рдХреА рдкреНрд░рдорд╛рдгрдкрддреНрд░ рд╕реЗрд╡рд╛рдУрдВ рдХреЛ LDAP рдХреНрд╡реЗрд░реА рдХреЗ рдорд╛рдзреНрдпрдо рд╕реЗ рдЧрдгрдирд╛ рдХреА рдЬрд╛ рд╕рдХрддреА рд╣реИ, рдЬреЛ Enterprise Certificate Authorities (CAs) рдФрд░ рдЙрдирдХреА рдХреЙрдиреНрдлрд╝рд┐рдЧрд░реЗрд╢рди рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рдЬрд╛рдирдХрд╛рд░реА рдкреНрд░рдХрдЯ рдХрд░рддреА рд╣реИред рдпрд╣ рдХрд┐рд╕реА рднреА рдбреЛрдореЗрди-рдкреНрд░рдорд╛рдгрд┐рдд рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛ рджреНрд╡рд╛рд░рд╛ рд╡рд┐рд╢реЗрд╖ рд╡рд┐рд╢реЗрд╖рд╛рдзрд┐рдХрд╛рд░ рдХреЗ рдмрд┐рдирд╛ рд╕реБрд▓рдн рд╣реИред Certify рдФрд░ Certipy рдЬреИрд╕реЗ рдЙрдкрдХрд░рдг AD CS рд╡рд╛рддрд╛рд╡рд░рдг рдореЗрдВ рдЧрдгрдирд╛ рдФрд░ рднреЗрджреНрдпрддрд╛ рдореВрд▓реНрдпрд╛рдВрдХрди рдХреЗ рд▓рд┐рдП рдЙрдкрдпреЛрдЧ рдХрд┐рдП рдЬрд╛рддреЗ рд╣реИрдВред
рдЗрди рдЙрдкрдХрд░рдгреЛрдВ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрдорд╛рдВрдб рдореЗрдВ рд╢рд╛рдорд┐рд▓ рд╣реИрдВ:
# Enumerate trusted root CA certificates and Enterprise CAs with Certify
Certify.exe cas
# Identify vulnerable certificate templates with Certify
Certify.exe find /vulnerable
# Use Certipy for enumeration and identifying vulnerable templates
certipy find -vulnerable -u john@corp.local -p Passw0rd -dc-ip 172.16.126.128
# Enumerate Enterprise CAs and certificate templates with certutil
certutil.exe -TCAInfo
certutil -v -dstemplate
рд╕рдВрджрд░реНрдн
- https://www.specterops.io/assets/resources/Certified_Pre-Owned.pdf
- https://comodosslstore.com/blog/what-is-ssl-tls-client-authentication-how-does-it-work.html
{% hint style="success" %}
AWS рд╣реИрдХрд┐рдВрдЧ рд╕реАрдЦреЗрдВ рдФрд░ рдЕрднреНрдпрд╛рд╕ рдХрд░реЗрдВ:HackTricks Training AWS Red Team Expert (ARTE)
GCP рд╣реИрдХрд┐рдВрдЧ рд╕реАрдЦреЗрдВ рдФрд░ рдЕрднреНрдпрд╛рд╕ рдХрд░реЗрдВ: HackTricks Training GCP Red Team Expert (GRTE)
HackTricks рдХрд╛ рд╕рдорд░реНрдерди рдХрд░реЗрдВ
- рд╕рджрд╕реНрдпрддрд╛ рдпреЛрдЬрдирд╛рдПрдБ рджреЗрдЦреЗрдВ!
- рд╣рдорд╛рд░реЗ ЁЯТм Discord рд╕рдореВрд╣ рдпрд╛ рдЯреЗрд▓реАрдЧреНрд░рд╛рдо рд╕рдореВрд╣ рдореЗрдВ рд╢рд╛рдорд┐рд▓ рд╣реЛрдВ рдпрд╛ рд╣рдорд╛рд░реЗ Twitter ЁЯРж @hacktricks_live** рдХрд╛ рдкрд╛рд▓рди рдХрд░реЗрдВред**
- рд╣реИрдХрд┐рдВрдЧ рдЯреНрд░рд┐рдХреНрд╕ рд╕рд╛рдЭрд╛ рдХрд░реЗрдВ рдФрд░ HackTricks рдФрд░ HackTricks Cloud рдЧрд┐рдЯрд╣рдм рд░рд┐рдкреЛрдЬрд┐рдЯрд░реА рдореЗрдВ PR рд╕рдмрдорд┐рдЯ рдХрд░реЗрдВред