forked from DataSploit/datasploit
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathip_shodan.py
88 lines (77 loc) · 3.38 KB
/
ip_shodan.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env python
import base
import config as cfg
import requests
import json
import sys
from termcolor import colored
ENABLED = True
class style:
BOLD = '\033[1m'
END = '\033[0m'
def banner():
print colored(style.BOLD + '[+] Searching in Shodan' + style.END)
def main(ip):
endpoint = "https://api.shodan.io/shodan/host/" + str(ip) + "?key=" + cfg.shodan_api
req = requests.get(endpoint)
return json.loads(req.content)
def output(data, ip=""):
if 'error' in data.keys():
print 'No information available for that IP.'
else:
asn = ''
print colored(style.BOLD + '\n----------- Per Port Results -----------' + style.END)
if 'data' in data.keys():
for x in data['data']:
print colored(style.BOLD + '\nResponse from Open Port: %s' + style.END, 'green') % (x['port'])
'''if 'title' in x.keys():
print colored(style.BOLD + '[+] Title:\t\t' + style.END, 'green') + str(x['title'])'''
if 'title' in x.keys():
print colored(style.BOLD + '[+] HTML Content:\t' + style.END, 'green') + str(
'Yes (Please inspect Manually on this port)')
if 'http' in x.keys():
print colored(style.BOLD + '[+] HTTP port present:\t' + style.END, 'green')
print '\tTitle: %s' % x['http']['title']
print '\tRobots: %s' % x['http']['robots']
print '\tServer: %s' % x['http']['server']
print '\tComponents: %s' % x['http']['components']
print '\tSitemap: %s' % x['http']['sitemap']
if 'ssh' in x.keys():
print colored(style.BOLD + '[+] HTTP port present:\t' + style.END, 'green')
print '\tType: %s' % x['ssh']['type']
print '\tCipher: %s' % x['ssh']['cipher']
print '\tFingerprint: %s' % x['ssh']['fingerprint']
print '\tMac: %s' % x['ssh']['mac']
print '\tKey: %s' % x['ssh']['key']
if 'ssl' in x.keys():
print '\tSSL Versions: %s' % x['ssl']['versions']
if 'asn' in x.keys():
asn = data['asn']
if 'vulns' in x['opts']:
for y in x['opts'].keys():
print x['opts'][y]
if 'product' in x.keys():
print 'Product: %s' % x['product']
if 'version' in x.keys():
print 'Version: %s' % x['version']
print colored(style.BOLD + '\n----------- Basic Info -----------' + style.END, 'blue')
print 'Open Ports: %s' % data['ports']
print 'Latitude: %s' % data['latitude']
print 'Hostnames: %s' % data['hostnames']
print 'Postal Code: %s' % data['postal_code']
print 'Country Code: %s' % data['country_code']
print 'Organization: %s' % data['org']
if asn != '':
print 'ASN: %s' % asn
if 'vulns' in data.keys():
print colored(style.BOLD + 'Vulnerabilties: %s' + style.END, 'red') % data['vulns']
print ""
if __name__ == "__main__":
try:
ip = sys.argv[1]
banner()
result = main(ip)
output(result, ip)
except Exception as e:
print e
print "Please provide an IP Address as argument"