Codebase list python-lsassy / 4b50090c-8a5a-416a-8fc4-021e922993d6/main lsassy / output / json_output.py
4b50090c-8a5a-416a-8fc4-021e922993d6/main

Tree @4b50090c-8a5a-416a-8fc4-021e922993d6/main (Download .tar.gz)

json_output.py @4b50090c-8a5a-416a-8fc4-021e922993d6/mainraw · history · blame

import json

from lsassy.output import IOutput


class Output(IOutput):
    """
    Return output in json format
    """
    def get_output(self):
        json_output = {}
        for cred in self._credentials:
            if cred["domain"] not in json_output:
                json_output[cred["domain"]] = {}
            if cred["username"] not in json_output[cred["domain"]]:
                json_output[cred["domain"]][cred["username"]] = []
            credential = {
                "password": cred["password"],
                "lmhash": cred["lmhash"],
                "nthash": cred["nthash"],
                "sha1": cred["sha1"]
            }
            if credential not in json_output[cred["domain"]][cred["username"]]:
                json_output[cred["domain"]][cred["username"]].append(credential)
        return json.dumps(json_output)