def has_xor_in_loop(self): import idc cylic = algorithms.find_cylic_nodes(self, self.name) for n in self.nodes.keys(): if type(n) == type('str'): n = idc.LocByName(n) m = idc.GetMnem(n) if m != 'xor': continue op0 = idc.GetOpnd(n, 0) op1 = idc.GetOpnd(n, 1) if op0 != op1 and n in cylic: return True return False
def tag_xors(): import function import idc import idautils fns = set(idautils.Functions()) rv = {} for f in fns: #print 'analyzing %x for xor loops' % (f) fg = FunctionGraph(f) rv[f] = False for n in fg.nodes: m = idc.GetMnem(n) if m != 'xor': continue op0 = idc.GetOpnd(n,0) op1 = idc.GetOpnd(n,1) if op0 != op1 and n in algorithms.find_cylic_nodes(fg,f): function.tag(f, 'xor in loop', True) rv[f] = True break return rv