feat: Compute gMSA AES keys when using --gmsa#1125
Conversation
|
Hi and thanks for the PR. Nice idea, but what is 988131e about? Please also elaborate the use of AI, as requested in the PR template: |
|
Hi! Oops, I didn't realize commits to the same branch would sync directly to this PR. Sorry about that... The extra changes were entirely claude coded and not meant to be included. I'll revert it back to the first commit. Would you prefer a fresh PR or should we continue with this one? |
Absolutely fine to continue on in here👍 |
|
Hey! I pr'ed an gmsadump script to impacket and I think it might be helpful for this :3 fortra/impacket#2171 We can simply use the generate_kerberos_keys() from impacket.krb5.crypto function to get the ntlm, aes128 and aes256 creds from the password blob |
|
This would be awesome to have :) Anything I can do to help get this merged? |
You could try if it would make sense to integrate the |
o/, Shouldn't we wait for the @ThatTotallyRealMyth's PR to be merged? |
The generate_kerberos_keys function lives in impacket, and not my PR. You could simply call it directly right now and get the nt hash and aes keys directly without adding custom logic |
NeffIsBack
left a comment
There was a problem hiding this comment.
Implemented the compute_kerberos_keys(), LGTM now:
@mpgn any chance you still have a deployed GMSA that you could try to manually decrypt? It should work but I haven't tested it.
|
@Marshall-Hallenbeck we also need your feedback, there is still a pending change request |
There was a problem hiding this comment.
Pull request overview
This PR extends the LDAP gMSA enumeration/decryption functionality to compute Kerberos AES128/AES256 keys (in addition to the existing RC4/NTLM-derived key) when --gmsa is used, reusing Impacket Kerberos key derivation.
Changes:
- Added Kerberos key derivation via
impacket.krb5.crypto.generate_kerberos_keysand introduced a helper to compute RC4/AES keys frommsDS-ManagedPassworddata. - Updated
--gmsaoutput to include AES128/AES256 keys when readable. - Updated
--gmsa-decrypt-lsato reuse the same key derivation logic and switched the LDAP search to the wrapperself.search().
Comments suppressed due to low confidence (1)
nxc/protocols/ldap.py:1404
- This debug log reports
len(gmsa_accounts)(raw LDAP response entries), which can include non-entry records (e.g., references) and will be inconsistent with other methods in this file that log parsed entry counts. Consider logginglen(gmsa_accounts_parsed)instead for an accurate record count.
gmsa_accounts_parsed = parse_result_attributes(gmsa_accounts)
if gmsa_accounts_parsed:
self.logger.debug(f"Total of records returned {len(gmsa_accounts):d}")
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Description
This PR computes both
aes128-cts-hmac-sha1-96andaes256-cts-hmac-sha1-96keys when using--gmsawithnxc ldap, provided the specified user hasReadGMSAPasswordrights over a gMSA account.This is a re-implementation of the logic from the gMSADumper tool.
Type of change
Setup guide for the review
To test this, you need a user with
ReadGMSAPasswordrights over a gMSA account. Run:Screenshots (if appropriate):
Checklist:
poetry run ruff check ., use--fixto automatically fix what it can)tests/e2e_commands.txtfile if necessary (new modules or features are required to be added to the e2e tests)