Better lmPwdHistory and ntPwdHistory decryption #1619
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.
/!\ This pull request might be a WIP
This PR has to do with secretsdump and the way it extracts hashed passwords histories
What are the changes I made:
CRYPTED_HASHW16
structure to indicate that the previouslyUnknown
bit is aLength
field for AES decrypted stuff. When decrypting AES encrypted histories (NT and LM), the decrypted blob often has a padding block (16 * \x10), which is DES decrypted and displayed as a hash even though it is not at all ! Using the length field can prevent that (this or removing the 16 * \x10 suffix you can see at the end of the AES decrypted blob);NoLMHash
policy to display or not LM hashes, as this policy does not dictate if LM hashes are present or not in thie lmPwdHistory field.Explainations and context:
I spent a few days fighting against a test environment and extracting many NTDS files with and without the NoLMHash policy, reseting passwords and dumping ntds with my ntdsdotsqlite utility. I found inconsistencies in my software and checked if impacket was impacted because I reused (shame on me) impacket code to decrypt these bits.
I found LM hashes stored in lmPwdHistory that I knew (set myself without the nolmhash policy) that I could not break even with a full
hashcat -i -m3000 -a3 ?a?a?a?a?a?a?a
attack. My conclusions are the following: Wether the NoLmHash policy is set or not, the lmPwdHistory attribute is updated on password change. When the policy is not set, the LM hashed password is added to the history, when the policy is set, random bytes are set and encrypted in the lmPwdHistory. However, when the policy is set, old passwords are not cleared from the history. It means that it is completely possible to find LM hashes encrypted in the lmPwdHistory attribute even though the policy is set. It means that even though th dbcsPwd attribute contains an "empty" hash, the history can contain useful LM hashes.On my way to discover this, I managed to find the few bits I mentioned before (aes encrypted lmpwdhistory attribute, the padding block being treated like an encrypted hash, etc...).
With that knowledge, it is possible to see the following problem : it is impossible to tell wether the lmPwdHistory contains random data (the nolmhash policy is and was always set), or if it contains valid lm hashes. The only way to say is to try and crack them.
Why I put a "warning this is WIP" at the beginning
when using drsuapi and not vss to dump data, it only performs ARC4 decryption and not AES, it seems fishy to me but i don't know how to do the proper changes (lines 2365 to 2378 and 2420 to 2437).
Tell me what you think of all this :-)