Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion decode-spam-headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2823,18 +2823,31 @@ def testOrganizationIsO365Tenant(self):
self.addSecurityAppliance('Office365')

try:
# First get the tenant ID via OpenID config
r = requests.get(f'https://login.microsoftonline.com/{value}/.well-known/openid-configuration')
out = r.json()

if 'error' in out.keys() and out['error'] != '':
m = out['error']
return []

result += '\n - Organization disclosed in "X-OriginatorOrg" is a valid Office 365 Tenant:\n'
# Extract tenant ID from token endpoint
tid = out['token_endpoint'].replace('https://login.microsoftonline.com/', '')
tid = tid.replace('/oauth2/token', '')

# Now query ai.moda's Azure AD Tools API with the tenant ID
r2 = requests.get(f'https://azure-ad-tools.ai.moda/api/v1.0.0/lookup-by-tenant-id/{tid}')
out2 = r2.json()

result += '\n - Organization disclosed in "X-OriginatorOrg" is a valid Office 365 Tenant:\n'
result += '\t- Office365 Tenant ID: ' + self.logger.colored(tid, 'green') + '\n'

if 'displayName' in out2:
result += f'\t- Display Name: {self.logger.colored(out2["displayName"], "green")}\n'

if 'federationBrandName' in out2 and out2['federationBrandName']:
result += f'\t- Federation Brand Name: {self.logger.colored(out2["federationBrandName"], "green")}\n'

tmp = ''

num0 = 0
Expand Down