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 をサポートする
- subscription plans を確認してください!
- 参加する 💬 Discord group または telegram group に参加するか、Twitter 🐦 @hacktricks_live をフォローしてください。
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
Azure テナント
テナント列挙
いくつかのpublic Azure APIsがあり、テナントのドメインを知っているだけで攻撃者はそれらにクエリを投げて追加情報を収集できます。
APIを直接クエリすることも、PowerShellライブラリAADInternals(Install-Module AADInternals)を使うこともできます:
- テナント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)- ユーザーのログイン情報。
NameSpaceTypeがManagedであれば、EntraIDが使用されていることを意味します Get-AADIntLoginInformation -UserName <UserName>(main APIlogin.microsoftonline.com/GetUserRealm.srf?login=<UserName>)
Azure テナントのすべての情報はAADInternalsのたった1つのコマンドで取得できます:
# 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
テナントの名前、ID、および「ブランド」名の詳細を確認できます。さらに、Desktop Single Sign-On (SSO)、別名 Seamless SSO のステータスも表示されます。有効になっている場合、この機能はターゲット組織内に特定のユーザーが存在するかどうか(列挙)を判定するのに役立ちます。
さらに、出力にはターゲットテナントに関連付けられたすべての検証済みドメイン名とそれぞれの identity type が表示されます。federated domains の場合、通常は ADFS サーバーである利用中の identity provider の FQDN も開示されます。“MX” 列はメールが Exchange Online にルーティングされているかを示し、“SPF” 列は Exchange Online がメール送信者としてリストされているかを示します。現在の reconnaissance 機能は SPF レコード内の “include” ステートメントを解析しないため、偽陰性が発生する可能性がある点に注意してください。
ユーザー列挙
Tip
テナントが同じユーザーに複数のメールアドレスを使用している場合でも、ユーザー名は一意であることに注意してください。これは、そのユーザーに関連付けられたドメインでのみ動作し、他のドメインでは動作しないことを意味します。
テナント内にユーザー名が存在するかどうかを確認することが可能です。これはゲストユーザーも含み、ゲストのユーザー名は次の形式です:
<email>#EXT#@<tenant name>.onmicrosoft.com
この email は、“@” がアンダースコア “_” に置き換えられたユーザーのメールアドレスです。
AADInternals を使うと、ユーザーが存在するかどうかを簡単に確認できます:
# Check does the user exist
Invoke-AADIntUserEnumerationAsOutsider -UserName "user@company.com"
ソースの README.md の内容がここに提供されていません。翻訳するテキスト(ファイル全体または該当部分)を貼り付けてください。長文の場合は対象のセクションを指定してください。
UserName Exists
-------- ------
user@company.com True
1行に1つのメールアドレスを含むテキストファイルを使うこともできます:
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つの異なる列挙方法があります。詳細は Get-Help Invoke-AADIntUserEnumerationAsOutsider を参照してください:
It supports following enumeration methods: Normal, Login, Autologon, and RST2.
-
The Normal method seems currently work with all tenants. Previously it required Desktop SSO (aka Seamless SSO) to be enabled for at least one domain.
-
The Login method works with any tenant, but enumeration queries will be logged to Azure AD sign-in log as failed login events!
-
The Autologon method doesn’t seem to work with all tenants anymore. Probably requires that DesktopSSO or directory sync is enabled.
有効なユーザー名を特定した後、ユーザーの情報を取得できます:
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 です。
Microsoft Teams の API はユーザーの検索を可能にします。特に “user search” エンドポイント 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 が使用するドメイン
It’s also possible to try to find Azure services exposed in common azure subdomains like the ones documented in this 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
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 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
Filesystem Credentials
The 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 を含みます
Note that in macOS and linux these files are unprotected stored in clear text.
References
- 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 をサポートする
- subscription plans を確認してください!
- 参加する 💬 Discord group または telegram group に参加するか、Twitter 🐦 @hacktricks_live をフォローしてください。
- Share hacking tricks by submitting PRs to the HackTricks and HackTricks Cloud github repos.
HackTricks Cloud

