Skip to content
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

Ldap Change Password module #19671

Merged
merged 5 commits into from
Dec 6, 2024
Merged

Conversation

smashery
Copy link
Contributor

@smashery smashery commented Nov 22, 2024

This adds a module, auxiliary/admin/ldap/change_password, for changing/resetting AD passwords over the LDAP protocol.

Actions:

  • CHANGE: Changing an existing (known password).
  • RESET: Forcing a password reset by having privileges over the target account.

Works on both standard 389 and SSL-encrypted on 636 (since we use GSS-API encryption)

Verification

Do the test cases below with:

  • NTLM auth
  • Existing LDAP session (mostly meaningful for the Reset behaviour, but technically you can run Change from an existing session, as long as you know and set the password)
  • Kerberos auth
  • SCHANNEL auth

Main use cases:

  • Change password for user (happy path)
  • Change password for user (failing cases)
  • Reset password for user (happy path)
  • Reset password for user (failing cases)

@smashery smashery marked this pull request as ready for review November 22, 2024 03:09
@smcintyre-r7 smcintyre-r7 self-assigned this Nov 26, 2024
modules/auxiliary/admin/ldap/change_password.rb Outdated Show resolved Hide resolved
modules/auxiliary/admin/ldap/change_password.rb Outdated Show resolved Hide resolved
modules/auxiliary/admin/ldap/change_password.rb Outdated Show resolved Hide resolved
modules/auxiliary/admin/ldap/change_password.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@smcintyre-r7 smcintyre-r7 left a comment

Choose a reason for hiding this comment

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

I pushed up a commit fixing a super minor typo that was throwing off msftidy. I then completed my testing by authenticating with Kerberos and resetting the password for an account and checking an invalid account. Everything is looking good to me so if the tests pass, I'll get this landed.

Thanks a lot for your work on this!

Testing Output
metasploit-framework.pr (S:0 J:0) auxiliary(admin/ldap/change_password) > run
[*] Running module against 192.168.159.10

[-] Auxiliary aborted due to failure: bad-config: The LDAP::Rhostname option is required when using Kerberos authentication.
[*] Auxiliary module execution completed
metasploit-framework.pr (S:0 J:0) auxiliary(admin/ldap/change_password) > set LDAP::Rhostname dc.msflab.local
LDAP::Rhostname => dc.msflab.local
metasploit-framework.pr (S:0 J:0) auxiliary(admin/ldap/change_password) > run
[*] Running module against 192.168.159.10

[+] 192.168.159.10:88 - Received a valid TGT-Response
[*] 192.168.159.10:389 - TGT MIT Credential Cache ticket saved to /home/smcintyre/.msf4/loot/20241206164448_default_192.168.159.10_mit.kerberos.cca_407813.bin
[+] 192.168.159.10:88 - Received a valid TGS-Response
[*] 192.168.159.10:389 - TGS MIT Credential Cache ticket saved to /home/smcintyre/.msf4/loot/20241206164448_default_192.168.159.10_mit.kerberos.cca_408381.bin
[+] 192.168.159.10:88 - Received a valid delegation TGS-Response
[+] 192.168.159.10:88 - Received AP-REQ. Extracting session key...
[+] Successfully bound to the LDAP server!
[*] Discovering base DN automatically
[*] 192.168.159.10:389 Discovered base DN: DC=msflab,DC=local
[+] Successfully reset password for mhatter.
[*] Auxiliary module execution completed
metasploit-framework.pr (S:0 J:0) auxiliary(admin/ldap/change_password) > set NEW_PASSWORD ItsBeer30!
NEW_PASSWORD => ItsBeer30!
metasploit-framework.pr (S:0 J:0) auxiliary(admin/ldap/change_password) > run
[*] Running module against 192.168.159.10

[*] Using cached credential for ldap/[email protected] [email protected]
[+] 192.168.159.10:88 - Received AP-REQ. Extracting session key...
[+] Successfully bound to the LDAP server!
[*] Discovering base DN automatically
[*] 192.168.159.10:389 Discovered base DN: DC=msflab,DC=local
[+] Successfully reset password for mhatter.
[*] Auxiliary module execution completed
metasploit-framework.pr (S:0 J:0) auxiliary(admin/ldap/change_password) > set TARGET_USER doesnotexist
TARGET_USER => doesnotexist
metasploit-framework.pr (S:0 J:0) auxiliary(admin/ldap/change_password) > run
[*] Running module against 192.168.159.10

[*] Using cached credential for ldap/[email protected] [email protected]
[+] 192.168.159.10:88 - Received AP-REQ. Extracting session key...
[+] Successfully bound to the LDAP server!
[*] Discovering base DN automatically
[*] 192.168.159.10:389 Discovered base DN: DC=msflab,DC=local
[-] Auxiliary aborted due to failure: not-found: Failed to find sAMAccountName: doesnotexist
[*] Auxiliary module execution completed
metasploit-framework.pr (S:0 J:0) auxiliary(admin/ldap/change_password) >
</details>

@smcintyre-r7 smcintyre-r7 merged commit 909476e into rapid7:master Dec 6, 2024
70 checks passed
@smcintyre-r7
Copy link
Contributor

Release Notes

This adds a module that is able to change a user's password knowing the current value or reset a user's password given the necessary permissions using LDAP.

@smcintyre-r7 smcintyre-r7 added the rn-modules release notes for new or majorly enhanced modules label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs module rn-modules release notes for new or majorly enhanced modules
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants