Translated ['src/pentesting-cloud/azure-security/az-services/az-azuread.

This commit is contained in:
Translator
2025-01-27 14:21:41 +00:00
parent 309d08be51
commit ae9340f855
@@ -4,7 +4,7 @@
## 기본 정보
Azure Active Directory (Azure AD)는 Microsoft의 클라우드 기반 아이덴티티 및 액세스 관리 서비스입니다. 이는 직원들이 조직 내외부의 리소스에 로그인하고 접근할 수 있도록 하는 데 중요한 역할을 하며, Microsoft 365, Azure 포털 및 다양한 다른 SaaS 애플리케이션을 포함합니다. Azure AD의 설계는 **인증, 권한 부여 및 사용자 관리**와 같은 필수 아이덴티티 서비스를 제공하는 데 중점을 두고 있습니다.
Azure Active Directory (Azure AD)는 Microsoft의 클라우드 기반 아이덴티티 및 액세스 관리 서비스입니다. 이는 직원들이 조직 내외부의 리소스에 로그인하고 접근할 수 있도록 하는 데 중요한 역할을 하며, Microsoft 365, Azure 포털 및 다양한 다른 SaaS 애플리케이션을 포함합니다. Azure AD의 설계는 **인증, 권한 부여 및 사용자 관리**를 포함한 필수 아이덴티티 서비스를 제공하는 데 중점을 두고 있습니다.
Azure AD의 주요 기능에는 **다단계 인증** 및 **조건부 액세스**가 포함되며, 다른 Microsoft 보안 서비스와의 원활한 통합이 특징입니다. 이러한 기능은 사용자 아이덴티티의 보안을 크게 향상시키고 조직이 액세스 정책을 효과적으로 구현하고 시행할 수 있도록 합니다. Microsoft의 클라우드 서비스 생태계의 기본 구성 요소로서, Azure AD는 사용자 아이덴티티의 클라우드 기반 관리를 위해 필수적입니다.
@@ -140,6 +140,34 @@ curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com&api-version=2017-
curl "$IDENTITY_ENDPOINT?resource=https://vault.azure.net&api-version=2017-09-01" -H secret:$IDENTITY_HEADER
```
{{#endtab }}
{{#tab name="MS Graph" }}
```bash
Get-MgTenantRelationshipDelegatedAdminCustomer
# Install the Microsoft Graph PowerShell module if not already installed
Install-Module Microsoft.Graph -Scope CurrentUser
# Import the module
Import-Module Microsoft.Graph
# Login to Microsoft Graph
Connect-MgGraph -Scopes "User.Read.All", "Group.Read.All", "Directory.Read.All"
# Enumerate available commands in Microsoft Graph PowerShell
Get-Command -Module Microsoft.Graph*
# Example: List users
Get-MgUser -All
# Example: List groups
Get-MgGroup -All
# Example: Get roles assigned to a user
Get-MgUserAppRoleAssignment -UserId <UserId>
# Disconnect from Microsoft Graph
Disconnect-MgGraph
```
{{#endtab }}
{{#tab name="Azure AD" }}
```bash
@@ -156,9 +184,9 @@ Connect-AzureAD -AccountId test@corp.onmicrosoft.com -AadAccessToken $token
{{#endtab }}
{{#endtabs }}
Azure에 **CLI**를 통해 로그인할 때, **Microsoft**에 속한 **tenant**의 **Azure Application**을 사용하고 있습니다. 이러한 애플리케이션은 귀하의 계정에서 생성할 수 있는 것처럼 **클라이언트 ID**를 가지고 있습니다. **콘솔에서 볼 수 있는 허용된 애플리케이션 목록**에서 모든 애플리케이션을 **볼 수는 없지만**, 기본적으로 허용됩니다.
Azure에 **CLI**를 통해 로그인할 때, **Microsoft**에 속한 **tenant**의 **Azure Application**을 사용하고 있습니다. 이러한 애플리케이션은 귀하의 계정에서 생성할 수 있는 것과 같이 **클라이언트 ID**를 가지고 있습니다. **콘솔에서 볼 수 있는 허용된 애플리케이션 목록**에서 모든 애플리케이션을 **볼 수는 없지만**, 기본적으로 허용됩니다.
예를 들어, **`1950a258-227b-4e31-a9cf-717495945fc2`** 클라이언트 ID를 가진 앱을 사용하는 **powershell 스크립트**가 **인증**을 수행합니다. 앱이 콘솔에 나타나지 않더라도, 시스템 관리자는 사용자가 해당 앱을 통해 연결할 수 없도록 **해당 애플리케이션을 차단**할 수 있습니다.
예를 들어, **`1950a258-227b-4e31-a9cf-717495945fc2`** 클라이언트 ID를 가진 앱을 사용하는 **powershell 스크립트**가 **인증**을 수행합니다. 앱이 콘솔에 나타나지 않더라도, 시스템 관리자는 사용자가 해당 앱을 통해 접근할 수 없도록 **해당 애플리케이션을 차단**할 수 있습니다.
그러나 **Azure에 연결할 수 있는 다른 클라이언트 ID**의 애플리케이션이 있습니다:
```bash
@@ -248,6 +276,34 @@ curl -X GET "https://graph.microsoft.com/beta/roleManagement/directory/roleDefin
```
{{#endtab }}
{{#tab name="MS Graph" }}
```bash
# Enumerate users using Microsoft Graph PowerShell
Get-MgUser -All
# Get user details
Get-MgUser -UserId "test@corp.onmicrosoft.com" | Format-List *
# Search "admin" users
Get-MgUser -All | Where-Object { $_.DisplayName -like "*test*" } | Select-Object DisplayName
# Search attributes containing the word "password"
Get-MgUser -All | Where-Object { $_.AdditionalProperties.PSObject.Properties.Name -contains "password" }
# All users from Entra ID
Get-MgUser -Filter "startswith(userPrincipalName, 't')" -All | Select-Object DisplayName, UserPrincipalName
# Get groups where the user is a member
Get-MgUserMemberOf -UserId <UserId>
# Get roles assigned to the user in Entra ID
Get-MgUserAppRoleAssignment -UserId <UserId>
# List available commands in Microsoft Graph PowerShell
Get-Command -Module Microsoft.Graph.Users
```
{{#endtab }}
{{#tab name="Azure AD" }}
```bash
# Enumerate Users
@@ -307,15 +363,15 @@ $password = "ThisIsTheNewPassword.!123" | ConvertTo- SecureString -AsPlainText
(Get-AzureADUser -All $true | ?{$_.UserPrincipalName -eq "victim@corp.onmicrosoft.com"}).ObjectId | Set- AzureADUserPassword -Password $password Verbose
```
### MFA & Conditional Access Policies
### MFA 및 조건부 액세스 정책
모든 사용자에게 MFA를 추가하는 것이 강력히 권장되지만, 일부 회사는 이를 설정하지 않거나 특정 위치, 브라우저 또는 **일부 조건**에서 로그인할 경우에만 MFA를 요구하는 Conditional Access를 설정할 수 있습니다. 이러한 정책이 올바르게 구성되지 않으면 **bypasses**에 취약할 수 있습니다. 확인하세요:
모든 사용자에게 MFA를 추가하는 것이 강력히 권장되지만, 일부 회사는 이를 설정하지 않거나 특정 위치, 브라우저 또는 **일부 조건**에서 로그인할 경우에만 MFA를 요구할 수 있습니다. 이러한 정책이 올바르게 구성되지 않으면 **우회**에 취약할 수 있습니다. 확인하세요:
{{#ref}}
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
{{#endref}}
### Groups
### 그룹
Entra ID 그룹에 대한 자세한 정보는 다음을 확인하세요:
@@ -368,7 +424,33 @@ Get-AzADGroupMember -GroupDisplayName <resource_group_name>
Get-AzRoleAssignment -ResourceGroupName <resource_group_name>
```
{{#endtab }}
{{#tab name="MS Graph" }}
```bash
# Enumerate groups using Microsoft Graph PowerShell
Get-MgGroup -All
# Get group details
Get-MgGroup -GroupId <GroupId> | Format-List *
# Search "admin" groups
Get-MgGroup -All | Where-Object { $_.DisplayName -like "*admin*" } | Select-Object DisplayName
# Get members of a group
Get-MgGroupMember -GroupId <GroupId> -All
# Get groups a group is member of
Get-MgGroupMemberOf -GroupId <GroupId>
# Get roles assigned to the group in Entra ID
Get-MgGroupAppRoleAssignment -GroupId <GroupId>
# Get group owner
Get-MgGroupOwner -GroupId <GroupId>
# List available commands in Microsoft Graph PowerShell
Get-Command -Module Microsoft.Graph.Groups
```
{{#endtab }}
{{#tab name="Azure AD" }}
```bash
# Enumerate Groups
@@ -467,6 +549,30 @@ Headers = @{
(Invoke-RestMethod @RequestParams).value
```
{{#endtab }}
{{#tab name="MS Graph" }}
```bash
# Get Service Principals using Microsoft Graph PowerShell
Get-MgServicePrincipal -All
# Get details of one Service Principal
Get-MgServicePrincipal -ServicePrincipalId <ServicePrincipalId> | Format-List *
# Search SP by display name
Get-MgServicePrincipal -All | Where-Object { $_.DisplayName -like "*app*" } | Select-Object DisplayName
# Get owner of Service Principal
Get-MgServicePrincipalOwner -ServicePrincipalId <ServicePrincipalId>
# Get objects owned by a Service Principal
Get-MgServicePrincipalOwnedObject -ServicePrincipalId <ServicePrincipalId>
# Get groups where the SP is a member
Get-MgServicePrincipalMemberOf -ServicePrincipalId <ServicePrincipalId>
# List available commands in Microsoft Graph PowerShell
Get-Command -Module Microsoft.Graph.ServicePrincipals
```
{{#endtab }}
{{#tab name="Azure AD" }}
```bash
@@ -495,7 +601,7 @@ Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalMembersh
<details>
<summary>각 엔터프라이즈 앱에 클라이언트 비밀을 나열하고 추가해 보세요</summary>
<summary>각 엔터프라이즈 앱에 클라이언트 비밀을 나열하고 추가해 보세요</summary>
```bash
# Just call Add-AzADAppSecret
Function Add-AzADAppSecret
@@ -645,6 +751,25 @@ Get-AzADAppCredential
```
{{#endtab }}
{{#tab name="MS Graph" }}
```bash
# List Applications using Microsoft Graph PowerShell
Get-MgApplication -All
# Get application details
Get-MgApplication -ApplicationId 7861f72f-ad49-4f8c-96a9-19e6950cffe1 | Format-List *
# Search App by display name
Get-MgApplication -Filter "startswith(displayName, 'app')" | Select-Object DisplayName
# Get owner of an application
Get-MgApplicationOwner -ApplicationId <ApplicationId>
# List available commands in Microsoft Graph PowerShell
Get-Command -Module Microsoft.Graph.Applications
```
{{#endtab }}
{{#tab name="Azure AD" }}
```bash
# List all registered applications
@@ -661,10 +786,10 @@ Get-AzureADApplication -ObjectId <id> | Get-AzureADApplicationOwner |fl *
> [!WARNING]
> **`AppRoleAssignment.ReadWrite`** 권한을 가진 앱은 **Global Admin**으로 **승격**할 수 있습니다.\
> 더 많은 정보는 [**여기 확인하세요**](https://posts.specterops.io/azure-privilege-escalation-via-azure-api-permissions-abuse-74aee1006f48).
> 더 많은 정보는 [**여기 확인하세요**](https://posts.specterops.io/azure-privilege-escalation-via-azure-api-permissions-abuse-74aee1006f48).
> [!NOTE]
> 애플리케이션이 토큰을 요청할 때 자신의 신원을 증명하는 데 사용하는 비밀 문자열은 애플리케이션 비밀번호입니다.\
> 애플리케이션이 토큰을 요청할 때 신원을 증명하는 데 사용하는 비밀 문자열은 애플리케이션 비밀번호입니다.\
> 따라서 이 **비밀번호**를 찾으면 **서비스 주체**로 **테넌트** **내부**에 접근할 수 있습니다.\
> 이 비밀번호는 생성될 때만 볼 수 있습니다(변경할 수는 있지만 다시 얻을 수는 없습니다).\
> **애플리케이션**의 **소유자**는 이를 **가짜로** 사용할 수 있도록 **비밀번호**를 추가할 수 있습니다.\
@@ -672,9 +797,9 @@ Get-AzureADApplication -ObjectId <id> | Get-AzureADApplicationOwner |fl *
Microsoft에 속하는 일반적으로 사용되는 App 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
### 관리되는 ID
Managed Identities에 대한 더 많은 정보는 다음을 확인하세요:
관리되는 ID에 대한 더 많은 정보는 다음을 확인하세요:
{{#ref}}
../az-basic-information/
@@ -719,7 +844,27 @@ az role assignment list --all --query "[].{principalName:principalName,principal
# Get all the roles assigned to a user
az role assignment list --assignee "<email>" --all --output table
# Get all the roles assigned to a user by filtering
az role assignment list --all --query "[?principalName=='carlos@carloshacktricks.onmicrosoft.com']" --output table
az role assignment list --all --query "[?principalName=='admin@organizationadmin.onmicrosoft.com']" --output table
```
{{#endtab }}
{{#tab name="MS Graph" }}
```bash
# List all available role templates using Microsoft Graph PowerShell
Get-MgDirectoryRoleTemplate -All
# List enabled built-in Entra ID roles
Get-MgDirectoryRole -All
# List all Entra ID roles with their permissions (including custom roles)
Get-MgDirectoryRoleDefinition -All
# List members of a Entra ID role
Get-MgDirectoryRoleMember -DirectoryRoleId <RoleId> -All
# List available commands in Microsoft Graph PowerShell
Get-Command -Module Microsoft.Graph.Identity.DirectoryManagement
```
{{#endtab }}
@@ -833,6 +978,24 @@ Get-AzureADMSScopedRoleMembership -Id <id> | fl *
# If you know how to do this send a PR!
```
{{#endtab }}
{{#tab name="MS Graph" }}
```bash
# Enumerate devices using Microsoft Graph PowerShell
Get-MgDevice -All
# Get device details
Get-MgDevice -DeviceId <DeviceId> | Format-List *
# Get devices managed using 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
Get-Command -Module Microsoft.Graph.Identity.DirectoryManagement
```
{{#endtab }}
{{#tab name="Azure AD" }}
```bash
@@ -913,9 +1076,9 @@ Get-AzureADMSScopedRoleMembership -Id <id> | fl #Get role ID and role members
### 권한 있는 ID 관리 (PIM)
Azure의 권한 있는 ID 관리(PIM)는 **불필요하게 사용자에게 과도한 권한이 부여되는 것을 방지**하는 데 도움을 줍니다.
Azure의 권한 있는 ID 관리 (PIM)는 **불필요하게 사용자에게 과도한 권한이 부여되는 것을 방지**하는 데 도움을 줍니다.
PIM이 제공하는 주요 기능 중 하나는 항상 활성화된 주체에게 역할을 할당하지 않고, **일정 기간(예: 6개월)** 동안 자격을 부여할 수 있다는 것입니다. 그런 다음 사용자가 해당 역할을 활성화하고 싶을 때, 필요한 권한의 시간을 지정하여 요청해야 합니다(예: 3시간). 그런 다음 **관리자가** 요청을 승인해야 합니다.\
PIM이 제공하는 주요 기능 중 하나는 항상 활성 상태인 주체에게 역할을 할당하지 않고 **일정 기간(예: 6개월)** 동안 **자격이 있도록**는 것입니다. 그런 다음 사용자가 해당 역할을 활성화하고 싶을 때 필요한 권한의 시간을 지정하여 요청해야 합니다(예: 3시간). 그런 다음 **관리자가** 요청을 승인해야 합니다.\
사용자는 또한 시간을 **연장** 요청할 수 있습니다.
또한, **PIM은** 권한 있는 역할이 누군가에게 할당될 때마다 이메일을 보냅니다.
@@ -930,7 +1093,7 @@ PIM이 활성화되면 각 역할에 대해 다음과 같은 특정 요구 사
- 활성화 시 정당화 요구
- 활성화 시 티켓 정보 요구
- 활성화 승인 요구
- 자격 부여의 만료 최대 시간
- 자격이 있는 할당의 최대 만료 시간
- 특정 작업이 해당 역할과 관련하여 발생할 때 알림을 보낼 사람과 시기를 구성하는 많은 추가 설정
### 조건부 액세스 정책
@@ -957,13 +1120,13 @@ Entra ID 보호는 **사용자 또는 로그인 시도가 너무 위험할 때
Entra 비밀번호 보호 ([https://portal.azure.com/index.html#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade](https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade))는 **여러 번의 로그인 시도가 실패할 때 계정을 잠금으로써 약한 비밀번호의 남용을 방지**하는 보안 기능입니다.\
또한 제공해야 하는 **사용자 정의 비밀번호 목록을 금지**할 수 있습니다.
이는 **클라우드 수준과 온프레미스 Active Directory 모두에 적용**될 수 있습니다.
클라우드 수준과 온프레미스 Active Directory 모두에 **적용**될 수 있습니다.
기본 모드는 **감사**입니다:
<figure><img src="../../../images/image (355).png" alt=""><figcaption></figcaption></figure>
## 참
## 참고 문헌
- [https://learn.microsoft.com/en-us/azure/active-directory/roles/administrative-units](https://learn.microsoft.com/en-us/azure/active-directory/roles/administrative-units)