def is_admin(ct): pt = aes.decrypt_cbc(ct, key) cookies = [] for i in pt.split(';'): parts = i.split('=') if len(parts) != 2: raise InvalidCookie() if parts[0] == 'admin' and parts[1] == 'true': return True return False
def valid_padding(ct): try: aes.decrypt_cbc(ct, key) except aes.InvalidPadding: return False return True
def consume_ct(ct): pt = aes.decrypt_cbc(key + ct, key) if not util.is_ascii(pt): raise NonAscii(pt)
def recv_ct(con, key): '''reads <len> <aes cbc encrypted msg>''' return aes.decrypt_cbc(recv_len_payload(con), key)
import aes import base64 with open('10.txt', 'r') as f: ct = base64.b64decode(''.join(f.read().split())) key = "YELLOW SUBMARINE" print aes.decrypt_cbc('\x00' * 16 + ct, key)