# Az - Enumeration Tools {{#include ../../banners/hacktricks-training.md}} ## PowerShell unter Linux installieren > [!TIP] > Unter Linux müssen Sie PowerShell Core installieren: ```bash sudo apt-get update sudo apt-get install -y wget apt-transport-https software-properties-common # Ubuntu 20.04 wget -q https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb # Update repos sudo apt-get update sudo add-apt-repository universe # Install & start powershell sudo apt-get install -y powershell pwsh # Az cli curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash ``` ## PowerShell auf MacOS installieren Anweisungen aus der [**Dokumentation**](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-macos?view=powershell-7.4): 1. Installiere `brew`, falls noch nicht installiert: ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` 2. Installieren Sie die neueste stabile Version von PowerShell: ```sh brew install powershell/tap/powershell ``` 3. PowerShell ausführen: ```sh pwsh ``` 4. Aktualisierung: ```sh brew update brew upgrade powershell ``` ## Haupt-Enumeration-Tools ### az cli [**Azure Command-Line Interface (CLI)**](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) ist ein plattformübergreifendes Tool, das in Python geschrieben wurde, um (die meisten) Azure- und Entra ID-Ressourcen zu verwalten und zu administrieren. Es verbindet sich mit Azure und führt administrative Befehle über die Befehlszeile oder Skripte aus. Folgen Sie diesem Link für die [**Installationsanweisungen¡**](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli#install). Befehle in Azure CLI sind nach folgendem Muster strukturiert: `az ` #### Debug | MitM az cli Mit dem Parameter **`--debug`** ist es möglich, alle Anfragen zu sehen, die das Tool **`az`** sendet: ```bash az account management-group list --output table --debug ``` Um einen **MitM** auf das Tool durchzuführen und **alle Anfragen**, die es manuell sendet, zu überprüfen, kannst du Folgendes tun: {{#tabs }} {{#tab name="Bash" }} ```bash export ADAL_PYTHON_SSL_NO_VERIFY=1 export AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1 export HTTPS_PROXY="http://127.0.0.1:8080" export HTTP_PROXY="http://127.0.0.1:8080" # If this is not enough # Download the certificate from Burp and convert it into .pem format # And export the following env variable 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="CMD" }} ```bash set ADAL_PYTHON_SSL_NO_VERIFY=1 set AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1 set HTTPS_PROXY="http://127.0.0.1:8080" set HTTP_PROXY="http://127.0.0.1:8080" # If this is not enough # Download the certificate from Burp and convert it into .pem format # And export the following env variable openssl x509 -in cacert.der -inform DER -out cacert.pem -outform PEM set REQUESTS_CA_BUNDLE=C:\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 ist ein Modul mit Cmdlets zur Verwaltung von Azure-Ressourcen direkt über die PowerShell-Befehlszeile. Folgen Sie diesem Link für die [**Installationsanweisungen**](https://learn.microsoft.com/en-us/powershell/azure/install-azure-powershell). Befehle im Azure PowerShell AZ-Modul sind strukturiert wie: `-Az ` #### Debug | MitM Az PowerShell Mit dem Parameter **`-Debug`** ist es möglich, alle Anfragen zu sehen, die das Tool sendet: ```bash Get-AzResourceGroup -Debug ``` Um ein **MitM** auf das Tool durchzuführen und **alle Anfragen**, die es manuell sendet, zu überprüfen, können Sie die Umgebungsvariablen `HTTPS_PROXY` und `HTTP_PROXY` gemäß den [**Dokumenten**](https://learn.microsoft.com/en-us/powershell/azure/az-powershell-proxy) festlegen. ### Microsoft Graph PowerShell Microsoft Graph PowerShell ist ein plattformübergreifendes SDK, das den Zugriff auf alle Microsoft Graph APIs ermöglicht, einschließlich Dienste wie SharePoint, Exchange und Outlook, über einen einzigen Endpunkt. Es unterstützt PowerShell 7+, moderne Authentifizierung über MSAL, externe Identitäten und erweiterte Abfragen. Mit einem Fokus auf den minimalen Zugriff gewährleistet es sichere Operationen und erhält regelmäßige Updates, um mit den neuesten Funktionen der Microsoft Graph API in Einklang zu stehen. Folgen Sie diesem Link für die [**Installationsanweisungen**](https://learn.microsoft.com/en-us/powershell/microsoftgraph/installation). Befehle in Microsoft Graph PowerShell sind strukturiert wie: `-Mg ` #### Debug Microsoft Graph PowerShell Mit dem Parameter **`-Debug`** ist es möglich, alle Anfragen zu sehen, die das Tool sendet: ```bash Get-MgUser -Debug ``` ### ~~**AzureAD Powershell**~~ Das Azure Active Directory (AD) Modul, jetzt **veraltet**, ist Teil von Azure PowerShell zur Verwaltung von Azure AD-Ressourcen. Es bietet Cmdlets für Aufgaben wie die Verwaltung von Benutzern, Gruppen und Anwendungsregistrierungen in Entra ID. > [!TIP] > Dies wird durch Microsoft Graph PowerShell ersetzt Folgen Sie diesem Link für die [**Installationsanweisungen**](https://www.powershellgallery.com/packages/AzureAD). ## Automatisierte Recon- & Compliance-Tools ### [turbot azure plugins](https://github.com/orgs/turbot/repositories?q=mod-azure) Turbot mit Steampipe und Powerpipe ermöglicht das Sammeln von Informationen aus Azure und Entra ID sowie die Durchführung von Compliance-Prüfungen und das Auffinden von Fehlkonfigurationen. Die derzeit am meisten empfohlenen Azure-Module, die ausgeführt werden sollten, sind: - [https://github.com/turbot/steampipe-mod-azure-compliance](https://github.com/turbot/steampipe-mod-azure-compliance) - [https://github.com/turbot/steampipe-mod-azure-insights](https://github.com/turbot/steampipe-mod-azure-insights) - [https://github.com/turbot/steampipe-mod-azuread-insights](https://github.com/turbot/steampipe-mod-azuread-insights) ```bash # Install brew install turbot/tap/powerpipe brew install turbot/tap/steampipe steampipe plugin install azure steampipe plugin install azuread # Config creds via env vars or az cli default creds will be used export AZURE_ENVIRONMENT="AZUREPUBLICCLOUD" export AZURE_TENANT_ID="" export AZURE_SUBSCRIPTION_ID="" export AZURE_CLIENT_ID="" export AZURE_CLIENT_SECRET="" # Run steampipe-mod-azure-insights cd /tmp mkdir dashboards cd dashboards powerpipe mod init powerpipe mod install github.com/turbot/steampipe-mod-azure-insights steampipe service start powerpipe server # Go to http://localhost:9033 in a browser ``` ### [Prowler](https://github.com/prowler-cloud/prowler) Prowler ist ein Open Source-Sicherheitstool, um Sicherheitsbest Practices-Bewertungen, Audits, Incident Response, kontinuierliche Überwachung, Härtung und forensische Bereitschaft für AWS, Azure, Google Cloud und Kubernetes durchzuführen. Es ermöglicht uns im Grunde, Hunderte von Prüfungen in einer Azure-Umgebung durchzuführen, um Sicherheitsfehlkonfigurationen zu finden und die Ergebnisse im json-Format (und anderen Textformaten) zu sammeln oder sie im Web zu überprüfen. ```bash # Create a application with Reader role and set the tenant ID, client ID and secret in prowler so it access the app # Launch web with docker-compose export DOCKER_DEFAULT_PLATFORM=linux/amd64 curl -LO https://raw.githubusercontent.com/prowler-cloud/prowler/refs/heads/master/docker-compose.yml curl -LO https://raw.githubusercontent.com/prowler-cloud/prowler/refs/heads/master/.env ## If using an old docker-compose version, change the "env_file" params to: env_file: ".env" docker compose up -d # Access the web and configure the access to run a scan from it # Prowler cli python3 -m pip install prowler --break-system-packages docker run --rm toniblyx/prowler:v4-latest azure --list-checks docker run --rm toniblyx/prowler:v4-latest azure --list-services docker run --rm toniblyx/prowler:v4-latest azure --list-compliance docker run --rm -e "AZURE_CLIENT_ID=" -e "AZURE_TENANT_ID=" -e "AZURE_CLIENT_SECRET=" toniblyx/prowler:v4-latest azure --sp-env-auth ## It also support other authentication types, check: prowler azure --help ``` ### [Monkey365](https://github.com/silverhack/monkey365) Es ermöglicht die automatische Durchführung von Sicherheitskonfigurationsüberprüfungen für Azure-Abonnements und Microsoft Entra ID. Die HTML-Berichte werden im Verzeichnis `./monkey-reports` im GitHub-Repository-Ordner gespeichert. ```bash git clone https://github.com/silverhack/monkey365 Get-ChildItem -Recurse monkey365 | Unblock-File cd monkey365 Import-Module ./monkey365 mkdir /tmp/monkey365-scan cd /tmp/monkey365-scan Get-Help Invoke-Monkey365 Get-Help Invoke-Monkey365 -Detailed # Scan with user creds (browser will be run) Invoke-Monkey365 -TenantId -Instance Azure -Collect All -ExportTo HTML # Scan with App creds $SecureClientSecret = ConvertTo-SecureString "" -AsPlainText -Force Invoke-Monkey365 -TenantId -ClientId -ClientSecret $SecureClientSecret -Instance Azure -Collect All -ExportTo HTML ``` ### [ScoutSuite](https://github.com/nccgroup/ScoutSuite) Scout Suite sammelt Konfigurationsdaten zur manuellen Überprüfung und hebt Risikobereiche hervor. Es ist ein Multi-Cloud-Sicherheitsprüfungswerkzeug, das die Bewertung der Sicherheitslage von Cloud-Umgebungen ermöglicht. ```bash virtualenv -p python3 venv source venv/bin/activate pip install scoutsuite scout --help # Use --cli flag to use az cli credentials # Use --user-account to have scout prompt for user credentials # Use --user-account-browser to launch a browser to login # Use --service-principal to have scout prompt for app credentials python scout.py azure --cli ``` ### [Azure-MG-Sub-Governance-Reporting](https://github.com/JulianHayward/Azure-MG-Sub-Governance-Reporting) Es ist ein PowerShell-Skript, das Ihnen hilft, **alle Ressourcen und Berechtigungen innerhalb einer Management-Gruppe und des Entra ID**-Mandanten zu visualisieren und Sicherheitsfehlkonfigurationen zu finden. Es funktioniert mit dem Az PowerShell-Modul, sodass jede Authentifizierung, die von diesem Tool unterstützt wird, auch von dem Tool unterstützt wird. ```bash import-module Az .\AzGovVizParallel.ps1 -ManagementGroupId [-SubscriptionIdWhitelist ] ``` ## Automatisierte Post-Exploitation-Tools ### [**ROADRecon**](https://github.com/dirkjanm/ROADtools) Die Enumeration von ROADRecon bietet Informationen über die Konfiguration von Entra ID, wie Benutzer, Gruppen, Rollen, bedingte Zugriffsrichtlinien... ```bash cd ROADTools pipenv shell # Login with user creds roadrecon auth -u test@corp.onmicrosoft.com -p "Welcome2022!" # Login with app creds roadrecon auth --as-app --client "" --password "" --tenant "" roadrecon gather roadrecon gui ``` ### [**AzureHound**](https://github.com/BloodHoundAD/AzureHound) ```bash # Launch AzureHound ## Login with app secret azurehound -a "" -s "" --tenant "" list -o ./output.json ## Login with user creds azurehound -u "" -p "" --tenant "" list -o ./output.json ``` Starte die **BloodHound**-Webanwendung mit **`curl -L https://ghst.ly/getbhce | docker compose -f - up`** und importiere die `output.json`-Datei. Dann kannst du im **EXPLORE**-Tab im **CYPHER**-Bereich ein **Ordnersymbol** sehen, das vorgefertigte Abfragen enthält. ### [**MicroBurst**](https://github.com/NetSPI/MicroBurst) MicroBurst umfasst Funktionen und Skripte, die die Entdeckung von Azure-Diensten, die Überprüfung schwacher Konfigurationen und nachgelagerte Aktionen wie Credential Dumping unterstützen. Es ist für den Einsatz während Penetrationstests gedacht, bei denen Azure verwendet wird. ```bash Import-Module .\MicroBurst.psm1 Import-Module .\Get-AzureDomainInfo.ps1 Get-AzureDomainInfo -folder MicroBurst -Verbose ``` ### [**PowerZure**](https://github.com/hausec/PowerZure) PowerZure wurde aus der Notwendigkeit geschaffen, ein Framework zu haben, das sowohl Aufklärung als auch Ausnutzung von Azure, EntraID und den zugehörigen Ressourcen durchführen kann. Es verwendet das **Az PowerShell**-Modul, sodass jede Authentifizierung, die von diesem Tool unterstützt wird, auch von dem Tool unterstützt wird. ```bash # Login Import-Module Az Connect-AzAccount # Clone and import PowerZure git clone https://github.com/hausec/PowerZure cd PowerZure ipmo ./Powerzure.psd1 Invoke-Powerzure -h # Check all the options # Info Gathering (read) Get-AzureCurrentUser # Get current user Get-AzureTarget # What can you access to Get-AzureUser -All # Get all users Get-AzureSQLDB -All # Get all SQL DBs Get-AzureAppOwner # Owners of apps in Entra Show-AzureStorageContent -All # List containers, shared and tables Show-AzureKeyVaultContent -All # List all contents in key vaults # Operational (write) Set-AzureUserPassword -Password -Username # Change password Set-AzureElevatedPrivileges # Get permissions from Global Administrator in EntraID to User Access Administrator in Azure RBAC. New-AzureBackdoor -Username -Password Invoke-AzureRunCommand -Command -VMName [...] ``` ### [**GraphRunner**](https://github.com/dafthack/GraphRunner/wiki/Invoke%E2%80%90GraphRunner) GraphRunner ist ein Post-Exploitation-Toolset zur Interaktion mit der Microsoft Graph API. Es bietet verschiedene Werkzeuge für die Durchführung von Aufklärung, Persistenz und das Plündern von Daten aus einem Microsoft Entra ID (Azure AD) Konto. ```bash #A good place to start is to authenticate with the Get-GraphTokens module. This module will launch a device-code login, allowing you to authenticate the session from a browser session. Access and refresh tokens will be written to the global $tokens variable. To use them with other GraphRunner modules use the Tokens flag (Example. Invoke-DumpApps -Tokens $tokens) Import-Module .\GraphRunner.ps1 Get-GraphTokens #This module gathers information about the tenant including the primary contact info, directory sync settings, and user settings such as if users have the ability to create apps, create groups, or consent to apps. Invoke-GraphRecon -Tokens $tokens -PermissionEnum #A module to dump conditional access policies from a tenant. Invoke-GraphRecon -Tokens $tokens -PermissionEnum #A module to dump conditional access policies from a tenant. Invoke-DumpCAPS -Tokens $tokens -ResolveGuids #This module helps identify malicious app registrations. It will dump a list of Azure app registrations from the tenant including permission scopes and users that have consented to the apps. Additionally, it will list external apps that are not owned by the current tenant or by Microsoft's main app tenant. This is a good way to find third-party external apps that users may have consented to. Invoke-DumpApps -Tokens $tokens #Gather the full list of users from the directory. Get-AzureADUsers -Tokens $tokens -OutFile users.txt #Create a list of security groups along with their members. Get-SecurityGroups -AccessToken $tokens.access_token #Gets groups that may be able to be modified by the current user Get-UpdatableGroups -Tokens $tokens #Finds dynamic groups and displays membership rules Get-DynamicGroups -Tokens $tokens #Gets a list of SharePoint site URLs visible to the current user Get-SharePointSiteURLs -Tokens $tokens #This module attempts to locate mailboxes in a tenant that have allowed other users to read them. By providing a userlist the module will attempt to access the inbox of each user and display if it was successful. The access token needs to be scoped to Mail.Read.Shared or Mail.ReadWrite.Shared for this to work. Invoke-GraphOpenInboxFinder -Tokens $tokens -Userlist users.txt #This module attempts to gather a tenant ID associated with a domain. 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 ``` ### [Stormspotter](https://github.com/Azure/Stormspotter) Stormspotter erstellt ein „Angriffsdiagramm“ der Ressourcen in einem Azure-Abonnement. Es ermöglicht roten Teams und Pentestern, die Angriffsfläche und Pivot-Möglichkeiten innerhalb eines Mandanten zu visualisieren und unterstützt Ihre Verteidiger dabei, sich schnell zu orientieren und die Incident-Response-Arbeit zu priorisieren. **Leider sieht es unmaintained aus**. ```bash # Start Backend cd stormspotter\backend\ pipenv shell python ssbackend.pyz # Start Front-end cd stormspotter\frontend\dist\spa\ quasar.cmd serve -p 9091 --history # Run Stormcollector cd stormspotter\stormcollector\ pipenv shell 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) ``` {{#include ../../banners/hacktricks-training.md}}