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

Windows Secrets Dump: Enable inline credentials dump #19048

Merged
5 commits merged into from May 1, 2024

Conversation

cdelafuente-r7
Copy link
Contributor

@cdelafuente-r7 cdelafuente-r7 commented Apr 2, 2024

This improves the Windows Secrets Dump module by retrieving the credentials without touching the disk. This is based on this Impacket PR.

This technique takes advantage of the WriteDACL privileges held by local administrators to set temporary read permissions on the SAM and SECURITY registry hives. With this, it is not necessary to write these hives to disk and parse them, like it was with the original implementation.

This technique is enabled by default and can be disable by setting the INLINE option to false.

The logic has been delegated to a new class Msf::Util::WindowsRegistry::RemoteRegistry, which takes care of setting the registry key security descriptor (DACL) to give enough permission to read it. It also takes care of restoring the original security descriptor immediately after the read operation. It also takes care of backing it up to a local file in case the restoring operation fails for some reason. The user will be able to restore it manually using a separate module, which will be added soon.

⚠️ Important ⚠️
These changes need this RubySMB related PR to be landed to work.

Verification

List the steps needed to make sure this thing works

  • Start msfconsole
  • use auxiliary/gather/windows_secrets_dump
  • run rhost=<remote host> smbuser=<username> smbpass=<user's password> verbose=true
  • Verify the security descriptor is correctly set on the registry keys
  • Verify the SAM and SECURITY hives are read correctly and the module retrieves the credentials the same way it does without this technique
  • Verify the original unmodified security descriptor are correctly restored on the registry keys. This can be observed in the MSF logs.
  • Re-run the module with inline=false
  • Verify the results are the same as with the inline technique enabled

@smcintyre-r7 smcintyre-r7 self-assigned this Apr 2, 2024
@cdelafuente-r7 cdelafuente-r7 marked this pull request as ready for review April 19, 2024 14:26
@cdelafuente-r7 cdelafuente-r7 added the blocked Blocked by one or more additional tasks label Apr 19, 2024
lib/msf/util/windows_registry/remote_registry.rb Outdated Show resolved Hide resolved
lib/msf/util/windows_registry/remote_registry.rb Outdated Show resolved Hide resolved
lib/msf/util/windows_registry/remote_registry.rb Outdated Show resolved Hide resolved
lib/msf/util/windows_registry/remote_registry.rb Outdated Show resolved Hide resolved
@smcintyre-r7 smcintyre-r7 removed the blocked Blocked by one or more additional tasks label Apr 26, 2024
@cdelafuente-r7
Copy link
Contributor Author

Thanks @smcintyre-r7 for your review. I believe I answered to all your comments and made the requested changes.

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 just finished testing the latest changes and everything appears to be working correctly. I checked running the module with the INLINE option both enabled and disabled. Each time, I confirmed with process monitor that the temporary file was online written when INLINE=false.

I think this is ready to go.

- This will bring in the GetKeySecurity and SetKeySecurity MS-RRP structures
@smcintyre-r7 smcintyre-r7 closed this pull request by merging all changes into rapid7:master in a98554a May 1, 2024
@smcintyre-r7
Copy link
Contributor

Release Notes

This updates the windows_secrets_dump module to enable accessing the necessary registry data without writing it to disk first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants