Created
May 25, 2020 00:46
-
-
Save dwisiswant0/4e070e78b3af913ee9a339d39c5fdc04 to your computer and use it in GitHub Desktop.
Check if an IP is owned by Cloudflare
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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