diff --git a/src/pentesting-cloud/azure-security/az-services/az-azuread.md b/src/pentesting-cloud/azure-security/az-services/az-azuread.md index 645b35145..8278af9c9 100644 --- a/src/pentesting-cloud/azure-security/az-services/az-azuread.md +++ b/src/pentesting-cloud/azure-security/az-services/az-azuread.md @@ -184,9 +184,9 @@ Connect-AzureAD -AccountId test@corp.onmicrosoft.com -AadAccessToken $token {{#endtab }} {{#endtabs }} -Azureに**CLI**を介してログインするとき、あなたは**Microsoft**に属する**テナント**からの**Azureアプリケーション**を使用しています。これらのアプリケーションは、あなたのアカウントで作成できるものと同様に、**クライアントID**を持っています。**コンソールで見ることができる許可されたアプリケーションのリスト**にはすべて表示されませんが、**デフォルトで許可されています**。 +Azureに**CLI**を介してログインするとき、あなたは**Microsoft**に属する**テナント**からの**Azureアプリケーション**を使用しています。これらのアプリケーションは、あなたのアカウントで作成できるもののように、**クライアントID**を持っています。**コンソールで見ることができる許可されたアプリケーションのリスト**にはすべて表示されませんが、**デフォルトで許可されています**。 -例えば、**認証**を行う**PowerShellスクリプト**は、クライアントID**`1950a258-227b-4e31-a9cf-717495945fc2`**を持つアプリを使用します。アプリがコンソールに表示されなくても、システム管理者は**そのアプリケーションをブロック**して、ユーザーがそのアプリを介して接続できないようにすることができます。 +例えば、**認証**を行う**PowerShellスクリプト**は、クライアントID **`1950a258-227b-4e31-a9cf-717495945fc2`**を持つアプリを使用します。アプリがコンソールに表示されなくても、システム管理者は**そのアプリケーションをブロック**して、ユーザーがそのアプリを介して接続できないようにすることができます。 しかし、**Azureに接続を許可する他のクライアントID**のアプリケーションもあります: ```bash @@ -789,17 +789,17 @@ Get-AzureADApplication -ObjectId | Get-AzureADApplicationOwner |fl * > 詳細については [**こちらを確認してください**](https://posts.specterops.io/azure-privilege-escalation-via-azure-api-permissions-abuse-74aee1006f48)。 > [!NOTE] -> アプリケーションがトークンを要求する際にそのアイデンティティを証明するために使用する秘密の文字列はアプリケーションパスワードです。\ +> アプリケーションがトークンを要求する際にそのアイデンティティを証明するために使用する秘密の文字列は、アプリケーションパスワードです。\ > したがって、この **パスワード** を見つけると、**テナント** 内の **サービスプリンシパル** としてアクセスできます。\ > このパスワードは生成時にのみ表示されることに注意してください(変更することはできますが、再取得することはできません)。\ > **アプリケーション** の **所有者** は、(彼がそれを偽装できるように)**パスワード** を追加できます。\ > これらのサービスプリンシパルとしてのログインは **リスクあり** としてマークされず、**MFA** はありません。 -一般的に使用される Microsoft のアプリ ID のリストは [https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications) で見つけることができます。 +一般的に使用される Microsoft のアプリ ID のリストは、[https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications) で見つけることができます。 ### Managed Identities -Managed Identities についての詳細は以下を確認してください: +Managed Identities についての詳細は、以下を確認してください: {{#ref}} ../az-basic-information/ @@ -840,11 +840,15 @@ az role definition list --resource-group # Get only roles assigned to the indicated scope az role definition list --scope # Get all the principals a role is assigned to -az role assignment list --all --query "[].{principalName:principalName,principalType:principalType,resourceGroup:resourceGroup,roleDefinitionName:roleDefinitionName}[?roleDefinitionName=='']" +az role assignment list --all --query "[].{principalName:principalName,principalType:principalType,scope:scope,roleDefinitionName:roleDefinitionName}[?roleDefinitionName=='']" # Get all the roles assigned to a user az role assignment list --assignee "" --all --output table # Get all the roles assigned to a user by filtering az role assignment list --all --query "[?principalName=='admin@organizationadmin.onmicrosoft.com']" --output table +# Get deny assignments +az rest --method GET --uri "https://management.azure.com/{scope}/providers/Microsoft.Authorization/denyAssignments?api-version=2022-04-01" +## Example scope of subscription +az rest --method GET --uri "https://management.azure.com/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/providers/Microsoft.Authorization/denyAssignments?api-version=2022-04-01" ``` {{#endtab }} @@ -877,12 +881,20 @@ Get-AzRoleDefinition -Name "Virtual Machine Command Executor" # Get roles of a user or resource Get-AzRoleAssignment -SignInName test@corp.onmicrosoft.com Get-AzRoleAssignment -Scope /subscriptions//resourceGroups//providers/Microsoft.Compute/virtualMachines/ +# Get deny assignments +Get-AzDenyAssignment # Get from current subscription +Get-AzDenyAssignment -Scope '/subscriptions/96231a05-34ce-4eb4-aa6a-70759cbb5e83/resourcegroups/testRG/providers/Microsoft.Web/sites/site1' ``` +{{#endtab }} +{{#endtabs }} +``` + {{#endtab }} {{#tab name="Raw" }} + ```bash -# Get permissions over a resource using ARM directly +# リソースに対する権限をARMを使用して直接取得する $Token = (Get-AzAccessToken).Token $URI = 'https://management.azure.com/subscriptions/b413826f-108d-4049-8c11-d52d5d388768/resourceGroups/Research/providers/Microsoft.Compute/virtualMachines/infradminsrv/providers/Microsoft.Authorization/permissions?api-version=2015-07-01' $RequestParams = @{ @@ -894,12 +906,13 @@ Headers = @{ } (Invoke-RestMethod @RequestParams).value ``` + {{#endtab }} {{#endtabs }} -### Entra ID ロール +### Entra ID Roles -Azure ロールに関する詳細情報は、以下を確認してください: +For more information about Azure roles check: {{#ref}} ../az-basic-information/ @@ -907,125 +920,134 @@ Azure ロールに関する詳細情報は、以下を確認してください: {{#tabs }} {{#tab name="az cli" }} + ```bash -# List template Entra ID roles +# Entra ID ロールのテンプレートをリスト az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/directoryRoleTemplates" -# List enabled built-in Entra ID roles +# 有効な組み込み Entra ID ロールをリスト az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/directoryRoles" -# List all Entra ID roles with their permissions (including custom roles) +# 権限を持つすべての Entra ID ロールをリスト(カスタムロールを含む) az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions" -# List only custom Entra ID roles +# カスタム Entra ID ロールのみをリスト az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions" | jq '.value[] | select(.isBuiltIn == false)' -# List all assigned Entra ID roles +# 割り当てられたすべての Entra ID ロールをリスト az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments" -# List members of a Entra ID roles +# Entra ID ロールのメンバーをリスト az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/directoryRoles//members" -# List Entra ID roles assigned to a user +# ユーザーに割り当てられた Entra ID ロールをリスト az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/users//memberOf/microsoft.graph.directoryRole" \ --query "value[]" \ --output json -# List Entra ID roles assigned to a group +# グループに割り当てられた Entra ID ロールをリスト az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/groups/$GROUP_ID/memberOf/microsoft.graph.directoryRole" \ --query "value[]" \ --output json -# List Entra ID roles assigned to a service principal +# サービスプリンシパルに割り当てられた Entra ID ロールをリスト az rest --method GET \ --uri "https://graph.microsoft.com/v1.0/servicePrincipals/$SP_ID/memberOf/microsoft.graph.directoryRole" \ --query "value[]" \ --output json ``` + {{#endtab }} {{#tab name="Azure AD" }} + ```bash -# Get all available role templates +# 利用可能なロールテンプレートを取得 Get-AzureADDirectoryroleTemplate -# Get enabled roles (Assigned roles) +# 有効なロールを取得(割り当てられたロール) Get-AzureADDirectoryRole -Get-AzureADDirectoryRole -ObjectId #Get info about the role -# Get custom roles - use AzureAdPreview +Get-AzureADDirectoryRole -ObjectId #ロールに関する情報を取得 +# カスタムロールを取得 - AzureAdPreviewを使用 Get-AzureADMSRoleDefinition | ?{$_.IsBuiltin -eq $False} | select DisplayName -# Users assigned a role (Global Administrator) +# ロールが割り当てられたユーザー(グローバル管理者) Get-AzureADDirectoryRole -Filter "DisplayName eq 'Global Administrator'" | Get-AzureADDirectoryRoleMember Get-AzureADDirectoryRole -ObjectId | fl -# Roles of the Administrative Unit (who has permissions over the administrative unit and its members) +# 管理ユニットのロール(管理ユニットとそのメンバーに対する権限を持つ者) Get-AzureADMSScopedRoleMembership -Id | fl * ``` + {{#endtab }} {{#endtabs }} -### デバイス +### Devices {{#tabs }} {{#tab name="az cli" }} + ```bash -# If you know how to do this send a PR! +# これを行う方法を知っている場合は、PRを送信してください! ``` + {{#endtab }} {{#tab name="MS Graph" }} + ```bash -# Enumerate devices using Microsoft Graph PowerShell +# Microsoft Graph PowerShellを使用してデバイスを列挙する Get-MgDevice -All -# Get device details +# デバイスの詳細を取得する Get-MgDevice -DeviceId | Format-List * -# Get devices managed using Intune +# Intuneで管理されているデバイスを取得する Get-MgDevice -Filter "isCompliant eq true" -All -# Get devices owned by a user +# ユーザーが所有するデバイスを取得する Get-MgUserOwnedDevice -UserId test@corp.onmicrosoft.com -# List available commands in Microsoft Graph PowerShell +# Microsoft Graph PowerShellで利用可能なコマンドのリスト Get-Command -Module Microsoft.Graph.Identity.DirectoryManagement ``` {{#endtab }} {{#tab name="Azure AD" }} + ```bash -# Enumerate Devices +# デバイスの列挙 Get-AzureADDevice -All $true | fl * -# List all the active devices (and not the stale devices) +# アクティブなデバイス(古いデバイスではない)をリスト Get-AzureADDevice -All $true | ?{$_.ApproximateLastLogonTimeStamp -ne $null} -# Get owners of all devices +# すべてのデバイスの所有者を取得 Get-AzureADDevice -All $true | Get-AzureADDeviceRegisteredOwner Get-AzureADDevice -All $true | %{if($user=Get-AzureADDeviceRegisteredOwner -ObjectId $_.ObjectID){$_;$user.UserPrincipalName;"`n"}} -# Registred users of all the devices +# すべてのデバイスの登録ユーザー Get-AzureADDevice -All $true | Get-AzureADDeviceRegisteredUser Get-AzureADDevice -All $true | %{if($user=Get-AzureADDeviceRegisteredUser -ObjectId $_.ObjectID){$_;$user.UserPrincipalName;"`n"}} -# Get dives managed using Intune +# Intuneで管理されているデバイスを取得 Get-AzureADDevice -All $true | ?{$_.IsCompliant -eq "True"} -# Get devices owned by a user +# ユーザーが所有するデバイスを取得 Get-AzureADUserOwnedDevice -ObjectId test@corp.onmicrosoft.com -# Get Administrative Units of a device +# デバイスの管理単位を取得 Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember -ObjectId $_.ObjectId | where {$_.ObjectId -eq $deviceObjId} } ``` + {{#endtab }} {{#endtabs }} > [!WARNING] -> デバイス (VM) が **AzureAD に参加している** 場合、AzureAD のユーザーは **ログインできる** ようになります。\ -> さらに、ログインしているユーザーがデバイスの **オーナー** である場合、彼は **ローカル管理者** になります。 +> If a device (VM) is **AzureAD joined**, users from AzureAD are going to be **able to login**.\ +> Moreover, if the logged user is **Owner** of the device, he is going to be **local admin**. -### 管理単位 +### Administrative Units -管理単位に関する詳細情報は、以下を確認してください: +For more information about administrative units check: {{#ref}} ../az-basic-information/ @@ -1033,100 +1055,104 @@ Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember {{#tabs }} {{#tab name="az cli" }} + ```bash -# List all administrative units +# すべての管理ユニットをリストする az rest --method GET --uri "https://graph.microsoft.com/v1.0/directory/administrativeUnits" -# Get AU info +# AU 情報を取得する az rest --method GET --uri "https://graph.microsoft.com/v1.0/directory/administrativeUnits/a76fd255-3e5e-405b-811b-da85c715ff53" -# Get members +# メンバーを取得する az rest --method GET --uri "https://graph.microsoft.com/v1.0/directory/administrativeUnits/a76fd255-3e5e-405b-811b-da85c715ff53/members" -# Get principals with roles over the AU +# AU に対するロールを持つプリンシパルを取得する az rest --method GET --uri "https://graph.microsoft.com/v1.0/directory/administrativeUnits/a76fd255-3e5e-405b-811b-da85c715ff53/scopedRoleMembers" ``` + {{#endtab }} {{#tab name="AzureAD" }} + ```bash -# Get Administrative Units +# 管理単位を取得 Get-AzureADMSAdministrativeUnit Get-AzureADMSAdministrativeUnit -Id -# Get ID of admin unit by string +# 文字列による管理単位のIDを取得 $adminUnitObj = Get-AzureADMSAdministrativeUnit -Filter "displayname eq 'Test administrative unit 2'" -# List the users, groups, and devices affected by the administrative unit +# 管理単位に影響を受けるユーザー、グループ、およびデバイスのリスト Get-AzureADMSAdministrativeUnitMember -Id -# Get the roles users have over the members of the AU -Get-AzureADMSScopedRoleMembership -Id | fl #Get role ID and role members +# AUのメンバーに対するユーザーの役割を取得 +Get-AzureADMSScopedRoleMembership -Id | fl #役割IDと役割メンバーを取得 ``` + {{#endtab }} {{#endtabs }} -## Entra ID 特権昇格 +## Entra ID Privilege Escalation {{#ref}} ../az-privilege-escalation/az-entraid-privesc/ {{#endref}} -## Azure 特権昇格 +## Azure Privilege Escalation {{#ref}} ../az-privilege-escalation/az-authorization-privesc.md {{#endref}} -## 防御メカニズム +## Defensive Mechanisms -### 特権アイデンティティ管理 (PIM) +### Privileged Identity Management (PIM) -Azure の特権アイデンティティ管理 (PIM) は、ユーザーに不必要に**過剰な特権**が割り当てられるのを**防ぐ**のに役立ちます。 +Privileged Identity Management (PIM) in Azure helps to **prevent excessive privileges** to being assigned to users unnecessarily. -PIM が提供する主な機能の一つは、常にアクティブなプリンシパルにロールを割り当てるのではなく、**一定の期間(例:6ヶ月)**そのロールを**適格**にすることができる点です。ユーザーがそのロールをアクティブにしたい場合、必要な特権の時間(例:3時間)を示してリクエストを行う必要があります。その後、**管理者が**リクエストを承認する必要があります。\ -ユーザーはまた、**時間を延長**するようにリクエストすることもできます。 +One of the main features provided by PIM is that It allows to not assign roles to principals that are constantly active, but make them **eligible for a period of time (e.g. 6months)**. Then, whenever the user wants to activate that role, he needs to ask for it indicating the time he needs the privilege (e.g. 3 hours). Then an **admin needs to approve** the request.\ +Note that the user will also be able to ask to **extend** the time. -さらに、**PIM は**特権ロールが誰かに割り当てられるたびにメールを送信します。 +Moreover, **PIM send emails** whenever a privileged role is being assigned to someone.
-PIM が有効になっていると、各ロールに対して次のような特定の要件を設定することができます: +When PIM is enabled it's possible to configure each role with certain requirements like: -- アクティベーションの最大期間(時間) -- アクティベーション時に MFA を要求 -- 条件付きアクセス認証コンテキストを要求 -- アクティベーション時に正当化を要求 -- アクティベーション時にチケット情報を要求 -- アクティベートするための承認を要求 -- 適格な割り当ての最大有効期限 -- 特定のアクションがそのロールで発生したときに通知を送信する際の設定がさらに多く +- Maximum duration (hours) of activation +- Require MFA on activation +- Require Conditional Access acuthenticaiton context +- Require justification on activation +- Require ticket information on activation +- Require approval to activate +- Max time to expire the elegible assignments +- A lot more configuration on when and who to send notifications when certain actions happen with that role -### 条件付きアクセス ポリシー +### Conditional Access Policies -チェック: +Check: {{#ref}} ../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md {{#endref}} -### Entra アイデンティティ保護 +### Entra Identity Protection -Entra アイデンティティ保護は、**ユーザーまたはサインインが受け入れられるにはリスクが高すぎる**場合を**検出**し、ユーザーまたはサインインの試行を**ブロック**することを可能にするセキュリティサービスです。 +Entra Identity Protection is a security service that allows to **detect when a user or a sign-in is too risky** to be accepted, allowing to **block** the user or the sig-in attempt. -管理者は、リスクが「低およびそれ以上」、「中程度およびそれ以上」または「高」である場合に**試行をブロック**するように設定できます。ただし、デフォルトでは完全に**無効**です: +It allows the admin to configure it to **block** attempts when the risk is "Low and above", "Medium and above" or "High". Although, by default it's completely **disabled**:
> [!TIP] -> 現在、可能な場合は条件付きアクセス ポリシーを介してこれらの制限を追加することが推奨されています。 +> Nowadays it's recommended to add these restrictions via Conditional Access policies where it's possible to configure the same options. -### Entra パスワード保護 +### Entra Password Protection -Entra パスワード保護 ([https://portal.azure.com/index.html#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade](https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade)) は、**複数の不成功なログイン試行が発生した場合にアカウントをロックアウトすることによって、弱いパスワードの悪用を防ぐのに役立つ**セキュリティ機能です。\ -また、提供する必要がある**カスタムパスワードリストを禁止**することもできます。 +Entra Password Protection ([https://portal.azure.com/index.html#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade](https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade)) is a security feature that **helps prevent the abuse of weak passwords in by locking out accounts when several unsuccessful login attempts happen**.\ +It also allows to **ban a custom password list** that you need to provide. -これは、**クラウドレベルとオンプレミスの Active Directory の両方に適用**できます。 +It can be **applied both** at the cloud level and on-premises Active Directory. -デフォルトモードは**監査**です: +The default mode is **Audit**:
-## 参考文献 +## References - [https://learn.microsoft.com/en-us/azure/active-directory/roles/administrative-units](https://learn.microsoft.com/en-us/azure/active-directory/roles/administrative-units)