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プランに依存します。

  • 無料および共有プランのアプリは共有VM上で実行されます。

  • スタンダードおよびプレミアムプランのアプリは専用VM上で実行されます。

これらの隔離は、ファイルアップロードインジェクションなどの一般的なウェブ脆弱性防ぐことはありません。また、管理アイデンティティが使用されている場合、その権限を侵害する可能性があります。

列挙

# 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

Webapp経由で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」など、特定のレベルの認証を必要とするエンドポイントがある場合があります。 攻撃者は、制限を回避し、機密データや機能にアクセスするためにanonymous allowed endpointsにアクセスしようとする可能性があります。

列挙

# Get only Function Apps
Get-AzFunctionApp

References

HackTricksをサポートする

Last updated