Elasticsearch未授權訪問漏洞
阿新 • • 發佈:2019-02-09
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了。
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:
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"]