From d22c6902b35af04a00a8e8561e92fb302759772e Mon Sep 17 00:00:00 2001 From: elhoim Date: Wed, 24 Jul 2019 17:35:39 +0200 Subject: [PATCH] Added list and tool to generate list for cloudflare IP ranges. --- lists/cloudflare/list.json | 34 ++++++++++++++++++++++++++++++++++ tools/generate-cloudflare.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 lists/cloudflare/list.json create mode 100755 tools/generate-cloudflare.py diff --git a/lists/cloudflare/list.json b/lists/cloudflare/list.json new file mode 100644 index 0000000..407ddfc --- /dev/null +++ b/lists/cloudflare/list.json @@ -0,0 +1,34 @@ +{ + "list": [ + "198.41.128.0/17", + "131.0.72.0/22", + "104.16.0.0/12", + "103.21.244.0/22", + "197.234.240.0/22", + "173.245.48.0/20", + "188.114.96.0/20", + "108.162.192.0/18", + "141.101.64.0/18", + "162.158.0.0/15", + "2400:cb00::/32", + "2803:f800::/32", + "103.22.200.0/22", + "2a06:98c0::/29", + "2c0f:f248::/32", + "2405:8100::/32", + "2405:b500::/32", + "190.93.240.0/20", + "2606:4700::/32", + "103.31.4.0/22", + "172.64.0.0/13" + ], + "type": "cidr", + "matching_attributes": [ + "ip-dst", + "ip-src", + "domain|ip" + ], + "name": "List of known Cloudflare IP ranges", + "version": 20190724, + "description": "List of known Cloudflare IP ranges (https://www.cloudflare.com/ips/)" +} diff --git a/tools/generate-cloudflare.py b/tools/generate-cloudflare.py new file mode 100755 index 0000000..155af9f --- /dev/null +++ b/tools/generate-cloudflare.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 + +import json +import os +import requests +import datetime +import io + +base_url="https://www.cloudflare.com/" +uri_list=['ips-v4','ips-v6'] +dict=dict() +dict['list']=list() +def source_read_and_add(input_file): + output_list=list() + + for line in input_file.splitlines(): + output_list.append(line) + return output_list + + +for uri in uri_list: + url = base_url + uri + r=requests.get(url) + dict['list'] += source_read_and_add(r.text) + +dict['type'] = "cidr" +dict['matching_attributes']=["ip-dst","ip-src","domain|ip"] +dict['name']="List of known Cloudflare IP ranges" +dict['version']= int(datetime.date.today().strftime('%Y%m%d')) +dict['description']="List of known Cloudflare IP ranges (https://www.cloudflare.com/ips/)" +dict['list']=list(set(dict['list'])) + +print(json.dumps(dict))