Skip to content

LDAP Reporting Improvements#21031

Open
zeroSteiner wants to merge 14 commits intorapid7:masterfrom
zeroSteiner:fix/issue/20959
Open

LDAP Reporting Improvements#21031
zeroSteiner wants to merge 14 commits intorapid7:masterfrom
zeroSteiner:fix/issue/20959

Conversation

@zeroSteiner
Copy link
Contributor

This updates a handful of LDAP related modules to report the LDAP and ADCS services automatically. It also updates vulnerability reporting to include the LDAP object's DN so users can tell exactly where the vulnerability is. This also means vulnerabilities can use common names, so for example all the instances of ESC# are grouped together, but reported separately for each object that's vulnerable as uniquely keyed by the template that's affected.

Closes #20959

Verification

None of the functionality of the modules really changed, we're just reporting more info.

  • Start msfconsole
  • use auxiliary/gather/ldap_passwords and run it, see a vulnerability reported for the plaintext credentials, NTLM hashes and Kerberos keys that are found, see a DN for each
  • use auxiliary/admin/ldap/rbcd and run the check method, see a vulnerability reported that's associated with the service and includes the affected object
  • use auxiliary/admin/ldap/shadow_credentials and run the check method, see a vulnerability reported that's associated with the service and includes the affected object
  • use auxiliary/gather/ldap_esc_vulnerable_cert_finder and run it, see vulnerabilities reported for each of the findins with the template info
  • use auxiliary/admin/dcerpc/icpr_cert and run it, see that the service is reported with the CA name, note that it's consistent with what was reported by the ldap_esc_vulnerable_cert_finder module

Example

After running through this content in my test environment, these are the services and vulns I have reported:

msf auxiliary(gather/ldap_esc_vulnerable_cert_finder) > services
Services
========

host            port  proto  name          state  info                                                                                         resource                    parents
----            ----  -----  ----          -----  ----                                                                                         --------                    -------
192.168.159.10  389   tcp    ldap          open                                                                                                {}
192.168.159.10  445   tcp    dcerpc        open   Module: auxiliary/admin/dcerpc/icpr_cert                                                     {"smb":{"share":"IPC$"}}    smb (445/tcp)
192.168.159.10  445   tcp    icertpassage  open                                                                                                {"dcerpc":{"pipe":"cert"}}  dcerpc (445/tcp)
192.168.159.10  445   tcp    adcs-ca       open                                                                                                {"name":"msflab-DC-CA"}     icertpassage (445/tcp)
192.168.159.10  445   tcp    smb           open   Module: auxiliary/admin/dcerpc/icpr_cert, last negotiated version: SMBv3 (dialect = 0x0311)  {}
192.168.159.10  636   tcp    ssl           open                                                                                                {}
192.168.159.10  636   tcp    ldap          open                                                                                                {}                          ssl (636/tcp)

msf auxiliary(gather/ldap_esc_vulnerable_cert_finder) > vulns

Vulnerabilities
===============

