Beispiel #1
0
 def activate(self, ctx):
     tform = idaapi.find_tform('Classes')
     if not tform:
         class_viewer = ClassViewer(classes.ProxyModel(), classes.TreeModel())
         class_viewer.Show()
     else:
         idaapi.switchto_tform(tform, True)
 def create_view(self, bap):
     "creates a new view"
     pid = bap.proc.pid
     name = 'BAP-{0}'.format(pid)
     view = View(name, bap, on_close=lambda: self.delete_view(pid))
     view.instance = bap
     curr = idaapi.get_current_tform()
     self.views[pid] = view
     view.Show()  # pylint: disable=no-member
     idaapi.switchto_tform(curr, True)
Beispiel #3
0
 def create_view(self, bap):
     "creates a new view"
     pid = bap.proc.pid
     name = 'BAP-{0}'.format(pid)
     view = View(name, bap, on_close=lambda: self.delete_view(pid))
     view.instance = bap
     curr = idaapi.get_current_tform()
     self.views[pid] = view
     view.Show()  # pylint: disable=no-member
     idaapi.switchto_tform(curr, True)
Beispiel #4
0
 def activate(self, ctx):
     """
     :param ctx: idaapi.action_activation_ctx_t
     :return:    None
     """
     tform = idaapi.find_tform('Classes')
     if not tform:
         class_viewer = Forms.ClassViewer()
         class_viewer.Show()
     else:
         idaapi.switchto_tform(tform, True)
Beispiel #5
0
def touch_window(target):
    """
    Touch a window/widget/form to ensure it gets drawn by IDA.

    XXX/HACK:

      We need to ensure that widget we will analyze actually gets drawn
      so that there are colors for us to steal.

      To do this, we switch to it, and switch back. I tried a few different
      ways to trigger this from Qt, but could only trigger the full
      painting by going through the IDA routines.

    """

    # get the currently active widget/form title (the form itself seems transient...)
    if using_ida7api:
        twidget = idaapi.get_current_widget()
        title = idaapi.get_widget_title(twidget)
    else:
        form = idaapi.get_current_tform()
        title = idaapi.get_tform_title(form)

    # touch/draw the widget by playing musical chairs
    if using_ida7api:

        # touch the target window by switching to it
        idaapi.activate_widget(target, True)
        flush_ida_sync_requests()

        # locate our previous selection
        previous_twidget = idaapi.find_widget(title)

        # return us to our previous selection
        idaapi.activate_widget(previous_twidget, True)
        flush_ida_sync_requests()

    else:

        # touch the target window by switching to it
        idaapi.switchto_tform(target, True)
        flush_ida_sync_requests()

        # locate our previous selection
        previous_form = idaapi.find_tform(title)

        # lookup our original form and switch back to it
        idaapi.switchto_tform(previous_form, True)
        flush_ida_sync_requests()
Beispiel #6
0
    def OnRefresh(self, n):

        if not self.is_select:
            form_title = "ETM coverage"
            form = idaapi.find_tform(form_title)

            if form != None:
                print "ETM coverage window already open. Switching to it."
                idaapi.switchto_tform(form, True)
                return n

            self.coverage_window = EtmCoverageChoose2(form_title, modal=False)
            self.coverage_window.fill(self.coverage)
            self.coverage_window.show()
            self.callgraph_window = EtmCallGraphViewer(self.callgraph)
            self.callgraph_window.show()

        self.is_select = False
        return n
 def run(arg):
     tform = idaapi.find_tform("Structure Builder")
     if tform:
         idaapi.switchto_tform(tform, True)
     else:
         Forms.StructureBuilder(Helper.temporary_structure).Show()
Beispiel #8
0
def activate_widget(form, active):
    if idaapi.IDA_SDK_VERSION <= 699:
        idaapi.switchto_tform(form, active)
    else:
        ida_kernwin.activate_widget(form, active)
 def activate(self, ctx):
     tform = idaapi.find_tform("Structure Builder")
     if tform:
         idaapi.switchto_tform(tform, True)
     else:
         StructureBuilder(cache.temporary_structure).Show()
 def OnSelectLine(self, n):
     tform = idaapi.open_disasm_window("%s" % self.items[n][3])
     idaapi.switchto_tform(tform, 1)
     idc.Jump(int(self.items[n][4], 16))
Beispiel #11
0
                patch_call_free(addr)

        #patch format vul
        if bfind_puts == True:
            printf_addr = search_printf_instr(func)
            if printf_addr != []:
                for addr in printf_addr:
                    patch_call_printf(addr)

    return


if __name__ == '__main__':
    #清空输出窗口
    form = idaapi.find_tform("Output window")
    idaapi.switchto_tform(form, True)
    idaapi.process_ui_action("msglist:Clear")

    #save to file
    path = os.path.abspath(__file__)
    path = os.path.realpath(__file__)
    path = os.path.dirname(path)

    #
    target_path = idc.GetInputFilePath()
    target_file = idc.GetInputFile()

    if idaapi.init_hexrays_plugin():
        #print("Hex-rays version %s has been detected" % idaapi.get_hexrays_version())
        pass
    else:
Beispiel #12
0
    def run(self, arg):
        if not idaapi.autoIsOk():
            if idaapi.askyn_c(
                    ASKBTN_CANCEL, "HIDECANCEL\n",
                    "The autoanalysis has not finished yet.\n",
                    "The result might be incomplete. Do you want to continue?"
            ) < ASKBTN_NO:
                return

        form_title = "ETM trace"
        form = idaapi.find_tform(form_title)

        if form != None:
            print "ETM trace window already open. Switching to it."
            idaapi.switchto_tform(form, True)
            return

        trace_file_name = idaapi.askfile_c(0, "",
                                           "Select a trace to display...")
        if len(trace_file_name) < 1:
            return

        image_name = idaapi.get_root_filename()

        f = open(trace_file_name, "r")

        #trace format: filename[0] id[1] type[2] description[3] src_addr[4] src_func_offset[5] src_image[6] =>[7] dst_addr[8] dst_func_offset[9] dst_image[10]
        start_branch = f.readline().split()

        if not start_branch:
            return

        while len(start_branch) != 11:
            start_branch = f.readline().split()
            if not start_branch:
                return

        self.c = EtmTraceChoose2(form_title, modal=False)

        self.c.callgraph.append("start")

        while True:
            next_branch = f.readline().split()
            if not next_branch:
                break

            start_branch[10] = start_branch[10].replace("(",
                                                        "").replace(")", "")
            start_branch[6] = start_branch[6].replace("(", "").replace(")", "")

            if start_branch[10].split("/")[-1] != image_name and start_branch[
                    6].split("/")[-1] != image_name:
                start_branch = next_branch
                continue

            if start_branch[10].split("/")[-1] != image_name:
                #to external lib
                self.c.add_jump_to_external(start_branch[1], start_branch[8],
                                            start_branch[10])
                start_branch = next_branch
                continue

            if start_branch[6].split("/")[-1] != image_name:
                #from external lib
                self.c.add_jump_from_external(start_branch[1], start_branch[4],
                                              start_branch[6])

            self.c.add_instruction_range(start_branch[1],
                                         [start_branch[8], next_branch[4]])
            start_branch = next_branch

        self.c.show()
Beispiel #13
0
 def OnSelectLine(self, n):
     tform = idaapi.open_disasm_window("%s" % self.items[n][3])
     idaapi.switchto_tform(tform, 1)
     idc.Jump(int(self.items[n][4], 16))