SYMMETRIC STARTER Passwords as Keys爆破import requests import tqdm from Crypto.Cipher import AES import hashlib from Crypto.Util.number import * import tqdm import random import binascii result requests.get(http://aes.cryptohack.org/passwords_as_keys/encrypt_flag) ciphertexthex result.json()[ciphertext] print(ciphertexthex) # ciphertexthexc92b7734070205bdf6c0087a751466ec13ae15e6f1bcdd3f3a535ec0f4bbae66 with open(D:/2023/crypto/words.txt, r)as f: for words in f.readlines(): wordswords.strip() #print(words) key_1 hashlib.md5(words.encode()).hexdigest() key bytes.fromhex(key_1) cipher AES.new(key, AES.MODE_ECB) ciphertext bytes.fromhex(ciphertexthex) decrypted cipher.decrypt(ciphertext) if bcrypto{ in decrypted: print(decrypted) break #print(decrypted)BLOCK CIPHERS ECB CBC WTFCBC加密 ECB解密key一样消除iv等影响即可result requests.get(https://aes.cryptohack.org/ecbcbcwtf/encrypt_flag/) ciphertexthex result.json()[ciphertext] print(ciphertexthex) ivciphertexthex[0:32] cciphertexthex[32:] c1int(c[0:32],16) c2int(c[32:],16) print(iv,c) print(len(c)) result requests.get(https://aes.cryptohack.org/ecbcbcwtf/decrypt/c) plaintexthex result.json()[plaintext] p1int(plaintexthex[0:32],16) p2int(plaintexthex[32:],16) ivint(iv,16) m1p1^iv m2p2^c1 print(long_to_bytes(m1)) print(long_to_bytes(m2))