if CONSEC_LIMIT > 0 and consec > CONSEC_LIMIT: limit = i + 1 - ZERO_LIMIT break seq = seq[:limit + 1] a1 = a1[:limit + 1] a2 = a2[:limit + 1] print "// automated comparison and test-generation of :" print "// file %s\n// %s" % (f1, " ".join( ["%02X" % ord(i) for i in d1[:limit]])) print "// file %s\n// %s" % (f2, " ".join( ["%02X" % ord(i) for i in d2[:limit]])) print from utils import get_disassembly a1 = get_disassembly("".join(chr(int(i, 16)) for i in a1)) a2 = get_disassembly("".join(chr(int(i, 16)) for i in a2)) hlen = max(len(i[0]) for i in a1) + 1 a1 = ["// %s:%s" % (i[0].ljust(hlen), i[1]) for i in a1] a2 = ["// %s:%s" % (i[0].ljust(hlen), i[1]) for i in a2] if len(a1) == len(a2): for i, j in enumerate(a1): print getwildstring(j, a2[i]) else: print "different length" print templatize(seq_to_snippets(seq))
# PyReI/O script to extract selection and turn it into a text file, ready for asm2test # BSD Licence, Ange Albertini 2011 from pyreio import * sel = getselection() if sel is None: msg("Empty Selection ! aborting...") else: from utils import get_disassembly, templatize, seq_to_snippets, code_to_seq r = get_disassembly(sel) hlen = max(len(i[0]) for i in r) + 1 import os filename = "temp%s.txt" % os.getpid() f = open(filename, "wt") f.write("// Add a * in front of the bytes you want to ignore\n") f.write("// this file will be deleted at the end of the procedure\n\n") f.write("\n".join(("// %s:%s" % (i[0].ljust(hlen), i[1]) for i in r))) f.close() #hiew.MessageWaitOpen() os.system(filename) #hiew.MessageWaitClose() f = open(filename, "rt") r = f.readlines() f.close()
# let's stop automatically if more than CONSEC_LIMIT consecutive bytes are differents consec += 1 if CONSEC_LIMIT > 0 and consec > CONSEC_LIMIT: limit = i + 1 - ZERO_LIMIT break seq = seq[:limit + 1] a1 = a1[:limit + 1] a2 = a2[:limit + 1] print "// automated comparison and test-generation of :" print "// file %s\n// %s" % (f1, " ".join(["%02X" % ord(i) for i in d1[:limit]])) print "// file %s\n// %s" % (f2, " ".join(["%02X" % ord(i) for i in d2[:limit]])) print from utils import get_disassembly a1 = get_disassembly("".join(chr(int(i, 16)) for i in a1)) a2 = get_disassembly("".join(chr(int(i, 16)) for i in a2)) hlen = max(len(i[0]) for i in a1) + 1 a1 = ["// %s:%s" % (i[0].ljust(hlen), i[1]) for i in a1] a2 = ["// %s:%s" % (i[0].ljust(hlen), i[1]) for i in a2] if len(a1) == len(a2): for i,j in enumerate(a1): print getwildstring(j, a2[i]) else: print "different length" print templatize(seq_to_snippets(seq))