2018-02-21 22:50:13 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
2021-06-12 12:13:23 +02:00
|
|
|
from generator import download_to_file, get_version, write_to_file, get_abspath_source_file, consolidate_networks
|
2020-07-17 10:06:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
def process(file, dst):
|
2020-07-27 10:44:30 +02:00
|
|
|
with open(get_abspath_source_file(file), 'r') as json_file:
|
2020-07-17 10:06:06 +02:00
|
|
|
amazon_aws_ip_list = json.load(json_file)
|
|
|
|
l = []
|
|
|
|
|
|
|
|
for prefix in amazon_aws_ip_list['prefixes']:
|
|
|
|
l.append(prefix['ip_prefix'])
|
|
|
|
|
|
|
|
for prefix in amazon_aws_ip_list['ipv6_prefixes']:
|
|
|
|
l.append(prefix['ipv6_prefix'])
|
|
|
|
|
2020-07-21 00:31:06 +02:00
|
|
|
warninglist = {
|
|
|
|
'name': 'List of known Amazon AWS IP address ranges',
|
|
|
|
'version': get_version(),
|
|
|
|
'description': 'Amazon AWS IP address ranges (https://ip-ranges.amazonaws.com/ip-ranges.json)',
|
|
|
|
'type': 'cidr',
|
2021-06-12 12:13:23 +02:00
|
|
|
'list': consolidate_networks(l),
|
2024-04-22 09:20:14 +02:00
|
|
|
'matching_attributes': ["ip-src", "ip-dst", "domain|ip", "ip-src|port", "ip-dst|port"]
|
2020-07-21 00:31:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
write_to_file(warninglist, dst)
|
2018-02-21 22:50:13 +01:00
|
|
|
|
|
|
|
|
2020-07-17 10:06:06 +02:00
|
|
|
if __name__ == '__main__':
|
|
|
|
amazon_url = "https://ip-ranges.amazonaws.com/ip-ranges.json"
|
|
|
|
amazon_file = "amazon_ip-ranges.json"
|
|
|
|
amazon_dst = "amazon-aws"
|
2018-02-21 22:50:13 +01:00
|
|
|
|
2020-07-17 10:06:06 +02:00
|
|
|
download_to_file(amazon_url, amazon_file)
|
|
|
|
process(amazon_file, amazon_dst)
|