def OnCommand(self, cmd_id): """ Triggered when a menu command is selected through the menu or its hotkey @return: None """ #print "command:", cmd_id if self.cmd_close == cmd_id: self.Close() return elif self.cmd_color == cmd_id: func_item = idaapi.get_func(idc.ScreenEA()) # get the default color idc.Jump(func_item.startEA) idautils.ProcessUiActions("GraphDefaultColor", 0) defaultcolor = idc.GetColor(func_item.startEA, idc.CIC_ITEM) # reset colors to default idc.SetColor(func_item.startEA, idc.CIC_FUNC, defaultcolor) # RGB for block in self.blocks: start, end = self.getBounds(block) # color all basic blocks for head in idautils.Heads(start, end): idc.SetColor(head, idc.CIC_ITEM, self.options['bb_path_color']) #branch_insn = idc.NextHead(end, func_item.endEA) #print "branch instruction is at 0x%08x" % branch_insn #idc.SetColor(branch_insn, idc.CIC_ITEM, self.options['bb_path_color']) idaapi.refresh_idaview_anyway()
def color(self): """Function color in IDA View""" color = idc.GetColor(self.ea, idc.CIC_FUNC) if color == 0xFFFFFFFF: return None return color
def color(self): """Line color in IDA View""" color = idc.GetColor(self.ea, idc.CIC_ITEM) if color == 0xFFFFFFFF: return None return color
def tracing(): global PRE_ADDR event = idc.GetDebuggerEvent(idc.WFNE_ANY, -1) if event <= 1: idc.RunTo(idc.BeginEA()) idc.GetDebuggerEvent(idc.WFNE_SUSP, -1) idc.EnableTracing(idc.TRACE_STEP, 1) idc.GetDebuggerEvent(idc.WFNE_ANY | idc.WFNE_CONT, -1) while True: event = idc.GetDebuggerEvent(idc.WFNE_ANY, -1) if event <= 1: break addr = idc.GetEventEa() print event, "==>", hex(addr) # judge breakpoint and same addr if PRE_ADDR != addr: PRE_ADDR = addr else: # same addr if event == idc.BREAKPOINT: # and now is breakpoint break current_color = idc.GetColor(addr, idc.CIC_ITEM) new_color = get_new_color(current_color) idc.SetColor(addr, idc.CIC_ITEM, new_color)
def colorize(self, node, color): ''' Colorize the entire code block. ''' block = self.LookupBlock(node) if block and idc.GetColor(block.startEA, idc.CIC_ITEM) != color: ea = block.startEA while ea < block.endEA: idc.SetColor(ea, idc.CIC_ITEM, color) ea += idaapi.decode_insn(ea)
def __color_read(cls, ea, what=1): bgr = idc.GetColor(ea, what) if bgr == 0xffffffff: return None a = bgr&0xff000000 bgr &= 0x00ffffff rgb = 0 for i in xrange(3): rgb,bgr = ((rgb*0x100) + (bgr&0xff), bgr/0x100) return rgb
def getText(self, addy): func = idaapi.get_func(addy) if (func): FName = idc.GetFunctionName(func.startEA) Demangled = None color = idc.GetColor(func.startEA, idc.CIC_ITEM) if color == 0xFFFFFFFF: color = idaapi.SCOLOR_INV else: color = idaapi.SCOLOR_STRING try: Demangled = idc.Demangle(FName, 8) except: pass if (Demangled): FName = Demangled return idaapi.COLSTR(" " + FName + " ", color) return " " + FName + " " return " " + idc.GetDisasm(addy) + " "
def color_read(ea, what=1): return idc.GetColor(ea, what)
ea = idc.ScreenEA() addr = idc.SegStart(ea) print "[!] Analyzing from %#x" % addr while True: res = idc.FindBinary(addr, idaapi.BIN_SEARCH_FORWARD, prolog_sequence, 16) if res == idaapi.BADADDR: break func = idc.GetFuncOffset(res) if func is not None: print "[*] %#x already matching function %s" % (res, func) else: print "[+] Matching at %#x" % res idc.Jump(res) col = idc.GetColor(res, idc.CIC_ITEM) idc.SetColor(res, idc.CIC_ITEM, hilight_color) idc.SetColor(res + 1, idc.CIC_ITEM, hilight_color) ret = idc.AskYN(0, "Would you like to create a function at %#x ?" % res) if ret == 1: idc.MakeFunction(res) print "[+] Creating function at %#x" % res idc.SetColor(res, idc.CIC_ITEM, col) idc.SetColor(res + 1, idc.CIC_ITEM, col) addr = res + len(prolog_sequence) print "[!] EOT"
def get_color(self): return idc.GetColor(self.addr, idc.CIC_ITEM)