NSSCTF 2nd WEB

本文详细解析了NSSCTF 2nd WEB挑战的四个部分:php签到、MyBox、MyHurricane和MyJS。涉及考点包括文件上传绕过、SSRF漏洞、Apache漏洞利用、Tornado模板注入、JWT伪造和EJS/Lodash原型链渲染。通过题目、题解和利用方法,展示了各种Web安全攻防技巧。
摘要由CSDN通过智能技术生成

php签到

考点

文件上传,绕过

题目

<?php

function waf($filename){
    $black_list = array("ph", "htaccess", "ini");
    $ext = pathinfo($filename, PATHINFO_EXTENSION);  //获取文件后缀
    foreach ($black_list as $value) {
        if (stristr($ext, $value)){   //检查后缀
            return false;
        }
    }
    return true;
}

if(isset($_FILES['file'])){
    $filename = urldecode($_FILES['file']['name']);
    $content = file_get_contents($_FILES['file']['tmp_name']);
    if(waf($filename)){
        file_put_contents($filename, $content);
    } else {
        echo "Please re-upload";
    }
} else{
    highlight_file(__FILE__);
}

题解

文件名为xxx.xxx/.时,pathinfo函数的PATHINFO_EXTENSION只能得到空。

这里使用了file_put_contents()和urlencode

当我们上传test.php/.这样的文件时候,因为file_put_contents()第一个参数是文件路径,操作系统会认为你要在test1.php文件所在的目录中创建一个名为.的文件,最后上传的结果就为test.php。

用表单上传

用蚁剑连接成功但找不到flag

法一:

法二:

MyBox

考点

flask,file协议

题目

进去一开始是一片空白

题解

看到有个url参数

猜测这里存在SSRF漏洞。尝试伪协议读取/etc/passwd,成功,存在SSRF。

/?url=file:///etc/passwd

image-20230829101135327

一:读取环境变量/proc/1/environ,获得flag。(非预期)

/?url=file:///proc/1/environ

image-20230829101334454

二:读取start.sh

/?url=file:///start.sh 

读取源码:/?url=file:///app/app.py

image-20230829101443029

from flask import Flask, request, redirect
import requests, socket, struct
from urllib import parse
app = Flask(__name__)

@app.route('/')
def index():
    if not request.args.get('url'):
        return redirect('/?url=dosth')
    url = request.args.get('url')
    if url.startswith('file://'):
        with open(url[7:], 'r') as f:
            return f.read()
    elif url.startswith('http://localhost/'):
        return requests.get(url).text
    elif url.startswith('mybox://127.0.0.1:'):
        port, content = url[18:].split('/_', maxsplit=1)
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.settimeout(5)
        s.connect(('127.0.0.1', int(port)))
        s.send(parse.unquote(content).encode()
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值