@@ -0,0 +1,1793 @@
+from Crypto.Cipher import AES%0A%0ABLOCKSIZE = 16%0A%0A%0Adef apply_pkcs_7_padding(plaintext, blocksize=BLOCKSIZE):%0A    padding_length = blocksize - len(plaintext) %25 blocksize%0A    pad = chr(padding_length)%0A    return ''.join((plaintext, pad*padding_length))%0A%0A%0Adef cbc_aes_encrypt(plaintext, iv, key, blocksize=BLOCKSIZE):%0A    aes_obj = AES.new(key)%0A%0A    plaintext = apply_pkcs_7_padding(plaintext, blocksize)%0A    plain_blocks = %5Bplaintext%5Bi*blocksize:(i+1)*blocksize%5D for i in range(len(plaintext)/blocksize)%5D%0A    xor_block = iv%0A    encrypted_blocks = %5B%5D%0A    for plain_block in plain_blocks:%0A        xored_block = ''.join(%5Bchr(ord(plain_block%5Bi%5D) %5E ord(xor_block%5Bi%5D)) for i in range(blocksize)%5D)%0A%0A        encrypted_block = aes_obj.encrypt(xored_block)%0A        encrypted_blocks.append(encrypted_block)%0A%0A        xor_block = encrypted_block%0A    return ''.join(encrypted_blocks)%0A%0A%0Adef cbc_aes_decrypt(ciphertext, iv, key, blocksize=BLOCKSIZE):%0A    aes_obj = AES.new(key)%0A%0A    cipher_blocks = %5Bciphertext%5Bi*blocksize:(i+1)*blocksize%5D for i in range(len(ciphertext)/blocksize)%5D%0A    xor_block = iv%0A%0A    plain_blocks = %5B%5D%0A    for cipher_block in cipher_blocks:%0A        xored_block = aes_obj.decrypt(cipher_block)%0A%0A        plain_block = ''.join(%5Bchr(ord(xored_block%5Bi%5D) %5E ord(xor_block%5Bi%5D)) for i in range(blocksize)%5D)%0A        plain_blocks.append(plain_block)%0A%0A        xor_block = cipher_block%0A    return ''.join(plain_blocks)%0A%0A%0Adef ecb_aes(text, key, blocksize=BLOCKSIZE):%0A    aes_obj = AES.new(key)%0A%0A    text = apply_pkcs_7_padding(text, blocksize)%0A    blocks = %5Btext%5Bi*blocksize:(i+1)*blocksize%5D for i in range(len(text)/blocksize)%5D%0A    cleared_blocks = %5B%5D%0A    for block in blocks:%0A        cleared_block = aes_obj.decrypt(block)%0A        cleared_blocks.append(cleared_block)%0A    return ''.join(cleared_blocks)%0A

Add crypto library, AES CBC/ECB oracles, PKCS#7 padding