Az - Azure App Service & Function Apps

支持 HackTricks

应用服务基本信息

来自文档: Azure 应用服务 是一个基于 HTTP 的服务,用于托管 web 应用程序、REST API 和移动后端。您可以使用您喜欢的语言进行开发,无论是 .NET、.NET Core、Java、Ruby、Node.js、PHP 还是 Python。应用程序可以在 Windows 和 Linux 环境中轻松运行和扩展。

每个应用程序都在沙箱内运行,但隔离取决于应用服务计划

  • 免费和共享层的应用程序运行在共享虚拟机上

  • 标准和高级层的应用程序运行在专用虚拟机上

请注意,这些隔离 并不能防止 其他常见的 网络漏洞(例如文件上传或注入)。如果使用了 管理身份,则可能会 危及其权限

枚举

# 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>

获取凭据并访问 webapp 代码

# 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 访问 webapp 的 Docker 容器:

# 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