少女祈祷中...

[BSidesCTF 2020]Had a bad day

离成功就差一步!!!

进入页面发现有读取url,于是尝试sql,失败了,但是我们发现好像存在文件读取漏洞:

image-20250319191210517

我们尝试读取flag,index,失败了,那就使用伪协议试试看,发现成功了

image-20250319191351317

但是不知道为什么我的无法翻译出来,后面也不知道怎么办了,看了一下wp

这些base64居然是源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
$file = $_GET['category'];

if(isset($file))
{
if( strpos( $file, "woofers" ) !== false || strpos( $file, "meowers" ) !== false || strpos( $file, "index")){
include ($file . '.php');
}
else{
echo "Sorry, we currently only support woofers and meowers.";
}
}
?>
</div>

答案是直接截断,也是学到新东西了:

1
http://0990b516-c740-417e-bef6-ccc0e8c688ba.node5.buuoj.cn:81/index.php?category=php://filter/read=convert.base64-encode/woofers/resource=flag

原理:

PHP的 php://filter 协议对路径的解析是“松散”的:

  • 即使路径中包含额外的字符串(如 index),只要最终 resource= 后的文件名正确,仍能读取目标文件。
  • 例如:
    php://filter/aaa/bbb/index/convert.base64-encode/resource=flag
    实际读取的文件是 resource= 后的 flag,而路径中的其他部分会被忽略。