ToB企服应用市场:ToB评测及商务社交产业平台

标题: Zookeeper占的那些端口 - 从Eclipse Jetty安全漏洞说起 [打印本页]

作者: 用户云卷云舒    时间: 2024-11-3 15:10
标题: Zookeeper占的那些端口 - 从Eclipse Jetty安全漏洞说起
因由

系统扫描报Jetty漏洞,很希奇,系统中明显没有利用Jetty! 后来发现是Zookeeper中会利用Jetty,因为有利用Kafka,所以也利用了Zookeeper。
Zookeeper利用Jetty重要干2个变乱:
1)提供给Prometheus用来输出监控指标用,占用端口7000
2)提供给AdminServer用来查询系统设置项,占用端口8080
也就是说,只要禁用这两个功能就可以了。
1)禁用7000端口

看下官方文档的描述:
   Since 3.6.0 ZooKeeper binary package bundles an integration with Prometheus.io
metricsProvider.className : Set to “org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider” to enable Prometheus.io exporter.
    metricsProvider.httpHost : New in 3.8.0: Prometheus.io exporter will start a Jetty server and listen this address, default is “0.0.0.0”
    metricsProvider.httpPort : Prometheus.io exporter will start a Jetty server and bind to this port, it defaults to 7000. Prometheus end point will be http://hostname:httPort/metrics.
    metricsProvider.exportJvmInfo : If this property is set to true Prometheus.io will export useful metrics about the JVM. The default is true.
    metricsProvider.numWorkerThreads : New in 3.7.1: Number of worker threads for reporting Prometheus summary metrics. Default value is 1. If the number is less than 1, the main thread will be used.
    metricsProvider.maxQueueSize : New in 3.7.1: The max queue size for Prometheus summary metrics reporting task. Default value is 1000000.
    metricsProvider.workerShutdownTimeoutMs : New in 3.7.1: The timeout in ms for Prometheus worker threads shutdown. Default value is 1000ms.
  在3.8.1版本中,7000端口默认就没打开,所以啥也不用动
  1. #metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
  2. #metricsProvider.httpHost=0.0.0.0
  3. #metricsProvider.httpPort=7000
  4. #metricsProvider.exportJvmInfo=true
复制代码
也就是说,只要注释掉metricsProvider相干设置即可。
2)禁用8080

还是看下官方文档:
   New in 3.5.0: The following options are used to configure the AdminServer.
    admin.enableServer : (Java system property: zookeeper.admin.enableServer) Set to “false” to disable the AdminServer. By default the AdminServer is enabled.
    admin.serverAddress : (Java system property: zookeeper.admin.serverAddress) The address the embedded Jetty server listens on. Defaults to 0.0.0.0.
    admin.serverPort : (Java system property: zookeeper.admin.serverPort) The port the embedded Jetty server listens on. Defaults to 8080.
    admin.idleTimeout : (Java system property: zookeeper.admin.idleTimeout) Set the maximum idle time in milliseconds that a connection can wait before sending or receiving data. Defaults to 30000 ms.
    admin.commandURL : (Java system property: zookeeper.admin.commandURL) The URL for listing and issuing commands relative to the root URL. Defaults to “/commands”.
  默认AdminServer是打开的,我们可以打开访问http://192.168.200.128:8080/commands这个url看下这个界面:

点击比如“configuration”:

这个功能是可以禁用的,只必要在设置文件中设置admin.enableServer=false大概在zkServer.sh中设置java系统变量-Dzookeeper.admin.enableServer=fasle就可以了。
3)禁用JMX端口

禁用了7000和8080以后,发现Zookeeper除了占用2181之外,还占用了一个随机的端口,这个又是干啥的,如下:
  1. [root@localhost apache-zookeeper-3.8.1-bin]# netstat -nap | grep 15216
  2. tcp6       0      0 :::2181                 :::*                    LISTEN      15216/java         
  3. tcp6       0      0 :::41897                :::*                    LISTEN      15216/java
复制代码
原来是JMX占用的,而且默认也是打开的,可以修改zkServer.sh禁用掉JMX:
  1. # 在最开始添加上这一行即可
  2. export JMXDISABLE=true
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4