Beispiel #1
0
def main(argv):
    if (len(argv)<2):
        print("Implementation tests")
        print("-----------------------------------------------------------------")
        info=opencl_information()
        info.printplatforms()
        print("\nPlease run as: python test.py [platform number]")
        return

    # Input values to be hashed
    passwordlist = [b'password', b'hmm', b'trolololl', b'madness']
    salt = b"salty"
    
    platform = int(argv[1])
    debug = 0
    write_combined_file = False
    opencl_algos = opencl.opencl_algos(platform, debug, write_combined_file,inv_memory_density=1)
    # Call the tests

    md5_test(opencl_algos,passwordlist)
    sha256_test(opencl_algos,passwordlist)
    sha1_test(opencl_algos,passwordlist)

    md5_hmac_test(opencl_algos, passwordlist, salt)
    sha1_hmac_test(opencl_algos, passwordlist, salt)
    sha256_hmac_test(opencl_algos, passwordlist, salt)
    
    pbkdf2_hmac_md5_test(opencl_algos, passwordlist, salt, 1000, 50)
    pbkdf2_hmac_sha1_test(opencl_algos, passwordlist, salt, 1000, 50)
    pbkdf2_hmac_sha256_test(opencl_algos, passwordlist, salt, 1000, 50)
    
    scrypt_test(opencl_algos,passwordlist,15,3,1,0x20,salt)

    print("Tests have finished.")
Beispiel #2
0
def create_pl(plat):
	platform = plat
	debug = 0
	write_combined_file = False
	opencl_algos = opencl.opencl_algos(platform, debug, write_combined_file,inv_memory_density=1)
	#print(opencl_information.printfullinfo(0))
	return opencl_algos
Beispiel #3
0
def main(argv):
    if len(argv) < 2:
        print("Implementation tests")
        print("-----------------------------------------------------------------")
        info = opencl_information()
        info.printplatforms()
        print("\nPlease run as: python test.py [platform number]")
        return

    # Input values to be hashed
    passwordlist = [b'password', b'hmm', b'trolololl', b'madness']
    salts = [b"salty123", b"salty12",b"\xd1\x0c\x00\xd2\xfe\x64\x02\x98",b"\x12\x34\x56\x78"]

    platform = int(argv[1])
    debug = 0
    write_combined_file = False
    opencl_algos = opencl.opencl_algos(platform, debug, write_combined_file, inv_memory_density=1)
    # Call the tests

    for salt in salts:
        print("Using salt: %s" % salt)
        md5_test(opencl_algos, passwordlist)
        md5_hmac_test(opencl_algos, passwordlist, salt)
        pbkdf2_hmac_md5_test(opencl_algos, passwordlist, salt, 1000, 32)
        pbkdf2_hmac_md5_test(opencl_algos, passwordlist, salt, 1000, 50)
        hash_iterations_md5_test(opencl_algos, passwordlist, 10000)
        
        sha1_test(opencl_algos, passwordlist)
        sha1_hmac_test(opencl_algos, passwordlist, salt)
        pbkdf2_hmac_sha1_test(opencl_algos, passwordlist, 16*b"\x00", 1000, 32)
        pbkdf2_hmac_sha1_test(opencl_algos, passwordlist, salt, 1000, 32)
        pbkdf2_hmac_sha1_test(opencl_algos, passwordlist, salt, 1000, 64)
        hash_iterations_sha1_test(opencl_algos, passwordlist, 10000)

        sha256_test(opencl_algos, passwordlist)
        sha256_hmac_test(opencl_algos, passwordlist, salt)
        pbkdf2_hmac_sha256_test(opencl_algos, passwordlist, salt, 10000, 32)
        pbkdf2_hmac_sha256_test(opencl_algos, passwordlist, salt, 10000, 50)
        hash_iterations_sha256_test(opencl_algos, passwordlist, 10000)

        sha512_test(opencl_algos, passwordlist)
        sha512_hmac_test(opencl_algos, passwordlist, salt)
        pbkdf2_hmac_sha512_test(opencl_algos, passwordlist, salt, 1000, 32)
        pbkdf2_hmac_sha512_test(opencl_algos, passwordlist, salt, 1000, 50)
        hash_iterations_sha512_test(opencl_algos, passwordlist, 10000)

        scrypt_test(opencl_algos, passwordlist, 15, 3, 1, 0x20, salt)

    """
    from time import perf_counter
    start=perf_counter()
    for i in range(200000):
        passwordlist.append(b"test%04d" % i)
    pbkdf2_hmac_sha256_speedtest(opencl_algos,passwordlist,salts[0],1000,50)
    end=perf_counter()
    print("Time: %f" % (end-start))
    """
    print("Tests have finished.")
