hacktricks/src/pentesting-web/grpc-web-pentest.md

141 lines
6.0 KiB
Markdown

# Pentesting gRPC-Web
{{#include ../banners/hacktricks-training.md}}
## **Manipulasie van gRPC-Web Payloads**
gRPC-Web gebruik Content-Type: `application/grpc-web-text` in versoeke wat 'n soort protobuf in base64-gecodeerde vorm is, jy kan die [gprc-coder](https://github.com/nxenon/grpc-pentest-suite) hulpmiddel gebruik, en jy kan ook sy [Burp Suite Extension](https://github.com/nxenon/grpc-pentest-suite) installeer.
### **Handmatig met gGRPC Coder Tool**
1. Eerstens decode die payload:
```bash
echo "AAAAABYSC0FtaW4gTmFzaXJpGDY6BVhlbm9u" | python3 grpc-coder.py --decode --type grpc-web-text | protoscope > out.txt
```
2. Wysig die inhoud van die gedecodeerde las
```
nano out.txt
2: {"Amin Nasiri Xenon GRPC"}
3: 54
7: {"<script>alert(origin)</script>"}
```
3. Kodifiseer die nuwe payload
```bash
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
```
4. Gebruik uitvoer in Burp-interceptor:
```
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+
```
### **Handleiding met gRPC-Web Coder Burp Suite Uitbreiding**
Jy kan gRPC-Web Coder Burp Suite Uitbreiding gebruik in [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite) wat makliker is. Jy kan die installasie en gebruiksaanwysings in sy repo lees.
## **Analiseer gRPC-Web Javascript Lêers**
Daar is ten minste een Javascript-lêer in elke gRPC-Web toepassing. Jy kan die lêer analiseer om nuwe boodskappe, eindpunte en dienste te vind. Probeer om die [gRPC-Scan](https://github.com/nxenon/grpc-pentest-suite) hulpmiddel te gebruik.
1. Laai die Javascript gRPC-Web Lêer af
2. Skandeer dit met grpc-scan.py:
```bash
python3 grpc-scan.py --file main.js
```
3. Analiseer uitset en toets die nuwe eindpunte en nuwe 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 |
+--------------+----------------+--------------+
```
## Verwysings
- [Hacking into gRPC-Web Artikel deur 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}}