Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check if an IP is owned by Cloudflare
#!/bin/env python
# Credits goes to @sw33tLie
from ipaddress import ip_network, ip_address
cidrs = ["173.245.48.0/20","103.21.244.0/22","103.22.200.0/22","103.31.4.0/22","141.101.64.0/18","108.162.192.0/18","190.93.240.0/20","188.114.96.0/20","197.234.240.0/22","198.41.128.0/17","162.158.0.0/15","104.16.0.0/12","172.64.0.0/13","131.0.72.0/22"]
def is_cloudflare(ip):
for cidr in cidrs:
net = ip_network(cidr)
if (ip_address(ip) in net):
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment