前言

机缘巧合,为了给bytectf出题,不会写代码,无奈拿起老本行,代码审计一下pbootcms,先说一次,CTF诚不欺我

cms相关历史

目前公网看到的最新的是3.0.1版本的rce,https://xz.aliyun.com/t/8321,简单审计之后发现这个cms的历史漏洞真多,比如比较新的有这个 https://www.anquanke.com/post/id/222849#h3-6,不过这里与之前漏洞不太一样的是,这是修改文件上传后缀getshell,前提还需要能破解admin的密码

waf正则

那么我们再来看这里的rce都是怎么防御的,总的来说,要过三个正则

\\{pboot:if\\(([^}^\\$]+)\\)\\}([\\s\\S]*?)\\{\\/pboot:if\\}

([\\w]+)([\\x00-\\x1F\\x7F\\/\\*\\<\\>\\%\\w\\s\\\\\\\\]+)?\\(

(\\$_GET\\[)|(\\$_POST\\[)|(\\$_REQUEST\\[)|(\\$_COOKIE\\[)|(\\$_SESSION\\[)|(file_put_contents)|(file_get_contents)|(fwrite)|(phpinfo)|(base64)|(`)|(shell_exec)|(eval)|(assert)|(system)|(exec)|(passthru)|(pcntl_exec)|(popen)|(proc_open)|(print_r)|(print)|(urldecode)|(chr)|(include)|(request)|(__FILE__)|(__DIR__)|(copy)|(call_user_)|(preg_replace)|(array_map)|(array_reverse)|(array_filter)|(getallheaders)|(get_headers)|(decode_string)|(htmlspecialchars)|(session_id)

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/100037e8-27ae-4199-a978-7a7ae9430f45/Untitled.png

可以说是非常的苛刻,最终调用的php代码如下

eval('if(' . $matches[1][$i] . '){$flag="if";}else{$flag="else";}');

我们首先来看第一个正则

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/a18dd18b-ca91-430c-813b-e69a86ba3df7/Untitled.png

这个正则主要是限制了,if语句里面不能出现}、^、$这三个字符

我们来看看第二个正则

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/e8e76c0c-ec37-486d-8288-c01582894718/Untitled.png

很明显,这里限制了调用了函数,在KCon2019大会上的提出的新特性也过滤掉了,导致调用函数基本不成可能??

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/93fb05b7-3781-4687-8e92-61dd4c92075c/Untitled.png