Add gMSA abuse module for discovery and exploitation#1216
Open
goosvorbook wants to merge 4 commits intoPennyw0rth:mainfrom
Open
Add gMSA abuse module for discovery and exploitation#1216goosvorbook wants to merge 4 commits intoPennyw0rth:mainfrom
goosvorbook wants to merge 4 commits intoPennyw0rth:mainfrom
Conversation
This module allows for the discovery and exploitation of gMSA accounts by checking write rights on the msDS-GroupMSAMembership attribute. It provides functionality to enumerate gMSA objects and grant read access to their passwords. Signed-off-by: Goos <23636293+goosvorbook@users.noreply.github.com>
Signed-off-by: Goos <23636293+goosvorbook@users.noreply.github.com>
Member
|
Hey and thanks for the PR! Definitely looks cool. Ima have to think about if we maybe could/should integrate it with the existing |
Member
|
You should read and review the code yourself at least once tho. Also, did you or the AI wrote the PR description? Could you include screenshots of a working example? |
Signed-off-by: Goos <23636293+goosvorbook@users.noreply.github.com>
Signed-off-by: Goos <23636293+goosvorbook@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a new LDAP module
gmsa_abusethat detects and exploits write rights on Group Managed Service Account (gMSA) objects to extract NT hashes.NetExec already supports dumping gMSA passwords via
--gmsa, but this requires the authenticated user to already be listed inmsDS-GroupMSAMembership. This module covers the preceding step: discovering which principals have write rights on gMSA objects and exploiting those rights to grant themselves read access to the managed password.Background: When a principal holds
GenericWrite(or similar write rights) on a gMSA object in Active Directory, they can overwrite themsDS-GroupMSAMembershipattribute — a security descriptor that controls who may read the gMSA's managed password. By replacing this SD with one that grants themselves access, the attacker can readmsDS-ManagedPasswordand recover the NT hash.Module actions:
ACTION=find(default) — Enumerates all gMSA objects, reads theirnTSecurityDescriptorvia DACL control, and reports non-privileged trustees withGenericAll,GenericWrite,WriteDACL,WriteOwner,WriteProperties, or targetedWritePropertyonmsDS-GroupMSAMembership. Results are deduplicated per trustee; built-in privileged groups are filtered automatically. Optionally filtered byPRINCIPAL=<account>.ACTION=exploit— GivenTARGET=<gMSA>andPRINCIPAL=<account>, patchesmsDS-GroupMSAMembershipto grant the principal read access, readsmsDS-ManagedPassword, outputs the NT hash in secretsdump format, and restores the original SD (or removes the attribute if it was absent before patching).No new dependencies — uses impacket (
ldaptypes,MODIFY_REPLACE,MODIFY_DELETE), ldap3 (security_descriptor_control), andCryptodome.Hash.MD4, all already required by NetExec.Technique references:
AI assistance: This module was developed with Claude Code (claude-sonnet-4-6). The module architecture, DACL parsing logic, security descriptor construction, and restore behaviour were designed and implemented collaboratively. The module was validated through live testing against a Windows Server 2019 domain controller. No independent manual code review was performed by the author.
Type of change
Setup guide for the review
Attacker environment: Kali Linux, Python 3.11, NetExec run from source (
pip install -e .)Target: Windows Server 2019 (Build 17763), domain functional level 2016
AD setup required:
GenericWriteon the gMSA object (via ADSI Edit orSet-Acl)Test commands:
Expected output (find):
Expected output (exploit):
Checklist
ruff check nxc/modules/gmsa_abuse.py→All checks passed!)tests/e2e_commands.txtfile if necessary