致远oa xxe getshell分析(附脚本)

admin 2023年10月23日09:25:53评论300 views字数 1319阅读4分23秒阅读模式

0x01 前言


最近看到有大佬公布了致远xxe的后利用,简单来说就是通过xxe漏洞去打本地60001端口Agent服务的testDBConnect接口,因为用户可通过传递driverClass参数自定义数据库driver,所以可以通过控制JDBC Connection URL打H2 RCE执行任意代码来获取权限。
这个xxe漏洞的URL是建议大家好好去跟一下,一个绕过吧前几年就已经有了,感兴趣的可以去看看。
过程就不详细带大家看了,就直接看一些重要位置。还有就是我新建了一个小密圈,暂时是免费的(0.1 100张券),主要是为了方便交流与反馈,然后就是之后有一些工具、文章、漏洞等我也会放到里面,希望与兄弟们一起打造我们的小圈子,这个漏洞的脚本我已经放到了小密圈,大家文末扫码进入即可。

0x02 漏洞分析


XXE漏洞
可以看到主要有四个参数需要传递,encode设置为true获取参数的时候会进行base64解码,elemId不为空可以进入循环体即可,imgvalue传入内容长度大于65即可。

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

然后会进入signature方法,它接收xmlValue并调用runSignature。

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

runSignature调用了xmlToList,xmlToList调用了getNodes,最后调用saxReader.read解析xml造成了XXE漏洞。

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

JDBC反序列化
driverClass可控,调用testDBConnect进而调用getConnection。

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

直接访问发现全局拦截器判断了用户token,首先需要token不为空还要满足TokenUtils.isChecktoken的条件才会返回true。

致远oa xxe getshell分析(附脚本)

tokenMap中如果包含传递的这个token就会返回true。

致远oa xxe getshell分析(附脚本)

全局搜索tokenMap.发现TokenUtils类中的getToken调用了 tokenMap.put将token存入

致远oa xxe getshell分析(附脚本)

全局搜索调用TokenUtils类getToken方法的位置,需要传递两个参数,传递之后会将传递的数据进行处理(看注释),最后经过toJavaBean的转换传递给各个变量。

致远oa xxe getshell分析(附脚本)

可以看到在调用TokenUtils类的getToken方法之前,还判断了seeyon用户的密码,校验通过之后才会生成token存进tokenMap,最后返回token到响应体。所以此时需要知道seeyon用户的密码。

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

在Dao层搜seeyon,可以看到modifyDefaultUserInfo修改了seeyon用户的密码。

致远oa xxe getshell分析(附脚本)

Service层没有任何条件直接调用Dao层这边修改了seeyon用户的密码。

致远oa xxe getshell分析(附脚本)

Controller这边也是直接接收了参数,然后调用了Service层的modifyDefaultUserInfo方法。

致远oa xxe getshell分析(附脚本)

0x03 漏洞复现


将111.xml与222.xml放到vps,开一个web端口,修改111.xml与222.xml中外带数据的请求地址为你的vps web端口地址,之后修改拼接xmldata1进行密码重置。

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

修改为xmldata2获取token。

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

修改上传的文件名以及内容,拼接xmldata3运行即可。

致远oa xxe getshell分析(附脚本)

致远oa xxe getshell分析(附脚本)

成功上传。

致远oa xxe getshell分析(附脚本)

原文始发于微信公众号(小黑说安全):致远oa xxe getshell分析(附脚本)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2023年10月23日09:25:53
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   致远oa xxe getshell分析(附脚本)http://cn-sec.com/archives/2134940.html

发表评论

匿名网友 填写信息