from Crypto.Cipher import AES from Crypto.Util.strxor import strxor as xor from Crypto.Util.Padding import pad from random import * from base64 import * from copy import copy from secret import data
iv=bytes([randint(0,2**8-1) for i inrange(16)]) iva=copy(iv) key=bytes([randint(0,2**8-1) for i inrange(16)]) cipher=AES.new(key,mode=AES.MODE_ECB) data=pad(data,16) c=b"" for i inrange(0,len(data),16): s=data[i:i+16].ljust(16,b"\n") c+=cipher.encrypt(xor(s,iv)) iv=xor(s,c[-16:])
from Crypto.Cipher import AES from Crypto.Util.strxor import strxor as xor from string import printable from base64 import b64decode from Crypto.Util.number import *
# 将密钥和密文 base64 解码 key = b64decode(b'+0zkhmid1PFjVdxSP09zSw==') ciphertext = b64decode(b'A0bzFxdM95YoXm64g0gZkiTloPsBAq7iV56t1M7Q4zVNxRJSTdZH0lzOMa7QyIQbKN/ftm01iZgQAk+JVgCB6hlCdMPWkdpKYHix8BTq/ClEHUPwMEjUEvgKD4tH3T/thoccBw1jfJ9RjhXbMFByWn5cyA/gHVvEEJRpII/ryKMQkzelioQ5b0MfhSy4INLqQk6yAgLzihip5ho7lDJCbYcaz85bDksOo5n9kjOfjFnjUn9G7jX+AtyhygPlGfrvauTeuPdVxqrJTVHvrzUNAqiqtCElX+BWpicP2mkZLt5B/gpquTv8U+StrdTOcr7UkWuz+YdhXkTJYUZguv7EbEnRy+M64QzqfnNf8Zk0tJQ5xOumbY8hxGTuZ8w3rWxjPKLhdgTGLgMcMYF3hPb2eqG9VZKC3T9zElI5MWPyIdkmqkrLEt6vGT8AxWJy1hl2ApkGhrJFB0DobJircN6kXUXvZXitjXSH+BA48muaRlAwK13re+zIcbI+B7+Tm3LuRT9j5NWD9RBoy+IeAQvR05IKWqEpqXEScmZsQxpAFZCSnbchYaYNAuHvBwMcMW7vTMyxROHRtyZ+gWNUhpd8CcZ9FA6w+cwQLMWW5D4nUCMK+NEsSyTBBm/jTiAp/waq+2dTVyBhbQtmm9pBtZtHJtfeVRKuZRXduNnlWDa7Wlwv0Jk2EIJp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MR3t2WO1cOaLE8IN5c71W+IqhaRbJ/Prlo/pk/XAtMvimZxIN4y5/oP5vQ/lCt5jM9wAtPKSoQbJxWIYWNrXVfkZUOOwD2tlOmyxMCcKFr8921JHgtWqcYliElNX19hzmYhow+19EV3zhITzsGOX/PP1BHIKz/NJyKcGqx1hlfrDfDVedhJWkQL9sg4clbfguprs3KG5YNbbjclaK9JoEboBY3EGBGHtsWfmIRAREwy1a53y/a/NUDLaQxrMsyV/YnbiyBevGjMVNnqIY5T0YtPLL/s5Wvmq7EU9qoMDIlaosCf616TagcZalGFQumL15q6wx3FxwVB5EAjFa/MKnZNc0CqbFhXgEevp1ZXRnjEAdSK99gyAmwVawWpxIWXZQvQ5w7tIQ+nF8utoG4ab/AdLbZyKCtT8pxjiHifNcCCkLfew8Qq9S2JnrhCUMs9SEiRrLZHiE9JVlwbUJzAQjCM6G4tdeLNEApqDv4eZ7zh2U9K2+Gk9OjBgSk5xMjRkCzKCrNAKgRLoJ1Gu8L4T9LSBp1juhUsyaIaK' ) cipher=AES.new(key,mode=AES.MODE_ECB) c2 = [ciphertext[i:i+16] for i inrange(0,len(ciphertext),16)] xor_s = [] xor_iv = b'' for ciphertext in c2: xor_s.append(cipher.decrypt(ciphertext))
s = b'' tiv = b'\xd4\x5d\x47\xaf\x96\xc5\xde\x2d\x96\x51\x6d\xf5\x3e\xe9\x30' for j in [0x99]: iv = tiv+long_to_bytes(j) trycry = '' for i inrange(len(xor_s)): s = xor(xor_s[i], iv) iv = xor(s, c2[i]) try: trycry += s.decode() if trycry[-1] notin printable: break trycry += '' except: break if'flag'in trycry: #查找关键字flag print(trycry) #flag{This's_why_PCBC_is_not_living}