コード例 #1
0
ファイル: cbc.py プロジェクト: HallowTeam/HolyLib
 def __init__(self, cipher, size, fn):
     self.fn = fn
     self.dv = []
     self.dvs = []
     self.size = size
     self.cipher = cipher
     self.chunks = split(self.cipher.decode("hex"), self.size)
コード例 #2
0
ファイル: cbc.py プロジェクト: HallowTeam/HolyLib
 def __init__(self, cipher, size, fn):
     self.fn     = fn
     self.dv     = []
     self.dvs    = []
     self.size   = size
     self.cipher = cipher
     self.chunks = split(self.cipher.decode("hex"), self.size)
コード例 #3
0
ファイル: cbc.py プロジェクト: HallowTeam/HolyLib
 def __init__(self, plain, size, fn, iv = None, dv = None, obj = None):
     self.iv     = iv
     self.fn     = fn
     self.dv     = []
     self.dvs    = []
     self.obj    = obj
     self.clue   = dv
     self.size   = size
     self.plain  = plain
     self.chunk  = ""
     self.chunks = split(pad(plain, self.size), self.size)
コード例 #4
0
ファイル: cbc.py プロジェクト: HallowTeam/HolyLib
 def __init__(self, plain, size, fn, iv=None, dv=None, obj=None):
     self.iv = iv
     self.fn = fn
     self.dv = []
     self.dvs = []
     self.obj = obj
     self.clue = dv
     self.size = size
     self.plain = plain
     self.chunk = ""
     self.chunks = split(pad(plain, self.size), self.size)
コード例 #5
0
ファイル: formatstring.py プロジェクト: HallowTeam/HolyLib
def _split(address, value, bits, size, endian):
    """
    Creation des differentes partie du payload
    """
    parts = []
    value = _format(value, bits, endian)
    for i, v in enumerate(split(value, size)):
        parts.append({
            "a": _format(address + i * size, bits, endian),
            "v": v[::-1] if endian else v,
            "i": -1,
        })
    return sorted(parts, key = lambda x: x["v"])
コード例 #6
0
ファイル: xor.py プロジェクト: HallowTeam/HolyLib
    def analyze(self, keylen, filters=None):
        """
        Analyze du xor pour une clef de longueur @keylen

        @filters = dict[index]{
            "charset": [], # Charset autorise pour l'index
            "exclude": [], # Lettres non autorise pour l'index
        }
        """
        self.errno = -1
        self.keylen = keylen
        self.chunks = split(self.cipher, self.keylen)
        self.charset = set()
        self.ignores = set()
        self.matches = [{} for i in xrange(self.keylen)]
        for i in xrange(self.keylen):
            for k in self.keyset:
                if not self.skip(i, k, filters):
                    match = False
                    chars = []
                    charset = set()
                    for chunk in self.chunks:
                        if i >= len(chunk):
                            break
                        c = xor(chunk[i], k)
                        if not c in self.textset:
                            match = False
                            self.ignores |= set(c)
                            break
                        match = True
                        charset |= set(c)
                        chars.append(c)
                    if match:
                        self.charset |= charset
                        self.matches[i][k] = {
                            "chars": chars,
                            "charset": charset,
                        }
            if len(self.matches[i]) == 0:
                self.errno = i
                break
コード例 #7
0
ファイル: xor.py プロジェクト: HallowTeam/HolyLib
    def analyze(self, keylen, filters = None):
        """
        Analyze du xor pour une clef de longueur @keylen

        @filters = dict[index]{
            "charset": [], # Charset autorise pour l'index
            "exclude": [], # Lettres non autorise pour l'index
        }
        """
        self.errno   = -1
        self.keylen  = keylen
        self.chunks  = split(self.cipher, self.keylen)
        self.charset = set()
        self.ignores = set()
        self.matches = [{} for i in xrange(self.keylen)]
        for i in xrange(self.keylen):
            for k in self.keyset:
                if not self.skip(i, k, filters):
                    match   = False
                    chars   = []
                    charset = set()
                    for chunk in self.chunks:
                        if i >= len(chunk):
                            break
                        c = xor(chunk[i], k)
                        if not c in self.textset:
                            match         = False
                            self.ignores |= set(c)
                            break
                        match    = True
                        charset |= set(c)
                        chars.append(c)
                    if match:
                        self.charset      |= charset
                        self.matches[i][k] = {
                            "chars"   : chars,
                            "charset" : charset,
                        }
            if len(self.matches[i]) == 0:
                self.errno = i
                break
コード例 #8
0
def btos(b):
    """bytes to string"""
    return "".join([c[2:].decode("hex") for c in split(b, 4)])