-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathitv_fofa.py
41 lines (36 loc) · 1.1 KB
/
itv_fofa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import requests
API_URL = "https://fofa.info/api/v1/search/all"
API_KEY = "g832@qq.com"
SECRET = "01eb0c0d94dab0f234627012f7e6b527"
QUERY = "你的查询语句" # 例如: "protocol=\"http\""
PAGE = 1
PAGE_SIZE = 50 # 每页条数,fofa API 限制最大 100
def get_token(key, secret):
url = "https://fofa.info/api/v1/info/ip"
data = {
"email": key,
"key": secret
}
response = requests.post(url, data=data)
return response.json()["data"]["Token"]
def search_fofa(query, page, page_size, token):
url = API_URL
data = {
"email": API_KEY,
"key": SECRET,
"qbase64": base64.b64encode(query.encode('utf-8')).decode('utf-8'),
"page": page,
"size": page_size,
"token": token
}
headers = {
"Range": f"items {page}-{page_size}"
}
response = requests.post(url, data=data, headers=headers)
return response.json()
if __name__ == "__main__":
token = get_token(API_KEY, SECRET)
results = search_fofa(QUERY, PAGE, PAGE_SIZE, token)
# 处理结果
for result in results:
print(result)