# Path: DPAPI/Core/blob.py
# class DPAPIBlob(eater.DataStruct):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def decrypt(self, masterkey, entropy=None, strongPassword=None):
#     def __repr__(self):


from DPAPI.probe import DPAPIProbe
from DPAPI.Core import blob
from collections import defaultdict

class RDPFile(DPAPIProbe):

    def parse(self, data):
        self.cleartext = None
        self.dpapiblob = None
        self.entropy = None
        self.values = defaultdict(lambda: None)

    def preprocess(self, **k):
        s = []
        if k.get('file') != None:
            f = open(k['file'], "r")
            s = f.read().split("\n")
            f.close()
        elif k.get('content') != None:
            s = k['content'].split("\n")
        for l in s:
            (n,t,v) = l.split(":", 3)
            v = v.rstrip()
            if t == 'i':
                v = int(v)
            elif t == 'b':
                if len(v) & 1 == 1:
                    ## if odd length, strip the last quartet which should be a
                    ## useless "0"
                    v = v[:-1]
                v = v.decode('hex')
            self.values[n] = v
            if self.values['password 51'] != None:

# Path: DPAPI/Core/blob.py
# class DPAPIBlob(eater.DataStruct):
#     def __init__(self, raw=None):
#     def parse(self, data):
#     def decrypt(self, masterkey, entropy=None, strongPassword=None):
#     def __repr__(self):


# Path: DPAPI/Probes/RDP.py
from DPAPI.probe import DPAPIProbe
from DPAPI.Core import blob
from collections import defaultdict


class RDPFile(DPAPIProbe):

    def parse(self, data):
        self.cleartext = None
        self.dpapiblob = None
        self.entropy = None
        self.values = defaultdict(lambda: None)

    def preprocess(self, **k):
        s = []
        if k.get('file') != None:
            f = open(k['file'], "r")
            s = f.read().split("\n")
            f.close()
        elif k.get('content') != None:
            s = k['content'].split("\n")
        for l in s:
            (n,t,v) = l.split(":", 3)
            v = v.rstrip()
            if t == 'i':
                v = int(v)
            elif t == 'b':
                if len(v) & 1 == 1:
                    ## if odd length, strip the last quartet which should be a
                    ## useless "0"
                    v = v[:-1]
                v = v.decode('hex')
            self.values[n] = v
            if self.values['password 51'] != None:

                self.dpapiblob = blob.DPAPIBlob(self.values['password 51'])