Azure Pentesting
Azure ペンテスト
基本情報
pageAz - Basic InformationAzure ペンテスター/Red Team メソドロジー
AZURE 環境を監査するためには、使用されているサービス、公開されているもの、誰が何にアクセス権を持っているか、および内部 Azure サービスと外部サービスがどのように接続されているかを知ることが非常に重要です。
Red Team の観点から、Azure 環境を侵害する最初のステップは、Azure AD の一部の資格情報を取得することです。以下は、それを行うためのいくつかのアイデアです:
github(または類似の)での情報漏洩 - OSINT
ソーシャルエンジニアリング
パスワード再利用(パスワード漏洩)
Azure ホストされたアプリケーションの脆弱性
サーバーサイドリクエストフォージェリ メタデータエンドポイントへのアクセス
ローカルファイル読み取り
/home/USERNAME/.azure
C:\Users\USERNAME\.azure
2022年1月までの
az cli
の**accessTokens.json
ファイル - 明文テキストでアクセストークンを保存**azureProfile.json
ファイルには、ログインユーザーに関する情報が含まれています。az logout
はトークンを削除します。古いバージョンの**
Az PowerShell
はTokenCache.dat
にアクセストークンを平文で保存していました。また、AzureRmContext.json
にServicePrincipalSecretを平文で保存しています。Save-AzContext
コマンドレットを使用してトークン**を保存できます。Disconnect-AzAccount
を使用して削除します。3者が侵害
内部従業員
一般的なフィッシング(資格情報またはOauthアプリ)
Azure テナント内のユーザーを侵害していなくても、いくつかの情報を収集できます:
pageAz - Unauthenticated Enum & Initial Entry資格情報を取得した後は、それらの資格情報が誰に属しているか、および何にアクセス権を持っているかを知る必要があるため、基本的な列挙を実行する必要があります:
基本列挙
列挙の最も騒々しい部分はログインであり、列挙そのものではありません。
SSRF
Azure内のマシンでSSRFを見つけた場合は、トリックのためにこのページをチェックしてください:
ログイン条件のバイパス
有効な資格情報があるにもかかわらずログインできない場合、以下は一般的な保護措置です:
IPホワイトリスト -- 有効なIPを侵害する必要があります
地理的制限 -- ユーザーの住所や会社のオフィスがどこにあるかを見つけ、同じ都市(または少なくとも同じ国)のIPを取得します
ブラウザ -- おそらく特定のOS(Windows、Linux、Mac、Android、iOS)からのみブラウザが許可されています。被害者/会社が使用しているOSを特定してください。
通常は制限が少なく、そのログインが少なく見直されるため、Service Principal 資格情報を侵害することもできます
これをバイパスした後、元のセットアップに戻り、引き続きアクセスできるかもしれません。
サブドメインの乗っ取り
Whoami
Az - AzureAD セクションで az cli、AzureAD、Az PowerShell のインストール方法を学んでください。
最初に知る必要があることの1つは、自分が誰であるか(どの環境にいるか)です:
AzureAD
AzureAD is a cloud-based identity and access management service provided by Microsoft. It allows organizations to manage user identities and create access policies to secure their resources.
Security Best Practices
Enable Multi-Factor Authentication (MFA) for all users to add an extra layer of security.
Regularly review and audit user permissions to ensure least privilege access.
Implement Conditional Access policies to control access based on specific conditions.
Monitor sign-in logs and set up alerts for any suspicious activities.
Enable password protection and smart lockout to prevent password attacks.
Tools for Testing
Azure AD Identity Protection: Helps in detecting potential vulnerabilities and risky accounts.
Azure AD Privileged Identity Management (PIM): Manages, controls, and monitors access within Azure AD.
Azure AD Connect Health: Monitors and provides insights into the health of on-premises identity infrastructure.
Additional Resources
Az PowerShell
Azure PowerShell is a set of cmdlets for managing Azure resources directly from the PowerShell command line. It provides a powerful and flexible command-line interface for interacting with Azure. You can use Azure PowerShell to automate common tasks, create and manage resources, and perform various administrative functions within your Azure environment.
Installation
To use Azure PowerShell, you need to install the Azure PowerShell module on your local machine. You can install it using the PowerShell Gallery by running the following command:
Connecting to Azure
Once you have installed the Azure PowerShell module, you can connect to your Azure account using the Connect-AzAccount
cmdlet. This will prompt you to log in with your Azure credentials and establish a connection to your Azure subscription.
Managing Azure Resources
With Azure PowerShell, you can manage various Azure resources such as virtual machines, storage accounts, databases, and more. You can create, update, delete, start, stop, and perform other operations on these resources using the cmdlets provided by Azure PowerShell.
Scripting and Automation
Azure PowerShell is commonly used for scripting and automation tasks in Azure environments. You can write PowerShell scripts to automate repetitive tasks, configure resources, deploy applications, and more. Azure PowerShell provides a rich set of cmdlets and functionalities to help you streamline your workflows and improve efficiency.
Summary
Azure PowerShell is a powerful tool for managing Azure resources through the command line. By installing the Azure PowerShell module, connecting to your Azure account, and leveraging the cmdlets provided, you can automate tasks, manage resources, and perform administrative functions efficiently within your Azure environment.
Azureを列挙するための最も重要なコマンドの1つは、Az PowerShellの**Get-AzResource
**であり、現在のユーザーが表示できるリソースを把握できます。
同じ情報をWebコンソールで取得することもできます。https://portal.azure.com/#view/HubsExtension/BrowseAllにアクセスするか、「All resources」を検索します。
AzureAD列挙
デフォルトでは、ユーザーはユーザー、グループ、ロール、サービス プリンシパルなどを列挙する十分な権限を持つはずです(デフォルトのAzureAD権限を確認してください)。 ここにガイドがあります:
pageAz - AzureAD (AAD)今、資格情報に関する情報を持っている(そしてあなたがレッドチームである場合、検出されていないことを願います)。環境で使用されているサービスを特定する時が来ました。 次のセクションでは、一般的なサービスを列挙するいくつかの方法を確認できます。
サービス プリンシパルとアクセス ポリシー
Azureサービスには、システム ID(サービス自体)を持つことも、ユーザー割り当てのマネージド IDを使用することもできます。この ID には、たとえば KeyVault からシークレットを読み取るためのアクセス ポリシーが付与されることがあります。これらのアクセス ポリシーは制限されるべきです(最小特権原則)、しかし必要以上の権限を持っている可能性があります。通常、App Service は KeyVault を使用してシークレットや証明書を取得します。
そのため、これらの ID を調査することが役立ちます。
App Service SCM
App Service 'container' にログインするための Kudu コンソール。
Webshell
portal.azure.com を使用してシェルを選択するか、shell.azure.com を使用して、bash または powershell を使用します。このシェルの 'disk' は、ストレージ アカウント内のイメージ ファイルとして保存されます。
Azure DevOps
Azure DevOps は Azure とは別です。リポジトリ、パイプライン(yaml またはリリース)、ボード、ウィキなどがあります。Variable Groups は変数値とシークレットを格納するために使用されます。
Automated Recon Tools
AzureHoundは、Azure AD環境内の権限エスカレーション経路を特定するためのツールです。BloodHoundの機能をAzure ADに拡張し、クラウド環境における攻撃経路を可視化します。
Azucarは、Azure環境におけるセキュリティの自動化された評価を目的としたツールです。
最終更新