Skip to content

Instantly share code, notes, and snippets.

@OlivierLaflamme
Created March 16, 2020 13:59
Show Gist options
  • Save OlivierLaflamme/f5473f0d20d542146407d1a2d74278fc to your computer and use it in GitHub Desktop.
Save OlivierLaflamme/f5473f0d20d542146407d1a2d74278fc to your computer and use it in GitHub Desktop.
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