def color_eas(self, cfunc, tainted_pcs):
     # the plugins/bap/utils/hexrays.py file found at
     # https://github.com/BinaryAnalysisPlatform/bap-ida-python/ was
     # invaluable in determining how to extract the effective addresses
     # from each pseudocode line
     sv = cfunc.get_pseudocode()
     anchor = ida_hexrays.ctree_anchor_t()
     for i in range(len(sv)):
         curline = copy(sv[i].line)
         while (len(curline) > 0):
             skipcode_index = ida_lines.tag_skipcode(curline)
             if (0 == skipcode_index):
                 # no code found, go to next character
                 curline = curline[1:]
             else:
                 if (self.tag_addrcode(curline)):
                     addr_tag = int(curline[2:skipcode_index], 16)
                     anchor.value = addr_tag
                     if (anchor.is_citem_anchor()
                             and not anchor.is_blkcmt_anchor()):
                         address = cfunc.treeitems.at(addr_tag).ea
                         if (address != ida_idaapi.BADADDR):
                             if (address in tainted_pcs):
                                 sv[i].bgcolor = INST_COLOR
                 curline = curline[skipcode_index:]
Example #2
0
 def _remove_color_tags(self, l):
     """removes all color tags from a tagged simple_line_t object
     but preserves COLOR_ADDR tags."""
     line = ""
     i = 0
     while i<len(l):
         if l[i] is il.COLOR_ON:
             n = il.tag_skipcode(l[i:])
             if l[i:].find(chr(il.COLOR_ADDR)) == 1:
                 line += l[i:i+n]
             i += n
         elif l[i] in [il.COLOR_OFF, il.COLOR_ESC, il.COLOR_INV]:
             n = il.tag_skipcode(l[i:])
             i += n
         else:
             line += l[i]
             i += 1
     return line