Microsoft 365 and Entra ID
Microsoft 365 (Exchange Online, SharePoint, Teams, OneDrive) and Entra ID (formerly Azure AD) are the identity and productivity of most companies. They share the same directory as Azure (see Azure Pentesting), so compromising M365 can give access to Azure and vice versa. The vectors combine identity attacks (phishing, spraying, app consent) with abuse of collaboration features.
Threat model
Section titled “Threat model”The attacker almost always starts without credentials: they enumerate the tenant, find valid users, and hunt for the weak authentication link (missing MFA, legacy protocols, password spraying, illicit consent). Once inside an account, they pivot to email, files, and Teams, enumerate the tenant from within, and look for escalation to privileged roles up to Global Administrator, which in turn allows elevation into the Azure plane. The final asset is control of the tenant (identity + data of the whole organization).
flowchart TD
A[No credentials] --> B[Enumerate tenant and users]
B --> C{Initial access}
C -->|password spraying| D[User account]
C -->|no MFA / legacy| D
C -->|illicit consent| E[User tokens]
D --> F[Email / files / Teams]
F --> G[Enumerate tenant from inside]
G --> H[Escalate to Global Admin]
H --> I[Elevate into Azure: cloud-azure]
Theory: what’s what
Section titled “Theory: what’s what”- Entra ID: identity directory (users, groups, apps, roles). The key role is Global Administrator = full tenant control.
- M365 workloads: Exchange Online (email), SharePoint/OneDrive (files), Teams (collaboration).
Entra ID is the same directory that governs Azure, hence the bridge between both worlds.
Red Team
Section titled “Red Team”Recon without credentials
Section titled “Recon without credentials”# does the domain use M365/Entra? and tenant datacurl -s "https://login.microsoftonline.com/target.com/.well-known/openid-configuration" | jq .# valid-user and tenant enumerationo365spray --validate --domain target.com# AADInternals (PowerShell): Get-AADIntLoginInformation, tenant info# federation: managed or federated? (affects the authentication attack)Initial access (identity)
Section titled “Initial access (identity)”# password spraying against M365 endpoints (see ad-spray)o365spray --spray -U users.txt -p 'Summer2025!' --domain target.com# MFASweep: which services do NOT require MFA? (MFA gaps)# leaked credentials (see recon-personas / HIBP)# illicit consent grant: malicious app requests permissions -> user consents -> tokensThe absence of MFA on some endpoint (or legacy protocols that bypass it) is the key finding for initial access.
Post-compromise of a user
Section titled “Post-compromise of a user”- Access to the victim’s email, files, and Teams.
- Email forwarding rules (stealthy exfiltration / BEC).
- Searching for secrets in email/SharePoint/OneDrive (passwords, documents).
- Enumerate the tenant from inside (ROADrecon, AzureHound → see Azure Pentesting).
- Internal phishing (from a legitimate account, with greater trust).
Escalation and bridge to Azure
Section titled “Escalation and bridge to Azure”- App/Service Principal with excessive permissions.
- Illicit consent → tokens of more users.
- Privileged Role Administrator role → Global Admin.
- A Global Admin can elevate to control the Azure subscriptions (see Azure Pentesting).
Persistence (authorized engagements only)
Section titled “Persistence (authorized engagements only)”- Forwarding / inbox rules (BEC).
- Add credentials to a Service Principal or app with permissions.
- Register your own device or MFA method on the victim account.
- Federation backdoors (AADInternals) → very stealthy, requires Global Admin.
Blue Team
Section titled “Blue Team”- MFA everywhere (Conditional Access); block legacy protocols (basic IMAP/POP/SMTP) that bypass MFA.
- Block user consent to apps; review apps/Service Principals and their permissions.
- PIM for privileged roles; minimum number of Global Admins; anomalous sign-in alerts.
- Detection: new forwarding rules, consents, impossible sign-ins (Entra ID Protection, Defender for Office/Cloud Apps).
- SPF/DKIM/DMARC (anti-spoofing, see Email Enumeration); anti-phishing training.
Checklist
Section titled “Checklist”- Does the domain use M365/Entra? tenant info (openid-configuration)
- Enumerate valid users (o365spray/AADInternals)
- Password spraying against M365 (Password Spraying)
- MFASweep: endpoints without MFA / legacy protocols
- Illicit consent grant (malicious app)
- Post-compromise: email/files/forwarding rules
- Enumerate tenant and escalate to Global Admin (Azure Pentesting)
- Bridge to Azure and persistence