Skip to content

Commit

Permalink
Merge pull request #160 from dadevel/patch-2
Browse files Browse the repository at this point in the history
chrome: support json output
  • Loading branch information
skelsec authored Jul 21, 2024
2 parents 1571892 + 16b11ac commit 52874ee
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pypykatz/dpapi/cmdhelper.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.')
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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']))
print('%s : %s' % (wificonfig['name'], wificonfig['key']))

0 comments on commit 52874ee

Please sign in to comment.