Timestamp                Host            Service            Resource                                                                             Name                                   References
---------                ----            -------            --------                                                                             ----                                   ----------
2026-02-27 20:07:28 UTC  192.168.159.10  ldap (389/tcp)     {"ldap_dn"=>"CN=Jabberwock,CN=Managed Service Accounts,DC=msflab,DC=local"}          NTLM hash found in LDAP                CWE-512
2026-02-27 20:07:28 UTC  192.168.159.10  ldap (389/tcp)     {"ldap_dn"=>"CN=Jabberwock,CN=Managed Service Accounts,DC=msflab,DC=local"}          Kerberos encryption key found in LDAP  CWE-312
2026-02-27 20:15:42 UTC  192.168.159.10  ldap (389/tcp)     {"ldap_dn"=>"CN=Alice Liddle,CN=Users,DC=msflab,DC=local"}                           Role Base Constrained Delegation       URL-https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/resource-based-constrained-delegation-ad-c
                                                                                                                                                                                        omputer-object-take-over-and-privilged-code-execution,URL-https://www.thehacker.recipes/ad/movement/kerberos/delegations/rbcd,URL-h
                                                                                                                                                                                        ttps://github.com/SecureAuthCorp/impacket/blob/3c6713e309cae871d685fa443d3e21b7026a2155/examples/rbcd.py,ATT&CK-T1098,ATT&CK-T1558
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=DomainControllerAuthentication,CN=Certificate Templates,CN=Public K  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            ey Services,CN=Services,CN=Configuration,DC=msflab,DC=local", "template_name"=>"Dom
                                                            ainControllerAuthentication"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=EFS,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            Configuration,DC=msflab,DC=local", "template_name"=>"EFS"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=EFS,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=  ESC16_2
                                                            Configuration,DC=msflab,DC=local", "template_name"=>"EFS"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=Administrator,CN=Certificate Templates,CN=Public Key Services,CN=Se  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            rvices,CN=Configuration,DC=msflab,DC=local", "template_name"=>"Administrator"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=Administrator,CN=Certificate Templates,CN=Public Key Services,CN=Se  ESC10                                  URL-https://research.ifcr.dk/certipy-4-0-esc9-esc10-bloodhound-gui-new-authentication-and-request-methods-and-more-7237d88061f7
                                                            rvices,CN=Configuration,DC=msflab,DC=local", "template_name"=>"Administrator"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=Administrator,CN=Certificate Templates,CN=Public Key Services,CN=Se  ESC16_2
                                                            rvices,CN=Configuration,DC=msflab,DC=local", "template_name"=>"Administrator"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=Administrator,CN=Certificate Templates,CN=Public Key Services,CN=Se  ESC16_1
                                                            rvices,CN=Configuration,DC=msflab,DC=local", "template_name"=>"Administrator"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=DirectoryEmailReplication,CN=Certificate Templates,CN=Public Key Se  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            rvices,CN=Services,CN=Configuration,DC=msflab,DC=local", "template_name"=>"Director
                                                            yEmailReplication"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=DomainController,CN=Certificate Templates,CN=Public Key Services,CN  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            =Services,CN=Configuration,DC=msflab,DC=local", "template_name"=>"DomainController"
                                                            }
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=EFS,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=  ESC16_1
                                                            Configuration,DC=msflab,DC=local", "template_name"=>"EFS"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=EFSRecovery,CN=Certificate Templates,CN=Public Key Services,CN=Serv  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            ices,CN=Configuration,DC=msflab,DC=local", "template_name"=>"EFSRecovery"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=EFSRecovery,CN=Certificate Templates,CN=Public Key Services,CN=Serv  ESC16_2
                                                            ices,CN=Configuration,DC=msflab,DC=local", "template_name"=>"EFSRecovery"}
