detect_aes_in_ecb_mode.py (487B)
1 from sets import Set 2 3 file = open('files/8.txt').read().splitlines() 4 5 for ciphertext in file: 6 charlist = [0 for x in range(256)] 7 8 for char in ciphertext.decode("hex"): 9 charlist[ord(char)] += 1 10 11 for char in charlist: 12 if char > 5: 13 print ciphertext 14 break 15 16 for ciphertext in file: 17 split_cipher = [ciphertext[i:i + 32] for i in range(0, len(ciphertext), 32)] 18 if len(split_cipher) != len(Set(split_cipher)): 19 print ciphertext