当前位置:网站首页>【信息收集】从FoFa—API接口数据写入TXT和Excel
【信息收集】从FoFa—API接口数据写入TXT和Excel
2022-07-21 19:13:00 【sGanYu】
email值和key值获取
更改代码url值
import requests
import base64
import xlwt
import time
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0"}
getquery = input("查询语法(无需base64编码):", )
strquery = str.encode(getquery)
bquery = base64.b64encode(strquery)
fquery = str(bquery, "utf-8")
size = input("查询条数:", )
url = "https://fofa.info/api/v1/search/all?email=你的email值&key=你的KEY值&" + "qbase64=" + fquery + "&page=1&size=" + str(
size) + "&results={ip}"
print(url)
html = requests.get(url=url, headers=headers).json()
print(f'开始写入{getquery}.txt')
for i in html['results']:
with open(f'{getquery}.txt', 'a+', encoding='utf-8') as Ip_Port:
Ip_Port.write('域名:' + i[0] + '\n' + 'IP:' + i[1] + '\n' + '端口:' + i[2] + '\n' + '=' * 20 + '\n')
print(i[0])
print(f'写入{getquery}.txt成功')
number = 1
File_Found = xlwt.Workbook(encoding='utf-8') # 工作簿
File_Sheet = File_Found.add_sheet('FOFA数据', cell_overwrite_ok=True) # 工作表
col = ('域名', 'IP', '端口')
nowtime = str(round(time.time())) + '_' + f'{getquery}'
for i in range(0, len(html["results"])):
data = html["results"][i]
for k in range(0, 3):
File_Sheet.write(0, k, col[k])
File_Sheet.write(i + 1, k, data[k])
savepath = f'M:/{nowtime}.xls'
File_Found.save(savepath)
print(f'Excel文件生成成功,已保存至M:/{nowtime}.xls')
边栏推荐
- At the age of 51, he wrote code for the satellite: tough life, never afraid of late
- 对话框管理器第一章:先热热身
- Is it safe for Dongfang fortune to open an account? What certificates do you need
- [explanation of PTA program design topic] [English version] [6-5 use function to verify Goldbach conjecture]
- 金仓数据库KingbaseES安全指南--2.2. KingbaseES对数据库安全威胁的预防
- Some personal understanding
- [cicadaplayer] vs2019 (v142) x64 ffmepg: error c2169: "lrintf": internal function, cannot be defined
- Explanation of fast SCNN and implementation using tensorflow 2.0
- List iterator
- The three-tier structure completes the addition, deletion, modification and search of chapter I
猜你喜欢
随机推荐
[Basic] Pointer in C
Concurrent modification exception
2022开源PHP留言反馈管理系统 v2.0
启动,关闭,查看MySQL服务(Linux)
std::thread 与类对象结合
Energy principle and variational method note 09: examples of virtual work principle
测试环境建设的基本原则
Collection (properties)
Start, close and view MySQL service (Linux)
11-GuliMall 后台管理中商品系统的分类维护
Login prompt ora-28000 the account is locked
能量原理与变分法笔记05:自然边界条件例题
2022 第三方宝塔面板 btcloud PHP源码
BigInteger :new BigInteger(tokenJson.getBytes()).toString(16)什么意思
他51岁,给卫星写代码:彪悍的人生,从来不怕晚
Google Earth Engine(GEE)—— 下载一个最简单的sentinel-2影像的单日ndvi下载
d编译时扩展ctfe
Standard input / output stream
D extend CTFE at compile time
Explanation of fast SCNN and implementation using tensorflow 2.0