# -*- coding: utf-8 -*- #""" prefix2 = b"""\ndiff = '''""" # Ensure prefix is a multiple of 64 bytes prefix = prefix1 + md5pad(prefix1 + prefix2, b' ') + prefix2 # Load the first half of the collision files that opens the 'diff' variable delcaration collider.bincat(prefix) # Fill in the 'diff' variable with 2 different blocks that may be chosen collider.safe_diverge() postfix = b"""''' same = '''""" c1, c2 = collider.get_last_coll() postfix += c1 postfix += b"""''' if (same == diff): print "good" else: print "evil" """ # Close the 'diff' variable string and declare the 'same' variable to always have the 1st collision block # Thus for one file: same == diff, but for the other: same != diff
first = i offset = i - startchars else: second = startchars + offset compdata[q] = 0 break if not (first and second): raise Exception('error: did not find marker strings') # Splice in the collision blocks according to the obtained offsets collider = Collider(blockfilter=filter_disallow_binstrings([b'\0'])) collider.bincat(compdata[:first]) collider.safe_diverge() c1, c2 = collider.get_last_coll() collider.bincat(compdata[first + 128:second] + c1 + compdata[second + 128:]) # Write out good and evil binaries cols = collider.get_collisions() GOOD = 'out_c_good' EVIL = 'out_c_evil' with open(GOOD, 'wb') as good: good.write(next(cols)) with open(EVIL, 'wb') as evil: evil.write(next(cols)) os.system('chmod +x {} {}'.format(GOOD, EVIL))