Exemple #1
0
def solve():
    filename = "test.txt"
    key = crypty.generate_key()
    correct_hash = hmac(key.decode("hex"),
                        open(filename, 'r').read()).decode("hex")
    print "[*] Key : %s" % (correct_hash.encode("hex"))
    guessed_hash = ["\x00"] * 20
    for i in xrange(20):
        found_byte = b''
        max_timetaken = 0
        for c in xrange(256):
            guessed_hash[i] = chr(c)
            timetaken = 0
            for j in xrange(1):
                t1 = time.time()
                insecure_compare("".join(guessed_hash), correct_hash)
                t2 = time.time()
                timetaken += (t2 - t1) * 1000
            avg_timetaken = timetaken / 1.0
            if avg_timetaken > max_timetaken:
                found_byte = chr(c)
                max_timetaken = avg_timetaken
        print "Found next byte : %s" % (found_byte.encode("hex"))
        guessed_hash[i] = found_byte

    print "[+] Found Key : %s" % ("".join(guessed_hash).encode("hex"))
    return
Exemple #2
0
def step4_1(msg, hash):
    h = E_knows['h']
    r = E_knows['r']
    p = E_knows['p']
    for x in xrange(1, r):
        k = getSHA1(format(powmod(h, x, p), 'x'))[0:32]
        if hmac(msg, k) == hash:
            print "[+] Found the private key. r = %d" % (r)
            print "[+] Key: %s" % (k)
            gk.append(k)
            return True
    print "[-] No keys Found."
    return False
Exemple #3
0
def solver():
    A, b, B, u, hash = srp("")
    fp = open("passwords.txt", "r")
    passwords = fp.readlines()
    for password in passwords:
        password = password.strip()
        print "[*] Trying Password: '******'" % (password)
        x = mpz(int(generate_hash("", password), 16))
        S = t_mod(powmod(A, b, N) * powmod(B, u * x, N), N)
        K = hash_sha256(str(S))
        h = hmac(K, "", hash_function=hash_sha256)
        if h == hash:
            print "[+] Got it. Password = '******'" % (password)
    return
Exemple #4
0
def step4(msg):
    k = B_knows['k']
    B_knows['msg'] = msg
    return hmac(msg, k)
Exemple #5
0
def step_8(hash):
    if hmac(Server['K'], Server['salt'], hash_function=hash_sha256) == hash:
        return "OK"
    else:
        return "NOT OK"
Exemple #6
0
def step_7():
    return hmac(Client['K'], Client['salt'], hash_function=hash_sha256)