diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 478e28676..c53000a33 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -292,7 +292,7 @@ - [AWS - KMS Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-kms-privesc.md) - [AWS - Lambda Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-lambda-privesc.md) - [AWS - Lightsail Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-lightsail-privesc.md) - - [AWS - Macie Enum](pentesting-cloud/aws-security/aws-privilege-escalation/aws-macie-privesc.md) + - [AWS - Macie Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-macie-privesc.md) - [AWS - Mediapackage Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-mediapackage-privesc.md) - [AWS - MQ Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-mq-privesc.md) - [AWS - MSK Privesc](pentesting-cloud/aws-security/aws-privilege-escalation/aws-msk-privesc.md) @@ -415,7 +415,7 @@ - [Az - Azure App Services](pentesting-cloud/azure-security/az-services/az-app-services.md) - [Az - Cloud Shell](pentesting-cloud/azure-security/az-services/az-cloud-shell.md) - [Az - Container Registry](pentesting-cloud/azure-security/az-services/az-container-registry.md) - - [Az - Container Instances](pentesting-cloud/azure-security/az-services/az-container-instances.md) + - [Az - Container Instances, Apps & Jobs](pentesting-cloud/azure-security/az-services/az-container-instances-apps-jobs.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) @@ -470,7 +470,7 @@ - [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 - Container Registry Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-container-registry-privesc.md) - - [Az - Container Instances Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-privesc.md) + - [Az - Container Instances, Apps & Jobs Privesc](pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-apps-jobs-privesc.md) - [Az - CosmosDB Privesc](pentesting-cloud/azure-security/az-privilege-escalation/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) diff --git a/src/pentesting-cloud/aws-security/aws-services/aws-organizations-enum.md b/src/pentesting-cloud/aws-security/aws-services/aws-organizations-enum.md index c60d69340..158c5ce4d 100644 --- a/src/pentesting-cloud/aws-security/aws-services/aws-organizations-enum.md +++ b/src/pentesting-cloud/aws-security/aws-services/aws-organizations-enum.md @@ -4,7 +4,7 @@ ## 基本信息 -AWS Organizations 使得创建新的 AWS 账户变得更加简单,而无需承担额外费用。资源可以轻松分配,账户可以高效分组,并且可以对单个账户或组应用治理政策,从而增强组织内的管理和控制。 +AWS Organizations 使得创建新的 AWS 账户变得更加简单,无需额外费用。资源可以轻松分配,账户可以高效分组,并且可以对单个账户或组应用治理政策,从而增强组织内的管理和控制。 要点: @@ -40,6 +40,6 @@ aws iam get-account-summary ``` ## 参考 -- https://aws.amazon.com/organizations/ +- [https://aws.amazon.com/organizations/](https://aws.amazon.com/organizations/) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/aws-security/aws-services/aws-sqs-and-sns-enum.md b/src/pentesting-cloud/aws-security/aws-services/aws-sqs-and-sns-enum.md index 7280fb939..05db2a397 100644 --- a/src/pentesting-cloud/aws-security/aws-services/aws-sqs-and-sns-enum.md +++ b/src/pentesting-cloud/aws-security/aws-services/aws-sqs-and-sns-enum.md @@ -4,7 +4,7 @@ ## SQS -亚马逊简单队列服务(SQS)被呈现为一个**完全托管的消息队列服务**。其主要功能是帮助扩展和解耦微服务、分布式系统和无服务器应用程序。该服务旨在消除管理和操作面向消息的中间件的需求,这通常可能是复杂且资源密集的。这种复杂性的消除使开发人员能够将精力集中在他们工作中更具创新性和差异化的方面。 +Amazon Simple Queue Service (SQS) 被呈现为一个 **完全托管的消息队列服务**。它的主要功能是帮助扩展和解耦微服务、分布式系统和无服务器应用程序。该服务旨在消除管理和操作面向消息的中间件的需求,这通常可能是复杂且资源密集的。这种复杂性的消除使开发人员能够将精力集中在他们工作中更具创新性和差异化的方面。 ### Enumeration ```bash @@ -18,7 +18,7 @@ aws sqs receive-message --queue-url aws sqs send-message --queue-url --message-body ``` > [!CAUTION] -> 此外,即使 `--queue-url` 包含区域,也请确保在 **`--region`** 中指定正确的区域,否则您将收到一个错误,表明您没有访问权限,但问题实际上是区域。 +> 此外,即使 `--queue-url` 包含区域,也请确保在 **`--region`** 中指定正确的区域,否则您将收到一个错误,表明您没有访问权限,但问题实际上是区域不正确。 #### 未经身份验证的访问 @@ -32,7 +32,7 @@ aws sqs send-message --queue-url --message-body ../aws-privilege-escalation/aws-sqs-privesc.md {{#endref}} -#### 利用后 +#### 后期利用 {{#ref}} ../aws-post-exploitation/aws-sqs-post-exploitation.md @@ -44,8 +44,8 @@ aws sqs send-message --queue-url --message-body ../aws-persistence/aws-sqs-persistence.md {{#endref}} -## 参考 +## 参考文献 -- https://docs.aws.amazon.com/cdk/api/v2/python/aws\_cdk.aws\_sqs/README.html +- [https://docs.aws.amazon.com/cdk/api/v2/python/aws\_cdk.aws\_sqs/README.html](https://docs.aws.amazon.com/cdk/api/v2/python/aws\_cdk.aws\_sqs/README.html) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-persistence/az-queue-persistance.md b/src/pentesting-cloud/azure-security/az-persistence/az-queue-persistance.md index e1f19fa29..3c4d4417e 100644 --- a/src/pentesting-cloud/azure-security/az-persistence/az-queue-persistance.md +++ b/src/pentesting-cloud/azure-security/az-persistence/az-queue-persistance.md @@ -1,8 +1,8 @@ -# Az - 队列存储持久性 +# Az - Queue Storage Persistence {{#include ../../../banners/hacktricks-training.md}} -## 队列 +## Queue 有关更多信息,请查看: @@ -10,7 +10,7 @@ ../az-services/az-queue-enum.md {{#endref}} -### 操作: `Microsoft.Storage/storageAccounts/queueServices/queues/write` +### Actions: `Microsoft.Storage/storageAccounts/queueServices/queues/write` 此权限允许攻击者在存储帐户内创建或修改队列及其属性。它可以用于创建未经授权的队列、修改元数据或更改访问控制列表(ACL)以授予或限制访问。此能力可能会干扰工作流程、注入恶意数据、外泄敏感信息或操纵队列设置以启用进一步的攻击。 ```bash @@ -22,8 +22,8 @@ az storage queue policy set --name --permissions rwd --expiry 2024- ``` ## 参考 -- 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/en-us/azure/storage/queues/storage-powershell-how-to-use-queues](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/rest/api/storageservices/queue-service-rest-api) +- [https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes](https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-queue-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-queue-post-exploitation.md index a53a4022a..01aa24701 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-queue-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-queue-post-exploitation.md @@ -12,15 +12,15 @@ ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/read` -具有此权限的攻击者可以从 Azure Storage Queue 中查看消息。这使攻击者能够查看消息的内容,而不将其标记为已处理或更改其状态。这可能导致对敏感信息的未经授权访问,从而使数据外泄或收集进一步攻击的情报。 +具有此权限的攻击者可以从 Azure 存储队列中查看消息。这使攻击者能够查看消息的内容,而不将其标记为已处理或更改其状态。这可能导致对敏感信息的未经授权访问,从而使数据外泄或收集进一步攻击的情报。 ```bash az storage message peek --queue-name --account-name ``` -**潜在影响**:未授权访问队列、消息暴露或未授权用户或服务对队列的操控。 +**潜在影响**:未授权用户或服务对队列的未授权访问、消息暴露或队列操控。 ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/process/action` -拥有此权限的攻击者可以从 Azure Storage Queue 中检索和处理消息。这意味着他们可以读取消息内容并将其标记为已处理,从而有效地将其隐藏于合法系统。这可能导致敏感数据被暴露、消息处理方式的中断,甚至通过使消息对其预期用户不可用而停止重要工作流程。 +拥有此权限的攻击者可以从 Azure 存储队列中检索和处理消息。这意味着他们可以读取消息内容并将其标记为已处理,从而有效地将其隐藏于合法系统。这可能导致敏感数据被暴露、消息处理方式的中断,甚至通过使消息对其预期用户不可用而停止重要工作流程。 ```bash az storage message get --queue-name --account-name ``` @@ -46,7 +46,7 @@ az storage message update --queue-name \ ``` ### Actions: `Microsoft.Storage/storageAccounts/queueServices/queues/delete` -此权限允许攻击者删除存储帐户中的队列。通过利用此能力,攻击者可以永久删除队列及其所有相关消息,从而对工作流程造成重大干扰,并导致依赖受影响队列的应用程序的关键数据丢失。此操作还可以通过删除系统的基本组件来破坏服务。 +此权限允许攻击者删除存储帐户中的队列。通过利用此能力,攻击者可以永久删除队列及其所有相关消息,从而对工作流程造成重大干扰,并导致依赖受影响队列的应用程序的关键数据丢失。此操作还可以通过删除系统的关键组件来破坏服务。 ```bash az storage queue delete --name --account-name ``` @@ -68,8 +68,8 @@ az storage queue policy set --name --permissions rwd --expiry 2024- ``` ## 参考 -- 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/en-us/azure/storage/queues/storage-powershell-how-to-use-queues](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/rest/api/storageservices/queue-service-rest-api) +- [https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes](https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-servicebus-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-servicebus-post-exploitation.md index 958e96524..bc6ee277b 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-servicebus-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-servicebus-post-exploitation.md @@ -24,7 +24,7 @@ az servicebus topic delete --resource-group --namespace-name ``` ### Actions: `Microsoft.ServiceBus/namespaces/queues/Delete` -拥有此权限的攻击者可以删除 Azure Service Bus 队列。此操作会删除队列及其内的所有消息,可能导致关键数据丢失,并干扰依赖于该队列的系统和工作流程。 +拥有此权限的攻击者可以删除 Azure Service Bus 队列。此操作会删除队列及其内所有消息,可能导致关键数据丢失,并干扰依赖于该队列的系统和工作流程。 ```bash az servicebus queue delete --resource-group --namespace-name --name ``` @@ -34,13 +34,6 @@ az servicebus queue delete --resource-group --namespace-name ```bash az servicebus topic subscription delete --resource-group --namespace-name --topic-name --name ``` -### Actions: `Microsoft.ServiceBus/namespaces/write` & `Microsoft.ServiceBus/namespaces/read` - -拥有创建或修改 Azure Service Bus 命名空间权限的攻击者可以利用这一点来干扰操作、部署未经授权的资源或暴露敏感数据。他们可以更改关键配置,例如启用公共网络访问、降低加密设置或更改 SKU,以降低性能或增加成本。此外,他们还可以禁用本地身份验证、操纵副本位置或调整 TLS 版本,以削弱安全控制,使命名空间错误配置成为一个重要的后期利用风险。 -```bash -az servicebus namespace create --resource-group --name --location -az servicebus namespace update --resource-group --name --tags -``` ### Actions: `Microsoft.ServiceBus/namespaces/queues/write` (`Microsoft.ServiceBus/namespaces/queues/read`) 拥有创建或修改 Azure Service Bus 队列权限的攻击者(要修改队列,您还需要 Action:`Microsoft.ServiceBus/namespaces/queues/read`)可以利用这一点来拦截数据、干扰工作流程或启用未经授权的访问。他们可以更改关键配置,例如将消息转发到恶意端点、调整消息 TTL 以不当保留或删除数据,或启用死信处理以干扰错误处理。此外,他们还可以操纵队列大小、锁定持续时间或状态,以干扰服务功能或逃避检测,这使得这成为一个重要的后期利用风险。 @@ -50,14 +43,14 @@ az servicebus queue update --resource-group --namespace-name ``` ### Actions: `Microsoft.ServiceBus/namespaces/topics/write` (`Microsoft.ServiceBus/namespaces/topics/read`) -拥有在 Azure Service Bus 命名空间中创建或修改主题权限的攻击者可以利用这一点来干扰消息工作流、暴露敏感数据或启用未经授权的操作。使用诸如 az servicebus topic update 的命令,他们可以操纵配置,例如启用分区以滥用可扩展性、修改 TTL 设置以不当保留或丢弃消息,或禁用重复检测以绕过控制。此外,他们还可以调整主题大小限制、改变状态以干扰可用性,或配置快速主题以暂时存储拦截的消息,使主题管理成为后期利用缓解的关键焦点。 +拥有在 Azure Service Bus 命名空间中创建或修改主题权限的攻击者可以利用这一点来干扰消息工作流、暴露敏感数据或启用未经授权的操作。使用诸如 az servicebus topic update 的命令,他们可以操纵配置,例如启用分区以滥用可扩展性、改变 TTL 设置以不当保留或丢弃消息,或禁用重复检测以绕过控制。此外,他们还可以调整主题大小限制、改变状态以干扰可用性,或配置快速主题以暂时存储拦截的消息,使主题管理成为后期利用缓解的关键焦点。 ```bash az servicebus topic create --resource-group --namespace-name --name az servicebus topic update --resource-group --namespace-name --name ``` ### Actions: `Microsoft.ServiceBus/namespaces/topics/subscriptions/write` (`Microsoft.ServiceBus/namespaces/topics/subscriptions/read`) -拥有创建或修改订阅权限的攻击者(要修改订阅,您还需要 Action: `Microsoft.ServiceBus/namespaces/topics/subscriptions/read`)可以利用 Azure Service Bus 主题中的这一点来拦截、重定向或干扰消息工作流。使用诸如 az servicebus topic subscription update 的命令,他们可以操纵配置,例如启用死信以转移消息,将消息转发到未经授权的端点,或修改 TTL 和锁定持续时间以保留或干扰消息传递。此外,他们可以更改状态或最大交付计数设置,以干扰操作或逃避检测,使订阅控制成为后期利用场景中的关键方面。 +拥有创建或修改订阅权限的攻击者(要修改订阅,您还需要操作:`Microsoft.ServiceBus/namespaces/topics/subscriptions/read`)可以利用这一点在 Azure Service Bus 主题中拦截、重定向或干扰消息工作流。使用诸如 az servicebus topic subscription update 的命令,他们可以操控配置,例如启用死信以转移消息,将消息转发到未经授权的端点,或修改 TTL 和锁定持续时间以保留或干扰消息传递。此外,他们可以更改状态或最大传递计数设置,以干扰操作或逃避检测,使订阅控制成为后期利用场景中的关键方面。 ```bash az servicebus topic subscription create --resource-group --namespace-name --topic-name --name az servicebus topic subscription update --resource-group --namespace-name --topic-name --name @@ -72,12 +65,12 @@ az servicebus topic subscription update --resource-group --n ## 参考文献 -- 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/en-us/azure/service-bus-messaging/service-bus-python-how-to-use-topics-subscriptions?tabs=passwordless -- https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/integration#microsoftservicebus -- https://learn.microsoft.com/en-us/cli/azure/servicebus/namespace?view=azure-cli-latest -- https://learn.microsoft.com/en-us/cli/azure/servicebus/queue?view=azure-cli-latest +- [https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues](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/rest/api/storageservices/queue-service-rest-api) +- [https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes](https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes) +- [https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-python-how-to-use-topics-subscriptions?tabs=passwordless](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-python-how-to-use-topics-subscriptions?tabs=passwordless) +- [https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/integration#microsoftservicebus](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/integration#microsoftservicebus) +- [https://learn.microsoft.com/en-us/cli/azure/servicebus/namespace?view=azure-cli-latest](https://learn.microsoft.com/en-us/cli/azure/servicebus/namespace?view=azure-cli-latest) +- [https://learn.microsoft.com/en-us/cli/azure/servicebus/queue?view=azure-cli-latest](https://learn.microsoft.com/en-us/cli/azure/servicebus/queue?view=azure-cli-latest) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-sql-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-sql-post-exploitation.md index 6ae18b4c9..3d5f49e8c 100644 --- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-sql-post-exploitation.md +++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-sql-post-exploitation.md @@ -1,8 +1,8 @@ -# Az - SQL 数据库后渗透 +# Az - SQL Database Post Exploitation {{#include ../../../banners/hacktricks-training.md}} -## SQL 数据库后渗透 +## SQL Database Post Exploitation 有关 SQL 数据库的更多信息,请查看: @@ -12,13 +12,23 @@ ### `Microsoft.Sql/servers/databases/read`, `Microsoft.Sql/servers/read` && `Microsoft.Sql/servers/databases/write` -拥有这些权限,攻击者可以在被攻陷的环境中创建和更新数据库。这种后渗透活动可能允许攻击者添加恶意数据、修改数据库配置或插入后门以进一步保持持久性,可能会干扰操作或启用其他恶意行为。 +拥有这些权限,攻击者可以在被攻陷的环境中创建和更新数据库。这种后期利用活动可能允许攻击者添加恶意数据、修改数据库配置或插入后门以进一步保持持久性,可能会干扰操作或启用其他恶意行为。 ```bash # Create Database az sql db create --resource-group --server --name # Update Database az sql db update --resource-group --server --name --max-size +``` +使用这些权限(`Microsoft.Sql/servers/read` && `Microsoft.Sql/servers/databases/write`),您可以恢复已删除的数据库: +```bash +az sql db restore \ +--dest-name \ +--name \ +--resource-group \ +--server \ +--deleted-time "" + ``` ### `Microsoft.Sql/servers/elasticPools/write` && `Microsoft.Sql/servers/elasticPools/read` @@ -62,7 +72,7 @@ az sql server connection-policy update \ ``` ### `Microsoft.Sql/servers/databases/export/action` -拥有此权限,您可以将数据库从 Azure SQL Server 导出到存储帐户。具有此权限的攻击者或授权用户可以通过将其导出到他们控制的位置来提取数据库中的敏感数据,从而带来重大数据泄露风险。了解存储密钥以便能够执行此操作非常重要。 +拥有此权限,您可以将数据库从 Azure SQL Server 导出到存储帐户。具有此权限的攻击者或授权用户可以通过将其导出到他们控制的位置来窃取数据库中的敏感数据,从而带来重大数据泄露风险。了解存储密钥以便能够执行此操作非常重要。 ```bash az sql db export \ --server \ @@ -87,4 +97,41 @@ az sql db import --admin-user \ --storage-key \ --storage-uri `https://.blob.core.windows.net/bacpac-container/MyDatabase.bacpac` ``` +### `Microsoft.Sql/servers/connectionPolicies/write` && `Microsoft.Sql/servers/connectionPolicies/read` + +通过这些权限,用户可以修改和检索 Azure SQL 服务器的连接策略。这些权限允许某人更改客户端如何连接到服务器——选择重定向或代理等方法——如果配置不当,可能会被利用来削弱安全性、重定向流量或拦截敏感数据。 +```bash +az sql server conn-policy update \ +--resource-group \ +--server \ +--connection-policy +``` +### `Microsoft.Sql/servers/keys/write` && `Microsoft.Sql/servers/keys/read` + +通过这些权限,用户可以更新和检索与 Azure SQL Server 相关的加密密钥。这些密钥通常用于通过加密保护敏感数据,因此操纵它们可能会通过允许未经授权的解密或密钥轮换更改来危害数据安全。 +```bash +az sql server key create \ +--resource-group MyResourceGroup \ +--server MyServer \ +--kid "https://mykeyvault.vault.azure.net/keys/mykey/1234567890abcdef +``` +### `Microsoft.Sql/servers/databases/ledgerDigestUploads/disable/action`, `Microsoft.Sql/locations/ledgerDigestUploadsAzureAsyncOperation/read`, `Microsoft.Sql/locations/ledgerDigestUploadsOperationResults/read` + +此权限允许禁用 Azure SQL 数据库的 Ledger Digest,这会停止定期将加密摘要记录上传到 Azure Blob 存储,以验证数据的完整性。 +```bash +az sql db ledger-digest-uploads disable \ +--name ledgerDB \ +--resource-group myResourceGroup \ +--server my-sql-server +``` +### `Microsoft.Sql/servers/databases/transparentDataEncryption/write`, `Microsoft.Sql/locations/transparentDataEncryptionAzureAsyncOperation/read`, `Microsoft.Sql/servers/databases/transparentDataEncryption/read` + +此权限允许授权用户或攻击者启用、禁用或修改 Azure SQL 数据库上的透明数据加密 (TDE) 设置,可能通过更改加密配置影响数据安全。 +```bash +az sql db tde set \ +--database \ +--resource-group \ +--server \ +--status +``` {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-privesc.md deleted file mode 100644 index 9c15ca970..000000000 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-privesc.md +++ /dev/null @@ -1,64 +0,0 @@ -# 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 --resource-group --exec-command 'ls' -``` -也可以通过以下方式**读取容器的输出**: -```bash -az container attach --name --resource-group -``` -或使用以下命令获取日志: -```bash -az container logs --name --resource-group -``` -### `Microsoft.ContainerInstance/containerGroups/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action` - -这些权限允许**将用户管理的身份**附加到容器组。这对于在容器中提升权限非常有用。 - -要将用户管理的身份附加到容器组: -```bash -az rest \ ---method PATCH \ ---url "/subscriptions//resourceGroups//providers/Microsoft.ContainerInstance/containerGroups/?api-version=2021-09-01" \ ---body '{ -"identity": { -"type": "UserAssigned", -"userAssignedIdentities": { -"/subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/": {} -} -} -}' \ ---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 > \ ---name nginx2 \ ---image mcr.microsoft.com/oss/nginx/nginx:1.9.15-alpine \ ---assign-identity "/subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/" \ ---restart-policy OnFailure \ ---os-type Linux \ ---cpu 1 \ ---memory 1.0 -``` -此外,还可以更新现有的容器组,例如添加 **`--command-line` 参数** 以实现反向 shell。 - -{{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md index 60e49a520..18b843d37 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-queue-privesc.md @@ -16,7 +16,7 @@ ```bash az storage message peek --queue-name --account-name ``` -**潜在影响**:未经授权访问队列、消息暴露或未经授权用户或服务对队列的操控。 +**潜在影响**:未授权用户或服务对队列的未授权访问、消息暴露或队列操控。 ### DataActions: `Microsoft.Storage/storageAccounts/queueServices/queues/messages/process/action` @@ -56,8 +56,8 @@ az storage queue policy set --name --permissions rwd --expiry 2024- ``` ## 参考 -- 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/en-us/azure/storage/queues/storage-powershell-how-to-use-queues](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/rest/api/storageservices/queue-service-rest-api) +- [https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes](https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md index e45b92216..7ab654be6 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-servicebus-privesc.md @@ -29,7 +29,7 @@ az servicebus namespace authorization-rule keys renew --key [PrimaryKey|Secondar az servicebus namespace authorization-rule create --authorization-rule-name "myRule" --namespace-name mynamespacespdemo --resource-group Resource_Group_1 --rights Manage Listen Send ``` >[!WARNING] ->此命令不会返回密钥,因此您需要通过之前的命令(和权限)获取它们,以便提升权限。 +>此命令不会返回密钥,因此您需要通过之前的命令(和权限)来获取它们,以便提升权限。 此外,通过该命令(和 `Microsoft.ServiceBus/namespaces/authorizationRules/read`),如果您通过 Azure CLI 执行此操作,可以使用以下命令更新现有的授权规则并赋予其更多权限(如果缺少某些权限): ```bash @@ -41,7 +41,7 @@ az servicebus namespace authorization-rule update \ ``` ### Microsoft.ServiceBus/namespaces/[queues|topics]/authorizationRules/ListKeys/action 或 Microsoft.ServiceBus/namespaces/[queues|topics]/authorizationRules/regenerateKeys/action -Service Bus 命名空间内的特定主题和队列可以拥有自己的授权规则,这些规则可用于控制对实体的访问。通过拥有这些权限,您可以 **检索或重新生成这些本地授权规则的密钥**,使您能够以实体的身份进行身份验证,并可能发送或接收消息、管理订阅或以可能干扰操作的方式与系统交互,冒充有效用户或向消息工作流注入恶意数据。 +Service Bus 命名空间内的特定主题和队列可以拥有自己的授权规则,这些规则可用于控制对实体的访问。通过拥有这些权限,您可以 **检索或重新生成这些本地授权规则的密钥**,使您能够以实体的身份进行身份验证,并可能发送或接收消息、管理订阅或以可能干扰操作的方式与系统交互,冒充有效用户或向消息工作流中注入恶意数据。 ```bash # List keys (topics) az servicebus topic authorization-rule keys list --resource-group --namespace-name --topic-name --name @@ -57,7 +57,7 @@ az servicebus queue authorization-rule keys renew --key [PrimaryKey|SecondaryKey ``` ### Microsoft.ServiceBus/namespaces/[queues|topics]/authorizationRules/write -通过此权限,可以**创建一个新的授权规则**,并拥有所有权限及其自己的密钥: +拥有此权限可以**创建一个新的授权规则**,并赋予所有权限及其自己的密钥: ```bash # In a topic az servicebus topic authorization-rule create --resource-group --namespace-name --topic-name --name --rights Manage Listen Send @@ -66,9 +66,9 @@ az servicebus topic authorization-rule create --resource-group --nam az servicebus queue authorization-rule create --resource-group --namespace-name --queue-name --name --rights Manage Listen Send ``` >[!WARNING] ->此命令不会返回密钥,因此您需要通过之前的命令(和权限)获取它们以提升权限。 +>此命令不会返回密钥,因此您需要通过之前的命令(和权限)获取它们,以便提升权限。 -此外,通过该命令(和 `Microsoft.ServiceBus/namespaces/[queues|topics]/authorizationRules/read`),如果您通过 Azure CLI 执行此操作,可以使用以下命令更新现有的授权规则并赋予其更多权限(如果缺少某些权限): +此外,通过该命令(和 `Microsoft.ServiceBus/namespaces/[queues|topics]/authorizationRules/read`),如果您通过 Azure CLI 执行此操作,可以使用以下命令更新现有的授权规则并赋予更多权限(如果缺少某些权限): ```bash # In a topic az servicebus topic authorization-rule update --resource-group --namespace-name --topic-name --name --rights Manage Listen Send @@ -84,127 +84,202 @@ az servicebus namespace update --disable-local-auth false -n -- ``` ### 发送带有密钥的消息 (Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action OR Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action) -您可以检索 `PrimaryConnectionString`,它作为 Service Bus 命名空间的凭据。使用此连接字符串,您可以完全以 Service Bus 命名空间的身份进行身份验证,从而使您能够向任何队列或主题发送消息,并可能以可能干扰操作、冒充有效用户或将恶意数据注入消息工作流的方式与系统进行交互。 +您可以检索 `PrimaryConnectionString`,它作为 Service Bus 命名空间的凭据。使用此连接字符串,您可以完全以 Service Bus 命名空间的身份进行身份验证,使您能够向任何队列或主题发送消息,并可能以可能干扰操作、冒充有效用户或将恶意数据注入消息工作流的方式与系统进行交互。如果 `--disable-local-auth` 设置为 false,则此方法有效。 ```python -#You need to install the following libraries -#pip install azure-servicebus -#pip install aiohttp -#pip install azure-identity - import asyncio from azure.servicebus.aio import ServiceBusClient from azure.servicebus import ServiceBusMessage -# Constants NAMESPACE_CONNECTION_STR = "" -TOPIC_NAME = "" +TOPIC_OR_QUEUE_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'") +async def send_message(): +async with ServiceBusClient.from_connection_string(NAMESPACE_CONNECTION_STR) as client: +async with client.get_topic_sender(topic_name=TOPIC_OR_QUEUE_NAME) as sender: +await sender.send_messages(ServiceBusMessage("Hacktricks-Training: Single Item")) +print("Sent message") -# 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'") +asyncio.run(send_message()) +``` +此外,您可以使用 az rest 发送消息,在这种情况下,您需要生成一个 sas 令牌来使用。 +```python +import time, urllib.parse, hmac, hashlib, base64 -# 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'") +def generate_sas_token(uri, key_name, key, expiry_in_seconds=3600): +expiry = int(time.time() + expiry_in_seconds) +string_to_sign = urllib.parse.quote_plus(uri) + "\n" + str(expiry) +signed_hmac_sha256 = hmac.new(key.encode('utf-8'), string_to_sign.encode('utf-8'), hashlib.sha256).digest() +signature = urllib.parse.quote_plus(base64.b64encode(signed_hmac_sha256)) +token = f"SharedAccessSignature sr={urllib.parse.quote_plus(uri)}&sig={signature}&se={expiry}&skn={key_name}" +return token -# 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) +# Replace these with your actual values +resource_uri = "https://.servicebus.windows.net/" +key_name = "" +primary_key = "" -# Run the asynchronous execution -asyncio.run(execute()) -print("Messages Sent") -print("----------------------------") +sas_token = generate_sas_token(resource_uri, key_name, primary_key) +print(sas_token) +``` + +```bash +az rest --method post \ +--uri "https://.servicebus.windows.net//messages" \ +--headers "Content-Type=application/atom+xml;type=entry;charset=utf-8" "Authorization=SharedAccessSignature sr=https%3A%2F%2F.servicebus.windows.net%2F&sig=&se=&skn=" \ +--body "" ``` -### 使用密钥接收 (Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action OR Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action) +### Receive with keys (Microsoft.ServiceBus/namespaces/authorizationRules/listkeys/action OR Microsoft.ServiceBus/namespaces/authorizationRules/regenerateKeys/action) -您可以检索 PrimaryConnectionString,它作为 Service Bus 命名空间的凭据。使用此连接字符串,您可以从命名空间内的任何队列或订阅接收消息,从而访问潜在的敏感或关键数据,允许数据外泄,或干扰消息处理和应用程序工作流。 +您可以检索 PrimaryConnectionString,它作为 Service Bus 命名空间的凭据。使用此连接字符串,您可以从命名空间内的任何队列或订阅接收消息,从而访问潜在的敏感或关键数据,启用数据外泄,或干扰消息处理和应用程序工作流。如果将 `--disable-local-auth` 设置为 false,此方法有效。 ```python -#You need to install the following libraries -#pip install azure-servicebus -#pip install aiohttp -#pip install azure-identity - import asyncio from azure.servicebus.aio import ServiceBusClient -NAMESPACE_CONNECTION_STR = "" -TOPIC_NAME = "" -SUBSCRIPTION_NAME = "" #Topic Subscription +CONN_STR = "" +QUEUE = "" -# 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: +# For topics/subscriptions, you would use: +# TOPIC = "" +# SUBSCRIPTION = "" -# 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 +async def receive(): +async with ServiceBusClient.from_connection_string(CONN_STR) as client: +# For a queue receiver: +async with client.get_queue_receiver(queue_name=QUEUE, max_wait_time=5) as receiver: +msgs = await receiver.receive_messages(max_wait_time=5, max_message_count=20) +for msg in msgs: +print("Received:", msg) await receiver.complete_message(msg) -# Run the asynchronous message processing function -asyncio.run(receive_and_process_messages()) -print("Message Receiving Completed") -print("----------------------------") +# For a topic/subscription receiver (commented out): +# async with client.get_subscription_receiver(topic_name=TOPIC, subscription_name=SUBSCRIPTION, max_wait_time=5) as receiver: +# msgs = await receiver.receive_messages(max_wait_time=5, max_message_count=20) +# for msg in msgs: +# print("Received:", msg) +# await receiver.complete_message(msg) + +asyncio.run(receive()) +print("Done receiving messages") +``` +此外,您可以使用 az rest 发送消息,在这种情况下,您需要生成一个 sas 令牌来使用。 +```python +import time, urllib.parse, hmac, hashlib, base64 + +def generate_sas_token(uri, key_name, key, expiry_in_seconds=3600): +expiry = int(time.time() + expiry_in_seconds) +string_to_sign = urllib.parse.quote_plus(uri) + "\n" + str(expiry) +signature = urllib.parse.quote_plus(base64.b64encode( +hmac.new(key.encode('utf-8'), string_to_sign.encode('utf-8'), hashlib.sha256).digest() +)) +token = f"SharedAccessSignature sr={urllib.parse.quote_plus(uri)}&sig={signature}&se={expiry}&skn={key_name}" +return token + +# Example usage: +resource_uri = "https://.servicebus.windows.net/queue" # For queue +# resource_uri = "https://.servicebus.windows.net//subscriptions/" # For topic subscription +sas_token = generate_sas_token(resource_uri, "", "") +print(sas_token) + +``` +对于队列,您可以获取或查看消息(获取消息会将其移除,而查看则不会): +```bash +#Get a message +az rest --method post \ +--uri "https://.servicebus.windows.net//messages/head?timeout=60" \ +--headers "Content-Type=application/atom+xml;type=entry;charset=utf-8" "Authorization=SharedAccessSignature sr=&sig=&se=&skn=" + +#Peek a message +az rest --method get \ +--uri "https://.servicebus.windows.net//messages/head?peekonly=true&timeout=60" \ +--headers "Authorization=SharedAccessSignature sr=&sig=&se=&skn=" + +#You can select the meesage changing the field PreviousSequenceNumber +az rest --method get \ +--uri "https://.servicebus.windows.net//messages?timeout=60&PreviousSequenceNumber=&api-version=2017-04" \ +--headers "Authorization=SharedAccessSignature sr=&sig=&se=&skn=" +``` +请提供您希望翻译的具体内容。 +```bash +#Get a message +az rest --method post \ +--uri "https://.servicebus.windows.net//subscriptions//messages/head?timeout=60" \ +--headers "Content-Type=application/atom+xml;type=entry;charset=utf-8" "Authorization=SharedAccessSignature sr=&sig=&se=&skn=" + +#Peek a message +az rest --method get \ +--uri "https://.servicebus.windows.net//subscriptions//messages/head?timeout=60&api-version=2017-04" \ +--headers "Authorization=SharedAccessSignature sr=&sig=&se=&skn=" + +#You can select the meesage changing the field PreviousSequenceNumber +az rest --method get \ +--uri "https://.servicebus.windows.net//subscriptions//messages?timeout=60&PreviousSequenceNumber=&api-version=2017-04" \ +--headers "Authorization=SharedAccessSignature sr=&sig=&se=&skn=" +``` +### 发送消息。DataActions: `Microsoft.ServiceBus/namespaces/messages/send/action` + +您可以使用此权限发送消息,即使 `--disable-local-auth` 设置为 true。 +```python +import asyncio +from azure.identity.aio import DefaultAzureCredential +from azure.servicebus.aio import ServiceBusClient +from azure.servicebus import ServiceBusMessage + +NS = ".servicebus.windows.net" # Your namespace +QUEUE_OR_TOPIC = "" # Your queue name + +async def run(): +credential = DefaultAzureCredential() +async with ServiceBusClient(fully_qualified_namespace=NS, credential=credential) as client: +async with client.get_queue_sender(queue_name=QUEUE) as sender: +await sender.send_messages(ServiceBusMessage("Single Message")) +print("Sent a single message") +await credential.close() + +if __name__ == "__main__": +asyncio.run(run()) +``` +### 接收消息。DataActions: `Microsoft.ServiceBus/namespaces/messages/receive/action` + +您可以使用此权限接收消息,即使 `--disable-local-auth` 设置为 true。 +```python +import asyncio +from azure.identity.aio import DefaultAzureCredential +from azure.servicebus.aio import ServiceBusClient + +NS = ".servicebus.windows.net" +QUEUE = "" + +# For a topic subscription, uncomment and set these values: +# TOPIC = "" +# SUBSCRIPTION = "" + +async def run(): +credential = DefaultAzureCredential() +async with ServiceBusClient(fully_qualified_namespace=NS, credential=credential) as client: +# Receiving from a queue: +async with client.get_queue_receiver(queue_name=QUEUE, max_wait_time=5) as receiver: +async for msg in receiver: +print("Received from Queue:", msg) +await receiver.complete_message(msg) + +# To receive from a topic subscription, uncomment the code below and comment out the queue receiver above: +# async with client.get_subscription_receiver(topic_name=TOPIC, subscription_name=SUBSCRIPTION, max_wait_time=5) as receiver: +# async for msg in receiver: +# print("Received from Topic Subscription:", msg) +# await receiver.complete_message(msg) + +await credential.close() + +asyncio.run(run()) +print("Done receiving messages") ``` ## 参考 -- 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/en-us/azure/service-bus-messaging/service-bus-python-how-to-use-topics-subscriptions?tabs=passwordless -- https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/integration#microsoftservicebus +- [https://learn.microsoft.com/en-us/azure/storage/queues/storage-powershell-how-to-use-queues](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/rest/api/storageservices/queue-service-rest-api) +- [https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes](https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes) +- [https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-python-how-to-use-topics-subscriptions?tabs=passwordless](https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-python-how-to-use-topics-subscriptions?tabs=passwordless) +- [https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/integration#microsoftservicebus](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/integration#microsoftservicebus) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-sql-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-sql-privesc.md index b23ff1352..2501e3986 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-sql-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-sql-privesc.md @@ -12,7 +12,7 @@ ### `Microsoft.Sql/servers/read` && `Microsoft.Sql/servers/write` -拥有这些权限的用户可以通过更新或创建 Azure SQL 服务器并修改关键配置(包括管理凭据)来进行权限提升。此权限允许用户更新服务器属性,包括 SQL 服务器管理员密码,从而实现对服务器的未经授权访问或控制。他们还可以创建新服务器,可能会引入用于恶意目的的影子基础设施。在“Microsoft Entra 仅身份验证”被禁用的环境中,这一点尤为关键,因为他们可以利用基于 SQL 的身份验证获得无限制访问权限。 +拥有这些权限的用户可以通过更新或创建 Azure SQL 服务器并修改关键配置(包括管理凭据)来进行权限提升。此权限允许用户更新服务器属性,包括 SQL 服务器管理员密码,从而实现未经授权的访问或对服务器的控制。他们还可以创建新服务器,可能会引入用于恶意目的的影子基础设施。在“Microsoft Entra 仅限身份验证”被禁用的环境中,这一点尤为关键,因为他们可以利用基于 SQL 的身份验证获得无限制访问权限。 ```bash # Change the server password az sql server update \ @@ -26,7 +26,7 @@ az sql server create \ --resource-group \ --location \ --admin-user \ ---admin-password +--admin-password ``` 此外,如果您想从非私有端点访问,则必须启用公共访问,启用方法: ```bash @@ -35,6 +35,31 @@ az sql server update \ --resource-group \ --enable-public-network true ``` +此外,凭借这些权限,您可以启用分配身份,并使用附加到服务器的托管身份进行操作。例如,这里有一个可以访问 Azure Storage 的托管身份: +```bash +az sql server update \ +--name \ +--resource-group \ +--assign_identity +``` + +```sql +CREATE EXTERNAL DATA SOURCE ManagedIdentity +WITH ( +TYPE = BLOB_STORAGE, +LOCATION = 'https://.blob.core.windows.net/', +CREDENTIAL = ManagedIdentityCredential +); +GO + +SELECT * +FROM OPENROWSET( +BULK 'message.txt', +DATA_SOURCE = 'ManagedIdentity', +SINGLE_CLOB +) AS DataFile; +GO +``` ### `Microsoft.Sql/servers/firewallRules/write` 攻击者可以操纵 Azure SQL 服务器上的防火墙规则,以允许未经授权的访问。这可以被利用来向特定的 IP 地址或整个 IP 范围(包括公共 IP)开放服务器,从而使恶意行为者能够访问。此后渗透活动可以用来绕过现有的网络安全控制,建立持久性,或通过暴露敏感资源来促进环境内的横向移动。 diff --git a/src/pentesting-cloud/azure-security/az-services/az-container-instances.md b/src/pentesting-cloud/azure-security/az-services/az-container-instances.md deleted file mode 100644 index 3552da60f..000000000 --- a/src/pentesting-cloud/azure-security/az-services/az-container-instances.md +++ /dev/null @@ -1,45 +0,0 @@ -# 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 --resource-group - -# Fetch logs from a container -az container logs --name --resource-group - -# Execute a command in a running container and get the output -az container exec --name --resource-group --exec-command "ls" - -# Get yaml configuration of the container group -az container export --name --resource-group -``` - diff --git a/src/pentesting-cloud/azure-security/az-services/az-queue-enum.md b/src/pentesting-cloud/azure-security/az-services/az-queue-enum.md index c7ac8c84e..0bc8c7cff 100644 --- a/src/pentesting-cloud/azure-security/az-services/az-queue-enum.md +++ b/src/pentesting-cloud/azure-security/az-services/az-queue-enum.md @@ -4,7 +4,7 @@ ## 基本信息 -Azure Queue Storage 是微软 Azure 云平台中的一项服务,旨在实现应用组件之间的消息排队,**支持异步通信和解耦**。它允许您存储无限数量的消息,每条消息最大为 64 KB,并支持创建和删除队列、添加、检索、更新和删除消息,以及管理元数据和访问策略等操作。虽然它通常以先进先出(FIFO)的方式处理消息,但不保证严格的 FIFO。 +Azure Queue Storage 是微软 Azure 云平台中的一项服务,旨在实现应用组件之间的消息排队,**实现异步通信和解耦**。它允许您存储无限数量的消息,每条消息最大为 64 KB,并支持创建和删除队列、添加、检索、更新和删除消息,以及管理元数据和访问策略等操作。虽然它通常以先进先出(FIFO)的方式处理消息,但不保证严格的 FIFO。 ### 枚举 @@ -70,7 +70,7 @@ $queueMessage.Value ../az-privilege-escalation/az-queue-privesc.md {{#endref}} -### 利用后 +### 后期利用 {{#ref}} ../az-post-exploitation/az-queue-post-exploitation.md @@ -82,10 +82,10 @@ $queueMessage.Value ../az-persistence/az-queue-persistance.md {{#endref}} -## 参考 +## 参考文献 -- 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/en-us/azure/storage/queues/storage-powershell-how-to-use-queues](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/rest/api/storageservices/queue-service-rest-api) +- [https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes](https://learn.microsoft.com/en-us/azure/storage/queues/queues-auth-abac-attributes) {{#include ../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/azure-security/az-services/az-servicebus-enum.md b/src/pentesting-cloud/azure-security/az-services/az-servicebus-enum.md index 7981fbe4c..121e13aff 100644 --- a/src/pentesting-cloud/azure-security/az-services/az-servicebus-enum.md +++ b/src/pentesting-cloud/azure-security/az-services/az-servicebus-enum.md @@ -4,52 +4,61 @@ ## Service Bus -Azure Service Bus 是一个基于云的 **消息服务**,旨在实现 **应用程序不同部分或独立应用程序之间的可靠通信**。它充当安全的中介,确保消息安全送达,即使发送者和接收者并不同时操作。通过解耦系统,它允许应用程序独立工作,同时仍然交换数据或指令。它特别适用于需要在多个工作者之间进行负载均衡、可靠消息传递或复杂协调的场景,例如按顺序处理任务或安全管理访问。 +Azure Service Bus 是一个基于云的 **消息服务**,旨在实现 **应用程序不同部分或独立应用程序之间的可靠通信**。它充当一个安全的中介,确保消息安全送达,即使发送者和接收者并不同时操作。通过解耦系统,它允许应用程序独立工作,同时仍然交换数据或指令。它特别适用于需要在多个工作者之间进行负载均衡、可靠消息传递或复杂协调的场景,例如按顺序处理任务或安全管理访问。 ### Key Concepts -1. **Queues:** 其目的是在接收者准备好之前存储消息。 +1. **Namespaces:** 消息系统中的命名空间是一个逻辑容器,用于组织和管理消息组件、队列和主题。它提供一个隔离的环境,应用程序可以在其中发送、接收和处理消息。队列和主题在 Service Bus 命名空间内共享相同的基础设施和配置,但它们独立操作而不相互交互。 +2. **Queues:** 其目的是存储消息,直到接收者准备好。 - 消息是有序的、带时间戳的,并且持久存储。 - 以拉取模式交付(按需检索)。 - 支持点对点通信。 -2. **Topics:** 发布-订阅消息用于广播。 -- 多个独立订阅接收消息的副本。 +3. **Topics:** 发布-订阅消息用于广播。 +- 多个独立的订阅接收消息的副本。 - 订阅可以有规则/过滤器来控制交付或添加元数据。 - 支持多对多通信。 -3. **Namespaces:** 所有消息组件、队列和主题的容器,就像您自己的一部分强大 Azure 集群,提供专用容量,并可选择跨越三个可用区。 -### Advance Features +服务总线端点/连接字符串是: +```bash +https://.servicebus.windows.net:443/ +``` +### 高级功能 一些高级功能包括: -- **Message Sessions**: 确保 FIFO 处理并支持请求-响应模式。 -- **Auto-Forwarding**: 在同一命名空间内在队列或主题之间转移消息。 -- **Dead-Lettering**: 捕获无法送达的消息以供审查。 -- **Scheduled Delivery**: 延迟消息处理以进行未来任务。 -- **Message Deferral**: 推迟消息检索直到准备好。 -- **Transactions**: 将操作分组为原子执行。 -- **Filters & Actions**: 应用规则以过滤或注释消息。 -- **Auto-Delete on Idle**: 在不活动后删除队列(最小:5分钟)。 -- **Duplicate Detection**: 在重发期间删除重复消息。 -- **Batch Deletion**: 批量删除过期或不必要的消息。 +- **消息会话**:确保FIFO处理并支持请求-响应模式。 +- **自动转发**:在同一命名空间内在队列或主题之间转移消息。 +- **死信处理**:捕获无法送达的消息以供审查。 +- **定时投递**:延迟消息处理以进行未来任务。 +- **消息延迟**:推迟消息检索直到准备好。 +- **事务**:将操作分组为原子执行。 +- **过滤器和操作**:应用规则以过滤或注释消息。 +- **空闲时自动删除**:在不活动后删除队列(最少:5分钟)。 +- **重复检测**:在重发期间移除重复消息。 +- **批量删除**:批量删除过期或不必要的消息。 -### Authorization-Rule / SAS Policy +### 授权规则 / SAS 策略 -SAS 策略定义了 Azure Service Bus 实体命名空间(最重要的一个)、队列和主题的访问权限。每个策略具有以下组件: +SAS 策略定义了 Azure Service Bus 实体命名空间(最重要的一个)、队列和主题的访问权限。每个策略包含以下组件: -- **Permissions**: 复选框以指定访问级别: -- Manage: 授予对实体的完全控制,包括配置和权限管理。 -- Send: 允许向实体发送消息。 -- Listen: 允许从实体接收消息。 -- **Primary and Secondary Keys**: 这些是用于生成安全令牌以验证访问的加密密钥。 -- **Primary and Secondary Connection Strings**: 预配置的连接字符串,包括端点和密钥,便于在应用程序中使用。 -- **SAS Policy ARM ID**: Azure 资源管理器(ARM)路径,用于程序识别该策略。 +- **权限**:复选框以指定访问级别: +- 管理:授予对实体的完全控制,包括配置和权限管理。 +- 发送:允许向实体发送消息。 +- 监听:允许从实体接收消息。 +- **主密钥和次密钥**:这些是用于生成安全令牌以进行访问身份验证的加密密钥。 +- **主连接字符串和次连接字符串**:预配置的连接字符串,包括端点和密钥,便于在应用程序中使用。 +- **SAS 策略 ARM ID**:用于程序识别的策略的 Azure 资源管理器(ARM)路径。 -### NameSpace +需要注意的是,一个命名空间只有一个 SAS 策略,这会影响其中的每个实体,而队列和主题可以拥有各自的单独 SAS 策略,以实现更细粒度的控制。 -sku, 授权规则, +### "--disable-local-auth" -### Enumeration +--disable-local-auth 参数用于控制是否为您的 Service Bus 命名空间启用本地身份验证(即使用共享访问签名(SAS)密钥)。以下是您需要了解的内容: + +- 设置为 true 时:禁用使用 SAS 密钥的本地身份验证,允许使用 Azure Active Directory(Azure AD)身份验证。 +- 设置为 false 时:同时可用 SAS(本地)身份验证和 Azure AD 身份验证,您可以使用包含 SAS 密钥的连接字符串访问您的 Service Bus 资源。 + +### 枚举 {{#tabs }} {{#tab name="az cli" }} @@ -133,7 +142,6 @@ Get-AzServiceBusTopic -ResourceGroupName -NamespaceName --resource-group ## List Server Firewalls diff --git a/src/pentesting-cloud/gcp-security/gcp-services/gcp-compute-instances-enum/gcp-compute-instance.md b/src/pentesting-cloud/gcp-security/gcp-services/gcp-compute-instances-enum/gcp-compute-instance.md index ff676559f..5c21276c1 100644 --- a/src/pentesting-cloud/gcp-security/gcp-services/gcp-compute-instances-enum/gcp-compute-instance.md +++ b/src/pentesting-cloud/gcp-security/gcp-services/gcp-compute-instances-enum/gcp-compute-instance.md @@ -10,7 +10,7 @@ Google Cloud Compute Instances 是 **可定制的虚拟机,运行在 Google 保密虚拟机使用 **最新一代 AMD EPYC 处理器** 提供的 **基于硬件的安全特性**,包括内存加密和安全加密虚拟化。这些特性使虚拟机能够保护处理和存储的数据,甚至免受主机操作系统和虚拟机监控程序的影响。 -要运行保密虚拟机,可能需要 **更改** 一些设置,如 **机器类型**、网络 **接口**、**启动磁盘映像**。 +要运行保密虚拟机,可能需要 **更改** 一些设置,例如 **机器类型**、网络 **接口**、**启动磁盘映像**。 ### 磁盘与磁盘加密 @@ -24,21 +24,21 @@ Google Cloud Compute Instances 是 **可定制的虚拟机,运行在 Google ### 部署容器 可以在虚拟机内部署 **容器**。\ -可以配置要使用的 **映像**,设置要在内部运行的 **命令**、**参数**、挂载 **卷** 和 **环境变量**(敏感信息?),并为该容器配置多个选项,如以 **特权** 身份执行、标准输入和伪 TTY。 +可以配置要使用的 **映像**,设置要在内部运行的 **命令**、**参数**、挂载 **卷** 和 **环境变量**(敏感信息?),并为该容器配置多个选项,例如以 **特权模式** 执行、标准输入和伪 TTY。 ### 服务账户 默认情况下,将使用 **Compute Engine 默认服务账户**。该服务账户的电子邮件格式为:`-compute@developer.gserviceaccount.com`\ -该服务账户在整个项目中具有 **编辑者角色(高权限)**。 +此服务账户在整个项目中具有 **编辑者角色(高权限)**。 默认访问范围如下: - **https://www.googleapis.com/auth/devstorage.read\_only** -- 对存储桶的读取访问 :) -- https://www.googleapis.com/auth/logging.write -- https://www.googleapis.com/auth/monitoring.write -- https://www.googleapis.com/auth/servicecontrol -- https://www.googleapis.com/auth/service.management.readonly -- https://www.googleapis.com/auth/trace.append +- [https://www.googleapis.com/auth/logging.write](https://www.googleapis.com/auth/logging.write) +- [https://www.googleapis.com/auth/monitoring.write](https://www.googleapis.com/auth/monitoring.write) +- [https://www.googleapis.com/auth/servicecontrol](https://www.googleapis.com/auth/servicecontrol) +- [https://www.googleapis.com/auth/service.management.readonly](https://www.googleapis.com/auth/service.management.readonly) +- [https://www.googleapis.com/auth/trace.append](https://www.googleapis.com/auth/trace.append) 不过,可以 **通过点击授予 `cloud-platform` 权限** 或指定 **自定义权限**。 @@ -52,8 +52,8 @@ Google Cloud Compute Instances 是 **可定制的虚拟机,运行在 Google ### 网络 -- **IP 转发**:可以在创建实例时 **启用 IP 转发**。 -- **主机名**:可以为实例指定一个永久主机名。 +- **IP 转发**:可以在实例创建时 **启用 IP 转发**。 +- **主机名**:可以为实例提供一个永久主机名。 - **接口**:可以添加网络接口。 ### 额外安全性 @@ -61,8 +61,8 @@ Google Cloud Compute Instances 是 **可定制的虚拟机,运行在 Google 这些选项将 **提高虚拟机的安全性**,并且推荐使用: - **安全启动**:安全启动有助于保护您的虚拟机实例免受启动级和内核级恶意软件和根套件的攻击。 -- **启用 vTPM**:虚拟可信任平台模块(vTPM)验证您的客户虚拟机的预启动和启动完整性,并提供密钥生成和保护。 -- **完整性监控**:完整性监控让您可以使用 Stackdriver 报告监控和验证受保护虚拟机实例的运行时启动完整性。需要启用 vTPM。 +- **启用 vTPM**:虚拟受信任平台模块(vTPM)验证您的客户虚拟机的预启动和启动完整性,并提供密钥生成和保护。 +- **完整性监控**:完整性监控允许您使用 Stackdriver 报告监控和验证受保护虚拟机实例的运行时启动完整性。需要启用 vTPM。 ### 虚拟机访问 @@ -86,7 +86,7 @@ curl "http://metadata.google.internal/computeMetadata/v1/project/attributes/?rec curl "http://metadata.google.internal/computeMetadata/v1/instance/attributes/?recursive=true&alt=text" \ -H "Metadata-Flavor: Google" ``` -此外,**附加服务帐户的身份验证令牌**和**有关实例、网络和项目的一般信息**也将可以从**元数据端点**获取。有关更多信息,请查看: +此外,**附加服务帐户的身份验证令牌**和**有关实例、网络和项目的一般信息**也可以从**元数据端点**获取。有关更多信息,请查看: {{#ref}} https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html#gcp