Az - Enumeration Tools

Reading time: 15 minutes

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें

Linux में PowerShell स्थापित करें

tip

Linux में आपको PowerShell Core स्थापित करने की आवश्यकता होगी:

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

MacOS में PowerShell स्थापित करें

दस्तावेज़ीकरण से निर्देश:

  1. यदि अभी तक स्थापित नहीं है तो brew स्थापित करें:
bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. PowerShell का नवीनतम स्थिर संस्करण स्थापित करें:
sh
brew install powershell/tap/powershell
  1. PowerShell चलाएँ:
sh
pwsh
  1. अपडेट:
sh
brew update
brew upgrade powershell

मुख्य एनुमेरेशन टूल्स

az cli

Azure Command-Line Interface (CLI) एक क्रॉस-प्लेटफ़ॉर्म टूल है जो Python में लिखा गया है, जो (अधिकतर) Azure और Entra ID संसाधनों का प्रबंधन और प्रशासन करने के लिए है। यह Azure से कनेक्ट करता है और कमांड लाइन या स्क्रिप्ट के माध्यम से प्रशासनिक आदेशों को निष्पादित करता है।

स्थापना निर्देशों के लिए इस लिंक का पालन करें¡

Azure CLI में आदेशों को इस पैटर्न का उपयोग करके संरचित किया गया है: az <service> <action> <parameters>

डिबग | MitM az cli

पैरामीटर --debug का उपयोग करके यह देखना संभव है कि टूल az सभी अनुरोध भेज रहा है:

bash
az account management-group list --output table --debug

एक MitM करने के लिए टूल पर और सभी अनुरोधों की मैन्युअल रूप से जांच करने के लिए आप कर सकते हैं:

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

Az PowerShell

Azure PowerShell एक मॉड्यूल है जिसमें Azure संसाधनों को सीधे PowerShell कमांड लाइन से प्रबंधित करने के लिए cmdlets होते हैं।

स्थापना निर्देशों के लिए इस लिंक का पालन करें।

Azure PowerShell AZ मॉड्यूल में कमांड इस प्रकार संरचित होते हैं: <Action>-Az<Service> <parameters>

Debug | MitM Az PowerShell

पैरामीटर -Debug का उपयोग करके यह देखना संभव है कि उपकरण सभी अनुरोधों को भेज रहा है:

bash
Get-AzResourceGroup -Debug

MitM करने और सभी अनुरोधों की मैन्युअल जांच करने के लिए, आप पर्यावरण चर HTTPS_PROXY और HTTP_PROXY को docs के अनुसार सेट कर सकते हैं।

Microsoft Graph PowerShell

Microsoft Graph PowerShell एक क्रॉस-प्लेटफ़ॉर्म SDK है जो सभी Microsoft Graph APIs, जैसे SharePoint, Exchange, और Outlook, तक पहुँचने की अनुमति देता है, एकल एंडपॉइंट का उपयोग करके। यह PowerShell 7+, MSAL के माध्यम से आधुनिक प्रमाणीकरण, बाहरी पहचान, और उन्नत प्रश्नों का समर्थन करता है। न्यूनतम विशेषाधिकार पहुँच पर ध्यान केंद्रित करते हुए, यह सुरक्षित संचालन सुनिश्चित करता है और नवीनतम Microsoft Graph API सुविधाओं के साथ संरेखित करने के लिए नियमित अपडेट प्राप्त करता है।

installation instructions के लिए इस लिंक का पालन करें।

Microsoft Graph PowerShell में कमांड इस प्रकार संरचित होते हैं: <Action>-Mg<Service> <parameters>

Debug Microsoft Graph PowerShell

पैरामीटर -Debug का उपयोग करके, यह देखना संभव है कि उपकरण सभी अनुरोधों को कैसे भेज रहा है:

bash
Get-MgUser -Debug

AzureAD Powershell

