Az - Unauthenticated Enum & Initial Entry

HackTricksのサポート

Azureテナント

テナントの列挙

テナントのドメインを知っているだけで、攻撃者はより多くの情報を収集するためにクエリできる一部の公開Azure APIがあります。 APIを直接クエリするか、PowerShellライブラリAADInternalsを使用できます:

API情報AADInternalsの機能

login.microsoftonline.com/<domain>/.well-known/openid-configuration

テナントIDを含むログイン情報

Get-AADIntTenantID -Domain <domain>

autodiscover-s.outlook.com/autodiscover/autodiscover.svc

テナントのすべてのドメイン

Get-AADIntTenantDomains -Domain <domain>

login.microsoftonline.com/GetUserRealm.srf?login=<UserName>

テナントのログイン情報、テナント名およびドメインを含む認証タイプ。 If NameSpaceTypeManagedである場合、AzureADが使用されていることを意味します。

Get-AADIntLoginInformation -UserName <UserName>

login.microsoftonline.com/common/GetCredentialType

デスクトップSSO情報を含むログイン情報

Get-AADIntLoginInformation -UserName <UserName>

AADInternalsライブラリの1つのコマンドでAzureテナントのすべての情報をクエリできます:

Invoke-AADIntReconAsOutsider -DomainName corp.onmicrosoft.com | Format-Table

Azure テナント情報の出力例:

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、および「ブランド」名の詳細を観察することが可能です。さらに、デスクトップシングルサインオン(SSO)の状態、別名Seamless SSOも表示されます。この機能が有効になっている場合、特定のユーザーが対象組織内に存在するかどうかを特定するのを容易にします。

さらに、出力には、対象テナントに関連付けられたすべての検証済みドメインの名前とそれぞれの識別タイプが表示されます。フェデレーテッドドメインの場合、使用されている識別プロバイダー(通常はADFSサーバー)の完全修飾ドメイン名(FQDN)も開示されます。"MX"列は、メールがExchange Onlineにルーティングされているかどうかを指定し、"SPF"列はExchange Onlineがメール送信者としてリストされていることを示します。現在の偵察機能は、SPFレコード内の「include」ステートメントを解析しないため、誤検出が発生する可能性があることに注意することが重要です。

ユーザー列挙

テナント内にユーザー名が存在するかどうかをチェックすることが可能です。これには、ゲストユーザーも含まれます。ゲストユーザーのユーザー名は次の形式です:

<email>#EXT#@<tenant name>.onmicrosoft.com

以下は、ユーザーのメールアドレスで、「@」がアンダースコア「_」に置き換えられています。

AADInternalsを使用して、ユーザーが存在するかどうかを簡単に確認できます。

# Check does the user exist
Invoke-AADIntUserEnumerationAsOutsider -UserName "user@company.com"

Unauthenticated Enumeration and Initial Entry

Introduction

In this section, we will cover the techniques used to perform unauthenticated enumeration and gain initial access to Azure environments. Unauthenticated enumeration involves gathering information from publicly available sources without the need for valid credentials. This information can then be used to identify potential entry points into the target Azure environment.

Tools and Techniques

1. Enumerating Azure Subdomains

One common technique is to use tools like Sublist3r or Amass to discover subdomains associated with the target Azure environment. By identifying subdomains, an attacker can potentially find services or applications that may be vulnerable to exploitation.

2. Identifying Azure Storage Accounts

Another important aspect of unauthenticated enumeration is identifying Azure storage accounts. Tools like Azure Storage Explorer or manual inspection of DNS records can help in discovering storage accounts that may contain sensitive data.

3. Exploring Azure Blob Containers

Once storage accounts are identified, attackers can explore Azure Blob containers within these accounts. This can lead to the discovery of exposed data such as configuration files, backups, or other critical information.

Conclusion

Unauthenticated enumeration is a crucial step in the reconnaissance phase of a penetration test. By leveraging publicly available information, attackers can gather valuable insights that may assist in gaining initial access to Azure environments.

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

以下は3つの異なる列挙方法から選択できます:

方法説明

通常

これは上記で言及されたGetCredentialType APIを指します。デフォルトの方法です。

ログイン

この方法はユーザーとしてログインしようとします。 注意: クエリはサインインログに記録されます。

自動ログオン

この方法は自動ログオンエンドポイントを介してユーザーとしてログインしようとします。 クエリはサインインログには記録されません!そのため、パスワードスプレーおよびブルートフォース攻撃にも適しています。

有効なユーザー名を発見した後、ユーザーに関する情報を取得できます。

Get-AADIntLoginInformation -UserName root@corp.onmicrosoft.com

スクリプトo365creeperは、メールが有効かどうかを特定することもできます。

# Put in emails.txt emails such as:
# - root@corp.onmicrosoft.com
python.exe .\o365creeper\o365creeper.py -f .\emails.txt -o validemails.txt

Microsoft Teamsを介したユーザー列挙

もう1つの情報源はMicrosoft Teamsです。

Microsoft TeamsのAPIを使用すると、ユーザーを検索できます。特に、「externalsearchv3」と「searchUsers」という「ユーザー検索」エンドポイントを使用して、Teamsに登録されたユーザーアカウントに関する一般情報をリクエストできます。

