[Azure] What To Do If?

"What To Do If" is a blog that will be updated continuously to contain valuable information about Azure Cloud resources exploit.

Last update: June, 29 2025

Hi there! In this blog, from its title, we will answer the question "What to do if you found resource XYZ in Azure?" It's very simple and will be updated continuously to contain the latest updates, commands, tools, and more. I used this guide to pass CARTP (Certified Azure Red Team Professional) certificate from Altered Security, so thanks to them especially Nikhil for the great content.

For example, If you have an assessment in an Azure environment and you gained access to a specific account or application-managed identity, what's the first step you will take? what are you gonna do if you find yourself having a specific role assignment to a virtual machine or key vault? Exactly that's what we gonna discuss here, so let's get started...

All the following steps we will follow are circular, not sequential, which means if you logged in and followed the 2 steps then you found leaked credentials and logged in again with the new user, you may need to follow the same steps from the beginning again depends on the resources you have.


Content

  1. Used Tools

  2. Azure AD user account & Managed Identity.

  3. Virtual Machine & Extensions

  4. KeyVaults

  5. Storage Blob & Storage Accounts

  6. Automation Account

  7. SQL Server


Used Tools

The most used tool we will depend on is Az Powershell, but we will use different tools for specific tasks, and we will add them here to collect them in one section

Az Powershell

Az CLi

Download and install it from here


Azure AD user account & Managed Identity

This is your first step in any assessment to have an account or managed identity with specific roles because Azure pentest is unlike any normal website pentest, it seems like configuration review more than doing red team on on-prem environments. So, once you get an account, please do the following steps to know your roles and the resources you have access to.

  1. Login using Az Powershell $passwd = ConvertTo-SecureString "pass@1234" -AsPlainText -Force;$creds = New-Object System.Management.Automation.PSCredential ("test@aykalam.onmicrosoft.com", $passwd);Connect-AzAccount -Credential $creds

  2. Or you can use Az CLI to login via the browser az login

First Checks

Here we're doing quick checks to know the resources, role assignment, owned objects and more.

  1. Check the Get-AzResource` to know the resources you have access to.

  2. Check the Get-AzRoleAssignment to know the roles you have in a specific resource

  3. Check the owned objects by the user using the Az Module az ad signed-in-user list-owned-objects

  4. Check if we have Storage accounts / Blob using MicroBrust Scripts

  5. Try to login to the Azure portal and check the Deployment history

  6. Try to login to the Azure portal and if you have a Dynamic Group try to invite other users.

  7. If you aren't able to login to the Azure portal due to access policy, check the following solutions:

    + Try to login using the Az CLI, Az PowerShell, or AzureAD tools.

    + Try to change the user-agent in the browser to any other device "Maybe allowed access only for specific devices".


Virtual Machine & Extensions

Check the VM network profile and IP

  1. Run Get-AzResource

  2. Run Get-AzRoleAssignment because you have to gain read access at least for the VM and the network profile

  3. Check the roles you have in this VM from the above API call to get the permissions

  4. Get the network profile name Get-AzVM -Name VMName -ResourceGroupName RGName | select -ExpandProperty NetworkProfile

  5. Get the interface name Get-AzNetworkInterface -Name InterfaceName

  6. Get the public IP Get-AzPublicIpAddress -Name IPAddressName

If you have a Command Executer role.

Run directly ready scripts to add a user

Connect using the created account

Extract credentials from console history (after gaining a shell)

Check if there's any User Data stored in the machine (after gaining a shell)

Try the PowerShell transcripts (after gaining a shell)

Dealing with Extensions if you have read or write permission

If you found yourself in the AzureAD Connect machine with On-Prem, try to reset the Sync_ account


KeyVault

At first, we will check if we have access to key vaults or not, and if we have, then we will try to get its secret and read it as plain text. It's very simple.


Storage Blob / Accounts

Enumerate the storage blob using MicroBrust

If you found a container, try to access it using the <Name> </Name> tag parameter after the URL endpoint.

Check Containers

If you find your user has access to the storage account. Check if there is a container that the user has access to

If you found SAS URL or Account creds have access to Storage Blob, Open the Storage Explorer application and authenticate using the SAS URL or the Account

Check the Storage Accounts using AZ CLI


Automation Account

Check your permissions over the automation account

Check if the hybrid worker is in use in the automation account

Gain reverse shell access

Import PowerShell runbook file to download a reverse shell from your host machine and run it on the hybrid worker.


SQL Server


To be continued...

Thanks for reading <3 Stay in touch

LinkedIn | GitHub

Last updated