Azure Exploit#
Offensive tradecraft for Azure. Local artifacts give the operator foothold material; MicroBurst harvests credentials across Key Vaults, App Services, Automation, and Storage; PowerZure provides full assessment functions broken out by Azure role.
Azure local artifacts#
Azure file or folder created locally.
# TokenCache.dat is cleartext containing the AccessKey;
# inject into user's process to view contents of file
C:\Users\<USERNAME>\.Azure\TokenCache.dat
PowerShell Azure modules installed.
# locations indicating installed Azure modules
C:\Program Files\windowsPowerShell\Modules\Az.*
C:\Users\<USERNAME>\Documents\WindowsPowerShell\Modules\Az.*
C:\Windows\system32\windowsPowerShell\v1.0\Modules\Az.*
Search for Save-AzContext usage and file location.
PS> Get-PSReadLineOption
PS> Select-String -Path <\path\to\ConsoleHost_history.txt> -Pattern 'Save-AzContext'
Azure token cached data, key inside TokenCache: JSON file is
base64-encoded data. Decode it to recreate TokenCache.dat.
Import decoded TokenCache.dat into attacker local PowerShell. Once
imported the attacker will not be prompted for user / password.
PS> Import-AzContext -Path C:\path\to\decoded_TokenCache.dat
MicroBurst#
Scenario, you have been able to obtain credentials for a privileged user for Azure AD (Owner or Contributor). Target this user by harvesting credentials stored in Key Vaults, App Services Configurations, Automation Accounts, and Storage Accounts.
Step 1, install PowerShell modules and import MicroBurst (NetSPI).
Install-Module -Name AzureRM
Install-Module -Name Azure
# https://github.com/NetSPI/MicroBurst
Import-Module .\Get-AzurePasswords.ps1
Step 2, retrieve all available credentials at once.
Get-AzurePasswords -Verbose | Export-CSV
PowerZure#
PowerZure is a PowerShell script for assessing Azure security. Functions are grouped by their context and the role needed to run them.
Help.
Function |
Description |
Role |
|---|---|---|
|
Help menu |
Any |
Mandatory.
Function |
Description |
Role |
|---|---|---|
|
Set the default subscription |
Reader |
Operational.
Function |
Description |
Role |
|---|---|---|
|
Create a Runbook that creates an Azure account and a webhook |
Admin |
|
Execute the backdoor; needs URI from Create-Backdoor |
Admin |
|
Execute a command on a specified VM |
Contributor |
|
Execute MSBuild payload on a specified VM (runs as SYSTEM) |
Contributor |
|
Execute a supplied program |
Contributor |
|
Upload a file to a storage share |
Contributor |
|
Stop, start, restart a VM |
Contributor |
|
Start a specific Runbook |
Contributor |
|
Assign a role on a resource or subscription |
Owner |
|
Remove a user from a role |
Owner |
|
Add a user to a group |
Admin |
Info gather.
Function |
Description |
Role |
|---|---|---|
|
Current user info (name, role, groups, owned objects) |
Reader |
|
All users in the subscription |
Reader |
|
Info on a specific user |
Reader |
|
All groups in Azure AD |
Reader |
|
All resources in the subscription |
Reader |
|
All applications in the subscription |
Reader |
|
Members of a group (group does not mean role) |
Reader |
|
Members of all groups |
Reader |
|
Members of all roles |
Reader |
|
Roles in the subscription |
Reader |
|
Members of a role |
Reader |
|
All service principals |
Reader |
|
Info on a specified service principal |
Reader |
|
Permissions of an app |
Reader |
|
Running web apps |
Reader |
|
Running web apps details |
Reader |
Secret gather.
Function |
Description |
Role |
|---|---|---|
|
List Key Vaults |
Reader |
|
Secrets from a specific Key Vault |
Contributor |
|
Secrets from all Key Vaults |
Contributor |
|
Application passwords or cert credentials |
Contributor |
|
All application secrets (if accessible) |
Contributor |
|
All secrets from Key Vaults and applications |
Contributor |
|
Credentials from any Automation Account |
Contributor |
Data exfil.
Function |
Description |
Role |
|---|---|---|
|
All storage accounts |
Reader |
|
Account keys for a storage account |
Contributor |
|
Contents of a storage container or file share |
Reader |
|
All Runbooks |
Reader |
|
Content of a specific Runbook |
Reader |
|
VM disks available |
Reader |
|
Generates a download link for a VM disk (valid for one hour) |
Contributor |
|
Available VMs |
Reader |