Edited at

Office365のURLやIPアドレスの一覧をCSVで取得する


公式ページ

https://docs.microsoft.com/en-us/office365/enterprise/urls-and-ip-address-ranges


Office365の最新情報のURL

最新のリストがXML形式からJSON形式で取得できるようになっています。

https://endpoints.office.com/endpoints/worldwide?clientrequestid=XXXXXXX

そのままCSV形式でダウンロードするときは後ろに「&Format=CSV」をつけてあげる

https://endpoints.office.com/endpoints/worldwide?clientrequestid=XXXXXXX&Format=CSV


Appendix

取得した情報を整形したり列とか行だけ取り出したりしたいのでちょっと書いてみた。


Python


o365check.py

import ssl

import urllib2
import json
import pandas as pd
import csv
# ignore ssl certificate check error
ssl._create_default_https_context = ssl._create_unverified_context
# client_id for microsoft office365 ip address list web site
client_id = 'XXXX';
# URL generation
URL = "https://endpoints.office.com/endpoints/worldwide?clientrequestid=" + client_id
# Use python urllib2 *check current python version
req = urllib2.Request(URL)
response = urllib2.urlopen(req)
o365_dict = response.read()
# cvs generation
df = pd.read_json(o365_dict)
print df.iloc[:,[7,10,3,8,9]


出力結果


o365check.py

[root@localhost ~]# ./o365check.py

serviceAreaDisplayName urls ips tcpPorts udpPorts
0 Exchange Online [outlook.office.com, outlook.office365.com] [13.107.6.152/31, 13.107.9.152/31, 13.107.18.1... 80,443 NaN
1 Exchange Online [smtp.office365.com] [13.107.6.152/31, 13.107.9.152/31, 13.107.18.1... 587 NaN
2 Exchange Online [r1.res.office365.com, r3.res.office365.com, r... NaN 80,443 NaN
3 Exchange Online [domains.live.com] NaN 80,443 NaN
4 Exchange Online [*.outlook.office.com, outlook.office365.com] [13.107.6.152/31, 13.107.9.152/31, 13.107.18.1... 143,993 NaN
5 Exchange Online [*.outlook.office.com, outlook.office365.com] [13.107.6.152/31, 13.107.9.152/31, 13.107.18.1... 995 NaN
6 Exchange Online [*.store.core.windows.net, asl.configure.offic... NaN 80,443 NaN
7 Exchange Online [*.outlook.com, *.outlook.office.com] NaN 80,443 NaN
8 Exchange Online [*.protection.outlook.com] [23.103.132.0/22, 23.103.136.0/21, 23.103.144.... 443 NaN
9 Exchange Online [*.mail.protection.outlook.com] [23.103.132.0/22, 23.103.136.0/21, 23.103.144.... 25 NaN
10 Skype for Business Online and Microsoft Teams NaN [13.107.64.0/18, 52.112.0.0/14] NaN 3478,3479,3480,3481
11 Skype for Business Online and Microsoft Teams [*.lync.com, *.teams.microsoft.com, teams.micr... [13.70.151.216/32, 13.71.127.197/32, 13.72.245... 80,443 NaN
12 Skype for Business Online and Microsoft Teams [*.broadcast.skype.com, broadcast.skype.com] [13.70.151.216/32, 13.71.127.197/32, 13.72.245... 443 NaN
13 Skype for Business Online and Microsoft Teams [quicktips.skypeforbusiness.com] NaN 443 NaN
14 Skype for Business Online and Microsoft Teams [*.sfbassets.com, *.urlp.sfbassets.com, skypem... NaN 80,443 NaN
15 Skype for Business Online and Microsoft Teams [*.keydelivery.mediaservices.windows.net, *.ms... NaN 443 NaN