1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| import base64 from Crypto.Cipher.AES import *
def arr_to_byte(arr): nbyte = "" for i in range(len(arr)): nbyte += chr(arr[i]) return nbyte.encode("latin") #key_stream = [0xDC, 0xB0, 0x04, 0x30, 0x4B, 0x32, 0xDF, 0x7D, 0x9B, 0x45, 0xCB, 0xF7, 0x5A, 0x21, 0xBB, 0x31, 0xEB, 0xF8, 0x73, 0x1D, 0x97, 0x87, 0xC7, 0x26, 0x49, 0x62, 0x09, 0xF3, 0x9F, 0xA4, 0xDF, 0xA4, 0xAD, 0x7B, 0xDC, 0x33, 0xB6, 0xDA, 0x20, 0x67, 0x30, 0x04, 0xB0, 0xDC, 0x7D, 0xDF, 0x32, 0x4B] key_stream = [0x30, 0x04, 0xB0, 0xDC, 0x7D, 0xDF, 0x32, 0x4B, 0xF7, 0xCB, 0x45, 0x9B, 0x31, 0xBB, 0x21, 0x5A, 0x1D, 0x73, 0xF8, 0xEB, 0x26, 0xC7, 0x87, 0x97, 0xF3, 0x09, 0x62, 0x49, 0xA4, 0xDF, 0xA4, 0x9F, 0x33, 0xDC, 0x7B, 0xAD, 0x67, 0x20, 0xDA, 0xB6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] key = [] iv = [] inp = [] for i in range(16): key.append(key_stream[0x18+i]) cipher_b64de = base64.b64decode(b"sOxxmnurlg68LoTgoBnO/lFTfJbuev+92GwwRPybFTZkPJhp") cipher_32 = cipher_b64de[:32] cipher_4 = cipher_b64de[32:] for i in range(16): iv.append(cipher_4[i % 4] ^ key_stream[i]) for i in range(32): inp.append(cipher_32[i] ^ key_stream[0x10 + i%8])
iv_byte = arr_to_byte(iv) key_byte = arr_to_byte(key) inp_byte = arr_to_byte(inp) print(iv_byte, key_byte) aes = new(key_byte, MODE_CBC, iv_byte) plaintext = aes.decrypt(inp_byte) print(plaintext) flag = "" for i in range(len(plaintext)): flag += chr(plaintext[i] ^ key_stream[0x10 + i%8]) print(flag)
|