Az - Azure App Service & Function Apps

Az - Azure App Service & Function Apps

htARTE (HackTricks AWS Red Team Expert)에서 제로에서 영웅까지 AWS 해킹 배우기를 배워보세요!

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>

Az Powershell

Az CLI

Python

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

PowerShell

Bash

Node.js

Ruby

Java

C\#

Go

REST

HTTP

Curl

{% tab title="PowerShell

# Get App Services and Function Apps
Get-AzWebApp
# Get only App Services
Get-AzWebApp | ?{$_.Kind -notmatch "functionapp"}

```bash #!/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

#### 자격 증명 획득 및 웹 앱 코드에 액세스하기

To obtain credentials and gain access to the web app code, you can follow these steps:

1. Use reconnaissance techniques to gather information about the target Azure App Service.
2. Identify potential vulnerabilities or misconfigurations in the Azure App Service.
3. Exploit any identified vulnerabilities to gain unauthorized access to the Azure App Service.
4. Once access is obtained, navigate to the web app code directory to view and analyze the code.

By following these steps, you can obtain the necessary credentials and gain access to the web app code for further analysis and exploitation.
```bash
# 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

SSH를 통한 웹 앱의 Docker 컨테이너에 액세스하기:

ssh -p 2222 root@<app_name>.scm.azurewebsites.net

Replace <app_name> with the name of your Azure App Service.

Azure App Service의 이름으로 <app_name>을(를) 대체하십시오.

# 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은 관리되는 ID를 지원합니다.

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

열거(Enumeration)

# Get only Function Apps
Get-AzFunctionApp

참고 자료

htARTE (HackTricks AWS Red Team Expert)를 통해 제로에서 영웅까지 AWS 해킹을 배워보세요!

HackTricks를 지원하는 다른 방법:

最終更新