Guest User

Untitled

a guest
Nov 19th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #!/usr/bin/env python
  2. ##################################
  3. # pip install netaddr
  4. from netaddr import IPAddress, IPNetwork
  5.  
  6. file_out = "./internet-connected.csv"
  7. with open(file_out, mode='a+') as f:
  8. for class_a in range(0, 255):
  9. a = IPAddress("%s.0.0.0" % class_a)
  10. if not a.is_reserved():
  11. for class_b in range(0, 255):
  12. b = IPAddress("%d.%d.0.0" % (class_a, class_b))
  13. if not b.is_reserved():
  14. for class_c in range(0, 255):
  15. c = IPAddress("%d.%d.%d.0" % (class_a, class_b, class_c))
  16. if not c.is_reserved() and not c.is_private():
  17. ip = "%s/24" % c
  18. for host_ip in IPNetwork(ip).iter_hosts():
  19. if host_ip.is_unicast():
  20. f.write(str(host_ip) + '\n')
Add Comment
Please, Sign In to add comment