-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshodanAPI.py
38 lines (30 loc) · 1.11 KB
/
shodanAPI.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
import shodan
import requests
target = str(input("Enter URL or IP Address of your target website: "))
SHODAN_API_KEY = "INSERT YOUR OWN KEY"
api = shodan.Shodan(SHODAN_API_KEY)
dns_resolve = 'https://api.shodan.io/dns/resolve?hostnames=' + \
target + '&key=' + SHODAN_API_KEY
try:
# First we need to resolve our targets domain to an IP
resolved = requests.get(dns_resolve)
hostIP = resolved.json()[target]
# Then we need to do a Shodan search on that IP
host = api.host(hostIP)
print("IP: %s" % host['ip_str'])
print("Organization: %s" % host.get('org', 'n/a'))
print("Operating System: %s" % host.get('os', 'n/a'))
# Print all banners
for item in host['data']:
print("Port: %s" % item['port'])
print("Banner: %s" % item['data'])
# Print vuln information
for item in host['vulns']:
CVE = item.replace('!', '')
print('Vulns: %s' % item)
exploits = api.exploits.search(CVE)
for item in exploits['matches']:
if item.get('cve')[0] == CVE:
print(item.get('description'))
except:
'An error occurred'