2026-02-27 20:15:54 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=EFSRecovery,CN=Certificate Templates,CN=Public Key Services,CN=Serv  ESC16_1
                                                            ices,CN=Configuration,DC=msflab,DC=local", "template_name"=>"EFSRecovery"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC13-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servi  ESC10                                  URL-https://research.ifcr.dk/certipy-4-0-esc9-esc10-bloodhound-gui-new-authentication-and-request-methods-and-more-7237d88061f7
                                                            ces,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC13-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC1-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC1                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC1-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC13-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servi  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            ces,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC13-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC13-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servi  ESC13                                  URL-https://posts.specterops.io/adcs-esc13-abuse-technique-fda4272fbd53
                                                            ces,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC13-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC13-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servi  ESC16_2
                                                            ces,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC13-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC13-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servi  ESC16_1
                                                            ces,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC13-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC15-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servi  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            ces,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC15-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC15-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servi  ESC15                                  URL-https://trustedsec.com/blog/ekuwu-not-just-another-ad-cs-esc
                                                            ces,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC15-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC2-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC2                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC2-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC2-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC10                                  URL-https://research.ifcr.dk/certipy-4-0-esc9-esc10-bloodhound-gui-new-authentication-and-request-methods-and-more-7237d88061f7
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC2-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC2-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC16_2
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC2-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC2-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC16_1
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC2-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC3-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC3                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC3-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC3-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC16_2
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC3-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC3-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC16_1
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC3-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC4-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC4-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC4-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC10                                  URL-https://research.ifcr.dk/certipy-4-0-esc9-esc10-bloodhound-gui-new-authentication-and-request-methods-and-more-7237d88061f7
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC4-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC4-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC16_2
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC4-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=ESC4-Test,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC16_1
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"ESC4-Test"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=KerberosAuthentication,CN=Certificate Templates,CN=Public Key Servi  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            ces,CN=Services,CN=Configuration,DC=msflab,DC=local", "template_name"=>"KerberosAut
                                                            hentication"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=Machine,CN=Certificate Templates,CN=Public Key Services,CN=Services  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            ,CN=Configuration,DC=msflab,DC=local", "template_name"=>"Machine"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=MachineEnrollmentAgent,CN=Certificate Templates,CN=Public Key Servi  ESC3                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            ces,CN=Services,CN=Configuration,DC=msflab,DC=local", "template_name"=>"MachineEnro
                                                            llmentAgent"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=User,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            =Configuration,DC=msflab,DC=local", "template_name"=>"User"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=SubCA,CN=Certificate Templates,CN=Public Key Services,CN=Services,C  ESC1                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            N=Configuration,DC=msflab,DC=local", "template_name"=>"SubCA"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=User,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN  ESC10                                  URL-https://research.ifcr.dk/certipy-4-0-esc9-esc10-bloodhound-gui-new-authentication-and-request-methods-and-more-7237d88061f7
                                                            =Configuration,DC=msflab,DC=local", "template_name"=>"User"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=User,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN  ESC16_2
                                                            =Configuration,DC=msflab,DC=local", "template_name"=>"User"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=User,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN  ESC16_1
                                                            =Configuration,DC=msflab,DC=local", "template_name"=>"User"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=WebServer,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC4                                   URL-https://posts.specterops.io/certified-pre-owned-d95910965cd2
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"WebServer"}
2026-02-27 20:15:55 UTC  192.168.159.10  adcs-ca (445/tcp)  {"ldap_dn"=>"CN=WebServer,CN=Certificate Templates,CN=Public Key Services,CN=Servic  ESC15                                  URL-https://trustedsec.com/blog/ekuwu-not-just-another-ad-cs-esc
                                                            es,CN=Configuration,DC=msflab,DC=local", "template_name"=>"WebServer"}

msf auxiliary(gather/ldap_esc_vulnerable_cert_finder) > 

@github-actions
Copy link

Thanks for your pull request! As part of our landing process, we manually verify that all modules work as expected.

We've added the additional-testing-required label to indicate that additional testing is required before this pull request can be merged.
For maintainers, this means visiting here.

@smcintyre-r7 smcintyre-r7 moved this from Todo to Ready in Metasploit Kanban Feb 27, 2026
@jenkins-eks-metasploit
Copy link

Additional test pipeline started ⌛
Note: build results only accessible to maintainers.

@jenkins-eks-metasploit
Copy link

Pipeline results available

Slice summary:

  • Test slice 1 - 🟢
  • Test slice 2 - 🟢
  • Test slice 3 - 🟢
  • Test slice 4 - 🟢

Note: build results only accessible to maintainers.

@cdelafuente-r7 cdelafuente-r7 self-assigned this Mar 2, 2026
@cdelafuente-r7 cdelafuente-r7 moved this from Ready to In Progress in Metasploit Kanban Mar 2, 2026
Copy link
Contributor

@cdelafuente-r7 cdelafuente-r7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these improvements! I left a few comments and suggestions for you to look into when you get a chance.

Also, there is an unrelated issue I found in the auxiliary/gather/ldap_passwords module while I was testing. Please see this issue for details.

# [[SAN URL prefix for strong SID mapping for KDCs running Windows Server Preview Build 25246 and later](https://techcommunity.microsoft.com/blog/askds/preview-of-san-uri-for-certificate-strong-mapping-for-kb5014754/3789785)]
SAN_URL_PREFIX = "tag:microsoft.com,2022-09-14:sid:"

ADCS_CA_SERVICE_NAME = 'adcs-ca'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this should be defined in the Report mixin instead. Since it is only used for reporting servicing and modules that don't include this file could also use?

@cdelafuente-r7 cdelafuente-r7 moved this from In Progress to Waiting on Contributor in Metasploit Kanban Mar 4, 2026
@cdelafuente-r7 cdelafuente-r7 moved this from Waiting on Contributor to In Progress in Metasploit Kanban Mar 5, 2026
}
end

def report_icertpassage_service
Copy link
Contributor

@cdelafuente-r7 cdelafuente-r7 Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icpr variable is missing here and I think this should be passed as argument:

Suggested change
def report_icertpassage_service
def report_icertpassage_service(icpr)

or maybe just passing the host and port:

Suggested change
def report_icertpassage_service
def report_icertpassage_service(host, port)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually use #simple so we don't need an argument at all. I added this in 7ff46b8.

@cdelafuente-r7 cdelafuente-r7 moved this from In Progress to Waiting on Contributor in Metasploit Kanban Mar 5, 2026
@cdelafuente-r7 cdelafuente-r7 moved this from Waiting on Contributor to In Progress in Metasploit Kanban Mar 5, 2026
host: icpr.tree.client.dispatcher.tcp_socket.peerhost,
port: icpr.tree.client.dispatcher.tcp_socket.peerport,
proto: 'tcp',
parents: report_icertpassage_service
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#report_icertpassage_service returns a Mdm::Service object and it is not the format expected by the :parents field. It should be a hash or an array of hashes (for multiple parents). If we want to have these helper methods being used directly into the :parents field, we need to make sure they return the expected format. Maybe doing something like this:

  def report_icertpassage_service
    service = {
      name: 'icertpassage',
      resource: { dcerpc: { pipe: 'cert' } },
      host: simple.peerhost,
      port: simple.peerport,
      proto: 'tcp',
      parents: report_dcerpc_service
    }
    report_service(service)
    service
  end
    def report_dcerpc_service
      service = {
        name: 'dcerpc',
        info: "Module: #{fullname}",
        host: simple.peerhost,
        port: simple.peerport,
        proto: 'tcp',
        resource: { smb: { share: 'IPC$' } },
        parents: {
          name: 'smb',
          host: simple.peerhost,
          port: simple.peerport,
          proto: 'tcp',
          info: "Module: #{fullname}, last negotiated version: SMBv#{simple.client.negotiated_smb_version} (dialect = #{simple.client.dialect})",
          parents: {
            name: 'tcp',
            host: simple.peerhost,
            port: simple.peerport,
            proto: 'tcp'
          }
        }
      }
      report_service(service)
      service
    end

