python脚本之批量提取fofa的漏洞IP
前言:
用cookie的目的是API调用多的话,是要付费的,所以。。。。
2023/8/7 更新:实现多线程,目前测试线程为2是最稳定,超过2数据就乱了,又写了一个通过大量IP查web系统的脚本。
2023/3/14 更新:爬取ip的参数更改,注释了部分不重要代码,只用来提取IP到txt中,不用再cmd中运行了。
本次python脚本是通过学习小迪师傅的课程学习而来,由于现在的fofa改变域名为fofa.info,所以下文中的python脚本中的一些值是根据目前的fofa网站改写的
脚本:(poc.py)
import requests
import base64
import time
from lxml import etree
import threading
def fofa_search(search_data, page_data):
# 必须要有cookie
headers = {
"cookie": ""
}
lock = threading.Lock() # 创建线程锁
def process_page(page):
url = 'https://fofa.info/result?qbase64='
search_data_bs = str(base64.b64encode(search_data.encode("utf-8")), "utf-8")
urls = url + search_data_bs + '&page=' + str(page) + '&page_size=10'
print(urls)
try:
retry_count = 3
while retry_count > 0:
try:
result = requests.get(url=urls, headers=headers, timeout=10).text
break # 请求成功,跳出重试循环
except requests.RequestException as e