-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Description
Steps to reproduce
msf6 > use auxiliary/gather/ldap_esc_vulnerable_cert_finder
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > show options
Module options (auxiliary/gather/ldap_esc_vulnerable_cert_finder):
Name Current Setting Required Description
---- --------------- -------- -----------
BASE_DN no LDAP base DN if you already have it
BIND_DN no The username to authenticate to LDAP server
BIND_PW no Password for the BIND_DN
REPORT_NONENROLLABLE false yes Report nonenrollable certificate templates
RHOSTS yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metas
ploit
RPORT 389 yes The target port
SSL false no Enable SSL on the LDAP connection
View the full module info with the info, or info -d command.
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > set RHOSTS 172.19.103.226
RHOSTS => 172.19.103.226
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > set BIND_PW DAFOREST\\normal
BIND_PW => DAFOREST\normal
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > set BIND_DN DAFOREST\\normal
BIND_DN => DAFOREST\normal
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > set BIND_PW thenormaluser123
BIND_PW => thenormaluser123
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > run
[*] Running module against 172.19.103.226
[*] Discovering base DN automatically
[+] 172.19.103.226:389 Discovered base DN: DC=daforest,DC=com
[-] Auxiliary failed: NoMethodError undefined method `read' for nil:NilClass
[-] Call stack:
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/io.rb:162:in `read_raw'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/io.rb:314:in `read'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/io.rb:278:in `readbytes'
[-] (eval):23:in `read_and_return_value'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/base_primitive.rb:129:in `do_read'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/struct.rb:140:in `block in do_read'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/struct.rb:140:in `each'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/struct.rb:140:in `do_read'
[-] /home/gwillcox/git/metasploit-framework/lib/rex/proto/ms_dtyp.rb:283:in `do_read'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/base.rb:147:in `block in read'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/base.rb:253:in `start_read'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/base.rb:145:in `read'
[-] /home/gwillcox/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/bindata-2.4.14/lib/bindata/base.rb:21:in `read'
[-] /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb:157:in `block in query_ldap_server_certificates'
[-] /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb:153:in `each'
[-] /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb:153:in `query_ldap_server_certificates'
[-] /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb:219:in `find_esc1_vuln_cert_templates'
[-] /home/gwillcox/git/metasploit-framework/modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb:352:in `run'
[*] Auxiliary module execution completed
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > set BIND_PW fakewrongpassword
BIND_PW => fakewrongpassword
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > run
[*] Running module against 172.19.103.226
[-] Auxiliary aborted due to failure: no-access: Invalid credentials provided!
[*] Auxiliary module execution completed
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) >
Now we if we try this with a domain administrator user and valid password the module works correctly:
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > set BIND_DN DAFOREST\\Administrator
BIND_DN => DAFOREST\Administrator
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > set BIND_PW theAdmin123
BIND_PW => theAdmin123
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > show options
Module options (auxiliary/gather/ldap_esc_vulnerable_cert_finder):
Name Current Setting Required Description
---- --------------- -------- -----------
BASE_DN no LDAP base DN if you already have it
BIND_DN DAFOREST\Administrator no The username to authenticate to LDAP server
BIND_PW theAdmin123 no Password for the BIND_DN
REPORT_NONENROLLABLE false yes Report nonenrollable certificate templates
RHOSTS 172.19.103.226 yes The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Usin
g-Metasploit
RPORT 389 yes The target port
SSL false no Enable SSL on the LDAP connection
View the full module info with the info, or info -d command.
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > run
[*] Running module against 172.19.103.226
[*] Discovering base DN automatically
[+] 172.19.103.226:389 Discovered base DN: DC=daforest,DC=com
[*] Template: SubCA
[*] Distinguished Name: CN=SubCA,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC1, ESC2, ESC3_TEMPLATE_2
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Template: ESC1-Template
[*] Distinguished Name: CN=ESC1-Template,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC1
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-513 (Domain Users)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Template: ESC2-Template
[*] Distinguished Name: CN=ESC2-Template,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC2
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-513 (Domain Users)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Template: ESC3-Template1
[*] Distinguished Name: CN=ESC3-Template1,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC3_TEMPLATE_1
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-513 (Domain Users)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Template: User
[*] Distinguished Name: CN=User,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC3_TEMPLATE_2
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-513 (Domain Users)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Template: Administrator
[*] Distinguished Name: CN=Administrator,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC3_TEMPLATE_2
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Template: Machine
[*] Distinguished Name: CN=Machine,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC3_TEMPLATE_2
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-515 (Domain Computers)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Template: DomainController
[*] Distinguished Name: CN=DomainController,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC3_TEMPLATE_2
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-498 (Enterprise Read-only Domain Controllers)
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-516 (Domain Controllers)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] * S-1-5-9 (Enterprise Domain Controllers)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Template: ESC3-Template2
[*] Distinguished Name: CN=ESC3-Template2,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=daforest,DC=com
[*] Vulnerable to: ESC3_TEMPLATE_2
[*] Certificate Template Enrollment SIDs:
[*] * S-1-5-21-3290009963-1772292745-3260174523-512 (Domain Admins)
[*] * S-1-5-21-3290009963-1772292745-3260174523-513 (Domain Users)
[*] * S-1-5-21-3290009963-1772292745-3260174523-519 (Enterprise Admins)
[*] Issuing CAs:
[*] * daforest-WIN-BR0CCBA815B-CA
[*] Server: WIN-BR0CCBA815B.daforest.com
[*] Enrollment SIDs:
[*] * S-1-5-11 (Authenticated Users)
[*] Auxiliary module execution completed
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) >
Were you following a specific guide/tutorial or reading documentation?
Found whilst writing documentation to explain the workflow of attacking ADCS using this module, ipcr certificate module, and the Kerberos PKINIT authentication.
Expected behavior
We should be able to use a normal domain user to gather information about vulnerable ESC certificates on a domain controller.
Current behavior
We get a weird error and crash from the module. I'm unaware of if this is related to a logon issue, but it seems at the very least that we should be handling such cases better cause atm the crash doesn't inform the user as to what is going wrong.
Metasploit version
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) > version
Framework: 6.2.29-dev-07a91df7a1
Console : 6.2.29-dev-07a91df7a1
msf6 auxiliary(gather/ldap_esc_vulnerable_cert_finder) >
Additional Information
I know the user in this case had some issues when I tried to log in via Hyper-V. This may be related to additional protections on a domain controller but I think I was able to get the login to work in the past. Not sure if Server 2022 has some additional protections preventing this from working but will have to see.