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"]
最后
歡迎關注個人微信公眾號:Bypass--,每周原創一篇技術干貨。