-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.py
44 lines (33 loc) · 1.22 KB
/
api.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
42
43
44
import requests
import base64
api_key = 'coloquesuakeyaqui'
query = 'product.name="Check Point SSL Network Extender" and web.title=="Check Point SSL Network Extender" and ip.port=="80"'
encoded_query = base64.urlsafe_b64encode(query.encode("utf-8")).decode('ascii')
start_time = '2024-01-01'
end_time = '2024-05-01'
page = 1
page_size = 100 # Ajuste o tamanho da página conforme necessário
all_results = []
while True:
url = "https://api.hunter.how/search?api-key=%s&query=%s&page=%d&page_size=%d&start_time=%s&end_time=%s" % (
api_key, encoded_query, page, page_size, start_time, end_time
)
r = requests.get(url)
data = r.json()
if data['code'] == 200:
results = data['data']['list']
all_results.extend(results)
total_results = data['data']['total']
current_count = len(all_results)
if current_count >= total_results:
break
page += 1
else:
print("Erro ao obter resultados: ", data['message'])
break
# Salvar todos os IPs em um arquivo
with open('ips.txt', 'w') as file:
for result in all_results:
ip = result['ip']
file.write(ip + '\n')
print("IPs salvos em 'ips.txt'")