Last active
February 25, 2020 06:11
-
-
Save FrankSpierings/fc595088c060d337d95517382bd1ce3f to your computer and use it in GitHub Desktop.
Only want the credentials from pypykatz
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