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

This commit is contained in:
Translator
2025-01-27 14:21:38 +00:00
parent 3f3ba92845
commit b18a724d07

View File

@@ -4,9 +4,9 @@
## Basiese Inligting
Azure Active Directory (Azure AD) dien as Microsoft se wolk-gebaseerde diens vir identiteit en toegang bestuur. Dit is noodsaaklik om werknemers in staat te stel om aan te meld en toegang te verkry tot hulpbronne, beide binne en buite die organisasie, insluitend Microsoft 365, die Azure-portaal, en 'n verskeidenheid ander SaaS-toepassings. Die ontwerp van Azure AD fokus op die lewering van noodsaaklike identiteit dienste, wat prominent **authentisering, autorisasie, en gebruikersbestuur** insluit.
Azure Active Directory (Azure AD) dien as Microsoft se wolk-gebaseerde diens vir identiteit en toegang bestuur. Dit is noodsaaklik om werknemers in staat te stel om aan te meld en toegang te verkry tot hulpbronne, beide binne en buite die organisasie, insluitend Microsoft 365, die Azure-portaal, en 'n verskeidenheid ander SaaS-toepassings. Die ontwerp van Azure AD fokus op die lewering van noodsaaklike identiteit dienste, wat prominent **autentisering, magtiging, en gebruikersbestuur** insluit.
Belangrike kenmerke van Azure AD sluit **multi-faktor authentisering** en **voorwaardelike toegang** in, tesame met naatlose integrasie met ander Microsoft sekuriteitsdienste. Hierdie kenmerke verhoog die sekuriteit van gebruikersidentiteite aansienlik en bemagtig organisasies om hul toegangbeleide effektief te implementeer en af te dwing. As 'n fundamentele komponent van Microsoft se wolkdienste-ekosisteem, is Azure AD van kardinale belang vir die wolk-gebaseerde bestuur van gebruikersidentiteite.
Belangrike kenmerke van Azure AD sluit **multi-faktor autentisering** en **voorwaardelike toegang** in, tesame met naatlose integrasie met ander Microsoft sekuriteitsdienste. Hierdie kenmerke verhoog die sekuriteit van gebruikersidentiteite aansienlik en bemagtig organisasies om hul toegangbeleide effektief te implementeer en af te dwing. As 'n fundamentele komponent van Microsoft se wolkdienste-ekosisteem, is Azure AD van kardinale belang vir die wolk-gebaseerde bestuur van gebruikersidentiteite.
## Opsomming
@@ -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
@@ -158,7 +186,7 @@ Connect-AzureAD -AccountId test@corp.onmicrosoft.com -AadAccessToken $token
Wanneer jy **aanmeld** via **CLI** in Azure met enige program, gebruik jy 'n **Azure-toepassing** van 'n **tenant** wat aan **Microsoft** behoort. Hierdie Toepassings, soos die wat jy in jou rekening kan skep, **het 'n kliënt-id**. Jy **sal nie al hulle kan sien nie** in die **toegelate toepassingslys** wat jy in die konsole kan sien, **maar hulle is standaard toegelaat**.
Byvoorbeeld, 'n **powershell-skrip** wat **authentiseer** gebruik 'n app met kliënt-id **`1950a258-227b-4e31-a9cf-717495945fc2`**. Selfs al verskyn die app nie in die konsole nie, kan 'n stelselsadministrateur **daardie toepassing blokkeer** sodat gebruikers nie toegang kan verkry nie met gereedskap wat via daardie App verbind.
Byvoorbeeld, 'n **powershell-skrip** wat **authentiseer** gebruik 'n app met kliënt-id **`1950a258-227b-4e31-a9cf-717495945fc2`**. Selfs al verskyn die app nie in die konsole nie, kan 'n stelselaanvoerder **daardie toepassing blokkeer** sodat gebruikers nie toegang kan verkry nie met gereedskap wat via daardie App verbind.
Daar is egter **ander kliënt-ids** van toepassings wat **jou sal toelaat om met Azure te verbind**:
```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 & Voorwaardelike Toegang Beleide
### MFA & Conditional Access Policies
Dit word sterk aanbeveel om MFA by elke gebruiker toe te voeg, maar sommige maatskappye sal dit nie instel nie of mag dit instel met 'n Voorwaardelike Toegang: Die gebruiker sal **MFA vereis word as** dit vanaf 'n spesifieke ligging, blaaier of **sekere voorwaarde** aanmeld. Hierdie beleide, as dit nie korrek geconfigureer is nie, mag vatbaar wees vir **omseilings**. Kontroleer:
Dit word sterk aanbeveel om MFA by elke gebruiker te voeg, egter, sommige maatskappye sal dit nie instel of mag dit instel met 'n Voorwaardelike Toegang: Die gebruiker sal **vereiste MFA wees as** dit vanaf 'n spesifieke ligging, blaaiers of **sekere voorwaarde** aanmeld. Hierdie beleide, as dit nie korrek geconfigureer is nie, mag geneig wees tot **bypasses**. Kontroleer:
{{#ref}}
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
{{#endref}}
### Groepe
### Groups
Vir meer inligting oor Entra ID groepe, kyk:
@@ -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
@@ -405,7 +487,7 @@ Eienaars van die groep kan nuwe gebruikers by die groep voeg
Add-AzureADGroupMember -ObjectId <group_id> -RefObjectId <user_id> -Verbose
```
> [!WARNING]
> Groepe kan dinamies wees, wat basies beteken dat **as 'n gebruiker aan sekere voorwaardes voldoen, sal hy by 'n groep gevoeg word**. Natuurlik, as die voorwaardes gebaseer is op **eienskappe** wat 'n **gebruiker** kan **beheer**, kan hy hierdie funksie misbruik om **in ander groepe te kom**.\
> Groepe kan dinamies wees, wat basies beteken dat **as 'n gebruiker aan sekere voorwaardes voldoen, sal hy aan 'n groep toegevoegd word**. Natuurlik, as die voorwaardes gebaseer is op **kenmerke** wat 'n **gebruiker** kan **beheer**, kan hy hierdie funksie misbruik om **in ander groepe te kom**.\
> Kyk hoe om dinamiese groepe te misbruik op die volgende bladsy:
{{#ref}}
@@ -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
@@ -491,11 +597,11 @@ Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalMembersh
{{#endtabs }}
> [!WARNING]
> Die eienaar van 'n dienshoof kan sy wagwoord verander.
> Die Eienaar van 'n Diens Prinsipaal kan sy wagwoord verander.
<details>
<summary>lys en probeer om 'n kliënt geheim by elke ondernemingsapp te voeg</summary>
<summary>lys en probeer om 'n kliënt geheim by elke Enterprise App te voeg</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
@@ -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
@@ -857,7 +1020,7 @@ Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember
{{#endtabs }}
> [!WARNING]
> As 'n toestel (VM) **AzureAD aangesluit** is, gaan gebruikers van AzureAD **in staat wees om aan te meld**.\
> As 'n toestel (VM) **AzureAD-verbonden** is, gaan gebruikers van AzureAD **in staat wees om aan te meld**.\
> Boonop, as die aangemelde gebruiker die **Eienaar** van die toestel is, gaan hy **lokale admin** wees.
### Administratiewe Eenhede
@@ -915,10 +1078,10 @@ Get-AzureADMSScopedRoleMembership -Id <id> | fl #Get role ID and role members
Privileged Identity Management (PIM) in Azure help om **oormatige voorregte** aan gebruikers onnodig toe te ken.
Een van die hoofkenmerke wat deur PIM verskaf word, is dat dit toelaat om nie rolle aan principals toe te ken wat konstant aktief is nie, maar hulle **verkieslik te maak vir 'n tydperk (bv. 6 maande)**. Dan, wanneer die gebruiker daardie rol wil aktiveer, moet hy daarvoor vra en die tyd aan dui wat hy die voorreg nodig het (bv. 3 ure). Dan moet 'n **admin die versoek goedkeur**.\
Een van die hoofkenmerke wat deur PIM verskaf word, is dat dit toelaat om nie rolle aan principals toe te ken wat konstant aktief is nie, maar hulle **verkieslik te maak vir 'n tydperk (bv. 6 maande)**. Dan, wanneer die gebruiker daardie rol wil aktiveer, moet hy daarvoor vra en die tyd aan dui wat hy die voorreg nodig het (bv. 3 uur). Dan moet 'n **admin die versoek goedkeur**.\
Let daarop dat die gebruiker ook kan vra om die tyd te **verleng**.
Boonop **stuur PIM e-posse** wanneer 'n voorregte rol aan iemand toegeken word.
Boonop, **PIM stuur e-posse** wanneer 'n voorregte rol aan iemand toegeken word.
<figure><img src="../../../images/image (354).png" alt=""><figcaption></figcaption></figure>
@@ -930,8 +1093,8 @@ Wanneer PIM geaktiveer is, is dit moontlik om elke rol met sekere vereistes te k
- Vereis regverdigheid op aktivering
- Vereis kaartjie-inligting op aktivering
- Vereis goedkeuring om te aktiveer
- Maks tyd om die verkieslike toekennings te laat verval
- Nog baie meer konfigurasie oor wanneer en aan wie om kennisgewings te stuur wanneer sekere aksies met daardie rol gebeur
- Maks tyd om die verkieslike toewysings te laat verval
- Nog baie meer konfigurasie oor wanneer en wie kennisgewings moet ontvang wanneer sekere aksies met daardie rol gebeur
### Voorwaardelike Toegang Beleide