makeiplistunique.py 397 B

1234567891011121314151617
  1. from netaddr import IPNetwork as CIDR
  2. import sys
  3. if len(sys.argv) != 2:
  4. print(f"usage: {sys.argv[0]} <iplist.txt>")
  5. exit(0)
  6. try:
  7. with open(sys.argv[1], "r") as iplist:
  8. networks = iplist.read().strip().split("\n")
  9. except FileNotFoundError as e:
  10. print("[-] File not found")
  11. exit(1)
  12. for nw in networks:
  13. for ip in CIDR(nw):
  14. sys.stdout.write(f"{str(ip)}\n")