Elasticsearch 未授权访问


   Elasticsearch服务普遍存在一个未授权访问的问题,攻击者通常可以请求一个开放9200或9300的服务器进行恶意攻击。

0x00 Elasticsearch 安装

前提,保证安装了JDK 1.7+

下载地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.zip (用迅雷打开下载,速度极慢)

1、解压elasticsearch安装包

2、进入bin 目录,双击执行 elasticsearch.bat

 

3、访问http://localhost:9200/,出现以下页面,说明安装成功。

0x01 漏洞测试

安装了river之后可以同步多种数据库数据(包括关系型的mysql、mongodb等)。
http://localhost:9200/_cat/indices里面的indices包含了_river一般就是安装了river了。

1
2
3
http: //localhost:9200/_cat/indices
http: //localhost:9200/_river/_search 查看数据库敏感信息
http: //localhost:9200/_nodes 查看节点数据
1
2
如有安装head插件:
http: //localhost:9200/_plugin/head/ web管理界面

0x02 Python未授权访问脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#! /usr/bin/env python
# _*_  coding:utf-8 _*_
 
import requests
def Elasticsearch_check(ip, port=9200, timeout=5):
     try :
       url =  "http://" +ip+ ":" +str(port)+ "/_cat"
       response = requests. get (url) 
     except:
       pass
     if  "/_cat/master"  in  response.content:
       print  '[+] Elasticsearch Unauthorized: '  +ip+ ':' +str(port)
 
if  __name__ ==  '__main__' :
     Elasticsearch_check( "127.0.0.1" )

0X03 加固方案

1、限制IP访问,绑定固定IP
2、在config/elasticsearch.yml中为9200端口设置认证:
  http.basic.enabled true #开关,开启会接管全部HTTP连接
  http.basic.user "admin" #账号
  http.basic.password "admin_pw" #密码
  http.basic.ipwhitelist ["localhost", "127.0.0.1"]


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM