Az - Unauthenticated Enum & Initial Entry
Tip
Вивчайте та практикуйте AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Вивчайте та практикуйте GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Вивчайте та практикуйте Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Підтримайте HackTricks
- Перегляньте the subscription plans!
- Приєднуйтесь до 💬 Discord group або до telegram group або стежте за нами в Twitter 🐦 @hacktricks_live.
- Діліться hacking tricks, надсилаючи PRs до HackTricks та HackTricks Cloud github repos.
Azure Tenant
Tenant Enumeration
Є деякі public Azure APIs, знаючи лише домен тенанта, нападник може виконувати запити, щоб зібрати більше інформації про нього.
Ви можете звертатися безпосередньо до API або використовувати бібліотеку PowerShell AADInternals (Install-Module AADInternals):
- Інформація для входу, включно з tenant ID
Get-AADIntTenantID -Domain <domain>(main APIlogin.microsoftonline.com/<domain>/.well-known/openid-configuration)- Усі дійсні домени в тенанті
Get-AADIntTenantDomains -Domain <domain>(main APIautodiscover-s.outlook.com/autodiscover/autodiscover.svc)- Інформація для входу користувача. Якщо
NameSpaceTypeisManaged, це означає, що використовується EntraID Get-AADIntLoginInformation -UserName <UserName>(main APIlogin.microsoftonline.com/GetUserRealm.srf?login=<UserName>)
Ви можете отримати всю інформацію про Azure tenant лише за одну команду з AADInternals:
# Doesn't work in macos because 'Resolve-DnsName' doesn't exist
Invoke-AADIntReconAsOutsider -DomainName corp.onmicrosoft.com | Format-Table
## Output Example of the Azure tenant info:
Tenant brand: Company Ltd
Tenant name: company
Tenant id: 1937e3ab-38de-a735-a830-3075ea7e5b39
DesktopSSO enabled: True
Name DNS MX SPF Type STS
---- --- -- --- ---- ---
company.com True True True Federated sts.company.com
company.mail.onmicrosoft.com True True True Managed
company.onmicrosoft.com True True True Managed
int.company.com False False False Managed
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.
User Enumeration
Tip
Note that even if a tenant is using several emails for the same user, the username is unique. This means that it’ll noly work with the domain the user has associated and not with the other domains.
It’s possible to check if a username exists inside a tenant. This includes also guest users, whose username is in the format:
<email>#EXT#@<tenant name>.onmicrosoft.com
Email — це адреса користувача, в якій символ “@” замінено на підкреслення “_”.
За допомогою AADInternals, ви можете легко перевірити, чи існує користувач чи ні:
# Check does the user exist
Invoke-AADIntUserEnumerationAsOutsider -UserName "user@company.com"
Будь ласка, вставте вміст файлу src/pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/README.md, який ви хочете перекласти на українську.
UserName Exists
-------- ------
user@company.com True
Ви також можете використати текстовий файл, що містить по одній електронній адресі в кожному рядку:
user@company.com
user2@company.com
admin@company.com
admin2@company.com
external.user_gmail.com#EXT#@company.onmicrosoft.com
external.user_outlook.com#EXT#@company.onmicrosoft.com
# Invoke user enumeration
Get-Content .\users.txt | Invoke-AADIntUserEnumerationAsOutsider -Method Normal
Наразі є 4 different enumeration methods на вибір. Інформацію можна знайти в Get-Help Invoke-AADIntUserEnumerationAsOutsider:
It supports following enumeration methods: Normal, Login, Autologon, and RST2.
-
Метод Normal, здається, наразі працює з усіма tenants. Раніше для нього потрібно було, щоб Desktop SSO (aka Seamless SSO) був увімкнений принаймні для одного домену.
-
Метод Login працює з будь-яким tenant, але запити enumeration будуть записані в Azure AD sign-in log як події невдалих входів!
-
Метод Autologon здається більше не працює з усіма tenants. Ймовірно вимагає, щоб DesktopSSO або directory sync були увімкнені.
Після виявлення дійсних імен користувачів ви можете отримати інформацію про користувача за допомогою:
Get-AADIntLoginInformation -UserName root@corp.onmicrosoft.com
Скрипт o365spray також дозволяє виявити чи електронна адреса дійсна.
git clone https://github.com/0xZDH/o365spray
cd o365spray
python3 -m pip install -r requirements.txt
# Check 1 email
python3 ./o365spray.py --enum -d carloshacktricks.onmicrosoft.com -u carlos
# Check a list of emails
python3 ./o365spray.py --enum -d carloshacktricks.onmicrosoft.com -U /tmp/users.txt
User Enumeration via Microsoft Teams
Ще одним хорошим джерелом інформації є Microsoft Teams.
API Microsoft Teams дозволяє шукати користувачів. Зокрема, “user search” endpoints externalsearchv3 та searchUsers можна використовувати для запиту загальної інформації про облікові записи користувачів, зареєстровані в Teams.
Залежно від відповіді API можна відрізнити неіснуючих користувачів від існуючих, які мають дійсну підписку Teams.
Скрипт TeamsEnum можна використовувати для перевірки заданого набору імен користувачів через Teams API, але для його використання потрібен обліковий запис із доступом до Teams.
# Install
git clone https://github.com/lucidra-security/TeamsEnum
cd TeamsEnum
python3 -m pip install -r requirements.txt
# Login and ask for password
python3 ./TeamsEnum.py -a password -u <username> -f inputlist.txt -o teamsenum-output.json
Я не отримав вміст файлу. Будь ласка, вставте вміст README.md (або конкретний текст), який потрібно перекласти. Я перекладу лише англійський текст у відповідні українські рядки, зберігаючи незмінними код, теги, шляхи та посилання.
[-] user1@domain - Target user not found. Either the user does not exist, is not Teams-enrolled or is configured to not appear in search results (personal accounts only)
[+] user2@domain - User2 | Company (Away, Mobile)
[+] user3@domain - User3 | Company (Available, Desktop)
Крім того, можна перерахувати інформацію про доступність існуючих користувачів, наприклад:
- Available
- Away
- DoNotDisturb
- Busy
- Offline
Якщо налаштовано повідомлення про відсутність, також можна отримати це повідомлення за допомогою TeamsEnum. Якщо вказано файл виводу, повідомлення про відсутність автоматично зберігаються у JSON-файлі:
jq . teamsenum-output.json
Я не отримав вміст файлу src/pentesting-cloud/azure-security/az-unauthenticated-enum-and-initial-entry/README.md. Будь ласка, вставте його сюди, і я перекладу згідно з інструкціями.
{
"email": "user2@domain",
"exists": true,
"info": [
{
"tenantId": "[REDACTED]",
"isShortProfile": false,
"accountEnabled": true,
"featureSettings": {
"coExistenceMode": "TeamsOnly"
},
"userPrincipalName": "user2@domain",
"givenName": "user2@domain",
"surname": "",
"email": "user2@domain",
"tenantName": "Company",
"displayName": "User2",
"type": "Federated",
"mri": "8:orgid:[REDACTED]",
"objectId": "[REDACTED]"
}
],
"presence": [
{
"mri": "8:orgid:[REDACTED]",
"presence": {
"sourceNetwork": "Federated",
"calendarData": {
"outOfOfficeNote": {
"message": "Dear sender. I am out of the office until March 23rd with limited access to my email. I will respond after my return.Kind regards, User2",
"publishTime": "2023-03-15T21:44:42.0649385Z",
"expiry": "2023-04-05T14:00:00Z"
},
"isOutOfOffice": true
},
"capabilities": ["Audio", "Video"],
"availability": "Away",
"activity": "Away",
"deviceType": "Mobile"
},
"etagMatch": false,
"etag": "[REDACTED]",
"status": 20000
}
]
}
Password Spraying / Brute-Force
Azure Services, які використовують домени
Також можна спробувати знайти Azure services exposed у поширених azure субдоменах, як-от перелічені в цій post:
- App Services:
azurewebsites.net - App Services – Management:
scm.azurewebsites.net - App Services:
p.azurewebsites.net - App Services:
cloudapp.net - Storage Accounts-Files:
file.core.windows.net - Storage Accounts-Blobs:
blob.core.windows.net - Storage Accounts-Queues:
queue.core.windows.net - Storage Accounts-Tables:
table.core.windows.net - Databases-Redis:
redis.cache.windows.net - Databases-Cosmos DB:
documents.azure.com - Databases-MSSQL:
database.windows.net - Key Vaults:
vault.azure.net - Microsoft Hosted Domain:
onmicrosoft.com - Email:
mail.protection.outlook.com - SharePoint:
sharepoint.com - CDN:
azureedge.net - Search Appliance:
search.windows.net - API Services:
azure-api.net
Для цього можна використати метод з MicroBust. Ця функція шукатиме базове доменне ім’я (та кілька його перестановок) у кількох azure domains:
Import-Module .\MicroBurst\MicroBurst.psm1 -Verbose
Invoke-EnumerateAzureSubDomains -Base corp -Verbose
Phishing
- Common Phishing for credentials or via OAuth Apps
- Device Code Authentication Phishing
Облікові дані файлової системи
Клієнт az cli зберігає багато цікавої інформації в <HOME>/.Azure:
azureProfile.jsonмістить інформацію про попередньо залогінених користувачівclouds.configмістить інформацію про підпискиservice_principal_entries.jsonмістить додатків credentials (tenant id, clients and secret)msal_token_cache.jsonмістить access tokens and refresh tokens
Зауважте, що на macOS і linux ці файли незахищені і зберігаються у відкритому тексті.
Посилання
- https://aadinternals.com/post/just-looking/
- https://www.securesystems.de/blog/a-fresh-look-at-user-enumeration-in-microsoft-teams/
- https://www.netspi.com/blog/technical-blog/cloud-penetration-testing/enumerating-azure-services/
Tip
Вивчайте та практикуйте AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Вивчайте та практикуйте GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Вивчайте та практикуйте Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Підтримайте HackTricks
- Перегляньте the subscription plans!
- Приєднуйтесь до 💬 Discord group або до telegram group або стежте за нами в Twitter 🐦 @hacktricks_live.
- Діліться hacking tricks, надсилаючи PRs до HackTricks та HackTricks Cloud github repos.
HackTricks Cloud

