16 KiB
Az - Enumerasie Gereedskap
{{#include ../../banners/hacktricks-training.md}}
Installeer PowerShell in Linux
Tip
In linux sal jy PowerShell Core moet installeer:
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
Installeer PowerShell in MacOS
Instruksies van die dokumentasie:
- Installeer
brewas dit nog nie geïnstalleer is nie:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Installeer die nuutste stabiele weergawe van PowerShell:
brew install powershell/tap/powershell
- Voer PowerShell uit:
pwsh
- Opdatering:
brew update
brew upgrade powershell
Hoof Enumerasie Gereedskap
az cli
Azure Command-Line Interface (CLI) is 'n kruis-platform hulpmiddel geskryf in Python vir die bestuur en administrasie van (meeste) Azure en Entra ID hulpbronne. Dit verbind met Azure en voer administratiewe opdragte uit via die opdraglyn of skripte.
Volg hierdie skakel vir die installasie instruksies¡.
Opdragte in Azure CLI is gestruktureer volgens 'n patroon van: az <service> <action> <parameters>
Debug | MitM az cli
Deur die parameter --debug is dit moontlik om al die versoeke wat die hulpmiddel az stuur te sien:
az account management-group list --output table --debug
Om 'n MitM op die hulpmiddel te doen en al die versoeke wat dit handmatig stuur te kontroleer, kan jy doen:
{{#tabs }} {{#tab name="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="PS" }}
$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 'n module met cmdlets om Azure hulpbronne direk vanaf die PowerShell-opdraglyn te bestuur.
Volg hierdie skakel vir die installasie instruksies.
Opdragte in Azure PowerShell AZ Module is gestruktureer soos: <Action>-Az<Service> <parameters>
Debug | MitM Az PowerShell
Met die parameter -Debug is dit moontlik om al die versoeke wat die hulpmiddel stuur te sien:
Get-AzResourceGroup -Debug
Om 'n MitM na die hulpmiddel te doen en al die versoeke wat dit handmatig stuur te kontroleer, kan jy die omgewing veranderlikes HTTPS_PROXY en HTTP_PROXY instel volgens die docs.
Microsoft Graph PowerShell
Microsoft Graph PowerShell is 'n kruis-platform SDK wat toegang tot al die Microsoft Graph API's moontlik maak, insluitend dienste soos SharePoint, Exchange, en Outlook, met 'n enkele eindpunt. Dit ondersteun PowerShell 7+, moderne verifikasie via MSAL, eksterne identiteite, en gevorderde navrae. Met 'n fokus op die minste privaatheidstoegang, verseker dit veilige bedrywighede en ontvang gereelde opdaterings om in lyn te wees met die nuutste Microsoft Graph API-funksies.
Volg hierdie skakel vir die installasie instruksies.
Opdragte in Microsoft Graph PowerShell is gestruktureer soos: <Action>-Mg<Service> <parameters>
Foutopsporing van Microsoft Graph PowerShell
Met die parameter -Debug is dit moontlik om al die versoeke wat die hulpmiddel stuur te sien:
Get-MgUser -Debug
AzureAD Powershell
Die Azure Active Directory (AD) module, nou verouderd, is deel van Azure PowerShell vir die bestuur van Azure AD hulpbronne. Dit bied cmdlets vir take soos die bestuur van gebruikers, groepe, en aansoekregistrasies in Entra ID.
Tip
Dit is vervang deur Microsoft Graph PowerShell
Volg hierdie skakel vir die installasie-instruksies.
Geoutomatiseerde Recon & Nakoming Gereedskap
turbot azure plugins
Turbot met steampipe en powerpipe maak dit moontlik om inligting van Azure en Entra ID te versamel en nakomingskontroles uit te voer en miskonfigurasies te vind. Die tans mees aanbevole Azure modules om te gebruik is:
- https://github.com/turbot/steampipe-mod-azure-compliance
- https://github.com/turbot/steampipe-mod-azure-insights
- https://github.com/turbot/steampipe-mod-azuread-insights
# 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 is 'n Open Source sekuriteitstoepassing om AWS, Azure, Google Cloud en Kubernetes sekuriteitsbeste praktyke assesserings, ouditte, insidentrespons, deurlopende monitering, verharding en forensiese gereedheid uit te voer.
Dit sal basies toelaat dat ons honderde kontroles teen 'n Azure-omgewing kan uitvoer om sekuriteitsmisconfigurasies te vind en die resultate in json (en ander teksformate) te versamel of dit op die web te kontroleer.
# 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
Dit stel jou in staat om Azure intekeninge en Microsoft Entra ID sekuriteitskonfigurasie hersienings outomaties uit te voer.
Die HTML-verslae word binne die ./monkey-reports gids in die github-berging gestoor.
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 versamel konfigurasie data vir handmatige inspeksie en beklemtoon risiko areas. Dit is 'n multi-cloud sekuriteitsouditering hulpmiddel, wat sekuriteitsposisie assessering van wolkomgewings moontlik maak.
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
Dit is 'n powershell-skrip wat jou help om alle hulpbronne en toestemmings binne 'n Bestuursgroep en die Entra ID huurders te visualiseer en sekuriteitsmisconfigurasies te vind.
Dit werk met die Az PowerShell-module, so enige outentisering wat deur hierdie hulpmiddel ondersteun word, word deur die hulpmiddel ondersteun.
import-module Az
.\AzGovVizParallel.ps1 -ManagementGroupId <management-group-id> [-SubscriptionIdWhitelist <subscription-id>]
Geoutomatiseerde Post-Exploitation gereedskap
ROADRecon
Die opsporing van ROADRecon bied inligting oor die konfigurasie van Entra ID, soos gebruikers, groepe, rolle, voorwaardelike toegangbeleide...
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
# 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
Laai die BloodHound web met curl -L https://ghst.ly/getbhce | docker compose -f - up en voer die output.json lêer in.
Dan, in die EXPLORE tab, in die CYPHER afdeling kan jy 'n folder ikoon sien wat voorafgeboude navrae bevat.
MicroBurst
MicroBurst sluit funksies en skripte in wat Azure Dienste ontdekking, swak konfigurasie ouditering, en post eksploitatie aksies soos geloofsbrief dumping ondersteun. Dit is bedoel om gebruik te word tydens penetrasietoetse waar Azure in gebruik is.
Import-Module .\MicroBurst.psm1
Import-Module .\Get-AzureDomainInfo.ps1
Get-AzureDomainInfo -folder MicroBurst -Verbose
PowerZure
PowerZure is geskep uit die behoefte aan 'n raamwerk wat beide verkenning en eksploitatie van Azure, EntraID, en die geassosieerde hulpbronne kan uitvoer.
Dit gebruik die Az PowerShell module, so enige outentisering wat deur hierdie hulpmiddel ondersteun word, word deur die hulpmiddel ondersteun.
# 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 is 'n post-exploitation hulpmiddelstel vir interaksie met die Microsoft Graph API. Dit bied verskeie hulpmiddels vir die uitvoering van verkenning, volharding en plundering van data uit 'n Microsoft Entra ID (Azure AD) rekening.
#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 skep 'n “aanval grafiek” van die hulpbronne in 'n Azure intekening. Dit stel rooi span en pentesters in staat om die aanval oppervlak en pivot geleenthede binne 'n huurder te visualiseer, en versterk jou verdedigers om vinnig te oriënteer en prioriteit te gee aan insident respons werk.
Ongelukkig, dit lyk ononderhoude.
# 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}}