Az - Enumeration Tools

Reading time: 13 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

리눅스에서는 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)는 Azure 및 Entra ID 리소스를 관리하고 운영하기 위해 Python으로 작성된 크로스 플랫폼 도구입니다. 이 도구는 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은 PowerShell 명령줄에서 Azure 리소스를 직접 관리하기 위한 cmdlet이 포함된 모듈입니다.

설치 지침 링크를 따라가세요.

Azure PowerShell AZ 모듈의 명령은 다음과 같이 구조화됩니다: <Action>-Az<Service> <parameters>

Debug | MitM Az PowerShell

-Debug 매개변수를 사용하면 도구가 보내는 모든 요청을 볼 수 있습니다:

bash
Get-AzResourceGroup -Debug

MitM 공격을 수행하고 도구가 수동으로 전송하는 모든 요청을 확인하려면 HTTPS_PROXYHTTP_PROXY 환경 변수를 문서에 따라 설정할 수 있습니다.

Microsoft Graph PowerShell

Microsoft Graph PowerShell은 단일 엔드포인트를 사용하여 SharePoint, Exchange 및 Outlook과 같은 서비스에 대한 모든 Microsoft Graph API에 액세스할 수 있는 크로스 플랫폼 SDK입니다. PowerShell 7+, MSAL을 통한 현대 인증, 외부 ID 및 고급 쿼리를 지원합니다. 최소 권한 액세스에 중점을 두어 보안 작업을 보장하며 최신 Microsoft Graph API 기능에 맞춰 정기적으로 업데이트를 받습니다.

설치 지침을 보려면 이 링크를 따르세요.

Microsoft Graph PowerShell의 명령은 다음과 같이 구조화됩니다: <Action>-Mg<Service> <parameters>

Microsoft Graph PowerShell 디버그

-Debug 매개변수를 사용하면 도구가 전송하는 모든 요청을 볼 수 있습니다:

bash
Get-MgUser -Debug

AzureAD Powershell

Azure Active Directory (AD) 모듈은 현재 사용 중단되었으며, Azure AD 리소스를 관리하기 위한 Azure PowerShell의 일부입니다. Entra ID에서 사용자, 그룹 및 애플리케이션 등록을 관리하는 작업을 위한 cmdlet을 제공합니다.

tip

이는 Microsoft Graph PowerShell로 대체됩니다.

설치 지침을 보려면 이 링크를 따르세요.

자동화된 정찰 및 준수 도구

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 보고서는 github 저장소 폴더 내의 ./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

이것은 Management Group 및 Entra ID 테넌트 내의 모든 리소스와 권한을 시각화하고 보안 잘못 구성된 부분을 찾는 데 도움을 주는 PowerShell 스크립트입니다.

이 도구는 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 구독 내 리소스의 “공격 그래프”를 생성합니다. 이를 통해 레드 팀과 펜테스터는 테넌트 내 공격 표면과 피벗 기회를 시각화할 수 있으며, 방어자가 사건 대응 작업을 신속하게 정렬하고 우선 순위를 매길 수 있도록 지원합니다.

불행히도, 유지 관리되지 않는 것 같습니다.

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 지원하기