mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-05 09:17:24 -08:00
Translated ['src/pentesting-cloud/azure-security/README.md', 'src/pentes
This commit is contained in:
@@ -66,12 +66,23 @@ $token = (az account get-access-token --resource https://graph.microsoft.com --q
|
||||
$secureToken = ConvertTo-SecureString $token -AsPlainText -Force
|
||||
Connect-MgGraph -AccessToken $secureToken
|
||||
|
||||
# Get token from session
|
||||
Parameters = @{
|
||||
Method = "GET"
|
||||
Uri = "/v1.0/me"
|
||||
OutputType = "HttpResponseMessage"
|
||||
}
|
||||
$Response = Invoke-MgGraphRequest @Parameters
|
||||
$Headers = $Response.RequestMessage.Headers
|
||||
$Headers.Authorization.Parameter
|
||||
|
||||
|
||||
# Find commands
|
||||
Find-MgGraphCommand -command *Mg*
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
Connect-AzAccount #Open browser
|
||||
# Using credentials
|
||||
@@ -80,15 +91,11 @@ $creds = New-Object System.Management.Automation.PSCredential("test@corp.onmicro
|
||||
Connect-AzAccount -Credential $creds
|
||||
|
||||
# Get Access Token
|
||||
(Get-AzAccessToken).Token
|
||||
# Request access token to other endpoints: AadGraph, AnalysisServices, Arm, Attestation, Batch, DataLake, KeyVault, MSGraph, OperationalInsights, ResourceManager, Storage, Synapse
|
||||
(Get-AzAccessToken -ResourceTypeName MSGraph).Token
|
||||
(Get-AzAccessToken -Resource "https://graph.microsoft.com").Token
|
||||
(ConvertFrom-SecureString (Get-AzAccessToken -ResourceTypeName Arm -AsSecureString).Token -AsPlainText)
|
||||
|
||||
# Connect with access token
|
||||
Connect-AzAccount -AccountId test@corp.onmicrosoft.com -AccessToken $token
|
||||
Connect-AzAccount -AccessToken $token -GraphAccessToken $graphaccesstoken -AccountId <ACCOUNT-ID>
|
||||
## The -AccessToken is from management.azure.com
|
||||
Connect-AzAccount -AccountId test@corp.onmicrosoft.com [-AccessToken $ManagementToken] [-GraphAccessToken $AADGraphToken] [-MicrosoftGraphAccessToken $MicrosoftGraphToken] [-KeyVaultAccessToken $KeyVaultToken]
|
||||
|
||||
# Connect with Service principal/enterprise app secret
|
||||
$password = ConvertTo-SecureString 'KWEFNOIRFIPMWL.--DWPNVFI._EDWWEF_ADF~SODNFBWRBIF' -AsPlainText -Force
|
||||
@@ -151,7 +158,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 stelselaanvoerder 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
|
||||
@@ -279,7 +286,7 @@ Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# Enumerate users
|
||||
Get-AzADUser
|
||||
@@ -302,7 +309,7 @@ $password = "ThisIsTheNewPassword.!123" | ConvertTo- SecureString -AsPlainText
|
||||
```
|
||||
### MFA & Voorwaardelike Toegang Beleide
|
||||
|
||||
Dit word sterk aanbeveel om MFA by elke gebruiker 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, blaaiert of **sekere voorwaarde** aanmeld. Hierdie beleide, as dit nie korrek geconfigureer is nie, mag geneig wees tot **omseilings**. Kontroleer:
|
||||
Dit word sterk aanbeveel om MFA by elke gebruiker toe te voeg, egter, sommige maatskappye sal dit nie instel of mag dit instel met 'n Voorwaardelike Toegang: Die gebruiker sal **MFA vereis word as** dit vanaf 'n spesifieke ligging, blaaiers of **sekere voorwaarde** aanmeld. Hierdie beleide, as dit nie korrek geconfigureer is nie, mag geneig wees tot **omseilings**. Kontroleer:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
|
||||
@@ -346,6 +353,22 @@ az role assignment list --include-groups --include-classic-administrators true -
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# 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>
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
```bash
|
||||
# Enumerate Groups
|
||||
@@ -373,22 +396,6 @@ Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember
|
||||
Get-AzureADGroup -ObjectId <id> | Get-AzureADGroupAppRoleAssignment | fl *
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
```bash
|
||||
# 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>
|
||||
```
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
#### Voeg gebruiker by groep
|
||||
@@ -398,7 +405,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 aan 'n groep bygevoeg 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 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**.\
|
||||
> Kyk hoe om dinamiese groepe te misbruik op die volgende bladsy:
|
||||
|
||||
{{#ref}}
|
||||
@@ -433,28 +440,7 @@ az ad sp list --query '[?length(keyCredentials) > `0` || length(passwordCredenti
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
```bash
|
||||
# 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 *
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# Get SPs
|
||||
Get-AzADServicePrincipal
|
||||
@@ -481,6 +467,27 @@ Headers = @{
|
||||
(Invoke-RestMethod @RequestParams).value
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
```bash
|
||||
# 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 *
|
||||
```
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!WARNING]
|
||||
@@ -625,6 +632,19 @@ az ad app list --query '[?length(keyCredentials) > `0` || length(passwordCredent
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# 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
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
```bash
|
||||
# List all registered applications
|
||||
@@ -637,19 +657,6 @@ Get-AzureADApplication -All $true | %{if(Get-AzureADApplicationPasswordCredentia
|
||||
Get-AzureADApplication -ObjectId <id> | Get-AzureADApplicationOwner |fl *
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
```bash
|
||||
# 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
|
||||
```
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!WARNING]
|
||||
@@ -665,9 +672,9 @@ Get-AzADAppCredential
|
||||
|
||||
Dit is moontlik om 'n lys van algemeen gebruikte App ID's wat aan Microsoft behoort te vind in [https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications)
|
||||
|
||||
### Gemanagte Identiteite
|
||||
### Managed Identities
|
||||
|
||||
Vir meer inligting oor Gemanagte Identiteite, kyk:
|
||||
Vir meer inligting oor Managed Identities kyk:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
@@ -716,7 +723,7 @@ az role assignment list --all --query "[?principalName=='carlos@carloshacktricks
|
||||
```
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
{{#tab name="Az" }}
|
||||
```bash
|
||||
# Get role assignments on the subscription
|
||||
Get-AzRoleDefinition
|
||||
@@ -904,14 +911,14 @@ Get-AzureADMSScopedRoleMembership -Id <id> | fl #Get role ID and role members
|
||||
|
||||
## Verdedigingsmeganismes
|
||||
|
||||
### Bevoorregte Identiteitsbestuur (PIM)
|
||||
### Privileged Identity Management (PIM)
|
||||
|
||||
Bevoorregte Identiteitsbestuur (PIM) in Azure help om **oormatige voorregte** aan gebruikers onnodig toe te ken.
|
||||
Privileged Identity Management (PIM) in Azure help om **oormatige voorregte** te voorkom wat onnodig aan gebruikers toegeken word.
|
||||
|
||||
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 vir 'n tydperk (bv. 6 maande)** te maak. 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**.\
|
||||
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**.\
|
||||
Let daarop dat die gebruiker ook kan vra om die tyd te **verleng**.
|
||||
|
||||
Boonop **stuur PIM e-posse** wanneer 'n bevoorregte 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>
|
||||
|
||||
@@ -924,7 +931,7 @@ Wanneer PIM geaktiveer is, is dit moontlik om elke rol met sekere vereistes te k
|
||||
- Vereis kaartjie-inligting op aktivering
|
||||
- Vereis goedkeuring om te aktiveer
|
||||
- Maks tyd om die verkieslike toewysings te laat verval
|
||||
- Nog baie meer konfigurasie oor wanneer en aan wie om kennisgewings te stuur wanneer sekere aksies met daardie rol gebeur
|
||||
- Nog baie meer konfigurasie oor wanneer en wie kennisgewings moet ontvang wanneer sekere aksies met daardie rol gebeur
|
||||
|
||||
### Voorwaardelike Toegang Beleide <a href="#title-text" id="title-text"></a>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user