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 0b9b75d02..1ac3b8100 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 @@ -4,25 +4,57 @@ ## 基本情報 -**Dynamic groups**は、設定された一連の**rules**を持つグループであり、ルールに一致するすべての**users or devices**がグループに追加されます。ユーザーまたはデバイスの**attribute**が**changed**されるたびに、動的ルールが**rechecked**されます。また、**new rule**が**created**されると、すべてのデバイスとユーザーが**checked**されます。 +**Dynamic groups** は、一連の **ルール** が設定され、それに一致するすべての **ユーザーまたはデバイス** がグループに追加されるグループです。ユーザーやデバイスの **属性** が **変更される** たびに、動的ルールは **再確認** されます。新しい **ルール** が **作成される** と、すべてのデバイスとユーザーが **チェック** されます。 -Dynamic groupsには**Azure RBAC roles**を割り当てることができますが、**AzureAD roles**を動的グループに追加することは**not possible**です。 +**Dynamic groups** には **Azure RBAC roles** を割り当てることができますが、**AzureAD roles** を dynamic groups に追加することは **できません**。 -この機能にはAzure ADプレミアムP1ライセンスが必要です。 +この機能は Azure AD premium P1 ライセンスを必要とします。 ## Privesc -デフォルトでは、任意のユーザーがAzure ADでゲストを招待できるため、動的グループの**rule**が**attributes**に基づいてユーザーに**permissions**を与える場合、新しい**guest**でこの属性を**set**することで**create a guest**し、**escalate privileges**することが可能です。また、ゲストは自分のプロフィールを管理し、これらの属性を変更することも可能です。 +デフォルトでは任意のユーザーが Azure AD にゲストを招待できることに注意してください。そのため、動的グループの **ルール** が新しい **ゲスト** に設定できる **属性** に基づいてユーザーに **権限** を付与する場合、これらの属性を持つゲストを作成して **権限を昇格** させることが可能です。ゲストは自分のプロファイルを管理してこれらの属性を変更することもできます。 -動的メンバーシップを許可するグループを取得します: **`az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table`** +動的メンバーシップを許可するグループを取得: **`az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table`** +### Dynamic Groups 列挙 + +動的グループのルールを取得: + +**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 +``` ### 例 -- **Rule example**: `(user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")` -- **Rule description**: 'security'という文字列を含む二次メールを持つゲストユーザーはグループに追加されます。 +- **ルール例**: `(user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")` +- **ルールの説明**: セカンダリメールに 'security' を含むゲストユーザーはグループに追加されます -ゲストユーザーのメールで招待を受け入れ、[https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView)で**that user**の現在の設定を確認します。\ -残念ながら、ページでは属性値を変更することができないため、APIを使用する必要があります。 +ゲストユーザーのメールについては、招待を受け入れ、[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/)