当前位置:网站首页>[WesternCTF2018]shrine
[WesternCTF2018]shrine
2022-07-29 00:56:00 【pakho_C】
[WesternCTF2018]shrine
flask框架
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)
os.environ.pop(‘FLAG’) 获取环境变量 存放在名为FLAG的config中
那么目的就是获取config中的值
flask框架首先考虑模板注入ssti
测试:
执行函数的黑名单有两个:config和self
不过python还有一些内置函数,比如url_for和get_flashed_messages
使用url_for测试:
shrine/{
{
url_for.__globals__}}
可以执行,查看current_app的配置信息:
shrine/{
{
url_for.__globals__['current_app'].config}}
边栏推荐
猜你喜欢
随机推荐
560 and K
【golang】使用select {}
Openpyxl border
C语言犄角旮旯的知识之形参、实参、main函数参数、数组或指针做函数参数等
uniapp createSelectorQuery(). Select get returns null error
【Golang】- runtime.Goexit()
规划数学期末模拟考试一
围绕新市民金融聚焦差异化产品设计、智能技术提效及素养教育
云原生应用综合练习上
[hcip] two mGRE networks are interconnected through OSPF (ENSP)
How to protect WordPress website from network attack? It is essential to take safety measures
【GoLang】同步锁 Mutex
ELMO,BERT和GPT简介
【HCIP】重发布及路由策略的实验
It is found that the data of decimal type in the database can be obtained through resultset.getdouble, but this attribute cannot be obtained through GetObject.
PCL point cloud intensity image
云原生应用综合练习下
【GoLang】网络连接 net.Dial
第二轮Okaleido Tiger热卖的背后,是背后生态机构战略支持
ELS stop at all