Created
March 16, 2020 13:59
-
-
Save OlivierLaflamme/f5473f0d20d542146407d1a2d74278fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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