2016-12-06 12:16:34 +01:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import requests
|
|
|
|
import json
|
2016-12-06 12:39:45 +01:00
|
|
|
import datetime
|
2016-12-06 12:16:34 +01:00
|
|
|
|
2019-03-10 01:43:13 +01:00
|
|
|
url = 'https://endpoints.office.com/endpoints/worldwide?clientrequestid=b10c5ed1-bad1-445f-b386-b919946339a7'
|
2016-12-06 12:16:34 +01:00
|
|
|
r = requests.get(url)
|
2019-03-10 01:43:13 +01:00
|
|
|
service_list = r.json()
|
2019-03-10 09:27:12 +01:00
|
|
|
lurls= []
|
|
|
|
lips = []
|
|
|
|
|
2019-03-10 01:43:13 +01:00
|
|
|
for service in service_list:
|
|
|
|
for url in service.get('urls', []):
|
2019-03-10 09:27:12 +01:00
|
|
|
lurls.append(url.replace('*', ''))
|
2019-03-10 01:43:13 +01:00
|
|
|
for ip in service.get('ips', []):
|
2019-03-10 09:27:12 +01:00
|
|
|
lips.append(ip)
|
2016-12-06 12:16:34 +01:00
|
|
|
|
|
|
|
warninglist = {}
|
2019-03-10 09:27:12 +01:00
|
|
|
warninglist['name'] = 'List of known Office 365 URLs 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'
|
2019-03-10 09:27:12 +01:00
|
|
|
warninglist['type'] = 'string'
|
|
|
|
warninglist['list'] = sorted(set(lurls))
|
|
|
|
warninglist['matching_attributes'] = ["domain", "domain|ip", "hostname"]
|
|
|
|
|
2016-12-06 12:16:34 +01:00
|
|
|
|
2019-03-10 01:43:13 +01:00
|
|
|
with open('../lists/microsoft-office365/list.json', 'w') as data_file:
|
|
|
|
json.dump(warninglist, data_file, indent=4, sort_keys=True)
|
2019-03-10 09:27:12 +01:00
|
|
|
|
|
|
|
warninglist = {}
|
2019-03-10 09:28:31 +01:00
|
|
|
warninglist['name'] = 'List of known Office 365 IP address ranges'
|
2019-03-10 09:27:12 +01:00
|
|
|
warninglist['version'] = int(datetime.date.today().strftime('%Y%m%d'))
|
|
|
|
warninglist['description'] = 'Office 365 URLs and IP address ranges'
|
|
|
|
warninglist['list'] = sorted(set(lips))
|
|
|
|
warninglist['type'] = 'cidr'
|
|
|
|
warninglist['matching_attributes'] = ["ip-src", "ip-dst", "domain|ip"]
|
|
|
|
|
|
|
|
|
2019-03-25 11:43:27 +01:00
|
|
|
with open('../lists/microsoft-office365-ip/list.json', 'w') as data_file:
|
2019-03-10 09:27:12 +01:00
|
|
|
json.dump(warninglist, data_file, indent=4, sort_keys=True)
|