attacking-oauth-with-device-code-phishing
できること
このツールは、フィッシング攻撃をシミュレーションして、メールやファイルなどのMicrosoftサービスのアクセストークンを盗むことを想定しています。ユーザーを騙して攻撃者のアクセスを許可させ、多要素認証(MFA)を回避します。
使う場面
- ✓権限を得て実施する、Microsoft 365システムに対するセキュリティテストの際。
- ✓MFAやトークン盗難への対策が機能しているかを確認するとき。
- ✓MFAを回避されるリスクと、より強力な認証の必要性を示すとき。
スキルのリンク
https://github.com/mukul975/Anthropic-Cybersecurity-Skills/blob/main/skills/attacking-oauth-with-device-code-phishing/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私のMicrosoft 365アカウントに対して、デバイスコードフィッシング攻撃をシミュレーションしてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このツールは、ユーザーを正規のMicrosoftページに誘導して「デバイスを接続」させる処理を開始します。ユーザーがツールから提供されたコードを入力すると、知らないうちに攻撃者にトークンへのアクセスを許可してしまいます。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Attacking OAuth with Device-Code Phishing
Legal Notice: This skill is for authorized security testing, red-team engagements, and educational purposes only. Device-code and consent-grant phishing manipulate real users into authorizing attacker-controlled access to corporate identities. Execute only against tenants you own or have explicit written authorization (rules of engagement) to test. Unauthorized use violates the Computer Fraud and Abuse Act and equivalent laws worldwide.
Overview
The OAuth 2.0 Device Authorization Grant (RFC 8628) was designed for input-constrained devices (smart TVs, CLI tools) that cannot easily present a browser-based login. A device requests a short user_code and a device_code, displays the user_code and a verification URL to the user, and polls the token endpoint while the user authenticates on a separate, fully-featured device. Attackers weaponize this flow: instead of a smart TV, the "device" is the attacker's machine. The attacker initiates the device-code request, then phishes a victim to visit the legitimate Microsoft verification page (https://microsoft.com/devicelogin) and enter the attacker-generated user_code. Because the victim authenticates on the genuine Microsoft login page — completing MFA — the resulting tokens are minted to the attacker's polling session. This bypasses MFA entirely: the second factor is satisfied by the victim, but the bearer tokens land with the attacker (mapped to MITRE ATT&CK T1528 – Steal Application Access Token).
Microsoft Threat Intelligence, Volexity, and Proofpoint documented sharp growth in device-code phishing through 2025, with Russia-aligned actors (tracked by Microsoft as Storm-2372) among the most prolific. Mandiant's M-Trends reporting similarly highlights OAuth token theft as a leading cloud initial-access vector. A closely related technique is the illicit consent grant ("OAuth phishing"): the attacker registers a multi-tenant app and tricks the victim into clicking an /adminconsent or user-consent URL, granting the malicious app delegated Microsoft Graph permissions (Mail.Read, Files.ReadWrite.All, offline_access) that persist independently of password resets. This skill covers both, plus token replay across Microsoft 365 services using TokenTactics and validation/access mapping with ROADtools.
The defining property red teams exploit: access tokens minted via the device-code flow are valid for roughly 60–90 minutes, but the accompanying refresh token (with offline_access scope) survives for up to 90 days and can be redeemed for fresh tokens against any first-party resource the client is allowed to request — Outlook, SharePoint, Teams, Azure Resource Manager — enabling durable, MFA-surviving access.
When to Use
- During an authorized red-team or assumed-breach engagement targeting Microsoft 365 / Entra ID where social-engineering is in scope
- When validating Conditional Access policies, MFA enforcement, and token-protection controls against real phishing techniques
- When testing whether an organization restricts the OAuth device-code flow or blocks unverified multi-tenant app consent
- When demonstrating MFA-bypass risk to justify phishing-resistant authentication (FIDO2) and token-binding controls
- When building detections (paired with the blue-team
hunting-saas-sso-token-abuseskill) and you need realistic telemetry
Prerequisites
- Written authorization / rules of engagement explicitly permitting phishing and token theft against the target tenant
- A controlled pretext-delivery channel (sanctioned phishing infrastructure or an internal test mailbox)
- Linux or Windows attacker host with Python 3.8+ and PowerShell 7+
- TokenTactics (PowerShell) and ROADtools (Python) installed:
# ROADtools (roadrecon + roadtx) — Dirk-jan Mollema / Outsider Security pip install roadtools roadtools_auth # roadtx (ROADtools Token eXchange) ships in roadtools_auth roadtx --help # TokenTactics v2 (rvrsh3ll) git clone https://github.com/rvrsh3ll/TokenTactics.git pwsh -c "Import-Module ./TokenTactics/TokenTactics.psd1" - Familiarity with OAuth 2.0 grant types, JWT structure, and Microsoft Graph scopes
Objectives
- Initiate an OAuth device-code request against Entra ID using a first-party client ID
- Deliver a credible pretext that drives the victim to the genuine Microsoft device-login page
- Poll the token endpoint and capture the victim's access and refresh tokens
…
よくある質問
アクセストークンとリフレッシュトークンとは何ですか?
アクセストークンは、サービスにアクセスするための一時的な鍵のようなものです。リフレッシュトークンは長期間有効な鍵で、パスワードを変更した後でも新しいアクセストークンを発行できます。
これはどうやってMFAを回避するのですか?
ユーザーは正規のMicrosoftページでコードを入力するため、二要素認証は完了します。しかし、発行されたトークンは正規のユーザーではなく攻撃者に渡されます。
このツールを使うには許可が必要ですか?
はい。テストを行うには、システム所有者からの明示的な書面による承認が不可欠です。無断での使用は違法です。
詳細
作者による元の説明
Run OAuth 2.0 device-code and illicit-consent phishing attacks against Microsoft Entra ID, using TokenTactics-style tooling to steal access and refresh tokens, bypass MFA, and pivot across Microsoft 365 services. Use for authorized red-team engagements simulating device-code or consent-grant phishing against a tenant you have explicit written permission to test.
人気
- GitHubのスター
- 35k
- ランキング
- #7673
- ライセンス
- Apache-2.0
- 更新日
- 2026/8/31
コメント
- …
このリポジトリの他のスキル
abusing-dpapi-for-credential-access
35k特定のタスク向けに用意された指示をAIエージェントに与え、より良く、より速く作業できるようにします。
abusing-shadow-credentials-for-privesc
35kAIエージェントに、明確で構成のしっかりした文章の書き方を教えます。
achieving-cmmc-level-2-compliance
35kエージェントがCMMC Level 2への準拠に向けた環境を整えられるようにします。セキュリティ要件を実装し、必要なドキュメントを管理します。
acquiring-disk-image-with-dd-and-dcfldd
35kエージェントがハードディスクの完全なコピーを作成できるようにします。調査中に情報が失われたり改変されたりしないようにするのに役立ちます。
似ているスキル
reverse-engineer-anything
422kREAツールを使って、出荷済みのアプリやパッケージの中身を調べ、機能の説明、版の比較、再構築の手順をエージェントが支援します。
1password
394k1Password CLIをセットアップし、サインインして、秘密情報の値を会話に表示せずに読み取ったり注入したりするようエージェントを支援します。
healthcheck
394kOpenClawを動かすコンピューターやサーバーを、SSH、ファイアウォール、更新、バックアップなどのセキュリティリスクについて監査し、安全な修正案を提案するようエージェントを支援します。