Example #1
0
#!/usr/bin/env python3

from coll import Collider, md5pad, filter_disallow_binstrings

file = open("../files/grade.txt", "r")

# Generate a 213-way collision as a test
c = Collider(pad=b' ', blockfilter=filter_disallow_binstrings([b'\0']))
# begin the output files with hello world text
c.strcat(file.read())

# Diverge 8 times. That means 2^8 possibilities
for i in range(8):
    print('Stage {} of 8'.format(i+1))
    # we fork into 2 different possibilities of collision blocks (128 byte garbage each) here
    c.diverge()
    # place some text in the middle of each divergence
    c.strcat('More text: {}\n'.format(i))

c.strcat('\nFinal.')

# Select the first 213 collisions to output to file
for i,data in enumerate(c.get_collisions(count=213)):
    with open('out_test_%03d.txt' % i, 'wb') as f:
        f.write(data)
        
print('Done')
#!/usr/bin/env python3

from coll import Collider, md5pad, filter_disallow_binstrings

# Generate a 213-way collision as a test
c = Collider(pad=b' ', blockfilter=filter_disallow_binstrings([b'\0']))
# begin the output files with hello world text
c.strcat('Hello world.')

# Diverge 8 times. That means 2^8 possibilities
for i in range(8):
    print('Stage {} of 8'.format(i+1))
    # we fork into 2 different possibilities of collision blocks (128 byte garbage each) here
    c.diverge()
    # place some text in the middle of each divergence
    c.strcat('More text: {}\n'.format(i))

c.strcat('\nFinal.')

# Select the first 213 collisions to output to file
for i,data in enumerate(c.get_collisions(count=213)):
    with open('out_test_%03d.txt' % i, 'wb') as f:
        f.write(data)
        
print('Done')
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#

diff = '''<one of 2 collision blocks>'''
same = '''<first of the 2 collision blocks>'''

if (same == diff):
    print "good"

else:
    print "evil"
"""


collider = Collider(blockfilter=filter_disallow_binstrings([b'\0', b"'''"]))

prefix1 = b"""#!/usr/bin/env python2
# -*- 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"""'''
            startchars = q-(64*3)
            if not first:
                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:
Example #5
0
        if compdata[q] == ord('+') or compdata[q] == ord('-'):
            startchars = q - (64 * 3)
            if not first:
                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:
"""
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#

diff = '''<one of 2 collision blocks>'''
same = '''<first of the 2 collision blocks>'''

if (same == diff):
    print "good"

else:
    print "evil"
"""

collider = Collider(blockfilter=filter_disallow_binstrings([b'\0', b"'''"]))

prefix1 = b"""#!/usr/bin/env python2
# -*- 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"""'''