easyjson

<?php
include 'security.php';

if(!isset($_GET['source'])){
    show_source(__FILE__);
    die();
}
$sandbox = 'sandbox/'.sha1($_SERVER['HTTP_X_FORWARDED_FOR']).'/';
var_dump($sandbox);
if(!file_exists($sandbox)){
    mkdir($sandbox);
    file_put_contents($sandbox."index.php","<?php echo 'Welcome To Dbapp OSS.';?>");
}
$action = $_GET['action'];
$content = file_get_contents("php://input");


if($action == "write" &&  SecurityCheck('filename',$_GET['filename']) &&SecurityCheck('content',$content)){
    $content = json_decode($content);
    $filename = $_GET['filename'];
    $filecontent = $content->content;
    $filename = $sandbox.$filename;
    file_put_contents($filename,$filecontent."\n Powered By Dbapp OSS.");
}elseif($action == "reset"){
    $files = scandir($sandbox);
    foreach($files as $file) {
        if(!is_dir($file)){
            if($file !== "index.php"){
                unlink($sandbox.$file);
            }
        }
    }
}
else{
    die('Security Check Failed.');
}

先GET一个$source参数,什么值都可以,并创建一个沙盒,将一句php写入index.php,这个时候访问sandbox/0763c3a8c2f6eabcaea913e1c51ab732cd082ecd/index.php是有回显的。

接着传入GET参数 $action,通过 php://input 协议读入没有处理的POST提交的数据。

如果 $action 值为 "write",通过GET方式得到filename,将 $content 通过 json 格式解码,最终在 $filename 写入 $content 中的 $content 参数。

可以得到最终GET的三个参数:

最后用POST提交的json参数伪协议流,构造比较有难度,可以直接写入/readflag:

其中 \u006e 绕过对 content 的WAF,代码执行/readflag

也可以上一句话木马,这里直接上了:

Last updated