Building An Azure AD Pentest Lab For Red Teams
Building An Azure AD Pentest Lab For Red Teams
Building an Azure AD
Pentest lab for Red Teams
You will spin up your own Azure AD lab using automated tools to
simulate a common cloud adoption use case
We will use Azure Cloud Shell with Bash + Powershell combined with the
SEC588 Slingshot Linux VM to cover learning objectives.
IaC has many use cases for cloud deployments and DevOps. We can also use
it for security use cases as well!
% python3 azure_ad.py --upn <UPN> --count <Number Of users to create> --apps <Apps> --groups <Groups>
% python3 azure_ad.py -c 25 --upn rtcfingroup.com --apps 7 -aa -ga -pra Create a privilege
[+] Number of users desired: 25 escalation abuse
[+] upn suffix: rtcfingroup.com vulnerable scenario with
[+] Desired applications enabled: 7
Azure AD applications
[+] Creating unique user list
[+] Number of users added into list: 25 and role assignments.
[+] Number of duplicate users filtered out: 0 One randomly selected
[+] Creating output files for Azure AD Users Azure AD user is assigned
[+] Users csv file: azure_users.csv into the Application
[+] Username txt file: azure_usernames.txt Administrator role.
[+] Email addresses txt file: azure_emails.txt
[+] Terraform file: users.tf
[+] Creating terraform file: apps.tf
[+] Assigning the Privileged Role Administrator to HelpDesk_Application
[+] Assigning the Global Administrator role to ITOps_Application
%
Service Principal
Run PurpleCloud $ python3 azure_ad.py -c 25 --upn YOUR_UPN --apps 7 -aa -ga -pra
Run terraform $ terraform init; terraform plan –out run.plan; terraform apply run.plan
• Command 1: Connect-AzureAD
• Summary: Connects with an authenticated Azure AD account
to a tenant so that further Azure Active Directory cmdlets can be
used.
The Application Administrator can login with the Service Principal of a PRA
and assign their own user to a Global Administrator
• Command 1: New-AzureADApplicationPasswordCredential
• Summary: Generate a new client secret for App Registration
based on the ObjectId of it.
• Command 4: Add-AzureADDirectoryRoleMember
• Summary: Assign role of Global Administrator to the user
Pass the Object ID of the Global Admin role and the user you are assigning the role to.
It’s a good idea for security and avoiding extra charges to delete all of
these lab resources if they aren’t being used.
Delete the ”azure-cli-*” app used for Terraform in Azure portal under “Azure Active
Delete the Application Directory” à “App Registrations”
Delete Storage Account Delete the Azure Storage Account used for Cloud Shell in Azure Portal