Skip to content

Fix --user and --enabled filtering for NTDS dump - #1521

Open
CobblePot59 wants to merge 4 commits into
Pennyw0rth:mainfrom
CobblePot59:fix/ntds-user-enabled-filter
Open

CobblePot59 wants to merge 4 commits into
Pennyw0rth:mainfrom
CobblePot59:fix/ntds-user-enabled-filter

Conversation

@CobblePot59

@CobblePot59 CobblePot59 commented Nov 12, 2026 •

Copy link
Copy Markdown

Description

Please include a summary of the change and which issue is fixed, or what the enhancement does.
List any dependencies that are required for this change.

Fix NTDS account filtering across extraction methods:

  • Filter usernames directly in the add_hash callback for all methods, since VSS ignores justUser and dumps every account.
  • Rewrite the .ntds output file to retain only the filtered accounts, as Impacket otherwise writes all accounts regardless of --user or --enabled.
  • Comment out the old grep -iv disabled extraction instructions, as they are now redundant with the --enabled filter.

No new dependency.

AI Assistance

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.

Note that if you have used AI, you:

  • MUST test the changes against a live system
  • MUST include a screenshot of such a test (e.g. with a before and after screenshot when submitting a bug fix)
  • MUST fill out this PR template by hand, see the project's AI policy: AI_POLICY.md

No AI.

Type of change

Insert an "x" inside the brackets for relevant items

  • 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

Please provide guidance on what setup is needed to test the introduced changes, such as the target(s) you tested against or software versions.

In particular:

  • Bug Fix: Please provide a short description on how to trigger the bug, to make the bug reproducable for the reviewer.
  • Added Feature/Enhancement: Please specify what setup is needed in order to test the changes, such as:
    • Is additional software needed?
    • GPO changes required?
    • Specific registry settings that need to be changed?

Test against a Windows DC.

Screenshots (if appropriate):

Screenshots are always nice to have and can give a visual representation of the change.
If appropriate, include before and after screenshot(s) to show which results are to be expected.

Screenshot 2026-11-12 175219

Checklist:

Insert an "x" inside the brackets for completed and relevant items (do not delete options)

  • I have ran Ruff against my changes (poetry: 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 that describes 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)

The VSS method ignores justUser in impacket and dumps every account, so filter by username directly in the add_hash callback for every method. Also rewrite the .ntds output file with the kept lines, since impacket writes all accounts regardless of --user/--enabled.
@github-actions

Copy link
Copy Markdown

It looks like the PR template may not have been filled out. The following sections appear to be missing:

  • Description

  • Type of change

  • Setup guide for the review

  • Checklist

Please edit your PR description to include them. The template helps reviewers understand and test your changes. Thanks!

@mpgn mpgn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the PR! Two points on the output file 👍

Comment thread nxc/protocols/smb.py Resolved
Comment thread nxc/protocols/smb.py Resolved
CobblePot59 and others added 2 commits November 13, 2026 08:19
Co-authored-by: mpgn <5891788+mpgn@users.noreply.github.com>
Signed-off-by: CobblePot59 <38343920+CobblePot59@users.noreply.github.com>
Co-authored-by: mpgn <5891788+mpgn@users.noreply.github.com>
Signed-off-by: CobblePot59 <38343920+CobblePot59@users.noreply.github.com>
@NeffIsBack

Copy link
Copy Markdown
Member

Thanks for the PR, but these sounds like bugs in impacket and should be fixed there and not in NetExec

@CobblePot59

Copy link
Copy Markdown
Author

Thanks for the PR, but these sounds like bugs in impacket and should be fixed there and not in NetExec

It's a Monkey Patch 🙈. I thought it would be easier to implement it here ^^'

@NeffIsBack

Copy link
Copy Markdown
Member

Thanks for the PR, but these sounds like bugs in impacket and should be fixed there and not in NetExec

It's a Monkey Patch 🙈. I thought it would be easier to implement it here ^^'

Naa if we find bugs in the nxc+impacket combination they should rather be fixed at the source :D

@CobblePot59

Copy link
Copy Markdown
Author

Thanks for the PR, but these sounds like bugs in impacket and should be fixed there and not in NetExec

It's a Monkey Patch 🙈. I thought it would be easier to implement it here ^^'

Naa if we find bugs in the nxc+impacket combination they should rather be fixed at the source :D

I'm trying to look at that

@mpgn

mpgn commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

I don't think enabled exist on impacket, so unless you add a new feature there is nothing to fix on impacket 🤔

@CobblePot59

Copy link
Copy Markdown
Author

I don't think enabled exist on impacket, so unless you add a new feature there is nothing to fix on impacket 🤔

No, that’s not in Impacket; I’m just going to look into the part about targeting a specific user, and I’ll provide the link to the Impacket PR.

@CobblePot59

Copy link
Copy Markdown
Author

I don't think enabled exist on impacket, so unless you add a new feature there is nothing to fix on impacket 🤔

No, that’s not in Impacket; I’m just going to look into the part about targeting a specific user, and I’ll provide the link to the Impacket PR.

It's done.
fortra/impacket#2378

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants