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

0x00 Elasticsearch 安装

前提,保证安装了JDK 1.7+

下载地址: artifacts.elastic.co/downloads/e… (用迅雷打开下载,速度极慢)

1、解压elasticsearch安装包

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

3、访问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未授权访问脚本

#! /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: 
	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"]

欢迎关注个人微信公众号:Bypass--,每周原创一篇技术干货。

 

分类:
代码人生
  •