mirror of
https://github.com/HackTricks-wiki/hacktricks.git
synced 2025-10-10 18:36:50 +00:00
141 lines
6.4 KiB
Markdown
141 lines
6.4 KiB
Markdown
# Pentesting gRPC-Web
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|
|
|
|
## **gRPC-Webペイロードの操作**
|
|
|
|
gRPC-WebはリクエストでContent-Type: `application/grpc-web-text`を使用します。これは、base64エンコードされたprotobufの一種です。[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. 新しいペイロードをエンコードする
|
|
```bash
|
|
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
|
|
```
|
|
4. Burpインターセプターで出力を使用する:
|
|
```
|
|
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+
|
|
```
|
|
### **gRPC-Web Coder Burp Suite Extensionのマニュアル**
|
|
|
|
[gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite)でgRPC-Web Coder Burp Suite Extensionを使用できます。これはより簡単です。インストールと使用の手順はリポジトリで読むことができます。
|
|
|
|
## **gRPC-Web Javascriptファイルの分析**
|
|
|
|
すべてのgRPC-Webアプリケーションには少なくとも1つの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 |
|
|
+--------------+----------------+--------------+
|
|
```
|
|
## 参考文献
|
|
|
|
- [Amin NasiriによるgRPC-Webへのハッキング記事](https://infosecwriteups.com/hacking-into-grpc-web-a54053757a45)
|
|
- [gRPC-Webペンテストスイート](https://github.com/nxenon/grpc-pentest-suite)
|
|
|
|
{{#include ../banners/hacktricks-training.md}}
|