The only drawback I see with the parent services will be processed each time #report_service is called, with cause multiple queries to the database where it is not really necessary. But it is not a big deal and it is something we can address later.

As a side note, if you register the service in one go (calling #report_service once like you did in #report_service_icertpassage in modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb). There will be only one database query per service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be updated to allow Mdm::Service?

Suggested change
return unless services.is_a?(Hash) || services.is_a?(::Array) || services.is_a?(Mdm::Service)

Or maybe completely remove this check since it is converted to an Array afterwards and each element is validated in the #map loop.

if service.is_a?(Mdm::Service)
service_obj = service
elsif service.is_a?(Hash)
return if service[:port].nil? || service[:proto].nil?
Copy link
Contributor

@cdelafuente-r7 cdelafuente-r7 Mar 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After thinking about it might not be a goos idea to return here. Maybe using next instead?

We can also make sure no nil is present in the resulting array:

services.map do |service|
  ...
end.compact

@jenkins-eks-metasploit
Copy link

Additional test pipeline started ⌛
Note: build results only accessible to maintainers.

@jenkins-eks-metasploit
Copy link

Pipeline results available

Slice summary:

  • Test slice 1 - 🟢
  • Test slice 2 - 🟢
  • Test slice 3 - 🔴
  • Test slice 4 - 🟢

Note: build results only accessible to maintainers.

@jenkins-eks-metasploit
Copy link

Additional test pipeline started ⌛
Note: build results only accessible to maintainers.

@jenkins-eks-metasploit
Copy link

Pipeline results available

Slice summary:

  • Test slice 1 - 🟢
  • Test slice 2 - 🟢
  • Test slice 3 - 🔴

Note: build results only accessible to maintainers.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances Metasploit’s LDAP/ADCS-related modules to automatically report related services (LDAP, DCERPC/ICertPassage/ADCS CA) and to improve vulnerability reporting by associating findings with the affected LDAP object’s DN (and, for ADCS template findings, the template name) so results are uniquely keyed and easier to interpret.

Changes:

  • Add automatic LDAP service reporting on successful bind, and introduce/standardize DCERPC → ICertPassage → ADCS-CA service reporting.
  • Update LDAP modules to attach LDAP object DNs (and template names where applicable) to vulnerability resources for more precise reporting/grouping.
  • Adjust DB service-chain processing behavior (return [] instead of nil for invalid service hashes) and update specs accordingly.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
spec/support/shared/examples/msf/db_manager/vuln.rb Updates shared vuln spec to stop relying on sname for reporting.
spec/support/shared/examples/msf/db_manager/service.rb Updates expectations for process_service_chain invalid-parameter behavior ([] vs nil).
modules/auxiliary/gather/ldap_passwords.rb Adds per-entry DN tracking and new vuln reporting for discovered LDAP secrets.
modules/auxiliary/gather/ldap_esc_vulnerable_cert_finder.rb Standardizes ADCS service reporting and adds DN/template metadata to reported vulns.
modules/auxiliary/admin/ldap/shadow_credentials.rb Adds DN/service context to check vuln reporting via CheckCode.vuln.
modules/auxiliary/admin/ldap/rbcd.rb Adds DN/service context to check vuln reporting via CheckCode.vuln.
lib/msf/core/exploit/remote/smb/client/ipc.rb Adds report_dcerpc_service and reports it on IPC connect, establishing service parents.
lib/msf/core/exploit/remote/ms_icpr.rb Introduces adcs-ca service name constant and reports ICPR/CA services with parents.
lib/msf/core/exploit/remote/ldap.rb Adds report_ldap_service, reports it after successful bind, and normalizes peer.
lib/msf/core/db_manager/service.rb Enhances process_service_chain to accept Mdm::Service objects and return compacted arrays.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +1259 to +1263
parents: {
name: 'smb',
parents: {
name: 'tcp'
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tcp parent in this service chain is missing host/port/proto. Because process_service_chain skips hash services without :port and :proto, this tcp parent will be dropped and the chain will stop at smb. Either remove the tcp parent entry or include the required fields so the full hierarchy is actually recorded.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Update LDAP service and vulnerability reporting

3 participants