mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-10 14:50:51 -08:00
Translated ['src/pentesting-cloud/azure-security/az-services/az-azuread.
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -309,7 +365,7 @@ $password = "ThisIsTheNewPassword.!123" | ConvertTo- SecureString -AsPlainText
|
||||
```
|
||||
### MFA y Políticas de Acceso Condicional
|
||||
|
||||
Se recomienda encarecidamente agregar MFA a cada usuario, sin embargo, algunas empresas no lo configurarán o podrían configurarlo con un Acceso Condicional: El usuario será **requerido MFA si** inicia sesión desde una ubicación, navegador o **alguna condición** específica. Estas políticas, si no se configuran correctamente, pueden ser propensas a **bypasses**. Verifica:
|
||||
Se recomienda encarecidamente agregar MFA a cada usuario, sin embargo, algunas empresas no lo configurarán o podrían configurarlo con un Acceso Condicional: El usuario será **requerido MFA si** inicia sesión desde una ubicación, navegador o **alguna condición** específica. Estas políticas, si no se configuran correctamente, podrían ser propensas a **bypasses**. Verifica:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
|
||||
@@ -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
|
||||
@@ -400,12 +482,12 @@ Get-AzureADGroup -ObjectId <id> | Get-AzureADGroupAppRoleAssignment | fl *
|
||||
|
||||
#### Agregar usuario al grupo
|
||||
|
||||
Los propietarios del grupo pueden agregar nuevos usuarios al grupo
|
||||
Los propietarios del grupo pueden agregar nuevos usuarios al grupo.
|
||||
```bash
|
||||
Add-AzureADGroupMember -ObjectId <group_id> -RefObjectId <user_id> -Verbose
|
||||
```
|
||||
> [!WARNING]
|
||||
> Los grupos pueden ser dinámicos, lo que básicamente significa que **si un usuario cumple ciertas condiciones, será agregado a un grupo**. Por supuesto, si las condiciones se basan en **atributos** que un **usuario** puede **controlar**, podría abusar de esta función para **ingresar a otros grupos**.\
|
||||
> Los grupos pueden ser dinámicos, lo que básicamente significa que **si un usuario cumple ciertas condiciones, será agregado a un grupo**. Por supuesto, si las condiciones se basan en **atributos** que un **usuario** puede **controlar**, podría abusar de esta función para **entrar en otros grupos**.\
|
||||
> Consulta cómo abusar de grupos dinámicos en la siguiente página:
|
||||
|
||||
{{#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
|
||||
@@ -608,10 +714,10 @@ Para más información sobre Aplicaciones consulta:
|
||||
../az-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
Cuando se genera una aplicación, se otorgan 2 tipos de permisos:
|
||||
Cuando se genera una App, se otorgan 2 tipos de permisos:
|
||||
|
||||
- **Permisos** otorgados al **Service Principal**
|
||||
- **Permisos** que la **aplicación** puede tener y usar en **nombre del usuario**.
|
||||
- **Permisos** que la **app** puede tener y usar en **nombre del usuario**.
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
@@ -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
|
||||
@@ -935,7 +1098,7 @@ Cuando PIM está habilitado, es posible configurar cada rol con ciertos requisit
|
||||
|
||||
### Políticas de Acceso Condicional
|
||||
|
||||
Verifique:
|
||||
Ver:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
|
||||
@@ -943,9 +1106,9 @@ Verifique:
|
||||
|
||||
### Protección de Identidad de Entra
|
||||
|
||||
La Protección de Identidad de Entra es un servicio de seguridad que permite **detectar cuándo un usuario o un inicio de sesión es demasiado arriesgado** para ser aceptado, permitiendo **bloquear** al usuario o el intento de inicio de sesión.
|
||||
La Protección de Identidad de Entra es un servicio de seguridad que permite **detectar cuando un usuario o un inicio de sesión es demasiado arriesgado** para ser aceptado, permitiendo **bloquear** al usuario o el intento de inicio de sesión.
|
||||
|
||||
Permite al administrador configurarlo para **bloquear** intentos cuando el riesgo es "Bajo y superior", "Medio y superior" o "Alto". Sin embargo, por defecto está completamente **deshabilitado**:
|
||||
Permite al administrador configurarlo para **bloquear** intentos cuando el riesgo es "Bajo y superior", "Medio y superior" o "Alto". Aunque, por defecto está completamente **deshabilitado**:
|
||||
|
||||
<figure><img src="../../../images/image (356).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
@@ -955,7 +1118,7 @@ Permite al administrador configurarlo para **bloquear** intentos cuando el riesg
|
||||
### Protección de Contraseñas de Entra
|
||||
|
||||
La Protección de Contraseñas de Entra ([https://portal.azure.com/index.html#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade](https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade)) es una característica de seguridad que **ayuda a prevenir el abuso de contraseñas débiles al bloquear cuentas cuando ocurren varios intentos de inicio de sesión fallidos**.\
|
||||
También permite **prohibir una lista de contraseñas personalizadas** que necesita proporcionar.
|
||||
También permite **prohibir una lista de contraseñas personalizadas** que debe proporcionar.
|
||||
|
||||
Se puede **aplicar tanto** a nivel de nube como en Active Directory local.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user