Beispiel #1
0
def try_decrypt_section(raw_data):
    diagnosis = []

    layers = 0
    while layers < 10:
        # can we load it yet?
        try:
            data, stmts = magic.safe_loads(raw_data, unrpyc.class_factory,
                                           {"_ast", "collections"})
        except Exception:
            pass
        else:
            return data, stmts, diagnosis

        layers += 1
        count = Counter(raw_data)

        for decryptor in DECRYPTORS:
            newdata = decryptor(raw_data, count)
            if newdata is None:
                continue
            else:
                raw_data = newdata
                diagnosis.append("performed a round of %s" %
                                 decryptor.__name__)
                break
        else:
            break

    diagnosis.append("Did not know how to decrypt data.")
    raise ValueError("\n".join(diagnosis))
Beispiel #2
0
def read_ast_from_file(in_file):
    # .rpyc files are just zlib compressed pickles of a tuple of some data and the actual AST of the file
    raw_contents = in_file.read()
    if raw_contents.startswith("RENPY RPC2"):
        # parse the archive structure
        position = 10
        chunks = {}
        while True:
            slot, start, length = struct.unpack("III", raw_contents[position: position + 12])
            if slot == 0:
                break
            position += 12

            chunks[slot] = raw_contents[start: start + length]

        raw_contents = chunks[1]

    raw_contents = raw_contents.decode('zlib')
    data, stmts = magic.safe_loads(raw_contents, class_factory, {"_ast"})
    return stmts
Beispiel #3
0
def read_ast_from_file(in_file):
    # .rpyc files are just zlib compressed pickles of a tuple of some data and the actual AST of the file
    raw_contents = in_file.read()
    if raw_contents.startswith("RENPY RPC2"):
        # parse the archive structure
        position = 10
        chunks = {}
        while True:
            slot, start, length = struct.unpack("III", raw_contents[position: position + 12])
            if slot == 0:
                break
            position += 12

            chunks[slot] = raw_contents[start: start + length]

        raw_contents = chunks[1]

    raw_contents = raw_contents.decode('zlib')
    data, stmts = magic.safe_loads(raw_contents, class_factory, {"_ast"})
    return stmts
Beispiel #4
0
def read_ast_from_file(in_file):
    # .rpyc files are just zlib compressed pickles of a tuple of some data and the actual AST of the file
    raw_contents = in_file.read().decode('zlib')
    data, stmts = magic.safe_loads(raw_contents, class_factory, {"_ast"})
    return stmts
Beispiel #5
0
def read_ast_from_file(in_file):
    # .rpyc files are just zlib compressed pickles of a tuple of some data and the actual AST of the file
    raw_contents = in_file.read().decode('zlib')
    data, stmts = magic.safe_loads(raw_contents, {"_ast"})
    return stmts