Az - Azure App Service & Function Apps

HackTricks 지원하기

App Service 기본 정보

문서에서: _Azure App Service_는 웹 애플리케이션, REST API 및 모바일 백엔드를 호스팅하기 위한 HTTP 기반 서비스입니다. .NET, .NET Core, Java, Ruby, Node.js, PHP 또는 Python과 같은 즐겨 사용하는 언어로 개발할 수 있습니다. 응용 프로그램은 Windows 및 Linux 기반 환경에서 쉽게 실행 및 확장됩니다.

각 앱은 샌드박스 내에서 실행되지만, 격리는 App Service 요금제에 따라 다릅니다.

  • Free 및 Shared 티어의 앱은 공유 VM에서 실행됩니다.

  • Standard 및 Premium 티어의 앱은 전용 VM에서 실행됩니다.

주의: 이러한 격리 중 어느 것도 일반적인 웹 취약점 (예: 파일 업로드 또는 인젝션)을 방지하지 않습니다. 그리고 관리 ID가 사용된 경우, 해당 권한을 침해할 수 있습니다.

열거

# 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

자격 증명 획득 및 웹앱 코드 액세스 얻기

# 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

웹앱을 통한 Docker 컨테이너에 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

Function Apps 기본 정보

Azure Functions은 서버리스 솔루션이며, 더 적은 코드를 작성하고 더 적은 인프라를 유지보수하며 비용을 절약할 수 있습니다. 서버를 배포하고 유지하는 것을 걱정할 필요 없이, 클라우드 인프라는 응용 프로그램을 계속 실행하는 데 필요한 모든 최신 리소스를 제공합니다.

Azure 포털에서 Azure Functions와 Azure API Management 간의 통합이 용이하며, HTTP 트리거 함수 엔드포인트를 REST API로 노출할 수 있습니다. 이 방식으로 노출된 API는 OpenAPI 정의를 사용하여 설명되며, RESTful API에 대한 표준, 언어 중립적 인터페이스를 제공합니다.

Function Apps는 관리 식별자를 지원합니다.

또한 Function App에는 "관리자" 또는 "익명"과 같은 특정 수준의 인증이 필요한 특정 엔드포인트가 있을 수 있습니다. 공격자는 익명으로 허용된 엔드포인트에 액세스하여 제한을 우회하고 민감한 데이터나 기능에 액세스할 수 있습니다.

열거

# Get only Function Apps
Get-AzFunctionApp

참고 자료

HackTricks 지원

Last updated