mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
141 lines
6.1 KiB
Markdown
141 lines
6.1 KiB
Markdown
# Pentesting gRPC-Web
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|
|
|
|
## **Manipulation von gRPC-Web-Payloads**
|
|
|
|
gRPC-Web verwendet Content-Type: `application/grpc-web-text` in Anfragen, was eine Art protobuf in base64-kodierter Form ist. Sie können das Tool [gprc-coder](https://github.com/nxenon/grpc-pentest-suite) verwenden, und Sie können auch seine [Burp Suite Extension](https://github.com/nxenon/grpc-pentest-suite) installieren.
|
|
|
|
### **Manuell mit dem gGRPC Coder Tool**
|
|
|
|
1. Zuerst dekodieren Sie den Payload:
|
|
```bash
|
|
echo "AAAAABYSC0FtaW4gTmFzaXJpGDY6BVhlbm9u" | python3 grpc-coder.py --decode --type grpc-web-text | protoscope > out.txt
|
|
```
|
|
2. Bearbeiten Sie den Inhalt der decodierten Nutzlast
|
|
```
|
|
nano out.txt
|
|
2: {"Amin Nasiri Xenon GRPC"}
|
|
3: 54
|
|
7: {"<script>alert(origin)</script>"}
|
|
```
|
|
3. Kodieren Sie die neue Payload
|
|
```bash
|
|
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
|
|
```
|
|
4. Verwenden Sie die Ausgabe im Burp-Interceptor:
|
|
```
|
|
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+
|
|
```
|
|
### **Handbuch mit gRPC-Web Coder Burp Suite Erweiterung**
|
|
|
|
Sie können die gRPC-Web Coder Burp Suite Erweiterung im [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite) verwenden, was einfacher ist. Sie können die Installations- und Nutzungshinweise in seinem Repository lesen.
|
|
|
|
## **Analyse von gRPC-Web Javascript-Dateien**
|
|
|
|
Es gibt mindestens eine Javascript-Datei in jeder gRPC-Web-Anwendung. Sie können die Datei analysieren, um neue Nachrichten, Endpunkte und Dienste zu finden. Versuchen Sie, das Tool [gRPC-Scan](https://github.com/nxenon/grpc-pentest-suite) zu verwenden.
|
|
|
|
1. Laden Sie die Javascript gRPC-Web Datei herunter
|
|
2. Scannen Sie sie mit grpc-scan.py:
|
|
```bash
|
|
python3 grpc-scan.py --file main.js
|
|
```
|
|
3. Analysiere die Ausgabe und teste die neuen Endpunkte und neuen Dienste:
|
|
```
|
|
Output:
|
|
Found Endpoints:
|
|
/grpc.gateway.testing.EchoService/Echo
|
|
/grpc.gateway.testing.EchoService/EchoAbort
|
|
/grpc.gateway.testing.EchoService/NoOp
|
|
/grpc.gateway.testing.EchoService/ServerStreamingEcho
|
|
/grpc.gateway.testing.EchoService/ServerStreamingEchoAbort
|
|
|
|
Found Messages:
|
|
|
|
grpc.gateway.testing.EchoRequest:
|
|
+------------+--------------------+--------------+
|
|
| Field Name | Field Type | Field Number |
|
|
+============+====================+==============+
|
|
| Message | Proto3StringField | 1 |
|
|
+------------+--------------------+--------------+
|
|
| Name | Proto3StringField | 2 |
|
|
+------------+--------------------+--------------+
|
|
| Age | Proto3IntField | 3 |
|
|
+------------+--------------------+--------------+
|
|
| IsAdmin | Proto3BooleanField | 4 |
|
|
+------------+--------------------+--------------+
|
|
| Weight | Proto3FloatField | 5 |
|
|
+------------+--------------------+--------------+
|
|
| Test | Proto3StringField | 6 |
|
|
+------------+--------------------+--------------+
|
|
| Test2 | Proto3StringField | 7 |
|
|
+------------+--------------------+--------------+
|
|
| Test3 | Proto3StringField | 16 |
|
|
+------------+--------------------+--------------+
|
|
| Test4 | Proto3StringField | 20 |
|
|
+------------+--------------------+--------------+
|
|
|
|
grpc.gateway.testing.EchoResponse:
|
|
+--------------+--------------------+--------------+
|
|
| Field Name | Field Type | Field Number |
|
|
+==============+====================+==============+
|
|
| Message | Proto3StringField | 1 |
|
|
+--------------+--------------------+--------------+
|
|
| Name | Proto3StringField | 2 |
|
|
+--------------+--------------------+--------------+
|
|
| Age | Proto3IntField | 3 |
|
|
+--------------+--------------------+--------------+
|
|
| IsAdmin | Proto3BooleanField | 4 |
|
|
+--------------+--------------------+--------------+
|
|
| Weight | Proto3FloatField | 5 |
|
|
+--------------+--------------------+--------------+
|
|
| Test | Proto3StringField | 6 |
|
|
+--------------+--------------------+--------------+
|
|
| Test2 | Proto3StringField | 7 |
|
|
+--------------+--------------------+--------------+
|
|
| Test3 | Proto3StringField | 16 |
|
|
+--------------+--------------------+--------------+
|
|
| Test4 | Proto3StringField | 20 |
|
|
+--------------+--------------------+--------------+
|
|
| MessageCount | Proto3IntField | 8 |
|
|
+--------------+--------------------+--------------+
|
|
|
|
grpc.gateway.testing.ServerStreamingEchoRequest:
|
|
+-----------------+-------------------+--------------+
|
|
| Field Name | Field Type | Field Number |
|
|
+=================+===================+==============+
|
|
| Message | Proto3StringField | 1 |
|
|
+-----------------+-------------------+--------------+
|
|
| MessageCount | Proto3IntField | 2 |
|
|
+-----------------+-------------------+--------------+
|
|
| MessageInterval | Proto3IntField | 3 |
|
|
+-----------------+-------------------+--------------+
|
|
|
|
grpc.gateway.testing.ServerStreamingEchoResponse:
|
|
+------------+-------------------+--------------+
|
|
| Field Name | Field Type | Field Number |
|
|
+============+===================+==============+
|
|
| Message | Proto3StringField | 1 |
|
|
+------------+-------------------+--------------+
|
|
|
|
grpc.gateway.testing.ClientStreamingEchoRequest:
|
|
+------------+-------------------+--------------+
|
|
| Field Name | Field Type | Field Number |
|
|
+============+===================+==============+
|
|
| Message | Proto3StringField | 1 |
|
|
+------------+-------------------+--------------+
|
|
|
|
grpc.gateway.testing.ClientStreamingEchoResponse:
|
|
+--------------+----------------+--------------+
|
|
| Field Name | Field Type | Field Number |
|
|
+==============+================+==============+
|
|
| MessageCount | Proto3IntField | 1 |
|
|
+--------------+----------------+--------------+
|
|
```
|
|
## Referenzen
|
|
|
|
- [Hacking into gRPC-Web Artikel von Amin Nasiri](https://infosecwriteups.com/hacking-into-grpc-web-a54053757a45)
|
|
- [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite)
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|