def get_ea_list(cls, cfunc, sl):
        """Get a list of EAs that are in a simpleline_t."""
        def ea_from_addr_tag(addr_tag):
            return cfunc.treeitems.at(addr_tag).ea

        def is_addr_code(s):
            return (s[0] == idaapi.COLOR_ON and s[1] == chr(idaapi.COLOR_ADDR))

        anchor = idaapi.ctree_anchor_t()
        line = sl.line[:]  # Copy
        ea_list = []

        while len(line) > 0:
            skipcode_index = idaapi.tag_skipcode(line)
            if skipcode_index == 0:  # No code found
                line = line[1:]  # Skip one character ahead
            else:
                if is_addr_code(line):
                    addr_tag = int(line[2:skipcode_index], 16)
                    anchor.value = addr_tag
                    if (anchor.is_citem_anchor()
                            and not anchor.is_blkcmt_anchor()):
                        line_ea = ea_from_addr_tag(addr_tag)
                        if line_ea != idaapi.BADADDR:
                            ea_list.append(line_ea)
                line = line[skipcode_index:]  # Skip the colorcodes

        return ea_list
Пример #2
0
    def get_ea_list(cls, cfunc, sl):
        """Get a list of EAs that are in a simpleline_t."""
        def ea_from_addr_tag(addr_tag):
            return cfunc.treeitems.at(addr_tag).ea

        def is_addr_code(s):
            return (s[0] == idaapi.COLOR_ON and
                    s[1] == chr(idaapi.COLOR_ADDR))

        anchor = idaapi.ctree_anchor_t()
        line = sl.line[:]  # Copy
        ea_list = []

        while len(line) > 0:
            skipcode_index = idaapi.tag_skipcode(line)
            if skipcode_index == 0:  # No code found
                line = line[1:]  # Skip one character ahead
            else:
                if is_addr_code(line):
                    addr_tag = int(line[2:skipcode_index], 16)
                    anchor.value = addr_tag
                    if (
                        anchor.is_citem_anchor() and
                        not anchor.is_blkcmt_anchor()
                    ):
                        line_ea = ea_from_addr_tag(addr_tag)
                        if line_ea != idaapi.BADADDR:
                            ea_list.append(line_ea)
                line = line[skipcode_index:]  # Skip the colorcodes

        return ea_list
Пример #3
0
 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 = idaapi.ctree_anchor_t()
     for i in range(len(sv)):
         curline = copy(sv[i].line)
         while (len(curline) > 0):
             skipcode_index = idaapi.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 != idaapi.BADADDR):
                             if (address in tainted_pcs):
                                 sv[i].bgcolor = INST_COLOR
                 curline = curline[skipcode_index:]
Пример #4
0
def extract_addresses(func, line):
    line = line.line
    anchor = idaapi.ctree_anchor_t()
    addresses = set()
    while len(line) > 0:
        skipcode_index = idaapi.tag_skipcode(line)
        if skipcode_index == 0:  # No code found
            line = line[1:]  # Skip one character ahead
        else:
            if tag_addrcode(line):
                addr_tag = int(line[2:skipcode_index], 16)
                anchor.value = addr_tag
                if anchor.is_citem_anchor() and not anchor.is_blkcmt_anchor():
                    address = func.treeitems.at(addr_tag).ea
                    if address != idaapi.BADADDR:
                        addresses.add(address)
            line = line[skipcode_index:]  # Skip the colorcodes
    return addresses
Пример #5
0
def get_obj_ids(vdui, lnnum):
    obj_ids = []
    pc = vdui.cfunc.get_pseudocode()
    if lnnum >= len(pc):
        return obj_ids
    line = pc[lnnum].line
    tag = idaapi.COLOR_ON + chr(idaapi.COLOR_ADDR)
    pos = line.find(tag)
    while pos != -1 and len(line[pos + len(tag):]) >= idaapi.COLOR_ADDR_SIZE:
        addr = line[pos + len(tag):pos + len(tag) + idaapi.COLOR_ADDR_SIZE]
        idx = int(addr, 16)
        a = idaapi.ctree_anchor_t()
        a.value = idx
        if a.is_valid_anchor() and a.is_citem_anchor():
            item = vdui.cfunc.treeitems.at(a.get_index())
            if item:
                obj_ids.append(item.obj_id)
        pos = line.find(tag, pos + len(tag) + idaapi.COLOR_ADDR_SIZE)
    return obj_ids
Пример #6
0
    def extract_addresses(self):
        '''A set of addresses associated with the line'''
        anchor = idaapi.ctree_anchor_t()
        line = copy(self.widget.line)
        addresses = set()

        while len(line) > 0:
            skipcode_index = idaapi.tag_skipcode(line)
            if skipcode_index == 0:  # No code found
                line = line[1:]  # Skip one character ahead
            else:
                if tag_addrcode(line):
                    addr_tag = int(line[2:skipcode_index], 16)
                    anchor.value = addr_tag
                    if anchor.is_citem_anchor() \
                       and not anchor.is_blkcmt_anchor():
                        address = self.parent.treeitems.at(addr_tag).ea
                        if address != idaapi.BADADDR:
                            addresses.add(address)
                line = line[skipcode_index:]  # Skip the colorcodes
        return addresses