Skip to content

Commit a2517fe

Browse files
elhoimclaude
andcommitted
add: [apple-ipv4/apple-ipv6] Apple IP ranges from AS714 and AS6185 (RIPEstat)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0121gk7vaCXX9bMri7tC9XVd
1 parent 84f0610 commit a2517fe

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

generate_all.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ set -x
66
pushd tools
77
# python3 generate_alexa.py # not updated since February 1, 2023 and offline after July 31, 2023
88
python3 generate-amazon-aws.py
9+
python3 generate-apple-ip-ranges.py
910
python3 generate-cisco.py
1011
python3 generate-cloudflare.py
1112
python3 generate-covid.py

tools/generate-apple-ip-ranges.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
import ipaddress
5+
import json
6+
7+
from generator import download, get_version, write_to_file, consolidate_networks
8+
9+
ASNS = ["AS714", "AS6185"]
10+
11+
12+
def fetch_prefixes(asn):
13+
url = "https://stat.ripe.net/data/announced-prefixes/data.json?resource={}".format(asn)
14+
r = download(url)
15+
data = json.loads(r.text)
16+
return [entry["prefix"] for entry in data["data"]["prefixes"]]
17+
18+
19+
def process(dst, name, description, prefixes):
20+
warninglist = {
21+
'name': name,
22+
'version': get_version(),
23+
'description': description,
24+
'matching_attributes': ["ip-src", "ip-dst", "domain|ip", "ip-src|port", "ip-dst|port"],
25+
'type': 'cidr'
26+
}
27+
28+
warninglist['list'] = consolidate_networks(prefixes)
29+
30+
write_to_file(warninglist, dst)
31+
32+
33+
if __name__ == '__main__':
34+
all_prefixes = []
35+
for asn in ASNS:
36+
all_prefixes.extend(fetch_prefixes(asn))
37+
38+
ipv4_prefixes = [p for p in all_prefixes if ipaddress.ip_network(p).version == 4]
39+
ipv6_prefixes = [p for p in all_prefixes if ipaddress.ip_network(p).version == 6]
40+
41+
process(
42+
"apple-ipv4",
43+
"List of known Apple IPv4 ranges",
44+
"Apple IPv4 ranges announced by AS714 and AS6185",
45+
ipv4_prefixes,
46+
)
47+
process(
48+
"apple-ipv6",
49+
"List of known Apple IPv6 ranges",
50+
"Apple IPv6 ranges announced by AS714 and AS6185",
51+
ipv6_prefixes,
52+
)

0 commit comments

Comments
 (0)