Skip to content

Instantly share code, notes, and snippets.

@macostag
Created February 10, 2020 02:39
Show Gist options
  • Save macostag/686fbd09d1283b81071a5bf6625574d4 to your computer and use it in GitHub Desktop.
Save macostag/686fbd09d1283b81071a5bf6625574d4 to your computer and use it in GitHub Desktop.
Shodan network block enumeration.
from shodan import Shodan
import ipaddress
import pprint
import json
pp = pprint.PrettyPrinter(indent=2)
api = Shodan('')
net = ipaddress.ip_network('')
for xIp in net.hosts():
try:
print(xIp)
ipinfo = api.host(str(xIp))
pp.pprint(ipinfo)
with open('ip_network.json', 'a') as fp:
json.dump(ipinfo, fp)
except:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment