Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2.7
- from Crypto.Cipher import AES
- import binascii, sys
- import itertools
- #KEY = "yn9RB3Lr43xJK2██".encode()
- #IV = "████████████████".encode()
- msg = "AES with CBC is very unbreakable".encode()
- #aes = AES.new(KEY, AES.MODE_CBC, IV)
- #print (binascii.hexlify(aes.encrypt(msg)).decode())
- # output:
- # c5██████████████████████████d49e78c670cb67a9e5773d696dc96b78c4e0
- plausible = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789="
- pairs_of_characters = list((itertools.product(plausible, repeat=2)))
- lastblock = bytes.fromhex("78c670cb67a9e5773d696dc96b78c4e0")
- for pair in pairs_of_characters:
- IV = b"\x00" * 16
- pair = str(''.join(pair))
- KEY = ("yn9RB3Lr43xJK2" + pair ).encode()
- #print(KEY)
- aes = AES.new(KEY, AES.MODE_CBC, IV)
- pt2 = b"very unbreakable"
- ciphertext = aes.decrypt(lastblock)
- #print(ciphertext)
- if ciphertext[0] ^ 0xc5 == b"v" and ciphertext[14] ^ 0xd4 == b"l" and ciphertext[15] ^ 0x9e == b"e":
- print("Found key: " + KEY.decode())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement