Az - Azure App Service & Function Apps

Support HackTricks

App Service Basic Information

From the docs: _Azure App Service_는 웹 애플리케이션, REST API 및 모바일 백엔드를 호스팅하기 위한 HTTP 기반 서비스입니다. .NET, .NET Core, Java, Ruby, Node.js, PHP 또는 Python 등 좋아하는 언어로 개발할 수 있습니다. 애플리케이션은 Windows 및 Linux 기반 환경에서 쉽게 실행되고 확장됩니다.

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

  • 무료 및 공유 계층의 앱은 공유 VM에서 실행됩니다.

  • 표준 및 프리미엄 계층의 앱은 전용 VM에서 실행됩니다.

이러한 격리파일 업로드주입과 같은 다른 일반적인 웹 취약점방지하지 않습니다. 그리고 관리 ID가 사용되는 경우, 권한을 손상시킬 수 있습니다.

Enumeration

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

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

열거

# Get only Function Apps
Get-AzFunctionApp

References

HackTricks 지원하기

Last updated