Advertisement
nicoviale_

Untitled

Apr 8th, 2024
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2.  
  3. from Crypto.Cipher import AES
  4. import binascii, sys
  5. import itertools
  6.  
  7. #KEY = "yn9RB3Lr43xJK2██".encode()
  8. #IV  = "████████████████".encode()
  9.  
  10. msg = "AES with CBC is very unbreakable".encode()
  11.  
  12. #aes = AES.new(KEY, AES.MODE_CBC, IV)
  13. #print (binascii.hexlify(aes.encrypt(msg)).decode())
  14.  
  15. # output:
  16. # c5██████████████████████████d49e78c670cb67a9e5773d696dc96b78c4e0
  17.  
  18. plausible = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789="
  19.  
  20. pairs_of_characters = list((itertools.product(plausible, repeat=2)))
  21.  
  22. lastblock = bytes.fromhex("78c670cb67a9e5773d696dc96b78c4e0")
  23.  
  24. for pair in pairs_of_characters:
  25.     IV = b"\x00" * 16
  26.     pair = str(''.join(pair))
  27.     KEY = ("yn9RB3Lr43xJK2" + pair ).encode()
  28.     #print(KEY)
  29.     aes = AES.new(KEY, AES.MODE_CBC, IV)
  30.    
  31.     pt2 = b"very unbreakable"
  32.  
  33.  
  34.     ciphertext = aes.decrypt(lastblock)
  35.     #print(ciphertext)
  36.     if ciphertext[0] ^ 0xc5 == b"v" and ciphertext[14] ^ 0xd4 == b"l" and ciphertext[15] ^ 0x9e == b"e":
  37.         print("Found key: " + KEY.decode())
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement