FunctionMatrix.py 文件源码

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

项目:IDAPython-Scripts 作者: razygon 项目源码 文件源码
def __init__(self):  
        '''
        one table is for one function and its xref_to functions
        the table's name is the source function's name
        how to store function features within the table still need consideration
        '''
        self.script_folder = ''
        self.project_name = ''
        print '---------------------', idc.ARGV[1]
        arg = idc.ARGV[1]
        self.script_folder = arg[arg.find('(')+2: arg.find(',')-1]
        self.project_name = arg[arg.find(',')+2: arg.find(')')-1]
        print '++++++++++project_name', self.project_name                  
        print '++++++++++script_folder',self.script_folder

        self.moduleName = idc.GetInputFile().replace('.','_') #name of current idb
        if os.path.exists(self.moduleName):
            #may need user's input to decide whether rewrite it or append it? this check shld be set as input in args
            print 'the db already exist'
            clear = ConfirmDialog("Delete the current DB and create a new one?")
            clear.Compile()
            ok = clear.Execute()
            if ok:
                os.remove(self.moduleName)
            else:
                return    
        print '[Get_FunctionFeatures]moduleName:  %s'%self.moduleName
        self.func_name_ea = {name:ea for ea, name in idautils.Names()} # all names within idb
        self.ftable = collections.defaultdict(dict) # a dictionary stores the features of one function, will be refreshed for every function
        self.exports = [] # all export functions
        self.memop = {} #instructions with memory operation
        self.syscalls = set()

        self.priorMatrix = [('returnpoints', '_feature_returnpoints'), ('loopcount', '_feature_loopcount')]
        #(ea, writemem, writetoglobal, cmpmem, loopcalc)  
        self.LoadExports()   
        print 'table name: ' + self.moduleName
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号