Ejemplo n.º 1
0
    def __translate(self, asm_instrs):
        instr_container = ReilContainer()

        asm_instr_last = None
        instr_seq_prev = None

        for asm_instr in asm_instrs:
            instr_seq = ReilSequence()

            for reil_instr in self._translator.translate(asm_instr):
                instr_seq.append(reil_instr)

            if instr_seq_prev:
                instr_seq_prev.next_sequence_address = instr_seq.address

            instr_container.add(instr_seq)

            instr_seq_prev = instr_seq

        if instr_seq_prev:
            if asm_instr_last:
                instr_seq_prev.next_sequence_address = (
                    asm_instr_last.address + asm_instr_last.size) << 8

        # instr_container.dump()

        return instr_container
Ejemplo n.º 2
0
    def __translate(self, asm_instrs):
        instr_container = ReilContainer()

        asm_instr_last = None
        instr_seq_prev = None

        for asm_instr in asm_instrs:
            instr_seq = ReilSequence()

            for reil_instr in self._translator.translate(asm_instr):
                instr_seq.append(reil_instr)

            if instr_seq_prev:
                instr_seq_prev.next_sequence_address = instr_seq.address

            instr_container.add(instr_seq)

            instr_seq_prev = instr_seq

        if instr_seq_prev:
            if asm_instr_last:
                instr_seq_prev.next_sequence_address = (asm_instr_last.address + asm_instr_last.size) << 8

        # instr_container.dump()

        return instr_container
Ejemplo n.º 3
0
    def __build_reil_container(self, asm_instr):
        reil_translator = self.ir_translator

        container = ReilContainer()
        instr_seq = ReilSequence()

        for reil_instr in reil_translator.translate(asm_instr):
            instr_seq.append(reil_instr)

        container.add(instr_seq)

        return container
Ejemplo n.º 4
0
    def build(self, functions):
        reil_container = ReilContainer()

        for _, start, end in functions:
            bbs, _ = self.__bb_builder.build(start, end)

            cfg = ControlFlowGraph(bbs)

            reil_container = self.__translate_cfg(cfg, reil_container=reil_container)

        return reil_container
Ejemplo n.º 5
0
    def __translate_cfg(self, cfg, reil_container=None):
        if not reil_container:
            reil_container = ReilContainer()

        asm_instrs = []

        for bb in cfg.basic_blocks:
            for dual_instr in bb:
                asm_instrs += [dual_instr.asm_instr]

        reil_container = self.__translate(asm_instrs, reil_container)

        return reil_container