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 b7af8f932..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 -자세한 정보는 다음을 확인하세요: +Fore more information check: {{#ref}} ../az-services/az-azuread.md @@ -12,38 +12,45 @@ ### Microsoft.Authorization/roleAssignments/write -이 권한은 특정 범위에 대해 주체에게 역할을 할당할 수 있게 하며, 공격자가 자신에게 더 높은 권한의 역할을 할당하여 권한을 상승시킬 수 있게 합니다: +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 -이 권한은 역할에 의해 부여된 권한을 수정할 수 있게 하여, 공격자가 자신이 할당한 역할에 더 많은 권한을 부여함으로써 권한 상승을 할 수 있게 합니다. +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**: -다음 **내용**으로 `role.json` 파일을 생성합니다: ```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/"] } ``` -그런 다음 이전 정의를 호출하여 역할 권한을 업데이트합니다: + +Then update the role permissions with the previous definition calling: + ```bash az role definition update --role-definition role.json ``` + ### Microsoft.Authorization/elevateAccess/action -이 권한은 권한을 상승시키고 Azure 리소스에 대한 권한을 모든 주체에게 할당할 수 있도록 허용합니다. 이는 Entra ID Global Administrators에게 부여되어 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] -> elevate 호출이 작동하려면 사용자가 Entra ID의 Global Administrator여야 한다고 생각합니다. +> 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 -이 권한은 관리되는 ID에 연합 자격 증명을 추가할 수 있게 해줍니다. 예를 들어, 관리되는 ID에 대한 리포지토리의 Github Actions에 대한 액세스를 부여합니다. 그런 다음, **사용자가 정의한 관리되는 ID에 액세스할 수 있게 해줍니다**. +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: -Github의 리포지토리에 관리되는 ID에 대한 액세스를 부여하는 예제 명령: ```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 fb7b3ad5c..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 - 소스 리포지토리 열거 +# GCP - Source Repositories Enum {{#include ../../../banners/hacktricks-training.md}} -## 기본 정보 +## Basic Information -Google Cloud Source Repositories는 완전한 기능을 갖춘 확장 가능한 **개인 Git 리포지토리 서비스**입니다. 이는 **완전 관리되는 환경에서 소스 코드를 호스팅하도록 설계되었으며**, 다른 GCP 도구 및 서비스와 원활하게 통합됩니다. 팀이 코드를 저장, 관리 및 추적할 수 있는 협업적이고 안전한 장소를 제공합니다. +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. -Cloud Source Repositories의 주요 기능은 다음과 같습니다: +Key features of Cloud Source Repositories include: -1. **완전 관리되는 Git 호스팅**: Git의 친숙한 기능을 제공하므로 일반 Git 명령 및 워크플로를 사용할 수 있습니다. -2. **GCP 서비스와의 통합**: Cloud Build, Pub/Sub 및 App Engine과 같은 다른 GCP 서비스와 통합되어 코드에서 배포까지의 종단 간 추적성을 제공합니다. -3. **개인 리포지토리**: 코드가 안전하고 비공식적으로 저장되도록 보장합니다. Cloud Identity and Access Management (IAM) 역할을 사용하여 액세스를 제어할 수 있습니다. -4. **소스 코드 분석**: 다른 GCP 도구와 함께 작동하여 소스 코드의 자동 분석을 제공하며, 버그, 취약점 또는 나쁜 코딩 관행과 같은 잠재적인 문제를 식별합니다. -5. **협업 도구**: 병합 요청, 댓글 및 리뷰와 같은 도구를 통해 협업 코딩을 지원합니다. -6. **미러 지원**: Cloud Source Repositories를 GitHub 또는 Bitbucket에 호스팅된 리포지토리와 연결할 수 있어 자동 동기화가 가능하며 모든 리포지토리에 대한 통합된 뷰를 제공합니다. +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. -### OffSec 정보 +### OffSec information -- 프로젝트 내의 소스 리포지토리 구성은 Cloud Pub/Sub 메시지를 게시하는 데 사용되는 **서비스 계정**을 가집니다. 기본적으로 사용되는 것은 **Compute SA**입니다. 그러나 **소스 리포지토리에서 그 토큰을 훔치는 것은 불가능하다고 생각합니다**. 이는 백그라운드에서 실행되고 있습니다. -- GCP Cloud Source Repositories 웹 콘솔 ([https://source.cloud.google.com/](https://source.cloud.google.com/))에서 코드를 보려면 코드가 **기본적으로 마스터 브랜치에 있어야** 합니다. -- **Github** 또는 **Bitbucket**의 리포지토리를 가리키는 **미러 Cloud Repository**를 **생성할 수 있습니다** (이 플랫폼에 대한 액세스를 제공). -- **GCP 내부에서 코드 작성 및 디버깅**이 가능합니다. -- 기본적으로 Source Repositories는 **개인 키가 커밋에 푸시되는 것을 방지**하지만, 이는 비활성화할 수 있습니다. +- 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. -### 클라우드 셸에서 열기 +### Open In Cloud Shell -클라우드 셸에서 리포지토리를 열 수 있으며, 다음과 같은 프롬프트가 나타납니다: +It's possible to open the repository in Cloud Shell, a prompt like this one will appear:
-이를 통해 클라우드 셸에서 코드 작성 및 디버깅이 가능하며 (cloudshell이 손상될 수 있음), +This will allow you to code and debug in Cloud Shell (which could get cloudshell compromised). + +### Enumeration -### 열거 ```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... ``` -### 권한 상승 및 포스트 익스플로잇 + +### Privilege Escalation & Post Exploitation {{#ref}} ../gcp-privilege-escalation/gcp-sourcerepos-privesc.md {{#endref}} -### 인증되지 않은 열거 +### Unauthenticated Enum {{#ref}} ../gcp-unauthenticated-enum-and-access/gcp-source-repositories-unauthenticated-enum.md {{#endref}} {{#include ../../../banners/hacktricks-training.md}} + + +