Beispiel #4
0
def main(argv):
    if (len(argv) < 2):
        print("Implementation tests")
        print(
            "-----------------------------------------------------------------"
        )
        info = opencl_information()
        info.printplatforms()
        print("\nPlease run as: python test.py [platform number]")
        return

    passwordlist = []

    # Input values to be hashed
    print("\nGenearating strings")
    for i in range(1):
        print("\nGenearated", i, "strings")
        passwordlist.append(str.encode(get_random_string(1048576)))
    #salts = [b"salty123",b"salty12"]

    platform = int(argv[1])
    debug = 0
    write_combined_file = False
    opencl_algos = opencl.opencl_algos(platform,
                                       debug,
                                       write_combined_file,
                                       inv_memory_density=1)
    # Call the tests

    print("opencl gpu test sha512")
    hash_iterations_sha512_test(opencl_algos, passwordlist, 1000000)
    '''
    for salt in salts:
        print("Using salt: %s" % salt)
        #hash_iterations_md5_test(opencl_algos, passwordlist, 10000)
        #hash_iterations_sha1_test(opencl_algos, passwordlist, 10000)
        #hash_iterations_sha256_test(opencl_algos, passwordlist, 10000)
        start = time.time()
        hash_iterations_sha512_test(opencl_algos, passwordlist, 10000)
        done = time.time()
        elapsed = done - start
        print("time used", elapsed)
    '''

    print("Tests have finished.")
Beispiel #5
0
def main(argv):
    info = opencl_information()
    if (len(argv) < 4):
        print("Implementation tests")
        print(
            "-----------------------------------------------------------------"
        )
        info.printplatforms()
        print(
            "\nPlease run as: python test.py [platform number] [number of passwords] [number of salts]"
        )
        return

    info.printfullinfo()

    passwords_count = int(argv[2])
    salts_count = int(argv[3])

    # Input values to be hashed
    t0 = time.time()
    passwordlist = list(random_string_generator(passwords_count))
    salts = list(random_string_generator(salts_count))
    t1 = time.time()
    print("%d random passwords and salts were generated in: %.6f\n" %
          ((passwords_count + salts_count), (t1 - t0)))

    platform = int(argv[1])
    debug = 1
    write_combined_file = False
    opencl_algos = opencl.opencl_algos(platform,
                                       debug,
                                       write_combined_file,
                                       inv_memory_density=1)
    # Call the tests

    for salt in salts:
        print("Using salt: %s" % salt)
        scrypt_test(opencl_algos, passwordlist, 14, 3, 3, 0x20, salt)
        print()

    print("Tests have finished.")
Beispiel #6
0
    ctx = opencl_algo.cl_sha256_init()
    clresult = opencl_algo.cl_sha256(ctx, pws)
    print('\n'.join("{}\t{}".format(l,
                                    hexlify(x).decode('utf-8'))
                    for l, x in zip(pws, clresult)))


if __name__ == "__main__":
    if (len(sys.argv) < 3):
        print("Implementation tests")
        print(
            "-----------------------------------------------------------------"
        )
        info = opencl_information()
        info.printplatforms()
        print("\nPlease run as: python {} [platform number] [input filename]".
              format(sys.argv[0]))
        exit(0)

    platform = int(sys.argv[1])
    inpf = sys.argv[2]
    debug = 0
    write_combined_file = False
    opencl_algos = opencl.opencl_algos(platform,
                                       debug,
                                       write_combined_file,
                                       inv_memory_density=1)
    sha256_test(opencl_algos, inpf, skiplines=0, clean=lambda x: x.lower())
    # get_sha256_hashes(opencl_algos, inpf)
    # test_sha256(opencl_algos, [b"*****@*****.**"[-119:], b"*****@*****.**"])
    enc = query['enc'][0]
except Exception:
    raise Exception('An "enc" parameter is a required part of the URI')

# Decode the enc parameter from base64
try:
    enc = base64.b64decode(enc, validate=True)
except Exception:
    raise Exception('Could not decode base64 from enc paramater')

# Get the salt from enc
kdfSalt = enc[0:8]

logging.debug("KDF Salt: 0x%s", kdfSalt.hex())

opencl_algo = opencl.opencl_algos(args.platform, 0, False, inv_memory_density=1)

ctx = opencl_algo.cl_pbkdf2_init("sha256", len(kdfSalt), 64)


maced_payload = o.query[0:o.query.rfind('&')].encode('utf-8')  # mac is last param, so can remove it this way
correctmac = base64.b64decode(query['mac'][0])

hashes_per_batch = 100_000
assert 100_000_000 % hashes_per_batch == 0

with tqdm(total=100_000_000, unit='Hacks', unit_scale=True) as pbar:
    for batch_start in range(0, 100_000_000, hashes_per_batch):

        passwords = (str(n).encode('ascii') for n in range(batch_start, batch_start + hashes_per_batch))
        clResult = opencl_algo.cl_pbkdf2(ctx, passwords, kdfSalt, 1000, 64)