Generate json file of Amazon AWS IP's

pull/54/head
eCrimeLabs 2018-02-21 22:50:13 +01:00 committed by GitHub
parent 3bda7dd622
commit f0c996b8de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

View File

@ -0,0 +1,32 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import datetime
import urllib.request
import json
res = urllib.request.urlopen('https://ip-ranges.amazonaws.com/ip-ranges.json')
res_body = res.read()
j = json.loads(res_body.decode("utf-8"))
l = []
for prefix in j['prefixes']:
#print("{0}".format(prefix['ip_prefix']))
l.append(prefix['ip_prefix'])
for prefix in j['ipv6_prefixes']:
#print("{0}".format(prefix['ipv6_prefix']))
prefix['ipv6_prefix']
warninglist = {}
warninglist['name'] = 'List of known Amazon AWS IP address ranges'
warninglist['version'] = int(datetime.date.today().strftime('%Y%m%d'))
warninglist['description'] = 'Amazon AWS IP address ranges (https://ip-ranges.amazonaws.com/ip-ranges.json)'
warninglist['list'] = sorted(set(l))
warninglist['matching_attributes'] = ["ip-src", "ip-dst", "domain|ip"]
print(json.dumps(warninglist))