AES can be susceptible to a copy-and-paste attack if ECB (Electronic Code Book) is used. Enter a passphrase (to generate a key) and a secret word. THe secret word will then be ciphered with each character, and Eve can rebuild to provide a valid ciphertext string:
AES Crack (copy-and-paste) |
Example
The following uses a password of 'napier' and a secret word of 'edinburgh':
2aeb8b1683f155b4009460ca4dcff462 d272bb15c17b9f21567f0bbc059f442d 11204d4653d3f5f9f9ad032efa706890 5dd5b2a1b5a420c1f0186ec3e58944df 2d63a1efa0160d5dafb90998bc9159d3 504e6d032c4ceaa9c367b8f747d263ba f2f7719f7b2d38dbe3650e3d59e7eed2 f4c44d30fe5d88fedd259d224c515ca2 734a4b6f540e17ba02845cc529138fc6 Decrypt: e☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼d☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼i☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼n☼☼ ☼☼☼☼☼☼☼☼☼☼☼u☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼r☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼g☼☼☼☼☼☼☼☼☼☼☼☼☼☼☼h
Code
An outline of the code used is:
from Crypto.Cipher import AES import hashlib import sys import binascii import Padding word='edinburgh' password='napier' plaintext='' def encrypt(plaintext,key, mode): encobj = AES.new(key,mode) return(encobj.encrypt(plaintext)) def decrypt(ciphertext,key, mode): encobj = AES.new(key,mode) return(encobj.decrypt(ciphertext)) ciphertext=[] key = hashlib.sha256(password.encode()).digest() for ch in word: plaintext = Padding.appendPadding(ch,blocksize=Padding.AES_blocksize,mode='CMS') ciphertext = ciphertext+ list(encrypt(plaintext.encode(),key,AES.MODE_ECB)) print(binascii.hexlify(encrypt(plaintext.encode(),key,AES.MODE_ECB))) plaintext = decrypt(bytes(ciphertext),key,AES.MODE_ECB).decode() plaintext = Padding.removePadding(plaintext,mode='CMS') print(" decrypt: "+plaintext)