Skip to content

Commit

Permalink
Merge pull request #150 from Signum21/main
Browse files Browse the repository at this point in the history
Add option to get the GUID of the preferred masterkey from the Preferred file
  • Loading branch information
skelsec authored Mar 6, 2024
2 parents 5f14769 + 0d608e5 commit 2878ca4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pypykatz/dpapi/cmdhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def add_args(self, parser, live_parser):
dpapi_minidump_group.add_argument('minidumpfile', help='path to minidump file')
dpapi_minidump_group.add_argument('-o', '--out-file', help= 'Master and Backup keys will be stored in this file. Easier to handle in other commands.')

dpapi_preferredkey_group = dpapi_subparsers.add_parser('preferredkey', help='Get preferred masterkey GUID')
dpapi_preferredkey_group.add_argument('preferredkeyfile', help='path to preferred masterkey file')

dpapi_masterkey_group = dpapi_subparsers.add_parser('masterkey', help='Decrypt masterkey file')
dpapi_masterkey_group.add_argument('masterkeyfile', help='path to masterkey file')
Expand Down Expand Up @@ -210,6 +212,8 @@ def run(self, args):
else:
dpapi.dump_pre_keys()

elif args.dapi_module == 'preferredkey':
dpapi.dump_preferred_masterkey_guid(args.preferredkeyfile)

elif args.dapi_module == 'masterkey':
if args.prekey is None:
Expand Down
9 changes: 9 additions & 0 deletions pypykatz/dpapi/dpapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ def load_prekeys(self, filename):
line = line.strip()
self.prekeys[bytes.fromhex(line)] = 1

def dump_preferred_masterkey_guid(self, filename):
from uuid import UUID

with open(filename, 'rb') as f:
b = f.read()[:16]

guid = UUID(bytes_le = b)
print('[GUID] %s' % guid)

def dump_masterkeys(self, filename = None):
if filename is None:
for x in self.masterkeys:
Expand Down

0 comments on commit 2878ca4

Please sign in to comment.