Skip to content

Instantly share code, notes, and snippets.

@FrankSpierings
Last active February 25, 2020 06:11
Show Gist options
  • Save FrankSpierings/fc595088c060d337d95517382bd1ce3f to your computer and use it in GitHub Desktop.
Save FrankSpierings/fc595088c060d337d95517382bd1ce3f to your computer and use it in GitHub Desktop.
Only want the credentials from pypykatz
import json
filenames = []
def findcred(dictionary):
for k, v in dictionary.items():
if k == 'password' and dictionary['password']:
result = {}
if 'domainname' in dictionary:
result['domainname'] = dictionary['domainname']
if 'username' in dictionary:
result['username'] = dictionary['username']
result['password'] = dictionary['password']
yield result
elif isinstance(v, dict):
for result in findcred(v):
yield result
elif isinstance(v, list):
for d in v:
if isinstance(d, dict):
for result in findcred(d):
yield result
output = []
for filename in filenames:
data = json.load(open(filename))
for cred in findcred(data):
if cred not in output:
print('{domainname} - {username} - {password}'.format(**cred))
output.append(cred)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment