Az - Entra ID セクションで az cli、AzureAD、および Az PowerShell の インストール方法を学んでください。
最初に知っておくべきことは 自分が誰であるか(どの環境にいるか)です:
azaccountlistazaccounttenantlist# Current tenant infoazaccountsubscriptionlist# Current subscription infoazadsigned-in-usershow# Current signed-in userazadsigned-in-userlist-owned-objects# Get owned objects by current userazaccountmanagement-grouplist#Not allowed by default
#Get the current session stateGet-AzureADCurrentSessionInfo#Get details of the current tenantGet-AzureADTenantDetail
# Get the information about the current context (Account, Tenant, Subscription etc.)Get-AzContext# List all available contextsGet-AzContext-ListAvailable# Enumerate subscriptions accessible by the current userGet-AzSubscription#Get Resource groupGet-AzResourceGroup# Enumerate all resources visible to the current userGet-AzResource# Enumerate all Azure RBAC role assignmentsGet-AzRoleAssignment# For all usersGet-AzRoleAssignment-SignInName test@corp.onmicrosoft.com # For current user
export ADAL_PYTHON_SSL_NO_VERIFY=1export AZURE_CLI_DISABLE_CONNECTION_VERIFICATION=1export 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 variableopensslx509-in~/Downloads/cacert.der-informDER-out~/Downloads/cacert.pem-outformPEMexport REQUESTS_CA_BUNDLE=/Users/user/Downloads/cacert.pem
Import-Module monkey365Get-HelpInvoke-Monkey365Get-HelpInvoke-Monkey365-DetailedInvoke-Monkey365-IncludeAzureActiveDirectory -ExportTo HTML -Verbose -Debug -InformationAction ContinueInvoke-Monkey365- Instance Azure -Analysis All -ExportTo HTML
# Start Backendcd stormspotter\backend\pipenv shellpython ssbackend.pyz# Start Front-endcd stormspotter\frontend\dist\spa\quasar.cmd serve -p 9091--history# Run Stormcollectorcd stormspotter\stormcollector\pipenv shellaz 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)
# You need to use the Az PowerShell and Azure AD modules:$passwd =ConvertTo-SecureString"Welcome2022!"-AsPlainText -Force$creds =New-Object System.Management.Automation.PSCredential ("test@corp.onmicrosoft.com", $passwd)Connect-AzAccount-Credential $credsImport-Module AzureAD\AzureAD.psd1Connect-AzureAD-Credential $creds# Launch AzureHound. AzureHound\AzureHound.ps1Invoke-AzureHound-Verbose# Simple queries## All Azure UsersMATCH (n:AZUser) return n.name## All Azure ApplicationsMATCH (n:AZApp) return n.objectid## All Azure DevicesMATCH (n:AZDevice) return n.name## All Azure GroupsMATCH (n:AZGroup) return n.name## All Azure Key VaultsMATCH (n:AZKeyVault) return n.name## All Azure Resource GroupsMATCH (n:AZResourceGroup) return n.name## All Azure Service PrincipalsMATCH (n:AZServicePrincipal) return n.objectid## All Azure Virtual MachinesMATCH (n:AZVM) return n.name## All Principals with the ‘Contributor’ roleMATCH p = (n)-[r:AZContributor]->(g) RETURN p# Advanced queries## Get Global AdminsMATCH p =(n)-[r:AZGlobalAdmin*1..]->(m) RETURN p## Owners of Azure GroupsMATCH p = (n)-[r:AZOwns]->(g:AZGroup) RETURN p## All Azure Users and their GroupsMATCH p=(m:AZUser)-[r:MemberOf]->(n) WHERE NOT m.objectid CONTAINS 'S-1-5'RETURN p## Privileged Service PrincipalsMATCH p = (g:AZServicePrincipal)-[r]->(n) RETURN p## Owners of Azure ApplicationsMATCH p = (n)-[r:AZOwns]->(g:AZApp) RETURN p## Paths to VMsMATCH p = (n)-[r]->(g: AZVM) RETURN p## Paths to KeyVaultMATCH p = (n)-[r]->(g:AZKeyVault) RETURN p## Paths to Azure Resource GroupMATCH p = (n)-[r]->(g:AZResourceGroup) RETURN p## On-Prem users with edges to AzureMATCH p=(m:User)-[r:AZResetPassword|AZOwns|AZUserAccessAdministrator|AZContributor|AZAddMembers|AZGlobalAdmin|AZVMContributor|AZOwnsAZAvereContributor]->(n) WHERE m.objectid CONTAINS 'S-1-5-21' RETURN p
## All Azure AD Groups that are synchronized with On-Premise ADMATCH (n:Group) WHERE n.objectid CONTAINS 'S-1-5' AND n.azsyncid IS NOT NULL RETURN n
# You should use an account with at least read-permission on the assets you want to accessgitclonehttps://github.com/nccgroup/azucar.gitPS> Get-ChildItem-Recursec:\Azucar_V10|Unblock-FilePS> .\Azucar.ps1-AuthModeUseCachedCredentials-Verbose-WriteLog-Debug-ExportToPRINTPS> .\Azucar.ps1 -ExportTo CSV,JSON,XML,EXCEL -AuthMode Certificate_Credentials -Certificate C:\AzucarTest\server.pfx -ApplicationId 00000000-0000-0000-0000-000000000000 -TenantID 00000000-0000-0000-0000-000000000000
PS> .\Azucar.ps1 -ExportTo CSV,JSON,XML,EXCEL -AuthMode Certificate_Credentials -Certificate C:\AzucarTest\server.pfx -CertFilePassword MySuperP@ssw0rd! -ApplicationId 00000000-0000-0000-0000-000000000000 -TenantID 00000000-0000-0000-0000-000000000000
# resolve the TenantID for an specific usernamePS> .\Azucar.ps1-ResolveTenantUserNameuser@company.com
#Get-GraphTokens#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.ps1Get-GraphTokens#Invoke-GraphRecon#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#Invoke-DumpCAPS#A module to dump conditional access policies from a tenant.Invoke-GraphRecon-Tokens $tokens -PermissionEnum#Invoke-DumpCAPS#A module to dump conditional access policies from a tenant.Invoke-DumpCAPS-Tokens $tokens -ResolveGuids#Invoke-DumpApps#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#Get-AzureADUsers#Gather the full list of users from the directory.Get-AzureADUsers-Tokens $tokens -OutFile users.txt#Get-SecurityGroups#Create a list of security groups along with their members.Get-SecurityGroups-AccessToken $tokens.access_tokenG#et-UpdatableGroups#Gets groups that may be able to be modified by the current userGet-UpdatableGroups-Tokens $tokens#Get-DynamicGroups#Finds dynamic groups and displays membership rulesGet-DynamicGroups-Tokens $tokens#Get-SharePointSiteURLs#Gets a list of SharePoint site URLs visible to the current userGet-SharePointSiteURLs-Tokens $tokens#Invoke-GraphOpenInboxFinder#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#Get-TenantID#This module attempts to gather a tenant ID associated with a domain.Get-TenantID-Domain#Invoke-GraphRunner#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