2016-12-06 12:16:34 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import requests
|
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
import json
|
2016-12-06 12:39:45 +01:00
|
|
|
import datetime
|
2016-12-06 12:16:34 +01:00
|
|
|
|
|
|
|
url = 'https://support.content.office.net/en-us/static/O365IPAddresses.xml'
|
|
|
|
r = requests.get(url)
|
|
|
|
office365 = ET.fromstring(r.text)
|
|
|
|
l = []
|
|
|
|
for address in office365.iter('address'):
|
|
|
|
l.append(address.text.replace('*', ''))
|
|
|
|
|
|
|
|
warninglist = {}
|
2016-12-06 12:39:45 +01:00
|
|
|
warninglist['name'] = 'List of known Office 365 URLs and IP address ranges'
|
2017-02-12 21:01:36 +01:00
|
|
|
warninglist['version'] = int(datetime.date.today().strftime('%Y%m%d'))
|
2016-12-06 12:16:34 +01:00
|
|
|
warninglist['description'] = 'Office 365 URLs and IP address ranges'
|
2017-02-12 21:01:36 +01:00
|
|
|
warninglist['list'] = sorted(set(l))
|
|
|
|
warninglist['matching_attributes'] = ["ip-src", "ip-dst", "domain|ip", "hostname"]
|
2016-12-06 12:16:34 +01:00
|
|
|
|
2016-12-06 12:39:45 +01:00
|
|
|
|
2017-02-12 21:01:36 +01:00
|
|
|
print(json.dumps(warninglist))
|