APIの応答に応じて、存在しないユーザーと有効なTeamsサブスクリプションを持つ既存のユーザーとを区別することが可能です。

スクリプトTeamsEnumを使用して、指定されたユーザー名のセットをTeams APIに対して検証することができます。

python3 TeamsEnum.py -a password -u <username> -f inputlist.txt -o teamsenum-output.json

Unauthenticated Enumeration and Initial Entry

Introduction

In this section, we will cover the techniques used to perform unauthenticated enumeration and gain initial access to Azure environments. Unauthenticated enumeration involves gathering information from publicly available sources without the need for valid credentials. This information can then be used to identify potential entry points into the target Azure environment.

Tools and Techniques

Azure Resource Manager (ARM) APIs

Azure Resource Manager (ARM) APIs can be leveraged to gather information about Azure resources without authentication. By querying these APIs, an attacker can discover valuable information such as resource types, configurations, and dependencies.

DNS Enumeration

Performing DNS enumeration can provide insights into the Azure environment's infrastructure, including subdomains, IP addresses, and services in use. This information can be crucial for identifying potential targets for further exploitation.

Web Scraping

Web scraping techniques can be used to extract information from publicly accessible Azure web portals and applications. This information may include sensitive data or configuration details that can aid in gaining unauthorized access.

Recommendations

To mitigate the risks associated with unauthenticated enumeration and initial entry, it is essential to follow these best practices:

  • Implement strong access controls and authentication mechanisms to prevent unauthorized access to Azure resources.

  • Regularly monitor and review publicly exposed information to identify and address any potential security vulnerabilities.

  • Conduct regular security assessments and penetration testing to proactively identify and address security weaknesses in Azure environments.

[-] 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)

さらに、次のような既存ユーザーの利用状況情報を列挙することが可能です:

  • 利用可能

  • 離席中

  • 邪魔しないで

  • 予定あり

  • オフライン

オフィス外メッセージが設定されている場合、TeamsEnumを使用してメッセージを取得することも可能です。出力ファイルが指定されている場合、オフィス外メッセージは自動的にJSONファイル内に保存されます。

jq . teamsenum-output.json

Unauthenticated Enumeration and Initial Entry

Introduction

In this section, we will cover the techniques used to perform unauthenticated enumeration and gain initial access to Azure environments. Unauthenticated enumeration involves gathering information from publicly available sources without the need for authentication. This information can then be used to identify potential entry points into the target Azure environment.

Tools and Techniques

1. DNS Enumeration

DNS enumeration can reveal valuable information about the target Azure environment, such as subdomains and associated IP addresses. Tools like dnsrecon and dnsenum can be used to perform DNS enumeration.

2. Subdomain Enumeration

Subdomain enumeration involves identifying subdomains associated with the target Azure environment. Tools like Sublist3r and Amass can be used to discover subdomains.

3. Cloud Storage Enumeration

Publicly accessible cloud storage buckets can sometimes reveal sensitive information. Tools like Bucket Finder and CloudEnum can be used to identify open storage buckets.

4. Service Enumeration

Identifying exposed services in the Azure environment can provide insight into potential vulnerabilities. Tools like Nmap and Masscan can be used to scan for open ports and services.

Initial Entry

Once potential entry points have been identified through unauthenticated enumeration, the next step is to attempt to gain initial access to the Azure environment. This can involve exploiting misconfigurations, weak credentials, or known vulnerabilities to establish a foothold in the target environment.

{
"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
}
]
}

Azureサービス

Azureテナントが使用しているドメインを知っているので、公開されているAzureサービスを見つけてみる時が来ました。

この目標を達成するために、MicroBustからのメソッドを使用できます。この機能は、いくつかのAzureサービスドメインでベースドメイン名(およびいくつかの順列)を検索します。

Import-Module .\MicroBurst\MicroBurst.psm1 -Verbose
Invoke-EnumerateAzureSubDomains -Base corp -Verbose

オープンストレージ

InvokeEnumerateAzureBlobs.ps1などのツールを使用してオープンストレージを発見できます。このツールは、**Microburst/Misc/permitations.txt**というファイルを使用してパーミュテーション(非常に単純なもの)を生成し、オープンストレージアカウントを見つけようとします

Import-Module .\MicroBurst\MicroBurst.psm1
Invoke-EnumerateAzureBlobs -Base corp
[...]
https://corpcommon.blob.core.windows.net/secrets?restype=container&comp=list
[...]

# Access https://corpcommon.blob.core.windows.net/secrets?restype=container&comp=list
# Check: <Name>ssh_info.json</Name>
# Access then https://corpcommon.blob.core.windows.net/secrets/ssh_info.json

SAS URLs

共有アクセス署名 (SAS) URL は、ストレージアカウントの特定の部分 (フルコンテナ、ファイルなど) に対するアクセス権を提供する URL であり、リソースに対する特定の権限 (読み取り、書き込みなど) を持っています。もし漏洩しているものを見つけた場合、機密情報にアクセスできる可能性があります。以下はその例です (これはコンテナにアクセスするためのもので、ファイルへのアクセス権を与える場合、URL のパスにもそのファイルが含まれます):

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

Storage Explorer を使用してデータにアクセスします

資格情報の侵害

フィッシング

パスワードスプレー / ブルートフォース

Az - Password Spraying

参考文献

HackTricks のサポート

Last updated