-
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
base: master
Are you sure you want to change the base?
Conversation
user_groups << group_sid | ||
end | ||
|
||
user_groups << Rex::Proto::Secauthz::WellKnownSids::SECURITY_AUTHENTICATED_USER_SID |
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.
In addition to this, I think we'll want to figure out if the account we're using is a User or a Computer. Once we know, we'll want to add the SID for Domain Users
or Domain Computers
as applicable. That means you'll also have to get the Domain SID though too.
Once you have the Users or Computers group, we'll want to look up it's DN and add it to the filter_with_users
using the logical OR operator. With this in place, we should be able to identify cases where one of these groups has inherited permissions.
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.
The module now differentiates between users and computer accounts and adds the necessary SIDs to the user_groups
where applicable.
New relevant testing output:
[+] Template: Copy 2 of Web Server
[*] Distinguished Name: CN=Copy 2 of Web Server,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=kerberos,DC=issue
[*] Manager Approval: Disabled
[*] Required Signatures:
[+] Vulnerable to: ESC4
[*] Notes: ESC4: The computer DC2$ is a part of the following groups: (Domain Computers) which have edit permissions over the template Copy 2 of Web Server making it vulnerable to ESC4
[*] Users or Groups SIDs with Certificate Template write access:
[*] * S-1-5-21-2324486357-3075865580-3606784161-515 (Domain Computers)
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-2324486357-3075865580-3606784161-512 (Domain Admins)
[*] * S-1-5-21-2324486357-3075865580-3606784161-519 (Enterprise Admins)
[*] * S-1-5-21-2324486357-3075865580-3606784161-515 (Domain Computers)
[*] * S-1-5-21-2324486357-3075865580-3606784161-1000 (msfuser)
[*] * S-1-5-11 (Authenticated Users)
[+] Issuing CA: kerberos-DC2-CA (dc2.kerberos.issue)
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] * S-1-5-21-2324486357-3075865580-3606784161-519 (Enterprise Admins)
[*] * S-1-5-21-2324486357-3075865580-3606784161-512 (Domain Admins)
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