Ejemplo n.º 1
0
def test_rc4_cf2():
    # RC4 cf2
    kb = h(b'24D7F6B6BAE4E5C00D2082C5EBAB3672')
    k1 = string_to_key(Enctype.RC4, b'key1', b'key1')
    k2 = string_to_key(Enctype.RC4, b'key2', b'key2')
    k = cf2(Enctype.RC4, k1, k2, b'a', b'b')
    assert (k.contents == kb)
Ejemplo n.º 2
0
def test_des3_cf2():
    # DES3 cf2
    kb = h(b'E58F9EB643862C13AD38E529313462A7F73E62834FE54A01')
    k1 = string_to_key(Enctype.DES3, b'key1', b'key1')
    k2 = string_to_key(Enctype.DES3, b'key2', b'key2')
    k = cf2(Enctype.DES3, k1, k2, b'a', b'b')
    assert (k.contents == kb)
Ejemplo n.º 3
0
def test_aes256_cf2():
    # AES256 cf2
    kb = h(b'4D6CA4E629785C1F01BAF55E2E548566B9617AE3A96868C337CB93B5E72B1C7B')
    k1 = string_to_key(Enctype.AES256, b'key1', b'key1')
    k2 = string_to_key(Enctype.AES256, b'key2', b'key2')
    k = cf2(Enctype.AES256, k1, k2, b'a', b'b')
    assert (k.contents == kb)
Ejemplo n.º 4
0
def test_aes128_cf2():
    # AES128 cf2
    kb = h(b'97DF97E4B798B29EB31ED7280287A92A')
    k1 = string_to_key(Enctype.AES128, b'key1', b'key1')
    k2 = string_to_key(Enctype.AES128, b'key2', b'key2')
    k = cf2(Enctype.AES128, k1, k2, b'a', b'b')
    assert (k.contents == kb)
Ejemplo n.º 5
0
def test_des3_str_to_key():
    # DES3 string-to-key
    string = b'password'
    salt = b'ATHENA.MIT.EDUraeburn'
    kb = h(b'850BB51358548CD05E86768C313E3BFEF7511937DCF72C3E')
    k = string_to_key(Enctype.DES3, string, salt)
    assert (k.contents == kb)
Ejemplo n.º 6
0
def test_aes256_string_to_key():
    # AES256 string-to-key
    string = b'X' * 64
    salt = b'pass phrase equals block size'
    params = h(b'000004B0')
    kb = h(b'89ADEE3608DB8BC71F1BFBFE459486B05618B70CBAE22092534E56C553BA4B34')
    k = string_to_key(Enctype.AES256, string, salt, params)
    assert (k.contents == kb)
Ejemplo n.º 7
0
def test_aes128_string_to_key():
    # AES128 string-to-key
    string = b'password'
    salt = b'ATHENA.MIT.EDUraeburn'
    params = h(b'00000002')
    kb = h(b'C651BF29E2300AC27FA469D693BDDA13')
    k = string_to_key(Enctype.AES128, string, salt, params)
    assert (k.contents == kb)
Ejemplo n.º 8
0
def create_key(salt, cipher, password):

    # Setup AES Iteration Count for both AES 128 and 256
    iterations = '\x00\x00\x10\x00'

    # Generate Keys based on cipher
    if cipher == "aes256-cts-hmac-sha1-96":
        key = crypto.string_to_key(crypto.Enctype.AES256, password, salt,
                                   iterations)
    elif cipher == "aes128-cts-hmac-sha1-96":
        key = crypto.string_to_key(crypto.Enctype.AES128, password, salt,
                                   iterations)
    elif cipher == "des-cbc-md5":
        key = crypto.string_to_key(crypto.Enctype.DES_MD5, password, salt)
    elif cipher == "rc4_hmac":
        key = crypto.string_to_key(crypto.Enctype.RC4, password, None)
    else:
        return None
    return ((key.contents).encode("hex"))
Ejemplo n.º 9
0
def main(username, password, domain, john):

    # Setup Constants
    salt = domain.upper() + username
    out_salt = domain.upper() + "\\" + username
    iterations = '\x00\x00\x10\x00'
    keys = []

    # AES-256
    key = crypto.string_to_key(crypto.Enctype.AES256, password, salt, iterations)
    if john:
        cid = 18
        out = "$krb%s$%s%s$%s" % (cid, domain.upper(), username, (key.contents).encode("hex"))
    else:
        out = "%s:aes256-cts-hmac-sha1-96:%s" % (out_salt, (key.contents).encode("hex"))
    keys.append(out)

    # AES-128
    key = crypto.string_to_key(crypto.Enctype.AES128, password, salt, iterations)
    if john:
        cid = 17
        out = "$krb%s$%s%s$%s" % (cid, domain.upper(), username, (key.contents).encode("hex"))
    else:
        out = "%s:aes128-cts-hmac-sha1-96:%s" % (out_salt, (key.contents).encode("hex"))
    keys.append(out)

    # DES
    key = crypto.string_to_key(crypto.Enctype.DES_MD5, password, salt)
    if john:
        cid = 3
        out = "$krb%s$%s%s$%s" % (cid, domain.upper(), username, (key.contents).encode("hex"))
    else:
        out = "%s:des-cbc-md5:%s" % (out_salt, (key.contents).encode("hex"))
    keys.append(out)

    # RC4
    key = crypto.string_to_key(crypto.Enctype.RC4, password, None)
    if not john:
        out = "%s:rc4_hmac:%s" % (out_salt, (key.contents).encode("hex"))
        keys.append(out)

    return keys
Ejemplo n.º 10
0
def test_rc4_str_to_key():
    # RC4 string-to-key
    string = b'foo'
    kb = h(b'AC8E657F83DF82BEEA5D43BDAF7800CC')
    k = string_to_key(Enctype.RC4, string, None)
    assert (k.contents == kb)
Ejemplo n.º 11
0
def test_aes256_prf():
    # AES256 prf
    kb = h(b'0D674DD0F9A6806525A4D92E828BD15A')
    k = string_to_key(Enctype.AES256, b'key2', b'key2')
    assert (prf(k, b'\x02\x62') == kb)
Ejemplo n.º 12
0
def test_aes128_prf():
    # AES128 prf
    kb = h(b'77B39A37A868920F2A51F9DD150C5717')
    k = string_to_key(Enctype.AES128, b'key1', b'key1')
    assert (prf(k, b'\x01\x61') == kb)