-
Notifications
You must be signed in to change notification settings - Fork 14.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ESC4 detection to ldap_esc_vulnerable_cert_finder module #19816
Conversation
d70e062
to
ffe0ec9
Compare
791834d
to
b8f82e0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to go now. I tested a few different cases for how the cert could be vulnerable and it identified all of them.
[+] Template: ESC4-Test
[*] Distinguished Name: CN=ESC4-Test,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=msflab,DC=local
[*] Manager Approval: Disabled
[*] Required Signatures:
[+] Vulnerable to: ESC4
[*] Notes: ESC4: The account: wrabbit is a part of the following groups: (Authenticated Users) which have edit permissions over the template ESC4-Test making it vulnerable to ESC4
[*] Users or Groups SIDs with Certificate Template write access:
[*] * S-1-5-11 (Authenticated Users)
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-519 (Enterprise Admins)
[*] * S-1-5-11 (Authenticated Users)
[+] Issuing CA: msflab-DC-CA (DC.msflab.local)
[*] Enrollment SIDs:
[*] Successfully queried (objectSID=S-1-5-11).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] * S-1-5-11 (Authenticated Users)
[*] * S-1-5-21-3978004297-3499718965-4169012971-519 (Enterprise Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[+] Template: ESC4-Test1
[*] Distinguished Name: CN=ESC4-Test1,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=msflab,DC=local
[*] Manager Approval: Disabled
[*] Required Signatures:
[+] Vulnerable to: ESC4
[*] Notes: ESC4: The account: wrabbit is a part of the following groups: (Domain Users) which have edit permissions over the template ESC4-Test1 making it vulnerable to ESC4
[*] Users or Groups SIDs with Certificate Template write access:
[*] * S-1-5-21-3978004297-3499718965-4169012971-513 (Domain Users)
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-513 (Domain Users)
[+] Issuing CA: msflab-DC-CA (DC.msflab.local)
[*] Enrollment SIDs:
[*] Successfully queried (objectSID=S-1-5-11).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] * S-1-5-11 (Authenticated Users)
[*] * S-1-5-21-3978004297-3499718965-4169012971-519 (Enterprise Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[+] Template: ESC4-Test2
[*] Distinguished Name: CN=ESC4-Test2,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=msflab,DC=local
[*] Manager Approval: Disabled
[*] Required Signatures:
[+] Vulnerable to: ESC4
[*] Notes: ESC4: The account: wrabbit is a part of the following groups: (Technical Staff) which have edit permissions over the template ESC4-Test2 making it vulnerable to ESC4
[*] Users or Groups SIDs with Certificate Template write access:
[*] * S-1-5-21-3978004297-3499718965-4169012971-2103 (Technical Staff)
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-2103 (Technical Staff)
[+] Issuing CA: msflab-DC-CA (DC.msflab.local)
[*] Enrollment SIDs:
[*] Successfully queried (objectSID=S-1-5-11).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] * S-1-5-11 (Authenticated Users)
[*] * S-1-5-21-3978004297-3499718965-4169012971-519 (Enterprise Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[+] Template: ESC4-Test3
[*] Distinguished Name: CN=ESC4-Test3,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=msflab,DC=local
[*] Manager Approval: Disabled
[*] Required Signatures:
[+] Vulnerable to: ESC4
[*] Notes: ESC4: The account: wrabbit has edit permissions over the template ESC4-Test3 making it vulnerable to ESC4
[*] Users or Groups SIDs with Certificate Template write access:
[*] * S-1-5-21-3978004297-3499718965-4169012971-2102 (wrabbit)
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-513 (Domain Users)
[*] * S-1-5-21-3978004297-3499718965-4169012971-519 (Enterprise Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-2102 (wrabbit)
[+] Issuing CA: msflab-DC-CA (DC.msflab.local)
[*] Enrollment SIDs:
[*] Successfully queried (objectSID=S-1-5-11).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] * S-1-5-11 (Authenticated Users)
[*] * S-1-5-21-3978004297-3499718965-4169012971-519 (Enterprise Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[*] Auxiliary module execution completed
Then in this run, I changed from a user account to a computer account and validated that the primary group ID logic is working and it's detecting that ESC4-Test4
is vulnerable because the Domain Computers
group has write access to it.
[+] Template: ESC4-Test4
[*] Distinguished Name: CN=ESC4-Test4,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=msflab,DC=local
[*] Manager Approval: Disabled
[*] Required Signatures:
[+] Vulnerable to: ESC4
[*] Notes: ESC4: The account: DESKTOP-5V184QI2$ is a part of the following groups: (Domain Computers) which have edit permissions over the template ESC4-Test4 making it vulnerable to ESC4
[*] Users or Groups SIDs with Certificate Template write access:
[*] * S-1-5-21-3978004297-3499718965-4169012971-515 (Domain Computers)
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-513 (Domain Users)
[*] * S-1-5-21-3978004297-3499718965-4169012971-519 (Enterprise Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-515 (Domain Computers)
[+] Issuing CA: msflab-DC-CA (DC.msflab.local)
[*] Enrollment SIDs:
[*] Successfully queried (objectSID=S-1-5-11).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-519).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] Successfully queried (objectSID=S-1-5-21-3978004297-3499718965-4169012971-512).
[*] * S-1-5-11 (Authenticated Users)
[*] * S-1-5-21-3978004297-3499718965-4169012971-519 (Enterprise Admins)
[*] * S-1-5-21-3978004297-3499718965-4169012971-512 (Domain Admins)
[*] Auxiliary module execution completed
Release NotesThis adds support to the existing |
This adds support for ESC4 to the
ldap_esc_vulnerable_cert_finder
module. Certificates vulnerable to ESC4 are certs where the user enumerating can edit them. The idea being that if the user has edit permissions they can modify the cert to be vulnerable to ESC1 then exploit it to get domain admin on the DC.This addition works by first running an LDAP query to determine what user we are authenticating with and what security groups they are a part of. The module then gets a list of all certificate templates and determines whether the user has the ability to edit any of them.
Verification Steps
First deploy a vulnerable template with
ad_cs_cert_template
use admin/ldap/ad_cs_cert_template
set TEMPLATE_FILE data/auxiliary/admin/ldap/ad_cs_cert_template/esc4_template.yaml
set CERT_TEMPLATE VulnToEsc4
set action CREATE
DOMAIN
PASSWORD
RHOSTS
USERNAME
certsrv
on the domain controller, right clickCertificate Templates
->New
->Certificate Template to Issue
and selectVulnToEsc4
Ensure
ldap_esc_vulnerable_cert_finder
finds the vulnerable certificateuse gather/ldap_esc_vulnerable_cert_finder
run domain=kerberos.issue password=N0tpassword! rhost=172.16.199.200 username=msfuser
VulnToEsc4
appears vulnerable to ESC4.Note if you run the vulnerable cert finder with a domain admin as you might expect, almost all templates should be reported as vulnerable to ESC4.
Testing