Generate json file of Amazon AWS IP's
parent
3bda7dd622
commit
f0c996b8de
|
@ -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))
|
Loading…
Reference in New Issue