Exemple #1
0
    def setUp(self):
        self._arch_info = X86ArchitectureInformation(ARCH_X86_MODE_32)

        self._emulator = ReilEmulator(self._arch_info)

        self._asm_parser = X86Parser()
        self._translator = X86Translator()
Exemple #2
0
 def __init__(self, binary):
     self.__binary = binary
     self.__arch_mode = self.__binary.architecture_mode
     self.__arch = X86ArchitectureInformation(self.__arch_mode)
     self.__disassembler = X86Disassembler(architecture_mode=self.__arch_mode)
     self.__translator = X86Translator(architecture_mode=self.__arch_mode)
     self.__bb_builder = BasicBlockBuilder(self.__disassembler, self.__binary.text_section, self.__translator, self.__arch)
Exemple #3
0
 def __init__(self, binary):
     self.__binary = binary
     self.__arch_mode = self.__binary.architecture_mode
     self.__arch = X86ArchitectureInformation(self.__arch_mode)
     self.__disassembler = X86Disassembler(architecture_mode=self.__arch_mode)
     self.__translator = X86Translator(architecture_mode=self.__arch_mode)
     self.__bb_builder = CFGRecoverer(RecursiveDescent(self.__disassembler, self.__binary.text_section,
                                                       self.__translator, self.__arch))
Exemple #4
0
def get_arch(binary):
    if binary.architecture == ARCH_X86:
        return X86ArchitectureInformation(
            architecture_mode=binary.architecture_mode)
    elif binary.architecture == ARCH_ARM:
        return ArmArchitectureInformation(
            architecture_mode=binary.architecture_mode)
    else:
        raise Exception("Architecture not supported.")
Exemple #5
0
    def __init__(self, architecture_mode=ARCH_X86_MODE_32):
        global arch_info, modifier_size

        arch_info = X86ArchitectureInformation(architecture_mode)

        self._cache = {}

        modifier_size["far ptr"] = arch_info.architecture_size
        modifier_size["far"] = arch_info.architecture_size
        modifier_size["ptr"] = arch_info.architecture_size
    def setUp(self):
        self._address_size = 32
        self._parser = ReilParser()
        self._solver = SmtSolver()
        self._translator = SmtTranslator(self._solver, self._address_size)

        self._arch_info = X86ArchitectureInformation(ARCH_X86_MODE_32)

        self._translator.set_arch_alias_mapper(self._arch_info.alias_mapper)
        self._translator.set_arch_registers_size(
            self._arch_info.registers_size)
Exemple #7
0
 def setUp(self):
     self._arch_info = X86ArchitectureInformation(ARCH_X86_MODE_32)
     self._operand_size = self._arch_info.operand_size
     self._memory = MemoryMock()
     self._smt_solver = SmtSolver()
     self._smt_translator = SmtTranslator(self._smt_solver, self._operand_size)
     self._smt_translator.set_arch_alias_mapper(self._arch_info.alias_mapper)
     self._smt_translator.set_arch_registers_size(self._arch_info.registers_size)
     self._disasm = X86Disassembler()
     self._ir_translator = X86Translator()
     self._bb_builder = BasicBlockBuilder(self._disasm, self._memory, self._ir_translator)
Exemple #8
0
    def setUp(self):
        self._arch_info = X86ArchitectureInformation(ARCH_X86_MODE_32)

        self._emulator = ReilEmulator(self._arch_info.address_size)

        self._emulator.set_arch_registers(self._arch_info.registers_gp_all)
        self._emulator.set_arch_registers_size(self._arch_info.registers_size)
        self._emulator.set_reg_access_mapper(self._arch_info.alias_mapper)

        self._asm_parser = X86Parser()
        self._translator = X86Translator()
Exemple #9
0
    def test_emulate_x86_64(self):
        binary = BinaryFile(get_full_path("./samples/bin/loop-simple.x86_64"))
        arch_mode = ARCH_X86_MODE_64
        arch_info = X86ArchitectureInformation(arch_mode)
        ir_emulator = ReilEmulator(arch_info)
        disassembler = X86Disassembler(architecture_mode=ARCH_X86_MODE_64)
        ir_translator = X86Translator(architecture_mode=ARCH_X86_MODE_64)

        emu = Emulator(arch_info, ir_emulator, ir_translator, disassembler)

        emu.load_binary(binary)

        emu.emulate(0x4004d6, 0x400507, {}, None, False)
Exemple #10
0
    def __init__(self, architecture_mode=ARCH_X86_MODE_32):
        super(X86Disassembler, self).__init__()

        arch_mode_map = {
            ARCH_X86_MODE_32: CS_MODE_32,
            ARCH_X86_MODE_64: CS_MODE_64
        }

        self._arch_mode = architecture_mode
        self._arch_info = X86ArchitectureInformation(architecture_mode)

        self._parser = X86Parser(architecture_mode)
        self._disassembler = Cs(CS_ARCH_X86, arch_mode_map[architecture_mode])
Exemple #11
0
    def __init__(self, binary, symbols):
        self.__binary = binary
        self.__arch_mode = self.__binary.architecture_mode
        self.__arch = X86ArchitectureInformation(self.__arch_mode)
        self.__disassembler = X86Disassembler(architecture_mode=self.__arch_mode)
        self.__translator = X86Translator(architecture_mode=self.__arch_mode)
        self.__bb_builder = BasicBlockBuilder(self.__disassembler, self.__binary.text_section, self.__translator, self.__arch)

        self.__container = {}
        self.__symbols = symbols

        self.__symbols_by_addr = {}

        for name, start, end in symbols:
            self.__symbols_by_addr[start] = (name, end)
Exemple #12
0
    def setUp(self):
        self._arch_info = X86ArchitectureInformation(ARCH_X86_MODE_32)

        self._smt_solver = SmtSolver()

        self._smt_translator = SmtTranslator(self._smt_solver,
                                             self._arch_info.address_size)
        self._smt_translator.set_arch_alias_mapper(
            self._arch_info.alias_mapper)
        self._smt_translator.set_arch_registers_size(
            self._arch_info.registers_size)

        self._x86_parser = X86Parser(architecture_mode=ARCH_X86_MODE_32)

        self._x86_translator = X86Translator(
            architecture_mode=ARCH_X86_MODE_32)

        self._code_analyzer = CodeAnalyzer(self._smt_solver,
                                           self._smt_translator,
                                           self._arch_info)
 def setUp(self):
     self._arch_mode = ARCH_X86_MODE_32
     self._arch_info = X86ArchitectureInformation(
         architecture_mode=self._arch_mode)
     self._disassembler = X86Disassembler()
     self._translator = X86Translator()