FunctionMatrix.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:IDAPython-Scripts 作者: razygon 项目源码 文件源码
def _feature_returnpoints(self, f_ea):
        '''
        Number of 'ret' within the function
        rets = [addr1, addr2. ...]

        prior feature: Null
        '''
#         rets = []
#         for ea in idautils.FuncItems(f_ea):
#             if idaapi.is_ret_insn(ea):
#                 rets.append(ea)
#         self.ftable["returnpoints"] = rets
        DEBUG_PRINT("in returnpoints")
        fun = idaapi.get_func(f_ea)
        visited = []
        retVal = []
        for ret in self.ftable["returnpoints"]:
            towalk = [ret]
#             print 'towalk',towalk
            while towalk:
                curr = towalk.pop()
#                 print 'curr',curr
                if curr not in range(fun.startEA,fun.endEA+2): # the start point also will record int the tree
#                     print 'not in range'
                    continue
#                 print '1', hex(curr)
                if curr not in visited:
                    visited.append(curr)
                inst = GetInstruction(curr)
#                 print '2', inst
                if inst is None:
                    continue
                elif 'eax' in inst:
#                     print ret, curr, inst
                    retVal.append((ret,curr,inst))
                    continue
                for xto in idautils.XrefsTo(curr, 0):
                    DEBUG_PRINT('xto')
                    if xto.frm not in visited:
                        DEBUG_PRINT(xto.frm)
                        towalk.append(xto.frm)
        DEBUG_PRINT(retVal)
        return len(self.ftable["returnpoints"]), retVal
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号