From 16b11acf81460bbb4eba37f3a42cd469fbeae25c Mon Sep 17 00:00:00 2001 From: dadevel Date: Wed, 26 Jun 2024 00:07:37 +0200 Subject: [PATCH] chrome: support json output --- pypykatz/dpapi/cmdhelper.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pypykatz/dpapi/cmdhelper.py b/pypykatz/dpapi/cmdhelper.py index abe2c0c..fe64215 100644 --- a/pypykatz/dpapi/cmdhelper.py +++ b/pypykatz/dpapi/cmdhelper.py @@ -1,5 +1,6 @@ from pypykatz.commons.common import UniversalEncoder, hexdump import argparse +import json import platform from pypykatz.dpapi.structures.blob import DPAPI_BLOB @@ -141,6 +142,7 @@ def add_args(self, parser, live_parser): dpapi_chrome_group.add_argument('localstate', help='Local State file') dpapi_chrome_group.add_argument('--logindata', help='Login Data file') dpapi_chrome_group.add_argument('--cookies', help='Cookies file') + dpapi_chrome_group.add_argument('--json', action='store_true', help='Print in JSON format') dpapi_wifi_group = dpapi_subparsers.add_parser('wifi', help='Decrypt Windows WIFI config file') dpapi_wifi_group.add_argument('mkf', help= 'Keyfile generated by the masterkey -o command.') @@ -315,9 +317,15 @@ def run(self, args): res = dpapi.decrypt_all_chrome(db_paths, throw=False) for file_path, url, user, password in res['logins']: - print('file: %s user: %s pass: %s url: %s' % (file_path, user, password, url)) + if args.json: + print(json.dumps(dict(type='login', file=file_path, url=url, user=user, password=password.decode()), cls=UniversalEncoder)) + else: + print('file: %s user: %s pass: %s url: %s' % (file_path, user, password, url)) for file_path, host_key, name, path, value in res['cookies']: - print('file: %s host_key: %s name: %s path: %s value: %s' % (file_path, host_key, name, path, value)) + if args.json: + print(json.dumps(dict(type='cookie', file=file_path, domain=host_key, name=name, path=path, value=value.decode()), cls=UniversalEncoder)) + else: + print('file: %s host_key: %s name: %s path: %s value: %s' % (file_path, host_key, name, path, value)) elif args.dapi_module == 'wifi': dpapi.load_masterkeys(args.mkf) @@ -450,4 +458,4 @@ def run_live(self, args): elif args.livedpapicommand == 'wifi': for wificonfig in dpapi.decrypt_wifi_live(): - print('%s : %s' % (wificonfig['name'], wificonfig['key'])) \ No newline at end of file + print('%s : %s' % (wificonfig['name'], wificonfig['key']))