[secretsdump] Filter foreign users when parsing NTDS.dit#1759
Merged
anadrianmanrique merged 1 commit intoMar 20, 2025
Merged
Conversation
Collaborator
|
thanks for the PR. merging now |
gabrielg5
pushed a commit
that referenced
this pull request
Mar 21, 2025
NtAlexio2
pushed a commit
to NtAlexio2/impacket
that referenced
this pull request
Jul 13, 2025
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.
Hi!
Problem
NTDS.dit files can contain entries relative to principals belonging to other trusted domains (intra- or extra-forest). Naturally, foreign principals passwords are not stored in the local domain's NTDS.dit.
When parsing these files, secretsdump outputs those principals anyway, with an empty password as their NT hash. It would be better to filter them out from the output to not mislead the user (many times I have been surprised at first to see an enabled T0 user with an empty password).
Solution
This PR aims to fix this by filtering out foreign principals based on the value of the
instanceTypeattribute. Through trial and error, I have observed that local principals have the bit0x4("The object is writable on this directory.") enabled in this attribute, while foreign ones do not.Example
This issue can be observed on the GOAD lab, for instance when dumping the NTDS.dit file of the
winterfell.north.sevenkingdoms.localdomain controller. Secretsdump's output will be as such. Note the presence of many foreign principals with an empty password as their NT hash, such as a duplicatedAdministratoruser.After applying this PR, the result is the following. Note that the foreign principals are not present anymore.
One thing to be aware of: when looking at the

instanceTypeattribute of accounts local to this domain on a live DC, we can observe that some of them have theirinstanceTypeattribute empty. However, in the NTDS.dit itself, this value is4as expected:As such, the filtering works correctly.
Cheers!
PS: thanks to @vletoux for https://github.com/vletoux/ADSecrets, very useful when diving into NTDS internals 🙂