Skip to content

Instantly share code, notes, and snippets.

Last active Apr 23, 2021
What would you like to do?
#!/usr/bin/env python3
import ipaddress
from SPF2IP import SPF2IP
ignore_list = set({''})
ignore_list.update({ # Microsoft O365
add_list = {
result = set()
for item in add_list:
with open('domains.csv', 'r') as f:
lines =
for line in lines:
lookup = SPF2IP(line)
for r in lookup.IPArray('4'):
if r not in ignore_list:
# TODO(frennkie) this is pretty "broad"
except Exception as e:
print(f"[WARN] {line}: {e}")
total = 0
for item in result:
ia = ipaddress.IPv4Network(item)
total += ia.num_addresses
print("[INFO] ===")
print(f"[INFO] Total number of Ranges: {len(result)}")
print(f"[INFO] Total number of IPs: {total}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment