-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathshodan_mrclw.py
29 lines (26 loc) · 900 Bytes
/
shodan_mrclw.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
import shodan
class ShodanMrclw:
def __init__(self, shoddan_api_key_str: str):
self._api = shodan.Shodan(shoddan_api_key_str)
def search_str(self, word: str):
try:
# Search Shodan
results = self._api.search(word)
if results:
return results
return None
except shodan.APIError as err:
print('Error: {}'.format(err))
def search_ip_str(self, word: str) -> list:
try:
if word:
ip_list = []
results = self.search_str(word)
if results:
for result in results['matches']:
ip_list.append(format(result['ip_str']))
return ip_list
return None
return None
except shodan.APIError as err:
print('Error: {}'.format(err))