Az - Azure App Service & Function Apps

Sostieni HackTricks

Informazioni di base sul servizio App

Dalla documentazione: Azure App Service è un servizio basato su HTTP per l'hosting di applicazioni web, API REST e back-end mobili. Puoi sviluppare nella tua lingua preferita, che sia .NET, .NET Core, Java, Ruby, Node.js, PHP o Python. Le applicazioni vengono eseguite e scalate facilmente sia in ambienti basati su Windows che su Linux.

Ogni app viene eseguita all'interno di un sandbox, ma l'isolamento dipende dai piani del servizio App

  • Le app nei livelli Free e Shared vengono eseguite su VM condivise

  • Le app nei livelli Standard e Premium vengono eseguite su VM dedicate

Nota che nessuno di questi isolamenti impedisce altre comuni vulnerabilità web (come il caricamento di file o le iniezioni). E se viene utilizzata un'identità di gestione, potrebbe essere in grado di compromettere i suoi permessi.

Enumerazione

# List webapps
az webapp list

## Less information
az webapp list --query "[].{hostName: defaultHostName, state: state, name: name, resourcegroup: resourceGroup}"

# Get access restrictions
az webapp config access-restriction show --resource-group <res-group> -n <name>

# Remove access restrictions
az webapp config access-restriction remove --resource-group <res-group> -n <name> --rule-name <rule-name>

# Get snapshots
az webapp config snapshot list --resource-group <res-group> -n <name>

# Restore snapshot
az webapp config snapshot restore -g <res-group> -n <name> --time 2018-12-11T23:34:16.8388367

# Restart webapp
az webapp restart --name <name> --resource-group <res-group>
# Get App Services and Function Apps
Get-AzWebApp
# Get only App Services
Get-AzWebApp | ?{$_.Kind -notmatch "functionapp"}

#!/bin/bash

# Get all App Service and Function Apps

# Define Azure subscription ID
azure_subscription="your_subscription_id"

# Log in to Azure
az login

# Select Azure subscription
az account set --subscription $azure_subscription

# Get all App Services in the specified subscription
list_app_services=$(az appservice list --query "[].{appServiceName: name, group: resourceGroup}" -o tsv)

# Iterate over each App Service
echo "$list_app_services" | while IFS=$'\t' read -r appServiceName group; do
# Get the type of the App Service
service_type=$(az appservice show --name $appServiceName --resource-group $group --query "kind" -o tsv)

# Check if it is a Function App and print its name
if [ "$service_type" == "functionapp" ]; then
echo "Function App Name: $appServiceName"
fi
done

Ottenere le credenziali e accedere al codice dell'applicazione web

# Get connection strings that could contain credentials (with DBs for example)
az webapp config connection-string list --name <name> --resource-group <res-group>
## Check how to use the DBs connection strings in the SQL page

# Get credentials to access the code and DB credentials if configured.
az webapp deployment list-publishing-profiles --resource-group <res-group> -n <name>


# Get git URL to access the code
az webapp deployment source config-local-git --resource-group <res-group> -n <name>

# Access/Modify the code via git
git clone 'https://<username>:<password>@name.scm.azurewebsites.net/repo-name.git'
## In my case the username was: $nameofthewebapp and the password some random chars
## If you change the code and do a push, the app is automatically redeployed

Accesso al container Docker con la webapp tramite ssh:

# Get ssh session
az webapp create-remote-connection --subscription <SUBSCRIPTION-ID> --resource-group <RG-NAME> -n <APP-SERVICE-NAME>

## If successfull you will get a message such as:
#Verifying if app is running....
#App is running. Trying to establish tunnel connection...
#Opening tunnel on port: 39895
#SSH is available { username: root, password: Docker! }

## So from that machine ssh into that port (you might need generate a new ssh session to the jump host)
ssh root@127.0.0.1 -p 39895

Informazioni di base sulle App di Funzione

Azure Functions è una soluzione serverless che ti consente di scrivere meno codice, mantenere meno infrastrutture e risparmiare sui costi. Invece di preoccuparti di distribuire e mantenere server, l'infrastruttura cloud fornisce tutte le risorse aggiornate necessarie per mantenere in esecuzione le tue applicazioni.

Nel portale di Azure, l'integrazione tra Azure Functions e Azure API Management è facilitata, consentendo agli endpoint delle funzioni trigger HTTP di essere esposti come API REST. Le API esposte in questo modo sono descritte utilizzando una definizione OpenAPI, che fornisce un'interfaccia standard e indipendente dal linguaggio per le API RESTful.

Le App di Funzione supportano le Identità Gestite.

Inoltre, un'app di funzione potrebbe avere determinati endpoint che richiedono un certo livello di autenticazione, come "admin" o "anonymous". Un attaccante potrebbe cercare di accedere agli endpoint consentiti agli utenti anonimi per eludere le restrizioni e ottenere accesso a dati o funzionalità sensibili.

Enumerazione

# Get only Function Apps
Get-AzFunctionApp

Riferimenti

Sostieni HackTricks

Last updated