From 7c8f2e2077773a69d1470a176da380a91274444d Mon Sep 17 00:00:00 2001 From: Translator Date: Thu, 9 Jan 2025 01:06:22 +0000 Subject: [PATCH] Translated ['src/pentesting-cloud/azure-security/az-privilege-escalation --- .../az-authorization-privesc.md | 58 +++++++++++-------- .../gcp-source-repositories-enum.md | 51 ++++++++-------- 2 files changed, 63 insertions(+), 46 deletions(-) diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md index 6ccb7d8d2..3076c610d 100644 --- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md +++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-authorization-privesc.md @@ -4,7 +4,7 @@ ## Azure IAM -Para mais informações, consulte: +Fore more information check: {{#ref}} ../az-services/az-azuread.md @@ -12,38 +12,45 @@ Para mais informações, consulte: ### Microsoft.Authorization/roleAssignments/write -Esta permissão permite atribuir funções a principais em um escopo específico, permitindo que um atacante eleve privilégios ao se atribuir uma função mais privilegiada: +This permission allows to assign roles to principals over a specific scope, allowing an attacker to escalate privileges by assigning himself a more privileged role: + ```bash # Example az role assignment create --role Owner --assignee "24efe8cf-c59e-45c2-a5c7-c7e552a07170" --scope "/subscriptions/9291ff6e-6afb-430e-82a4-6f04b2d05c7f/resourceGroups/Resource_Group_1/providers/Microsoft.KeyVault/vaults/testing-1231234" ``` + ### Microsoft.Authorization/roleDefinitions/Write -Esta permissão permite modificar as permissões concedidas por um papel, permitindo que um atacante escale privilégios ao conceder mais permissões a um papel que ele tenha atribuído. +This permission allows to modify the permissions granted by a role, allowing an attacker to escalate privileges by granting more permissions to a role he has assigned. + +Create the file `role.json` with the following **content**: -Crie o arquivo `role.json` com o seguinte **conteúdo**: ```json { -"Name": "", -"IsCustom": true, -"Description": "Custom role with elevated privileges", -"Actions": ["*"], -"NotActions": [], -"DataActions": ["*"], -"NotDataActions": [], -"AssignableScopes": ["/subscriptions/"] + "Name": "", + "IsCustom": true, + "Description": "Custom role with elevated privileges", + "Actions": ["*"], + "NotActions": [], + "DataActions": ["*"], + "NotDataActions": [], + "AssignableScopes": ["/subscriptions/"] } ``` -Então atualize as permissões de função com a definição anterior chamando: + +Then update the role permissions with the previous definition calling: + ```bash az role definition update --role-definition role.json ``` + ### Microsoft.Authorization/elevateAccess/action -Esta permissão permite elevar privilégios e ser capaz de atribuir permissões a qualquer principal para recursos do Azure. É destinada a ser concedida a Administradores Globais do Entra ID para que eles também possam gerenciar permissões sobre os recursos do Azure. +This permissions allows to elevate privileges and be able to assign permissions to any principal to Azure resources. It's meant to be given to Entra ID Global Administrators so they can also manage permissions over Azure resources. > [!TIP] -> Eu acho que o usuário precisa ser Administrador Global no Entra ID para que a chamada de elevação funcione. +> I think the user need to be Global Administrator in Entrad ID for the elevate call to work. + ```bash # Call elevate az rest --method POST --uri "https://management.azure.com/providers/Microsoft.Authorization/elevateAccess?api-version=2016-07-01" @@ -51,22 +58,27 @@ az rest --method POST --uri "https://management.azure.com/providers/Microsoft.Au # Grant a user the Owner role az role assignment create --assignee "" --role "Owner" --scope "/" ``` + ### Microsoft.ManagedIdentity/userAssignedIdentities/federatedIdentityCredentials/write -Esta permissão permite adicionar credenciais federadas a identidades gerenciadas. Por exemplo, conceder acesso ao Github Actions em um repositório a uma identidade gerenciada. Em seguida, permite **acessar qualquer identidade gerenciada definida pelo usuário**. +This permission allows to add Federated credentials to managed identities. E.g. give access to Github Actions in a repo to a managed identity. Then, it allows to **access any user defined managed identity**. + +Example command to give access to a repo in Github to the a managed identity: -Exemplo de comando para conceder acesso a um repositório no Github a uma identidade gerenciada: ```bash # Generic example: az rest --method PUT \ ---uri "https://management.azure.com//subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities//federatedIdentityCredentials/?api-version=2023-01-31" \ ---headers "Content-Type=application/json" \ ---body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:/:ref:refs/heads/","audiences":["api://AzureADTokenExchange"]}}' + --uri "https://management.azure.com//subscriptions//resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities//federatedIdentityCredentials/?api-version=2023-01-31" \ + --headers "Content-Type=application/json" \ + --body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:/:ref:refs/heads/","audiences":["api://AzureADTokenExchange"]}}' # Example with specific data: az rest --method PUT \ ---uri "https://management.azure.com//subscriptions/92913047-10a6-2376-82a4-6f04b2d03798/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/funcGithub-id-913c/federatedIdentityCredentials/CustomGH2?api-version=2023-01-31" \ ---headers "Content-Type=application/json" \ ---body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:carlospolop/azure_func4:ref:refs/heads/main","audiences":["api://AzureADTokenExchange"]}}' + --uri "https://management.azure.com//subscriptions/92913047-10a6-2376-82a4-6f04b2d03798/resourceGroups/Resource_Group_1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/funcGithub-id-913c/federatedIdentityCredentials/CustomGH2?api-version=2023-01-31" \ + --headers "Content-Type=application/json" \ + --body '{"properties":{"issuer":"https://token.actions.githubusercontent.com","subject":"repo:carlospolop/azure_func4:ref:refs/heads/main","audiences":["api://AzureADTokenExchange"]}}' ``` + {{#include ../../../banners/hacktricks-training.md}} + + diff --git a/src/pentesting-cloud/gcp-security/gcp-services/gcp-source-repositories-enum.md b/src/pentesting-cloud/gcp-security/gcp-services/gcp-source-repositories-enum.md index 7f7523936..3f40c6ca6 100644 --- a/src/pentesting-cloud/gcp-security/gcp-services/gcp-source-repositories-enum.md +++ b/src/pentesting-cloud/gcp-security/gcp-services/gcp-source-repositories-enum.md @@ -1,37 +1,38 @@ -# GCP - Enumeração de Repositórios de Código Fonte +# GCP - Source Repositories Enum {{#include ../../../banners/hacktricks-training.md}} -## Informações Básicas +## Basic Information -O Google Cloud Source Repositories é um **serviço de repositório Git privado** totalmente funcional e escalável. Ele é projetado para **hospedar seu código-fonte em um ambiente totalmente gerenciado**, integrando-se perfeitamente com outras ferramentas e serviços do GCP. Oferece um local colaborativo e seguro para as equipes armazenarem, gerenciarem e acompanharem seu código. +Google Cloud Source Repositories is a fully-featured, scalable, **private Git repository service**. It's designed to **host your source code in a fully managed environment**, integrating seamlessly with other GCP tools and services. It offers a collaborative and secure place for teams to store, manage, and track their code. -As principais características do Cloud Source Repositories incluem: +Key features of Cloud Source Repositories include: -1. **Hospedagem Git Totalmente Gerenciada**: Oferece a funcionalidade familiar do Git, o que significa que você pode usar comandos e fluxos de trabalho Git regulares. -2. **Integração com Serviços do GCP**: Integra-se com outros serviços do GCP, como Cloud Build, Pub/Sub e App Engine, para rastreabilidade de ponta a ponta do código à implantação. -3. **Repositórios Privados**: Garante que seu código seja armazenado de forma segura e privada. Você pode controlar o acesso usando funções do Cloud Identity and Access Management (IAM). -4. **Análise de Código Fonte**: Trabalha com outras ferramentas do GCP para fornecer análise automatizada do seu código-fonte, identificando problemas potenciais como bugs, vulnerabilidades ou más práticas de codificação. -5. **Ferramentas de Colaboração**: Suporta codificação colaborativa com ferramentas como solicitações de mesclagem, comentários e revisões. -6. **Suporte a Espelhos**: Permite conectar o Cloud Source Repositories com repositórios hospedados no GitHub ou Bitbucket, possibilitando a sincronização automática e fornecendo uma visão unificada de todos os seus repositórios. +1. **Fully Managed Git Hosting**: Offers the familiar functionality of Git, meaning you can use regular Git commands and workflows. +2. **Integration with GCP Services**: Integrates with other GCP services like Cloud Build, Pub/Sub, and App Engine for end-to-end traceability from code to deployment. +3. **Private Repositories**: Ensures your code is stored securely and privately. You can control access using Cloud Identity and Access Management (IAM) roles. +4. **Source Code Analysis**: Works with other GCP tools to provide automated analysis of your source code, identifying potential issues like bugs, vulnerabilities, or bad coding practices. +5. **Collaboration Tools**: Supports collaborative coding with tools like merge requests, comments, and reviews. +6. **Mirror Support**: Allows you to connect Cloud Source Repositories with repositories hosted on GitHub or Bitbucket, enabling automatic synchronization and providing a unified view of all your repositories. -### Informações OffSec +### OffSec information -- A configuração dos repositórios de código fonte dentro de um projeto terá uma **Conta de Serviço** usada para publicar mensagens do Cloud Pub/Sub. A padrão utilizada é a **Compute SA**. No entanto, **não acho que seja possível roubar seu token** dos Repositórios de Código Fonte, pois está sendo executado em segundo plano. -- Para ver o código dentro do console web do GCP Cloud Source Repositories ([https://source.cloud.google.com/](https://source.cloud.google.com/)), você precisa que o código esteja **dentro do branch master por padrão**. -- Você também pode **criar um repositório Cloud espelho** apontando para um repositório do **Github** ou **Bitbucket** (dando acesso a essas plataformas). -- É possível **codificar e depurar de dentro do GCP**. -- Por padrão, os Repositórios de Código Fonte **impedem que chaves privadas sejam enviadas em commits**, mas isso pode ser desativado. +- The source repositories configuration inside a project will have a **Service Account** used to publishing Cloud Pub/Sub messages. The default one used is the **Compute SA**. However, **I don't think it's possible steal its token** from Source Repositories as it's being executed in the background. +- To see the code inside the GCP Cloud Source Repositories web console ([https://source.cloud.google.com/](https://source.cloud.google.com/)), you need the code to be **inside master branch by default**. +- You can also **create a mirror Cloud Repository** pointing to a repo from **Github** or **Bitbucket** (giving access to those platforms). +- It's possible to **code & debug from inside GCP**. +- By default, Source Repositories **prevents private keys to be pushed in commits**, but this can be disabled. -### Abrir no Cloud Shell +### Open In Cloud Shell -É possível abrir o repositório no Cloud Shell, um prompt como este aparecerá: +It's possible to open the repository in Cloud Shell, a prompt like this one will appear:
-Isso permitirá que você codifique e depure no Cloud Shell (o que pode comprometer o cloudshell). +This will allow you to code and debug in Cloud Shell (which could get cloudshell compromised). + +### Enumeration -### Enumeração ```bash # Repos enumeration gcloud source repos list #Get names and URLs @@ -42,7 +43,7 @@ gcloud source repos get-iam-policy gcloud source repos clone gcloud source repos get-iam-policy ... git add & git commit -m ... -git push --set-upstream origin master +git push --set-upstream origin $BRANCH git push -u origin master # Access via git @@ -50,16 +51,20 @@ git push -u origin master git clone ssh://username@domain.com@source.developers.google.com:2022/p//r/ git add, commit, push... ``` -### Escalação de Privilégios & Pós Exploração + +### Privilege Escalation & Post Exploitation {{#ref}} ../gcp-privilege-escalation/gcp-sourcerepos-privesc.md {{#endref}} -### Enumeração Não Autenticada +### Unauthenticated Enum {{#ref}} ../gcp-unauthenticated-enum-and-access/gcp-source-repositories-unauthenticated-enum.md {{#endref}} {{#include ../../../banners/hacktricks-training.md}} + + +