Skip to content

Add LAPSv1 and LAPSv2 LDAP Module #20017

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

zeroSteiner
Copy link
Contributor

@zeroSteiner zeroSteiner commented Apr 9, 2025

This updates and moves the existing ldap_hashdump module to ldap_passwords and extends the attributes it searches for to process those used by LAPSv1 and LAPSv2 (both encrypted and unencrypted). The original ldap_hashdump module would search for hashes and passwords from misc LDAP server implementations. The original seemed to have been inspired by CVE-2020-3952, for which there is still a dedicated module. The changers herein effectively add techniques specific to Active Directory LDAP servers. I think it makes a lot of sense to combine the functionality because:

  • Users don't need to know if the target server is an Active Directory server or not removing the need for them to fingerprint then run the appropriate module.
  • The module still only runs a single LDAP query for secret harvesting, so there's no major increase in query activity.
  • The logic is effectively the same, LDAP objects that have certain attributes are returned and processed

I'm open to suggestions on better names for the module. Perhaps ldap_secrets_dump would be more intuitive given everything it looks for.

In addition to the module updates, the ldap_spec tests have been updated for this module. The target LDAP server that the tests use is Samba as an Active Directory Domain Controller, so it makes sense to add the new password data that is applicable in AD environments. To support that, the tests were updated to add test accounts with both LAPSv1 and LAPSv2 passwords in use. Only plaintext LAPSv2 can be used, because the encrypted variant requires the GKDI service that Samba does not support.

Closes #19838

Verification

Testing requires changes from rapid7/ruby_smb#286 and rapid7/ruby_smb#284. The last commit points to a temporary branch to make testing easier. The temporary branch includes changes from both PRs.

  • Test the original functionality still works against an OpenLDAP target
    • Clone HynekPetrak/bitnami-docker-openldap by running git clone https://github.com/HynekPetrak/bitnami-docker-openldap.git
    • Use docker to set it up by running cd bitnami-docker-openldap && docker-compose up -d
    • Run the module against it and see two passwords recovered
  • Setup a Windows Active Directory Domain Controller (snapshot it if you're using virtualization so you can toggle between LAPS versions)
    • Setup LAPSv1 by following the Microsoft Docs and the extra setup instructions in the module docs
    • Run the module against the DC and see that LAPS secrets were extracted from the ms-mcs-admpwd attribute
    • Setup LAPSv2 by following the Microsoft documentation
    • Run the module against the DC and see that LAPS secrets were extracted from the mslaps-encryptedpassword or mslaps-password attribute depending on if encryption was enabled

Demo

msf6 auxiliary(gather/ldap_passwords) > run
[+] Successfully bound to the LDAP server!
[*] Discovered base DN: DC=msflab,DC=local
[*] Checking if the target LDAP server is an Active Directory Domain Controller...
[*] The target LDAP server is an Active Directory Domain Controller.
[*] Searching base DN: DC=msflab,DC=local
[*] Connecting to Group Key Distribution (GKDI) Protocol
[*] Mapping GKDI endpoints...
[*] Binding to GKDI via ncacn_ip_tcp:192.168.159.10[49693]...
[*] Bound to GKDI
[+] Credentials (password) found in mslaps-encryptedpassword: Administrator:m8L3A.LcZ9!lnT (expires: 2025-03-08 17:22:57 UTC)
[*] Found 1 entries and 1 credentials in 'DC=msflab,DC=local'.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(gather/ldap_passwords) >

@zeroSteiner zeroSteiner marked this pull request as ready for review April 9, 2025 20:45
@smcintyre-r7 smcintyre-r7 added docs rn-modules release notes for new or majorly enhanced modules labels Apr 9, 2025
@jheysel-r7 jheysel-r7 self-assigned this Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs rn-modules release notes for new or majorly enhanced modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a module for LAPS v1 and v2
3 participants