Azure Active Directory (AD) मॉड्यूल, जो अब deprecated है, Azure PowerShell का हिस्सा है जो Azure AD संसाधनों का प्रबंधन करता है। यह Entra ID में उपयोगकर्ताओं, समूहों और अनुप्रयोग पंजीकरणों का प्रबंधन करने के लिए cmdlets प्रदान करता है।

tip

इसे Microsoft Graph PowerShell द्वारा प्रतिस्थापित किया गया है

स्थापना निर्देशों के लिए इस लिंक का पालन करें।

Automated Recon & Compliance Tools

turbot azure plugins

Turbot, steampipe और powerpipe के साथ, Azure और Entra ID से जानकारी एकत्र करने और अनुपालन जांच करने और गलत कॉन्फ़िगरेशन खोजने की अनुमति देता है। वर्तमान में चलाने के लिए सबसे अनुशंसित Azure मॉड्यूल हैं:

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="<tenant-id>"
export AZURE_SUBSCRIPTION_ID="<subscription-id>"
export AZURE_CLIENT_ID="<client-id>"
export AZURE_CLIENT_SECRET="<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

Prowler एक ओपन सोर्स सुरक्षा उपकरण है जो AWS, Azure, Google Cloud और Kubernetes सुरक्षा सर्वोत्तम प्रथाओं का आकलन, ऑडिट, घटना प्रतिक्रिया, निरंतर निगरानी, हार्डनिंग और फॉरेंसिक्स तैयारी करने के लिए उपयोग किया जाता है।

यह मूल रूप से हमें Azure वातावरण के खिलाफ सैकड़ों जांचें चलाने की अनुमति देगा ताकि सुरक्षा गलत कॉन्फ़िगरेशन को खोजा जा सके और परिणामों को json (और अन्य पाठ प्रारूप) में इकट्ठा किया जा सके या उन्हें वेब में चेक किया जा सके।

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=<client-id>" -e "AZURE_TENANT_ID=<tenant-id>" -e "AZURE_CLIENT_SECRET=<secret>" toniblyx/prowler:v4-latest azure --sp-env-auth
## It also support other authentication types, check: prowler azure --help

Monkey365

यह Azure सब्सक्रिप्शन और Microsoft Entra ID सुरक्षा कॉन्फ़िगरेशन समीक्षाएँ स्वचालित रूप से करने की अनुमति देता है।

HTML रिपोर्ट ./monkey-reports निर्देशिका के अंदर गिटहब रिपॉजिटरी फ़ोल्डर के अंदर संग्रहीत होती हैं।

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 <tenant-id> -Instance Azure -Collect All -ExportTo HTML

# Scan with App creds
$SecureClientSecret = ConvertTo-SecureString "<secret>" -AsPlainText -Force
Invoke-Monkey365 -TenantId <tenant-id> -ClientId <client-id> -ClientSecret $SecureClientSecret -Instance Azure -Collect All -ExportTo HTML

ScoutSuite

Scout Suite मैन्युअल निरीक्षण के लिए कॉन्फ़िगरेशन डेटा एकत्र करता है और जोखिम क्षेत्रों को उजागर करता है। यह एक मल्टी-क्लाउड सुरक्षा-ऑडिटिंग उपकरण है, जो क्लाउड वातावरण के सुरक्षा स्थिति का आकलन करने में सक्षम बनाता है।

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

यह एक powershell स्क्रिप्ट है जो आपको एक प्रबंधन समूह और Entra ID टेनेट के अंदर सभी संसाधनों और अनुमतियों को दृश्य बनाने में मदद करती है और सुरक्षा गलत कॉन्फ़िगरेशन खोजने में मदद करती है।

यह Az PowerShell मॉड्यूल का उपयोग करके काम करती है, इसलिए इस उपकरण द्वारा समर्थित कोई भी प्रमाणीकरण इस उपकरण द्वारा समर्थित है।

