Elasticsearch服务广泛存在一个未受权访问的问题,攻击者一般能够请求一个开放9200或9300的服务器进行恶意攻击。node
0x00 Elasticsearch 安装python
前提,保证安装了JDK 1.7+mysql
下载地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.zip (用迅雷打开下载,速度极慢)web
一、解压elasticsearch安装包sql
二、进入bin 目录,双击执行 elasticsearch.batmongodb
三、访问http://localhost:9200/,出现如下页面,说明安装成功。数据库
0x01 漏洞测试服务器
安装了river以后能够同步多种数据库数据(包括关系型的mysql、mongodb等)。
http://localhost:9200/_cat/indices里面的indices包含了_river通常就是安装了river了。微信
http://localhost:9200/_cat/indices http://localhost:9200/_river/_search 查看数据库敏感信息
http://localhost:9200/_nodes 查看节点数据
若有安装head插件:
http://localhost:9200/_plugin/head/ web管理界面
0x02 Python未受权访问脚本elasticsearch
#! /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 加固方案
一、限制IP访问,绑定固定IP
二、在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"]
最后
欢迎关注我的微信公众号:Bypass--,每周原创一篇技术干货。