Notes on Microsoft 365 and Azure Active Directory

This post is intended to be a collection of resources, techniques and knowledge around security in Microsoft 365 and Azure Active Directory. The pages heavily relies on public resources.

The following topics are discussed:

Identify Microsoft 365 subscription and tenantID

One of the first questions that comes in mind when approaching simulated attacks, is if the targret organization has a Microsoft 365 subscription. To answer this question public APIs can be leveraged. Each tenant on Microsoft 365 has a unique identifier, namely GUID (Globally Unique IDentifier). This ID is publicly available. To get this information programatically, a GET request can be made to the following URI:<FQDN>/.well-known/openid-configuration

Fans of linux’s curl can do:


The response to the request, will have a structure similar to the listed below:

  "token_endpoint": "<GUID>/oauth2/token",
  "token_endpoint_auth_methods_supported": [
  "jwks_uri": "",
  "response_modes_supported": [
  "subject_types_supported": [
  "id_token_signing_alg_values_supported": [
  "response_types_supported": [
    "code id_token",
    "token id_token",
  "scopes_supported": [
  "issuer": "<GUID>/",
  "microsoft_multi_refresh_token": true,
  "authorization_endpoint": "<GUID>/oauth2/authorize",
  "device_authorization_endpoint": "<GUID>/oauth2/devicecode",
  "http_logout_supported": true,
  "frontchannel_logout_supported": true,
  "end_session_endpoint": "<GUID>/oauth2/logout",
  "claims_supported": [
  "check_session_iframe": "<GUID>/oauth2/checksession",
  "userinfo_endpoint": "<GUID>/openid/userinfo",
  "kerberos_endpoint": "<GUID>/kerberos",
  "tenant_region_scope": "WW",
  "cloud_instance_name": "",
  "cloud_graph_host_name": "",
  "msgraph_host": "",
  "rbac_url": ""

The PowerShell cmdlet Get-AADIntTenantID from AADInternals [1] will parse the output and print the GUID of the tenant, effectively providing the tenantID. If this cmdlet prints a GUID it can be safely concluded that the company behind the provided FQDN, has a Microsoft 365 subscription.

Identify domains registered from a tenant

A request to the URL listed below returns the domains registered from the tenant of the given domain. This information was pulled from [1].

For Threat Intelligence purposes, that means that if an attacker uses a Microsoft tenant to host phishing infrastructure (for example register phising domains), the following URL reveals additional domains. This information may become useful to attribute activity to a specific threat actor (threat actor that uses a single tenant to conduct phishing against multiple targets).

For teams that emulate attacker activities (attack simulation, red team) caution must be exercised to not use the same tenant for registering phishing domains used in different attacks or for different stages of an engagement. This will increase the operational security (OPSEC) of the engagement and contribute to the stealthiness.

Fans of Linux’s curl (body.txt contains the SOAP request):

curl -i -H “Content-Type:text/xml; charset=utf-8” -H ‘SOAPAction:””’ -H “User-Agent:AutodiscoverClient” -d @./body.txt “”

Complete request (replace <DOMAIN> with the desired domain):

POST /autodiscover/autodiscover.svc HTTP/1.1
Accept: */*
Content-Type:text/xml; charset=utf-8
SOAPAction: ""
User-Agent: AutodiscoverClient

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:exm="" xmlns:ext="" xmlns:a="" xmlns:soap="" xmlns:xsi="" xmlns:xsd="">
                <a:Action soap:mustUnderstand="1"></a:Action>
                <a:To soap:mustUnderstand="1"></a:To>
                <GetFederationInformationRequestMessage xmlns="">

Sample response:

<s:Envelope xmlns:s="" xmlns:a="">
		<a:Action s:mustUnderstand="1"></a:Action>
		<h:ServerVersionInfo xmlns:h="" xmlns:i="">
		<GetFederationInformationResponseMessage xmlns="">
			<Response xmlns:i="">

Enumerate user accounts on Microsoft 365

It is possible to enumerate user accounts on Microsoft O365 [1], [3] by calling the API located at:

The enumeration allows an attacker to identify valid users accounts in preparation for phishing.

The API enforces throttling and therefore if a large number of requests is to be made, a tool such as Fireprox [4] could allow attackers avoid this defense.

Sample request with curl:

curl -H “Content-Type: application/json; charset=UTF-8” -d ‘{“flowToken”:””,”isCookieBannerShown”:”false”,”isRemoteNGCSupported”:”false”,”originalRequest”:””,”isOtherIdpSupported”:”true”,”checkPhones”:”true”,”username”:”<USER_ACCOUNT>@<DOMAIN>”,”isFidoSupported”:”false”}’ “”

Sample request:

POST /common/GetCredentialType HTTP/1.1
Accept: */*
Content-Type: application/json; charset=UTF-8
Content-Length: 400


Body of sample Response if account exists (IfExistsResult equals 0):

  "Username": "",
  "Display": "",
  "IfExistsResult": 0,
  "IsUnmanaged": false,
  "ThrottleStatus": 1,
  "Credentials": {
    "PrefCredential": 1,
    "HasPassword": true,
    "RemoteNgcParams": null,
    "FidoParams": null,
    "SasParams": null,
    "CertAuthParams": null,
    "GoogleParams": null,
    "FacebookParams": null
  "EstsProperties": {
    "UserTenantBranding": [
        "Locale": 0,
        "BannerLogo": "<REDACTED>",
        "Illustration": "<REDACTED>",
        "KeepMeSignedInDisabled": false,
        "UseTransparentLightBox": false
    "DomainType": 3
  "IsSignupDisallowed": true,
  "apiCanary": "<REDACTED>"

Notes on Active Directory Federation Services auditing

To identify the FQDN of a ADFS server (the server may be internet-facing or sitting behind a proxy):

curl -s<USERNAME>@<DOMAIN>?api-version=2.0 | jq ‘.AuthURL’

Shodan and Censys provide a broader list of ADFS servers exposed (directly or through a proxy) to the internet.

To list the available ADFS endpoints use the federation metadata endpoint [5]:

curl https://<ADFS FQDN>/adfs/services/trust/mex

If either or both endpoints /adfs/services/trust/2005/windowstransport and /adfs/services/trust/13/windowstransport are available, they leak the internal hostname of the ADFS server (not the hostname of the proxy), including the Active Directory domain name. These endpoints support NTLM-based authentication for on-premises users and Microsoft recommends they should be intranet facing only [6]. Exposing these endpoints to the internet could allow attackers bypass account lockout protections.

After identifying the ADFS server and the endpoint it exposes, to identify the internal hostname and domain name acquiring information from NTLM tools such as Shodan (a form of passive scan - a third party does the scanning) or nmap (a form of active scan - the one who scans hits the scanned infrastructure) give the answer.

To retrieve disclosed NTLM information with nmap, the script http-ntlm-info is the way to go. For example:

nmap -sS -p 443 –script http-ntlm-info –script-args http-ntlm-info.root=/adfs/services/trust/2005/windowstransport <ADFS_server>

Or, in case the endpoint used above is not available:

nmap -sS -p 443 –script http-ntlm-info –script-args http-ntlm-info.root=/adfs/services/trust/13/windowstransport <ADFS_server>

Another interesting endpoint in terms of enumeration is /adfs/ls/idpinitiatedsignon.aspx. If enabled, this endpoint lists all the relying parties and provides an additional form for authentication. The list of relying parties may be utilised for spear phishing (targeted attacks) as in inspire lures related to relying parties.

Hybrid Environments

In hybrid environments authentication for valid accounts may not redirect to the ADFS server. If that’s the case, the following request returns null.

curl -s<USERNAME>@<DOMAIN>?api-version=2.0 | jq ‘.AuthURL’

To retrieve the ADFS FQDN repeat the request with an invalid email address.

Deliver emails to Office 365 bypassing third-party mail filtering

This section provides a methodology on how to bypass third-party mail filtering (if this is possible) to deliver an email to the Office 365 of tenant, leveraging publicly available information.

Organizations that migrate their email infrastructure to Office 365 often add an additional security layer by sending first the emails to a third-party mail filtering service (such as Proofpoint). However, due to misconfigurations it may still be possible to send an email directly to the tenant effectively bypassing the third-party filtering.

First things first. To identify what email fitlering service is used, first look at the MX record of a domain. Assuming Proofpoint services are used to filter incoming emails for the imaginary domain, the MX DNS record for should like:

;; ANSWER SECTION:   1800   IN   MX   10 <SUBDOMAIN1>   1800   IN   MX   10 <SUBDOMAIN2>

Next step is to identify if the imaginary domain is linked to Microsoft cloud infrastructure. For this, the cmdlet Get-AADIntTenantID [1] provides the answer.

Get-AADIntTenantID -Domain

After confirming that the domain is linked to a tenant, next is to identify all the domains that are registered from that tenant. If the MX record for the domain formatted as points to the domain formatted as * that indicates that Office 365 is used for emails. The list of registered domains under the tenant, is:

Get-AADIntTenantDomains -Domain

Run through the list of domains the above cmdlet returns and look for Assuming this is, the next step is to check the MX record for that domain:

dig mx

If the result includes the domain that means Office 365 is used for email delivery. Therefore, if the mail filtering is not configured properly, it may be possible to send emails directly to <DOMAIN>

The next step in the process is to identify the address to send the email. To find this information, traverse the MX record of the <DOMAIN> domain. This is in the form:


The IP address the domain listed above resolves to is the destination address.

The information posted in this section was acquired from [2].


Microsoft Exchange Online legacy protocols MFA check

When the user agent BAV2ROPC is send along with an authentication request to Microsoft Exchange Online, the ROPC OAuth [9] flow is initiated. If invalid_grant is returned, this is indicative that MFA is enabled.

Attackers have used this technique to identify if MFA is enabled [8] and avoid other services that may be sitting behind MFA. For an attacker with valid credential this could lead to Business Email Compromise (BEC).

The request to check this:

POST {tenant}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
User-Agent: BAV2ROPC












tags: #Microsoft 365 and Azure Active Directory