예제 #1
0
 def _activate(self, ctx):
     if lca_plugin._lca_viewer:
         with ignored(KeyError):
             lca_plugin._lca_viewer.add_target(ctx.cur_ea)
             lca_plugin._lca_viewer.rebuild_graph()
             idaapi.msg("[LCA] Target Added: {}\n".format(
                 idc.Name(ctx.cur_ea)))
예제 #2
0
파일: enum.py 프로젝트: 453483289/Sark
def add_enum(name=None, index=None, flags=idaapi.hexflag(), bitfield=False):
    """Create a new enum.

    Args:
        name: Name of the enum to create.
        index: The index of the enum. Leave at default to append the enum as the last enum.
        flags: Enum type flags.
        bitfield: Is the enum a bitfield.

    Returns:
        An `Enum` object.
    """
    if name is not None:
        with ignored(exceptions.EnumNotFound):
            _get_enum(name)
            raise exceptions.EnumAlreadyExists()

    if index is None or index < 0:
        index = idaapi.get_enum_qty()

    eid = idaapi.add_enum(index, name, flags)

    if eid == idaapi.BADADDR:
        raise exceptions.EnumCreationFailed('Failed creating enum "{}"'.format(name))

    if bitfield:
        idaapi.set_enum_bf(eid, bitfield)

    return Enum(eid=eid)
예제 #3
0
def add_enum(name=None, index=None, flags=idaapi.hexflag(), bitfield=False):
    """Create a new enum.

    Args:
        name: Name of the enum to create.
        index: The index of the enum. Leave at default to append the enum as the last enum.
        flags: Enum type flags.
        bitfield: Is the enum a bitfield.

    Returns:
        An `Enum` object.
    """
    if name is not None:
        with ignored(exceptions.EnumNotFound):
            _get_enum(name)
            raise exceptions.EnumAlreadyExists()

    if index is None or index < 0:
        index = idaapi.get_enum_qty()

    eid = idaapi.add_enum(index, name, flags)

    if eid == idaapi.BADADDR:
        raise exceptions.EnumCreationFailed(
            'Failed creating enum "{}"'.format(name))

    if bitfield:
        idaapi.set_enum_bf(eid, bitfield)

    return Enum(eid=eid)
예제 #4
0
파일: DIE.py 프로젝트: waders909/DIE
    def term(self):
        with ignored(AttributeError):
            if not self.die_manager.die_db.is_saved:
                response = idc.AskYN(1, "DIE DB was not saved, Would you like to save it now?")
                if response == 1:
                    self.die_manager.save_db()

            self.die_manager.del_menu_items()
예제 #5
0
    def run(self):
        with ignored(sark.exceptions.SarkNoFunction):
            current_func = sark.Function()
            if current_func != self.last_func:
                highlight_calls_in_function(current_func.startEA)
            self.last_func = current_func

        return self.interval
예제 #6
0
파일: DIE.py 프로젝트: 453483289/DIE
    def term(self):
        with ignored(AttributeError):
            if not self.die_manager.die_db.is_saved:
                response = idc.AskYN(1, "DIE DB was not saved, Would you like to save it now?")
                if response == 1:
                    self.die_manager.save_db()

            self.die_manager.del_menu_items()
예제 #7
0
def show_function_strings(function):
    idaapi.msg("\n\nString References in {}:0x{:08X}\n".format(function.name, function.startEA))
    idaapi.msg("From          To            String\n")

    for xref in function.xrefs_from:
        with ignored(sark.exceptions.SarkNoString):
            string = sark.get_string(xref.to)
            # Trim the string for easier display
            string = string[:100]

            idaapi.msg("0x{:08X}    0x{:08X}    {}\n".format(xref.frm, xref.to, repr(string)))
예제 #8
0
    def _make_function_ea_item(self, function_context):
        """
        Build a tree item for a function_ea node (level-1)
        @param function_context: a dbFunction_Context object
        @return: QStandradItemModel item for the function context
        """
        calling_function_start = None
        with ignored(sark.exceptions.SarkNoFunction):
            calling_function_start = sark.Function(
                function_context.calling_ea).startEA

        if calling_function_start is not None:
            call_offset = function_context.calling_ea - calling_function_start
            func_ea_txt = "%s+%s" % (function_context.calling_func_name,
                                     hex(call_offset))
        else:
            func_ea_txt = "[%s]:%s" % (function_context.calling_func_name,
                                       hex(function_context.calling_ea))

        item_func_context_ea = QtGui.QStandardItem(func_ea_txt)
        item_func_context_ea.setEditable(False)
        item_func_context_ea.setData(hex(function_context.calling_ea),
                                     role=QtCore.Qt.ToolTipRole)
        item_func_context_ea.setData(function_context,
                                     role=DIE.UI.FunctionContext_Role)
        item_func_context_ea.setData(
            id(function_context),
            role=DIE.UI.ContextId_Role)  # Used for module look-ups

        item_func_is_indirect = QtGui.QStandardItem()
        item_func_is_indirect.setEditable(False)
        if function_context.is_indirect:
            item_func_is_indirect.setIcon(self.die_icons.icon_v)

        item_func_is_new = QtGui.QStandardItem()
        item_func_is_new.setEditable(False)
        if function_context.is_new_func:
            item_func_is_new.setIcon(self.die_icons.icon_v)

        item_list = [
            item_func_context_ea,
            QtGui.QStandardItem(), item_func_is_indirect, item_func_is_new,
            QtGui.QStandardItem(),
            QtGui.QStandardItem(),
            QtGui.QStandardItem(),
            QtGui.QStandardItem(),
            QtGui.QStandardItem(),
            QtGui.QStandardItem()
        ]

        return item_list
