From f6fce7884e04e629644cc0890032b14d2e9398d2 Mon Sep 17 00:00:00 2001 From: Translator Date: Wed, 19 Nov 2025 17:18:19 +0000 Subject: [PATCH] Translated ['', 'src/pentesting-cloud/azure-security/az-privilege-escala --- .../az-entraid-privesc/dynamic-groups.md | 52 +++++++++++++++---- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md index 6c0605dd5..6a3e50d05 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md @@ -1,28 +1,60 @@ -# Az - 动态组权限提升 +# Az - 动态组 提权 {{#include ../../../../banners/hacktricks-training.md}} ## 基本信息 -**动态组**是具有一组配置的**规则**的组,所有符合规则的**用户或设备**将被添加到该组。每当用户或设备的**属性**被**更改**时,动态规则会被**重新检查**。当**新规则**被**创建**时,所有设备和用户都会被**检查**。 +**动态组** 是一类配置了若干 **规则** 的组,所有符合这些规则的 **用户或设备** 会被加入到该组。每当用户或设备的 **属性** 被 **更改** 时,动态规则会被 **重新检查**。当创建 **新规则** 时,所有设备和用户也会被 **检查**。 -动态组可以被分配**Azure RBAC 角色**,但**无法**将**AzureAD 角色**添加到动态组中。 +动态组可以被分配 **Azure RBAC roles**,但无法将 **AzureAD roles** 添加到动态组。 此功能需要 Azure AD premium P1 许可证。 -## 权限提升 +## 提权 -请注意,默认情况下,任何用户都可以在 Azure AD 中邀请来宾,因此,如果动态组的**规则**根据可以在新**来宾**中**设置**的**属性**授予**权限**,则可以使用这些属性**创建来宾**并**提升权限**。来宾也可以管理自己的个人资料并更改这些属性。 +注意默认情况下任何用户均可在 Azure AD 中邀请来宾,因此,如果动态组的 **规则** 根据可以在新 **来宾** 中 **设置** 的 **属性** 来授予 **权限**,那么就可以通过使用这些属性 **创建来宾** 并 **提升权限**。来宾还可以管理自己的个人资料并更改这些属性。 获取允许动态成员资格的组:**`az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table`** +### 动态组 枚举 + +获取动态组的规则: + +使用 **Azure CLI**: +```bash +az ad group list \ +--filter "groupTypes/any(c:c eq 'DynamicMembership')" \ +--query "[].{displayName:displayName, rule:membershipRule}" \ +-o table +``` +使用 **PowerShell** 和 **Microsoft Graph SDK**: +```bash +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 ''" ` +-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 +``` ### 示例 -- **规则示例**:`(user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")` -- **规则描述**:任何具有包含字符串 'security' 的次要电子邮件的来宾用户将被添加到该组 +- **规则示例**: `(user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")` +- **规则描述**: 任何具有包含字符串 'security' 的备用邮箱的 Guest 用户将被添加到该组 -对于来宾用户电子邮件,接受邀请并检查**该用户**在 [https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView) 的当前设置。\ -不幸的是,该页面不允许修改属性值,因此我们需要使用 API: +对于 Guest 用户的邮箱,接受邀请并在 [https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView).\ +不幸的是,该页面不允许修改属性值,因此我们需要使用 API: ```bash # Login with the gust user az login --allow-no-subscriptions @@ -41,7 +73,7 @@ az rest --method GET \ --url "https://graph.microsoft.com/v1.0/users/" \ --query "otherMails" ``` -## 参考 +## 参考资料 - [https://www.mnemonic.io/resources/blog/abusing-dynamic-groups-in-azure-ad-for-privilege-escalation/](https://www.mnemonic.io/resources/blog/abusing-dynamic-groups-in-azure-ad-for-privilege-escalation/)