Az - Unauthenticated Enum & Initial Entry
Last updated
Last updated
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
There are some public Azure APIs that just knowing the domain of the tenant an attacker could query to gather more info about it. You can query directly the API or use the PowerShell library AADInternals:
API | Information | AADInternals function |
---|---|---|
You can query all the information of an Azure tenant with just one command of the AADInternals library:
Output Example of the Azure tenant info:
It's possible to observe details about the tenant's name, ID, and "brand" name. Additionally, the status of the Desktop Single Sign-On (SSO), also known as Seamless SSO, is displayed. When enabled, this feature facilitates the determination of the presence (enumeration) of a specific user within the target organization.
Moreover, the output presents the names of all verified domains associated with the target tenant, along with their respective identity types. In the case of federated domains, the Fully Qualified Domain Name (FQDN) of the identity provider in use, typically an ADFS server, is also disclosed. The "MX" column specifies whether emails are routed to Exchange Online, while the "SPF" column denotes the listing of Exchange Online as an email sender. It is important to note that the current reconnaissance function does not parse the "include" statements within SPF records, which may result in false negatives.
It's possible to check if a username exists inside a tenant. This includes also guest users, whose username is in the format:
The email is user’s email address where at “@” is replaced with underscore “_“.
With AADInternals, you can easily check if the user exists or not:
Output:
You can also use a text file containing one email address per row:
There are three different enumeration methods to choose from:
After discovering the valid usernames you can get info about a user with:
The script o365creeper also allows you to discover if an email is valid.
User Enumeration via Microsoft Teams
Another good source of information is Microsoft Teams.
The API of Microsoft Teams allows to search for users. In particular the "user search" endpoints externalsearchv3 and searchUsers could be used to request general information about Teams-enrolled user accounts.
Depending on the API response it is possible to distinguish between non-existing users and existing users that have a valid Teams subscription.
The script TeamsEnum could be used to validate a given set of usernames against the Teams API.
Output:
Furthermore it is possible to enumerate availability information about existing users like the following:
Available
Away
DoNotDisturb
Busy
Offline
If an out-of-office message is configured, it's also possible to retrieve the message using TeamsEnum. If an output file was specified, the out-of-office messages are automatically stored within the JSON file:
Output:
Know that we know the domains the Azure tenant is using is time to try to find Azure services exposed.
You can use a method from MicroBust for such goal. This function will search the base domain name (and a few permutations) in several azure service domains:
You could discover open storage with a tool such as InvokeEnumerateAzureBlobs.ps1 which will use the file Microburst/Misc/permitations.txt
to generate permutations (very simple) to try to find open storage accounts.
A shared access signature (SAS) URL is an URL that provides access to certain part of a Storage account (could be a full container, a file...) with some specific permissions (read, write...) over the resources. If you find one leaked you could be able to access sensitive information, they look like this (this is to access a container, if it was just granting access to a file the path of the URL will also contain that file):
https://<storage_account_name>.blob.core.windows.net/newcontainer?sp=r&st=2021-09-26T18:15:21Z&se=2021-10-27T02:14:21Z&spr=https&sv=2021-07-08&sr=c&sig=7S%2BZySOgy4aA3Dk0V1cJyTSIf1cW%2Fu3WFkhHV32%2B4PE%3D
Use Storage Explorer to access the data
Common Phishing (credentials or OAuth App -Illicit Consent Grant Attack-)
Method | Description |
---|---|
Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE) Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Normal
This refers to the GetCredentialType API mentioned above. The default method.
Login
This method tries to log in as the user. Note: queries will be logged to sign-ins log.
Autologon
This method tries to log in as the user via autologon endpoint. Queries are not logged to sign-ins log! As such, works well also for password spray and brute-force attacks.
login.microsoftonline.com/<domain>/.well-known/openid-configuration
Login information, including tenant ID
Get-AADIntTenantID -Domain <domain>
autodiscover-s.outlook.com/autodiscover/autodiscover.svc
All domains of the tenant
Get-AADIntTenantDomains -Domain <domain>
login.microsoftonline.com/GetUserRealm.srf?login=<UserName>
Login information of the tenant, including tenant Name and domain authentication type.
If NameSpaceType
is Managed
, it means AzureAD is used.
Get-AADIntLoginInformation -UserName <UserName>
login.microsoftonline.com/common/GetCredentialType
Login information, including Desktop SSO information
Get-AADIntLoginInformation -UserName <UserName>