Exemplo n.º 1
0
 def trackRegister(self): 
     highlighted = idaversion.getHighlight()
     if highlighted is None  or not self.isReg(highlighted):
        print('%s not in reg list' % highlighted)
        print('%s' % str(self.reg_list))
        return
        c=idaapi.Choose([], "back track to source of selected register", 1)
        c.width=50
        c.list = self.reg_list
        chose = c.choose()
        if chose == 0:
            print('user canceled')
            return
        else:
            highlighted = self.reg_list[chose-1]
     print 'backtrack to source of to %s...' % highlighted
     command = "@cgc.revTaintReg('%s')" % highlighted
     simicsString = gdbProt.Evalx('SendGDBMonitor("%s");' % command)
     print('trackRegister got simicsString %s' % simicsString)
     eip = None
     if self.checkNoRev(simicsString):
         eip = gdbProt.getEIPWhenStopped()
         self.signalClient()
     else:
         return
     curAddr = idaversion.get_reg_value(self.PC)
     print('Current instruction (0x%x) is as far back as we can trace reg %s' % (curAddr, highlighted))
     self.showSimicsMessage()
     bookmark_list = self.bookmark_view.updateBookmarkView()
     return eip
Exemplo n.º 2
0
 def chooseBookmark(self): 
     c=idaapi.Choose([], "select a bookmark", 1, deflt=self.recent_bookmark)
     c.width=50
     command = '@cgc.listBookmarks()'
     simicsString = gdbProt.Evalx('SendGDBMonitor("%s");' % command)
     #print lines
     lines = simicsString.split('\n')
     for l in lines:
         if ':' in l:
             #print l
             num, bm = l.split(':',1)
             c.list.append(bm.strip())
     chose = c.choose()
     if chose != 0:
         self.recent_bookmark = chose
         self.goToBookmarkRefresh(c.list[chose-1])
     else:
         print('user canceled')
Exemplo n.º 3
0
    def OnCommand(self, cmd_id):
        try:
            cmd = self.commands[cmd_id]
            if cmd == "refresh":
                self.Refresh()
            elif cmd == "hide":
                l = {}
                i = 0
                for x in self.nodes:
                    name = idc.GetFunctionName(int(x))
                    if name and name != "":
                        l[i] = name
                        i += 1
                for x in self.hidden:
                    name = idc.GetFunctionName(int(x))
                    if name and name != "":
                        l[i] = name
                        i += 1

                chooser = idaapi.Choose([], "Show/Hide functions", 3)
                chooser.width = 50
                chooser.list = l
                c = chooser.choose()

                if c:
                    c = c - 1
                    c = idc.LocByName(l[c])

                    if c in self.hidden:
                        self.hidden.remove(c)
                    else:
                        self.hidden.append(c)
                    self.Refresh()
            elif cmd == "unhide":
                self.hidden = []
                self.Refresh()
            elif cmd == "strings":
                self.show_string = not self.show_string
                self.Refresh()
            elif cmd == "apis":
                self.show_runtime_functions = not self.show_runtime_functions
                self.Refresh()
            elif cmd == "recursion":
                num = idc.AskLong(self.max_level, "Maximum recursion level")
                if num:
                    self.max_level = num
                    self.Refresh()
            elif cmd == "open":
                g = self.mynav.showSavedGraphs()
                if g:
                    nodes, hidden = self.mynav.loadSavedGraphNodes(g)
                    name, ea, level, strings, runtime = self.mynav.loadSavedGraphData(
                        g)
                    self.title = name
                    self.father = ea
                    self.max_level = level
                    self.show_runtime_functions = runtime
                    self.show_string = strings
                    self.hidden = hidden
                    self.result = nodes
                    self.Refresh()
            elif cmd == "save":
                self.mynav.saveGraph(self.father, self.max_level, self.show_runtime_functions, \
                                     self.show_string, self.hidden, self.result)
        except:
            print "OnCommand:", sys.exc_info()[1]

        return True