Skip to content

Sticky userSID when triaging masterkeys - #45

Open
jsundin wants to merge 1 commit into
GhostPack:masterfrom
jsundin:local-sid-bugfix
Open

jsundin wants to merge 1 commit into
GhostPack:masterfrom
jsundin:local-sid-bugfix

Conversation

@jsundin

@jsundin jsundin commented Nov 5, 2026

Copy link
Copy Markdown

There is a small issue with how the SID is discovered when doing masterkeys triage. As masterkeys triage is used for "regular" triage, it is affected by this as well.

When a SID is not provided by the user and multiple user masterkeys are processed, the userSID variable is assigned to the first discovered SID and will never be reassigned.

This change will instead use a more locally scoped variable for SIDs.

Example output from latest:

C:\Users\Administrator\Documents> cmd.exe /c '.\SharpDPAPI.exe masterkeys /password:thepasswordgoeshere'

[*] Action: User DPAPI Masterkey File Triage

[*] Found MasterKey : C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500\0cfe4c97-8788-41a0-8149-492d06277c71
[*] Found MasterKey : C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500\85213b4a-7840-4c50-b33e-a460b6da236d
[*] Found MasterKey : C:\Users\s.gomez\AppData\Roaming\Microsoft\Protect\S-1-5-21-1442656047-993108804-857766263-1113\f059812c-7f1a-4d18-800d-ee840c56b288

[*] Preferred master keys:

C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500:85213b4a-7840-4c50-b33e-a460b6da236d
C:\Users\s.gomez\AppData\Roaming\Microsoft\Protect\S-1-5-21-1442656047-993108804-857766263-1113:f059812c-7f1a-4d18-800d-ee840c56b288

[!] No master keys decrypted!

If we add logging on userSID we can see it is never reassigned from S-1-5-21-2312049551-2099622528-4211643157-500:

[*] Action: User DPAPI Masterkey File Triage

[+] Using SID: S-1-5-21-2312049551-2099622528-4211643157-500
[+] Using SID: S-1-5-21-2312049551-2099622528-4211643157-500
[+] Using SID: S-1-5-21-2312049551-2099622528-4211643157-500
[*] Found MasterKey : C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500\0cfe4c97-8788-41a0-8149-492d06277c71
[X] Error triaging C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500\0cfe4c97-8788-41a0-8149-492d06277c71 : HMAC integrity check failed!
[*] Found MasterKey : C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500\85213b4a-7840-4c50-b33e-a460b6da236d
[X] Error triaging C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500\85213b4a-7840-4c50-b33e-a460b6da236d : HMAC integrity check failed!
[+] Using SID: S-1-5-21-2312049551-2099622528-4211643157-500
[+] Using SID: S-1-5-21-2312049551-2099622528-4211643157-500
[+] Using SID: S-1-5-21-2312049551-2099622528-4211643157-500
[*] Found MasterKey : C:\Users\s.gomez\AppData\Roaming\Microsoft\Protect\S-1-5-21-1442656047-993108804-857766263-1113\f059812c-7f1a-4d18-800d-ee840c56b288
[X] Error triaging C:\Users\s.gomez\AppData\Roaming\Microsoft\Protect\S-1-5-21-1442656047-993108804-857766263-1113\f059812c-7f1a-4d18-800d-ee840c56b288 : HMAC integrity check failed!

[*] Preferred master keys:

C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500:85213b4a-7840-4c50-b33e-a460b6da236d
C:\Users\s.gomez\AppData\Roaming\Microsoft\Protect\S-1-5-21-1442656047-993108804-857766263-1113:f059812c-7f1a-4d18-800d-ee840c56b288

[!] No master keys decrypted!

With this change applied:

[*] Action: User DPAPI Masterkey File Triage

[*] Found MasterKey : C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500\0cfe4c97-8788-41a0-8149-492d06277c71
[*] Found MasterKey : C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500\85213b4a-7840-4c50-b33e-a460b6da236d
[*] Found MasterKey : C:\Users\s.gomez\AppData\Roaming\Microsoft\Protect\S-1-5-21-1442656047-993108804-857766263-1113\f059812c-7f1a-4d18-800d-ee840c56b288

[*] Preferred master keys:

C:\Users\Administrator\AppData\Roaming\Microsoft\Protect\S-1-5-21-2312049551-2099622528-4211643157-500:85213b4a-7840-4c50-b33e-a460b6da236d
C:\Users\s.gomez\AppData\Roaming\Microsoft\Protect\S-1-5-21-1442656047-993108804-857766263-1113:f059812c-7f1a-4d18-800d-ee840c56b288

[*] User master key cache:

{f059812c-7f1a-4d18-800d-ee840c56b288}:1A74E542C8FD3661940879551B436376F9AE1D31

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.

1 participant