Translated ['', 'src/pentesting-cloud/azure-security/az-privilege-escala

This commit is contained in:
Translator
2025-11-19 17:18:19 +00:00
parent abcdc49a54
commit f6fce7884e
@@ -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 '<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
```
### 示例
- **规则示例**`(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/<user-object-id>" \
--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/)