RCE漏洞案例-PbootCMS1.3.2

1.网站搭建

网站下载地址:下载仓库 · 星梦/PbootCMS - Gitee.com

下载下来之后先看下md文件

我们小皮上面设置好网站和数据库之后,在对应文件进行修改

然后导入数据库文件之后我们直接打开网站

我在这个时候遇到了两个问题

1.一直显示php版本过低,我换了很多次都没办法

2.显示没有带上php扩展gd扩展,这个我查看扩展是带了的

我解决1的方法是不要带127.0.0.1这个前标去访问,改一下网站的域名,最好不要带特殊字符比如.这些的,可能容易造成浏览器的错误

2的解决方法是换php的版本,我从5.5换到了7.0,终于登上 了

我的配置是php7.3+ngnix1.15+mysql5.7

2.漏洞注入

全文搜索eval之后

里面使用函数的只有一个ParserController.php在里面找到这个函数

public function parserIfLabel($content)
    {
        $pattern = '/\{pboot:if\(([^}]+)\)\}([\s\S]*?)\{\/pboot:if\}/';
        $pattern2 = '/pboot:([0-9])+if/';
        if (preg_match_all($pattern, $content, $matches)) {
            $count = count($matches[0]);
            for ($i = 0; $i < $count; $i ++) {
                $flag = '';
                $out_html = '';
                $danger = false;
                
                $white_fun = array(
                    'date',
                    'in_array',
                    'explode',
                    'implode',
                    'get',
                    'post'
                );
                
                // 带有函数的条件语句进行安全校验
                if (preg_match_all('/([\w]+)([\s]+)?\(/i', $matches[1][$i], $matches2)) {
                    foreach ($matches2[1] as $value) {
                        if ((function_exists($value) || preg_match('/^eval$/i', $value)) && ! in_array($value, $white_fun)) {
                            $danger = true;
                            break;
                        }
                    }
                }
                
                // 如果有危险函数,则不解析该IF
                if ($danger) {
                    continue;
                } else {
                    $matches[1][$i] = decode_string($matches[1][$i]); // 解码条件字符串
                }
                
                eval('if(' . $matches[1][$i] . '){$flag="if";}else{$flag="else";}');
                if (preg_match('/([\s\S]*)?\{else\}([\s\S]*)?/', $matches[2][$i], $matches2)) { // 判断是否存在else
                    switch ($flag) {
                        case 'if': // 条件为真
                            if (isset($matches2[1])) {
                                $out_html = $matches2[1];
                            }
                            break;
                        case 'else': // 条件为假
                            if (isset($matches2[2])) {
                                $out_html = $matches2[2];
                            }
                            break;
                    }
                } elseif ($flag == 'if') {
                    $out_html = $matches[2][$i];
                }
                
                // 无限极嵌套解析
                if (preg_match($pattern2, $out_html, $matches3)) {
                    $out_html = str_replace('pboot:' . $matches3[1] . 'if', 'pboot:if', $out_html);
                    $out_html = str_replace('{' . $matches3[1] . 'else}', '{else}', $out_html);
                    $out_html = $this->parserIfLabel($out_html);
                }
                
                // 执行替换
                $content = str_replace($matches[0][$i], $out_html, $content);
            }
        }
        return $content;
    }
可以发现这个函数的使用需要前面不检测到危险函数

由于是函数我们需要知道是谁在调用

是另一个函数调用,在全局搜索这个函数

这些调用的都可以利用这个漏洞进行注入,但是我这里出了个问题

不知道又是哪里出了问题,要是有知道的可以让我学习学习

所以我们干脆下一步看看大佬的:【漏洞分析】PbootCMS v1.3.2命令执行和SQL注入漏洞(0day) - 知乎 (zhihu.com)

3.思路

eval(标志函数)<-ParserConroller.php(parserIfLabel)(漏洞点)<-ParserConroller.php(parserAfter)(调用)<-多个页面调用

  • 23
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值