def CBC_padding_oracle_encrypt(key):
    plaintext = base64.b64decode(random_strings[random.randint(
        0,
        len(random_strings) - 1)])
    print '.',
    iv = chal11.get_random_bytes(16)
    plaintext = chal9.pad(plaintext, 16)
    ciphertext = chal10.encrypt_CBC(plaintext, key, iv)
    return ciphertext, iv
def encrypt_CBC(plaintext, key, iv):
    ciphertext = ''
    last_cipher = iv
    plaintext = chal9.pad(plaintext, 16)
    for i in range(len(plaintext) / BLOCK_SIZE):
        plain_block = plaintext[i * BLOCK_SIZE:(i + 1) * BLOCK_SIZE]
        plain_block = xor_data(plain_block, last_cipher)
        last_cipher = chal7.encrypt_ECB(plain_block, key)
        ciphertext += last_cipher
    return ciphertext
Пример #3
0
def encryption_oracle(plaintext):
    aes_key = get_random_bytes(16)
    plaintext = get_random_bytes(random.randint(
        5, 10)) + plaintext + get_random_bytes(random.randint(5, 10))
    ecb_flag = (0 == random.randint(0, 1))
    #print ecb_flag
    if ecb_flag:
        #ecb encryption
        plaintext = chal9.pad(plaintext, 16)
        return chal7.encrypt_ECB(plaintext, aes_key)
    else:
        iv = get_random_bytes(16)
        return chal10.encrypt_CBC(plaintext, aes_key, iv)
Пример #4
0
def encryption_oracle(plaintext):
	plaintext = plaintext+base64.b64decode(unknown_string)
	plaintext = chal9.pad(plaintext,16)
	return chal7.encrypt_ECB(plaintext,KEY)
def cbc_oracle(plaintext):
	plaintext = plaintext.replace(';','')
	plaintext = plaintext.replace('=','')
	plaintext = "comment1=cooking%20MCs;userdata="+plaintext+";comment2=%20like%20a%20pound%20of%20bacon"
	plaintext = chal9.pad(plaintext,16)
	return chal10.encrypt_CBC(plaintext,KEY,iv)
Пример #6
0
def encrypt(plaintext, key):
    plaintext = chal9.pad(plaintext, 16)
    return chal7.encrypt_ECB(plaintext, key)
Пример #7
0
def ecb_encrypt(plaintext, key):
    cipher = AES.new(key, AES.MODE_ECB)
    return cipher.encrypt(pad(plaintext, 16))