bash
import-module Az
.\AzGovVizParallel.ps1 -ManagementGroupId <management-group-id> [-SubscriptionIdWhitelist <subscription-id>]

Automated Post-Exploitation tools

ROADRecon

ROADRecon की गणना Entra ID की कॉन्फ़िगरेशन के बारे में जानकारी प्रदान करती है, जैसे उपयोगकर्ता, समूह, भूमिकाएँ, शर्तीय पहुँच नीतियाँ...

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 "<client-id>" --password "<secret>" --tenant "<tenant-id>"
roadrecon gather
roadrecon gui

AzureHound

bash
# Launch AzureHound
## Login with app secret
azurehound -a "<client-id>" -s "<secret>" --tenant "<tenant-id>" list -o ./output.json
## Login with user creds
azurehound -u "<user-email>" -p "<password>" --tenant "<tenant-id>" list -o ./output.json

BloodHound वेब को curl -L https://ghst.ly/getbhce | docker compose -f - up के साथ लॉन्च करें और output.json फ़ाइल आयात करें।

फिर, EXPLORE टैब में, CYPHER सेक्शन में आप एक फोल्डर आइकन देख सकते हैं जिसमें पूर्व-निर्मित क्वेरीज़ होती हैं।

MicroBurst

MicroBurst में फ़ंक्शन और स्क्रिप्ट शामिल हैं जो Azure सेवाओं की खोज, कमजोर कॉन्फ़िगरेशन ऑडिटिंग, और क्रेडेंशियल डंपिंग जैसी पोस्ट एक्सप्लॉइटेशन क्रियाओं का समर्थन करते हैं। इसका उपयोग पेनिट्रेशन टेस्ट के दौरान किया जाना है जहाँ Azure का उपयोग हो रहा है।

bash
Import-Module .\MicroBurst.psm1
Import-Module .\Get-AzureDomainInfo.ps1
Get-AzureDomainInfo -folder MicroBurst -Verbose

PowerZure

PowerZure को Azure, EntraID, और संबंधित संसाधनों की पहचान और शोषण करने के लिए एक ढांचे की आवश्यकता के कारण बनाया गया था।

यह Az PowerShell मॉड्यूल का उपयोग करता है, इसलिए इस उपकरण द्वारा समर्थित कोई भी प्रमाणीकरण इस उपकरण द्वारा समर्थित है।

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 <password> -Username <username> # Change password
Set-AzureElevatedPrivileges # Get permissions from Global Administrator in EntraID to User Access Administrator in Azure RBAC.
New-AzureBackdoor -Username <username> -Password <password>
Invoke-AzureRunCommand -Command <command> -VMName <vmname>
[...]

GraphRunner

GraphRunner एक पोस्ट-एक्सप्लोइटेशन टूलसेट है जो Microsoft Graph API के साथ इंटरैक्ट करने के लिए है। यह Microsoft Entra ID (Azure AD) खाते से डेटा की पहचान, स्थिरता और लूटने के लिए विभिन्न उपकरण प्रदान करता है।

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

Stormspotter एक Azure सब्सक्रिप्शन में संसाधनों का “हमला ग्राफ” बनाता है। यह रेड टीमों और pentesters को हमले की सतह और एक टेनेट के भीतर पिवट अवसरों को दृश्य बनाने में सक्षम बनाता है, और आपके रक्षकों को तेजी से घटना प्रतिक्रिया कार्य को प्राथमिकता देने और अभिविन्यास करने में सुपरचार्ज करता है।

दुर्भाग्यवश, यह अनदेखा लगता है

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)

tip

AWS हैकिंग सीखें और अभ्यास करें:HackTricks Training AWS Red Team Expert (ARTE)
GCP हैकिंग सीखें और अभ्यास करें: HackTricks Training GCP Red Team Expert (GRTE) Azure हैकिंग सीखें और अभ्यास करें: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks का समर्थन करें