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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| import base64
cipher = "uLdAuO8duojAFLEKjIgdpfGeZoELjJp9kSieuIsAjJ/LpSXDuCGduouz" original_format = "flag{de63de21-082b-4a9d-acbd-7d47a55840c6}" leak_cipher = "pTjMwJ9WiQHfvC+eFCFKTBpWQtmgjopgqtmPjfKfjSmdFLpeFf/Aj2ud3tN7u2+enC9+nLN8kgdWo29ZnCrOFCDdFCrOFoF=" leak_plain = "ashlkj!@sj1223%^&*Sd4564sd879s5d12f231a46qwjkd12J;DJjl;LjL;KJ8729128713" base64_table = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', ] base_split_step = 6 dic = [] s2b_step = 3 b2s_step = 4 for i in range(0, len(leak_plain), s2b_step): res = leak_plain[i:i + s2b_step] rr = "" for j in res: rr += bin(ord(j))[2:].zfill(8) for k in range(0, len(rr), base_split_step): dic.append(rr[k:k + base_split_step].ljust(6, "0"))
res_dict = {} rd = [] for i, j in zip(leak_cipher, dic): res_dict[i] = int(j, 2) rd.append(i) print(res_dict) print(set(base64_table) - set(rd))
non_existent = [] translate = "" for i in cipher: try: translate += base64_table[res_dict[i]] except: translate += i non_existent.append(i) non_existent = set(non_existent) print(non_existent) for i in range(0, int(len(cipher) / b2s_step)): tmp = translate[i * b2s_step:(i + 1) * b2s_step] tmp_format = original_format[i * s2b_step:(i + 1) * s2b_step] for j in tmp: if j in non_existent: print(tmp, tmp_format) break
|