mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
141 lines
6.7 KiB
Markdown
141 lines
6.7 KiB
Markdown
# Pentesting gRPC-Web
|
||
|
||
{{#include ../banners/hacktricks-training.md}}
|
||
|
||
## **Manipulating gRPC-Web Payloads**
|
||
|
||
gRPC-Web χρησιμοποιεί το Content-Type: `application/grpc-web-text` σε αιτήματα, το οποίο είναι μια μορφή protobuf σε κωδικοποιημένη μορφή base64. Μπορείτε να χρησιμοποιήσετε το [gprc-coder](https://github.com/nxenon/grpc-pentest-suite) εργαλείο, και μπορείτε επίσης να εγκαταστήσετε την [Burp Suite Extension](https://github.com/nxenon/grpc-pentest-suite).
|
||
|
||
### **Manual with gGRPC Coder Tool**
|
||
|
||
1. Πρώτα αποκωδικοποιήστε το payload:
|
||
```bash
|
||
echo "AAAAABYSC0FtaW4gTmFzaXJpGDY6BVhlbm9u" | python3 grpc-coder.py --decode --type grpc-web-text | protoscope > out.txt
|
||
```
|
||
2. Επεξεργαστείτε το περιεχόμενο του αποκωδικοποιημένου φορτίου
|
||
```
|
||
nano out.txt
|
||
2: {"Amin Nasiri Xenon GRPC"}
|
||
3: 54
|
||
7: {"<script>alert(origin)</script>"}
|
||
```
|
||
3. Κωδικοποιήστε το νέο payload
|
||
```bash
|
||
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
|
||
```
|
||
4. Χρησιμοποιήστε την έξοδο στον Burp interceptor:
|
||
```
|
||
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+
|
||
```
|
||
### **Εγχειρίδιο με gRPC-Web Coder Burp Suite Extension**
|
||
|
||
Μπορείτε να χρησιμοποιήσετε το gRPC-Web Coder Burp Suite Extension στο [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite) που είναι πιο εύκολο. Μπορείτε να διαβάσετε τις οδηγίες εγκατάστασης και χρήσης στο αποθετήριο του.
|
||
|
||
## **Ανάλυση gRPC-Web Javascript Αρχείων**
|
||
|
||
Υπάρχει τουλάχιστον ένα αρχείο Javascript σε κάθε εφαρμογή gRPC-Web. Μπορείτε να αναλύσετε το αρχείο για να βρείτε νέα μηνύματα, endpoints και υπηρεσίες. Δοκιμάστε να χρησιμοποιήσετε το εργαλείο [gRPC-Scan](https://github.com/nxenon/grpc-pentest-suite).
|
||
|
||
1. Κατεβάστε το Javascript gRPC-Web Αρχείο
|
||
2. Σαρώστε το με το grpc-scan.py:
|
||
```bash
|
||
python3 grpc-scan.py --file main.js
|
||
```
|
||
3. Αναλύστε την έξοδο και δοκιμάστε τα νέα endpoints και τις νέες υπηρεσίες:
|
||
```
|
||
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 |
|
||
+--------------+----------------+--------------+
|
||
```
|
||
## Αναφορές
|
||
|
||
- [Hacking into gRPC-Web Article by 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}}
|