CTFwriteup

一道有趣的ctf题目

 题目描述

<?php include 'flag.php'; 
    if(isset($_GET['code'])){ $code = $_GET['code']; 
      if(strlen($code)>35){
        die("Long.");
    }
    if(preg_match("/[A-Za-z0-9_$]+/",$code)){
        die("NO.");
    }
    @evaal($code);
}else{
    highlight_file(__FILE__);
}
//$hint =  "php function getFlag() to get flag";
?>
初看到这题还以为是个原题,可以看phithon牛的一篇文章https://www.leavesongs.com/penetration/webshell-without-alphanum.html,但是这道题
不一样之处在于过滤了$,这个php变量符,导致我们无法继续像文中所说那样构造payload,不过这里还有一个办法,这办法不能getshell,也就只能读文件,
在于linux下可以用 "?" "*" "%" 当作命令替代符,经过测试 /bin/cat 可以用 /???/??? 来替代,那么我们便可以用cat命令打印出flag.
思路如下:
     1.打印出flag.php的内容
     2.继续匹配flag文件

留言

您的电子邮箱地址不会被公开。 必填项已用 * 标注