-
Notifications
You must be signed in to change notification settings - Fork 65
/
zoomeye_search.py
44 lines (30 loc) · 1002 Bytes
/
zoomeye_search.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
from __future__ import print_function
import requests
import configparser
config = configparser.ConfigParser()
config.read("api.conf")
username = config.get('zoomeye', 'username')
password = config.get('zoomeye', 'password')
def zoomeye_search(word):
try:
data = '{ "username": "'+username+'", "password": "'+password+'" }'
response = requests.post('https://api.zoomeye.org/user/login', data=data)
token = response.json()['access_token']
except:
print("[-] We got an error with your zoomeye credentials. (Check if zoomeye is down ¯\_(ツ)_/¯)")
exit(1)
try:
headers = {
'Authorization': 'JWT {0}'.format(token),
}
params = {
('query', 'title: "{0}"'.format(word))
}
response = requests.get('https://api.zoomeye.org/host/search', headers=headers, params=params)
final = response.json()['matches']
title_result = set([host['ip'] for host in final])
if title_result:
return title_result
except:
print("[-] We got an error here!")
exit(1)