Created
November 10, 2015 21:43
-
-
Save byt3bl33d3r/c3919985888ef3834342 to your computer and use it in GitHub Desktop.
Get up hosts using Shodan! Takes as input a comma separated subnet list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import shodan | |
import sys | |
from shodan import APIError | |
from netaddr import IPNetwork | |
SHODAN_API_KEY= 'APIKEY' | |
api = shodan.Shodan(SHODAN_API_KEY) | |
targets = map(IPNetwork, sys.argv[1].split(',')) | |
hosts = [] | |
for net in targets: | |
for target in net.iter_hosts(): | |
hosts.append(str(target)) | |
for host in hosts: | |
try: | |
res = api.host(host) | |
print host | |
except (APIError, KeyboardInterrupt): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment