Skip to content

feat: Compute gMSA AES keys when using --gmsa#1125

Open
Ne0re0 wants to merge 2 commits intoPennyw0rth:mainfrom
Ne0re0:main
Open

feat: Compute gMSA AES keys when using --gmsa#1125
Ne0re0 wants to merge 2 commits intoPennyw0rth:mainfrom
Ne0re0:main

Conversation

@Ne0re0
Copy link

@Ne0re0 Ne0re0 commented Feb 27, 2026

Description

This PR computes both aes128-cts-hmac-sha1-96 and aes256-cts-hmac-sha1-96 keys when using --gmsa with nxc ldap, provided the specified user has ReadGMSAPassword rights over a gMSA account.

This is a re-implementation of the logic from the gMSADumper tool.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Deprecation of feature or functionality
  • This change requires a documentation update
  • This requires a third party update (such as Impacket, Dploot, lsassy, etc)
  • This PR was created with the assistance of AI (list what type of assistance, tool(s)/model(s) in the description)

Setup guide for the review

To test this, you need a user with ReadGMSAPassword rights over a gMSA account. Run:

nxc ldap <target> -u <user> -p <password> --gmsa

Screenshots (if appropriate):

image image image

Checklist:

  • I have run Ruff against my changes (poetry run ruff check ., use --fix to automatically fix what it can)
  • I have added or updated the tests/e2e_commands.txt file if necessary (new modules or features are required to be added to the e2e tests)
  • If reliant on changes of third party dependencies such as Impacket, dploot, lsassy, etc, I have linked the relevant PRs in those projects
  • I have linked relevant sources describing the added technique (blog posts, documentation, etc)
  • I have performed a self-review of my own code (not an AI review)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (PR here: https://github.com/Pennyw0rth/NetExec-Wiki)

@NeffIsBack
Copy link
Member

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:

If you have used AI in any form, please state the tool you used (e.g. Claude Code, Cursor, Amp) along with the extent that the work was AI-assisted. See the project's AI policy for more details: https://github.com/Pennyw0rth/NetExec/blob/main/AI_POLICY.md

ggroup.add_argument("--gmsa-convert-id", help="Get the secret name of specific gmsa or all gmsa if no gmsa provided")
ggroup.add_argument("--gmsa-decrypt-lsa", help="Decrypt the gmsa encrypted value from LSA")

ldap_parser.add_argument(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please put this all on one line


# Allow explicit override for cross-domain/cross-forest enumeration
if getattr(self.args, "target_domain", None):
self.baseDN = ",".join([f"DC={part}" for part in self.args.target_domain.split(".")])
Copy link
Collaborator

Choose a reason for hiding this comment

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

variable naming should by pythonic, e.g. base_dn and target_domain

ntlm_hash = MD4.new()
ntlm_hash.update(currentPassword)
passwd = hexlify(ntlm_hash.digest()).decode("utf-8")
# Compute Kerberos AES keys
Copy link
Collaborator

Choose a reason for hiding this comment

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

This code is used twice but with only one different, it should be functionalized so there isn't the same code in two separate places if that is possible

Copy link
Author

Choose a reason for hiding this comment

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

I factorized as much code as possible and removed duplicated code in the NT hash computation as well :)

@Ne0re0
Copy link
Author

Ne0re0 commented Feb 27, 2026

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?

@NeffIsBack
Copy link
Member

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👍

@NeffIsBack NeffIsBack added the enhancement New feature or request label Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants