Esempio n. 1
0
    def visit_expr(self, cexpr):
        if self._skip:
            if self._is_initial_object(cexpr):
                self._skip = False
            else:
                return 0

        if cexpr.op != idaapi.cot_asg:
            return 0

        x_cexpr = cexpr.x
        if cexpr.y.op == idaapi.cot_cast:
            y_cexpr = cexpr.y.x
        else:
            y_cexpr = cexpr.y

        for obj in self._objects:
            if obj.is_target(x_cexpr):
                if self.__is_object_overwritten(x_cexpr, obj, y_cexpr):
                    logger.info("Removed object {} from scanning at {}".format(
                        obj, to_hex(self._find_asm_address(x_cexpr))))
                    self._objects.remove(obj)
                return 0
            elif obj.is_target(y_cexpr):
                new_obj = ScanObject.create(self._cfunc, x_cexpr)
                if new_obj:
                    self._objects.append(new_obj)
                return 0
        return 0
Esempio n. 2
0
    def _manipulate(self, cexpr, obj):
        """
        Method called for every object having assignment relationship with starter object. This method should be
        reimplemented in order to do something useful

        :param cexpr: idaapi_cexpr_t
        :param id: one of the SO_* constants
        :return: None
        """
        logger.debug("Expression {} at {} Id - {}".format(
            cexpr.opname, to_hex(self._find_asm_address(cexpr)), obj.id))
Esempio n. 3
0
    def _recursive_process(self):
        super(RecursiveObjectDownwardsVisitor, self)._recursive_process()

        while self._new_for_visit:
            func_ea, arg_idx = self._new_for_visit.pop()
            if is_imported_ea(func_ea):
                continue
            cfunc = decompile_function(func_ea)
            if cfunc:
                assert arg_idx < len(
                    cfunc.get_lvars()), "Wrong argument at func {}".format(
                        to_hex(func_ea))
                obj = VariableObject(cfunc.get_lvars()[arg_idx], arg_idx)
                self.prepare_new_scan(cfunc, arg_idx, obj)
                self._recursive_process()
 def __manipulate(self, cexpr, obj):
     logger.debug("Expression {} at {} Id - {}".format(
         cexpr.opname, to_hex(self._find_asm_address(cexpr)), obj.id))