def test_single_file_different_sizes(): output1 = DummyOutput() output2 = DummyOutput() target_size1 = 10000 target_size2 = 100000 gz.options['type'] = 'single_file' gz.options['target_size'] = target_size1 gz.run(output1) gz.options['target_size'] = target_size2 gz.run(output2) assert output1.count() == 1 assert output2.count() == 1 assert len(output1[0]) < len(output2[0])
def test_single_file_bomb(): output = DummyOutput() target_size = 1000 gz.options['type'] = 'single_file' gz.options['target_size'] = target_size gz.run(output) assert output.count() == 1 assert len(gzip.decompress(output[0])) == target_size
def test_run_small_collision_count(): output = DummyOutput() n_collisions = 10 hash_table_size = 2**32 target = '42' java.options['n_collisions'] = n_collisions java.options['target_type'] = 'image' java.options['target'] = target java.options['hash_table_size'] = hash_table_size java.run(CharGenerator(), output) assert output.count() == n_collisions for i in output: assert java_common.java_hash(i, hash_table_size) == int(target)
def test_preimage(): output = DummyOutput() n_collisions = 10 hash_table_size = 2**32 preimage_target = 'hello world' java.options['n_collisions'] = n_collisions java.options['target_type'] = 'preimage' java.options['target'] = preimage_target java.options['hash_table_size'] = hash_table_size java.run(CharGenerator(), output) target = java_common.java_hash(preimage_target, hash_table_size) assert output.count() == n_collisions for i in output: assert java_common.java_hash(i, hash_table_size) == target
def test_run_small_collision_count(): output = DummyOutput() n_collisions = 20 hash_table_size = 2**32 target = '42' php5_fast.options['n_collisions'] = n_collisions php5_fast.options['n_substrings'] = 10 php5_fast.options['target_type'] = 'image' php5_fast.options['target'] = target php5_fast.options['hash_table_size'] = hash_table_size php5_fast.run(CharGenerator(), output) assert output.count() == n_collisions for i in output: assert php5_common.php_hash(i, hash_table_size) == int(target)
def test_preimage(): output = DummyOutput() n_collisions = 10 hash_table_size = 2**32 preimage_target = 'hello world' php5_fast.options['n_collisions'] = n_collisions php5_fast.options['n_substrings'] = 10 php5_fast.options['target_type'] = 'preimage' php5_fast.options['target'] = preimage_target php5_fast.options['hash_table_size'] = hash_table_size php5_fast.run(CharGenerator(), output) target = php5_common.php_hash(preimage_target, hash_table_size) assert output.count() == n_collisions for i in output: assert php5_common.php_hash(i, hash_table_size) == target
def test_run_small_collision_output(): output = DummyOutput() n_collisions = 2 length = 7 substring_length = 3 target = '42' python2_32.options['n_collisions'] = n_collisions python2_32.options['length'] = length python2_32.options['substring_length'] = substring_length python2_32.options['target'] = target python2_32.options['target_type'] = 'image' python2_32.run(CharGenerator(), output) assert output.count() == n_collisions for i in output: assert python2_32.hash(i) == int(target)
def test_preimage(): output = DummyOutput() n_collisions = 2 length = 8 substring_length = 4 target = 'hello' python2_32.options['n_collisions'] = n_collisions python2_32.options['length'] = length python2_32.options['substring_length'] = substring_length python2_32.options['target'] = target python2_32.options['target_type'] = 'preimage' python2_32.run(CharGenerator(), output) assert output.count() == n_collisions for i in output: assert python2_32.hash(i) == python2_32.hash(target)
def test_short_length(): output = DummyOutput() n_collisions = 10 hash_table_size = 100 target = '42' length = 5 bsd.options['n_collisions'] = n_collisions bsd.options['length'] = length bsd.options['target_type'] = 'image' bsd.options['target'] = target bsd.options['hash_table_size'] = hash_table_size bsd.run(output) assert output.count() == n_collisions for i in output: assert bsd_hash(i, hash_table_size) == int(target) assert len(i) == length
def test_run_larger_hash_table_size(): output = DummyOutput() n_collisions = 10 hash_table_size = 1024 target = '42' length = 10 lrc.options['n_collisions'] = n_collisions lrc.options['length'] = length lrc.options['target_type'] = 'image' lrc.options['target'] = target lrc.options['hash_table_size'] = hash_table_size lrc.run(output) assert output.count() == n_collisions for i in output: assert z3lrc_hash(i, hash_table_size) == int(target) assert len(i) == length
def test_more_collisions(): output = DummyOutput() n_collisions = 20 hash_table_size = 10 target = '5' length = 10 adler32.options['n_collisions'] = n_collisions adler32.options['length'] = length adler32.options['target_type'] = 'image' adler32.options['target'] = target adler32.options['hash_table_size'] = hash_table_size adler32.run(output) assert output.count() == n_collisions for i in output: assert adler32_hash(i, hash_table_size) == int(target) assert len(i) == length
def test_more_collisions(): output = DummyOutput() n_collisions = 3 length = 5 hash_table_size = 100 target = '42' sum.options['n_collisions'] = n_collisions sum.options['length'] = length sum.options['hash_table_size'] = hash_table_size sum.options['target_type'] = 'image' sum.options['target'] = target sum.run(output) assert output.count() == n_collisions for i in output: assert sum_hash(i, hash_table_size) == int(target) assert len(i) == length
def test_larger_width(): output = DummyOutput() n_collisions = 1 length = 5 hash_table_size = 100 target = '42' xor8.options['n_collisions'] = n_collisions xor8.options['length'] = length xor8.options['hash_table_size'] = hash_table_size xor8.options['target_type'] = 'image' xor8.options['target'] = target xor8.run(output) assert output.count() == n_collisions for i in output: assert xor8_hash(i, hash_table_size) == int(target) assert len(i) == length
def test_run(): output = DummyOutput() n_collisions = 1 hash_table_size = 0xffffffff target = '42' length = 10 crc32.options['n_collisions'] = n_collisions crc32.options['length'] = length crc32.options['target_type'] = 'image' crc32.options['target'] = target crc32.options['hash_table_size'] = hash_table_size crc32.run(output) assert output.count() == n_collisions for i in output: assert crc32_hash(i, hash_table_size) == int(target) assert len(i) == length
def test_run(): output = DummyOutput() n_collisions = 1 hash_table_size = 2**32 target = '42' length = 10 java_z3.options['n_collisions'] = n_collisions java_z3.options['length'] = length java_z3.options['target_type'] = 'image' java_z3.options['target'] = target java_z3.options['hash_table_size'] = hash_table_size java_z3.run(output) assert output.count() == n_collisions for i in output: assert java_common.java_hash(i, hash_table_size) == int(target) assert len(i) == length
def test_no_zero_intial_key(): output = DummyOutput() n_collisions = 1 hash_table_size = 0x3FFFFFFFFFFFFFFF target = '42' initial_key = 11312 chicken_scheme.options['n_collisions'] = n_collisions chicken_scheme.options['n_substrings'] = 1 chicken_scheme.options['initial_key'] = initial_key chicken_scheme.options['target_type'] = 'image' chicken_scheme.options['target'] = target chicken_scheme.options['hash_table_size'] = hash_table_size chicken_scheme.run(output) assert output.count() == n_collisions for i in output: assert chicken_scheme_hash(i, hash_table_size, initial_key) == int(target)
def test_preimage(): output = DummyOutput() n_collisions = 10 hash_table_size = 100 target = 'hello' length = len(target) adler32.options['n_collisions'] = n_collisions adler32.options['length'] = length adler32.options['target_type'] = 'preimage' adler32.options['target'] = target adler32.options['hash_table_size'] = hash_table_size adler32.run(output) assert output.count() == n_collisions for i in output: assert adler32_hash(i, hash_table_size) == adler32_hash( target, hash_table_size) assert len(i) == length
def test_preimage(): output = DummyOutput() n_collisions = 10 hash_table_size = 0xffff target = 'hello' length = len(target) bsd.options['n_collisions'] = n_collisions bsd.options['length'] = length bsd.options['target_type'] = 'preimage' bsd.options['target'] = target bsd.options['hash_table_size'] = hash_table_size bsd.run(output) assert output.count() == n_collisions for i in output: assert bsd_hash(i, hash_table_size) == bsd_hash(target, hash_table_size) assert len(i) == length
def test_larger_width(): output = DummyOutput() n_collisions = 1 length = 5 width = 32 hash_table_size = 100 target = '42' fletcher.options['n_collisions'] = n_collisions fletcher.options['length'] = length fletcher.options['hash_table_size'] = hash_table_size fletcher.options['width'] = width fletcher.options['target_type'] = 'image' fletcher.options['target'] = target fletcher.run(output) assert output.count() == n_collisions for i in output: assert fletcher_hash(i, hash_table_size, (2**(width/2))-1) == int(target) assert len(i) == length
def test_preimage(): output = DummyOutput() n_collisions = 10 hash_table_size = 0x3FFFFFFFFFFFFFFF target = 'hello' initial_key = 0 chicken_scheme.options['n_collisions'] = n_collisions chicken_scheme.options['n_substrings'] = 1 chicken_scheme.options['initial_key'] = initial_key chicken_scheme.options['target_type'] = 'preimage' chicken_scheme.options['target'] = target chicken_scheme.options['hash_table_size'] = hash_table_size chicken_scheme.run(output) assert output.count() == n_collisions for i in output: assert (chicken_scheme_hash(i, hash_table_size, initial_key) == chicken_scheme_hash( target, hash_table_size, initial_key))
def test_recursive_bomb(): output = DummyOutput() gz.options['type'] = 'recursive' gz.run(output) assert output.count() == 1