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

This commit is contained in:
Translator
2025-02-09 17:53:32 +00:00
parent 6d588acbc2
commit ea0f33a37b
@@ -184,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 스크립트**가 **인증**을 수행합니다. 앱이 콘솔에 나타나지 않더라도, 시스템 관리자는 사용자가 해당 앱을 통해 접근할 수 없도록 **해당 애플리케이션을 차단**할 수 있습니다.
예를 들어, **인증**을 수행하는 **powershell 스크립트**는 클라이언트 ID **`1950a258-227b-4e31-a9cf-717495945fc2`**를 가진 애플리케이션을 사용합니다. 애플리케이션이 콘솔에 나타나지 않더라도, 시스템 관리자는 사용자가 해당 앱을 통해 연결할 수 없도록 **해당 애플리케이션을 차단**할 수 있습니다.
그러나 **Azure에 연결할 수 있는 다른 클라이언트 ID**의 애플리케이션이 있습니다:
```bash
@@ -365,7 +365,7 @@ $password = "ThisIsTheNewPassword.!123" | ConvertTo- SecureString -AsPlainText
```
### MFA 및 조건부 액세스 정책
모든 사용자에게 MFA를 추가하는 것이 강력히 권장되지만, 일부 회사는 이를 설정하지 않거나 특정 위치, 브라우저 또는 **일부 조건**에서 로그인할 경우에만 MFA를 요구할 수 있습니다. 이러한 정책 올바르게 구성되지 않으면 **우회**에 취약할 수 있습니다. 확인하세요:
모든 사용자에게 MFA를 추가하는 것이 강력히 권장되지만, 일부 회사는 이를 설정하지 않거나 특정 위치, 브라우저 또는 **일부 조건**에서 로그인할 경우에만 MFA를 요구하는 조건부 액세스를 설정할 수 있습니다. 이러한 정책 올바르게 구성되지 않으면 **우회**에 취약할 수 있습니다. 확인하세요:
{{#ref}}
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
@@ -786,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]
> 애플리케이션이 토큰을 요청할 때 신원을 증명하는 데 사용하는 비밀 문자열은 애플리케이션 비밀번호입니다.\
> 애플리케이션이 토큰을 요청할 때 자신의 신원을 증명하는 데 사용하는 비밀 문자열은 애플리케이션 비밀번호입니다.\
> 따라서 이 **비밀번호**를 찾으면 **서비스 주체**로 **테넌트** **내부**에 접근할 수 있습니다.\
> 이 비밀번호는 생성될 때만 볼 수 있습니다(변경할 수는 있지만 다시 얻을 수는 없습니다).\
> **애플리케이션**의 **소유자**는 이를 **가짜로** 사용할 수 있도록 **비밀번호**를 추가할 수 있습니다.\
@@ -840,11 +840,15 @@ az role definition list --resource-group <resource_group>
# Get only roles assigned to the indicated scope
az role definition list --scope <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=='<ROLE_NAME>']"
az role assignment list --all --query "[].{principalName:principalName,principalType:principalType,scope:scope,roleDefinitionName:roleDefinitionName}[?roleDefinitionName=='<ROLE_NAME>']"
# 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=='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/<subscription-id>/resourceGroups/<res_group_name>/providers/Microsoft.Compute/virtualMachines/<vm_name>
# 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/<role-id>/members"
# List Entra ID roles assigned to a user
# 사용자에게 할당된 Entra ID 역할 목록
az rest --method GET \
--uri "https://graph.microsoft.com/v1.0/users/<user-id>/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 <roleID> #Get info about the role
# Get custom roles - use AzureAdPreview
Get-AzureADDirectoryRole -ObjectId <roleID> # 역할에 대한 정보 가져오기
# 사용자 정의 역할 가져오기 - 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 <id> | fl
# Roles of the Administrative Unit (who has permissions over the administrative unit and its members)
# 관리 단위의 역할 (관리 단위 및 그 구성원에 대한 권한이 있는 사람)
Get-AzureADMSScopedRoleMembership -Id <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 <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 <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 <id>
# Get the roles users have over the members of the AU
Get-AzureADMSScopedRoleMembership -Id <id> | fl #Get role ID and role members
# AU의 구성원에 대한 사용자의 역할 가져오기
Get-AzureADMSScopedRoleMembership -Id <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
### 권한 있는 ID 관리 (PIM)
### Privileged Identity Management (PIM)
Azure의 권한 있는 ID 관리 (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.
<figure><img src="../../../images/image (354).png" alt=""><figcaption></figcaption></figure>
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 ID 보호
### Entra Identity Protection
Entra ID 보호는 **사용자 또는 로그인 시도가 너무 위험할 때 이를 감지**하여 사용자를 **차단**하거나 로그인 시도를 차단할 수 있는 보안 서비스입니다.
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**:
<figure><img src="../../../images/image (356).png" alt=""><figcaption></figcaption></figure>
> [!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**:
<figure><img src="../../../images/image (355).png" alt=""><figcaption></figcaption></figure>
## 참고 문헌
## 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)