Skip to content

Instantly share code, notes, and snippets.

@dwisiswant0
Created May 25, 2020 00:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dwisiswant0/4e070e78b3af913ee9a339d39c5fdc04 to your computer and use it in GitHub Desktop.
Save dwisiswant0/4e070e78b3af913ee9a339d39c5fdc04 to your computer and use it in GitHub Desktop.
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