예제 #9
0
파일: enum.py 프로젝트: boogie1337/Sark
def add_enum(name=None, index=idaapi.BADADDR, flags=idaapi.hexflag(), bitfield=False):
    """Create a new enum."""
    if name is not None:
        with ignored(exceptions.EnumNotFound):
            _get_enum(name)
            raise exceptions.EnumAlreadyExists()

    eid = idaapi.add_enum(index, name, flags)

    if eid == idaapi.BADADDR:
        raise exceptions.EnumCreationFailed('Failed creating enum "{}"'.format(name))

    if bitfield:
        idaapi.set_enum_bf(eid, bitfield)

    return Enum(eid=eid)
예제 #10
0
    def _make_function_ea_item(self, function_context):
        """
        Build a tree item for a function_ea node (level-1)
        @param function_context: a dbFunction_Context object
        @return: QStandradItemModel item for the function context
        """
        calling_function_start = None
        with ignored(sark.exceptions.SarkNoFunction):
            calling_function_start = sark.Function(function_context.calling_ea).startEA

        if calling_function_start is not None:
            call_offset = function_context.calling_ea - calling_function_start
            func_ea_txt = "%s+%s" % (function_context.calling_func_name, hex(call_offset))
        else:
            func_ea_txt = "[%s]:%s" % (function_context.calling_func_name, hex(function_context.calling_ea))

        item_func_context_ea = QtGui.QStandardItem(func_ea_txt)
        item_func_context_ea.setEditable(False)
        item_func_context_ea.setData(hex(function_context.calling_ea), role=QtCore.Qt.ToolTipRole)
        item_func_context_ea.setData(function_context, role=DIE.UI.FunctionContext_Role)
        item_func_context_ea.setData(id(function_context), role=DIE.UI.ContextId_Role)  # Used for module look-ups

        item_func_is_indirect = QtGui.QStandardItem()
        item_func_is_indirect.setEditable(False)
        if function_context.is_indirect:
            item_func_is_indirect.setIcon(self.die_icons.icon_v)

        item_func_is_new = QtGui.QStandardItem()
        item_func_is_new.setEditable(False)
        if function_context.is_new_func:
            item_func_is_new.setIcon(self.die_icons.icon_v)

        item_list = [item_func_context_ea,
                     QtGui.QStandardItem(),
                     item_func_is_indirect,
                     item_func_is_new,
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem(),
                     QtGui.QStandardItem()]

        return item_list
예제 #11
0
def _try_get_function_start(ea):
    with ignored(exceptions.SarkNoFunction):
        return sark.Function(ea).startEA

    return ea
예제 #12
0
    def updating_actions(self, ctx):
        if ctx.form_type == idaapi.BWN_DISASM:
            with ignored(sark.exceptions.SarkNoFunction):
                self.lines.update(highlight_calls_in_function(ctx.cur_ea))

        return super(UiHooks, self).updating_actions(ctx)
    def updating_actions(self, ctx):
        if ctx.form_type == idaapi.BWN_DISASM:
            with ignored(sark.exceptions.SarkNoFunction):
                self.lines.update(highlight_calls_in_function(ctx.cur_ea))

        return super(UiHooks, self).updating_actions(ctx)
예제 #14
0
파일: lca.py 프로젝트: danse-macabre/Sark
 def _activate(self, ctx):
     if lca_plugin._lca_viewer:
         with ignored(KeyError):
             lca_plugin._lca_viewer.add_target(ctx.cur_ea)
             lca_plugin._lca_viewer.rebuild_graph()
             idaapi.msg("[LCA] Target Added: {}\n".format(idc.Name(ctx.cur_ea)))
예제 #15
0
def _try_get_function_start(ea):
    with ignored(exceptions.SarkNoFunction):
        return sark.Function(ea).startEA

    return ea