Exemple #1
0
def ascii_cycle(cblock1, cblock2):
    cookie = ''
    for i in range(0, 256):  #Ascii values 0-255
        try_string = cblock1 + chr(i) + cblock2  #Block combo formula
        hx_try = try_string.encode(
            "hex")  #Convert to hex to encrypt (required)
        encrypted = oracle.encrypt(hx_try)  #Returns ascii
        if rypto.ecb_detect(encrypted):  #If its detected (If 1)
            cookie += chr(i)  #Add to selected

        return cookie
Exemple #2
0
    oracle = rypto.ecb_cookie_oracle(file_name)

    #A
    user_input = 'A'.encode("hex")
    print 'A.\nDetecting key size..'
    Aresponse = oracle.encrypt(user_input)  #Response from oracle
    original = len(Aresponse)  #Original length of response with a single x

    answer = size_detect(Aresponse, original, user_input)
    print 'Key size detected:', answer
    print 'Moving on..'

    #B
    Bresponse = oracle.encrypt(user_input * answer * 2)  #Encrypt "A" * 32
    print 'B.\nDetecting encryption mode..'
    detected = rypto.ecb_detect(Bresponse)
    if detected:
        print "ECB detected.\nMoving on.."
    else:
        print "ECB not detected. Not sure how to proceed."
        print "Exiting."
        exit()

    #C
    print 'C.\nBreaking ecb encryption cookie..'
    block = ''
    full_string = ''
    """
    This is somewhat like a counter. Assumes string is somewhat short.
    """
    for h in range(1, 50):
Exemple #3
0
    #Convert acsii to hex
    hx = f.encode("hex")

    #Chooses number between 1 and 2 to decide ecb or cbc
    choice = randInt(1, 2)  #randomChoiceOfECB-CBC (1 = ecb), (2 = cbc)

    if choice == 1:
        print "ECB mode selected"
        x = rypto.aes_ecb_encrypt(hx, key_rand)

    if choice == 2:
        print "CBC mode selected"
        x = enc_cbc(hx, key_rand, iv)

    #Checks for ecb
    result = rypto.ecb_detect(x.encode("hex"))

    if result == 1:
        print '\nThis was likely encrypted with ecb'

    else:
        print '\nThis was likely encrypted with cbc'

    while (1):
        print '\nType 1 to view result in hex.\nType 2 to view result as is.'
        print 'Type 3 to view result in base64\nType 4 to exit'
        z = int(raw_input("\nYour choice:"))
        if z == 1:
            print x.encode("hex")

        if z == 2: