# Pentesting gRPC-Web
{% hint style="success" %}
Learn & practice AWS Hacking:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
Learn & practice GCP Hacking: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
Support HackTricks
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
* **Join the** ๐ฌ [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** ๐ฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
{% endhint %}
## **Manipulating gRPC-Web Payloads**
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)๋ ์ค์นํ ์ ์์ต๋๋ค.
### **Manual with gGRPC Coder Tool**
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: {""}
```
3. ์๋ก์ด ํ์ด๋ก๋ ์ธ์ฝ๋ฉ
```bash
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
```
4. Burp ์ธํฐ์
ํฐ์์ ์ถ๋ ฅ ์ฌ์ฉ:
```
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+
```
### **Manual with 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 ์๋ฐ์คํฌ๋ฆฝํธ ํ์ผ ๋ถ์**
๋ชจ๋ gRPC-Web ์ ํ๋ฆฌ์ผ์ด์
์๋ ์ต์ํ ํ๋์ ์๋ฐ์คํฌ๋ฆฝํธ ํ์ผ์ด ์์ต๋๋ค. ํ์ผ์ ๋ถ์ํ์ฌ ์๋ก์ด ๋ฉ์์ง, ์๋ํฌ์ธํธ ๋ฐ ์๋น์ค๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค. [gRPC-Scan](https://github.com/nxenon/grpc-pentest-suite) ๋๊ตฌ๋ฅผ ์ฌ์ฉํด ๋ณด์ธ์.
1. ์๋ฐ์คํฌ๋ฆฝํธ 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 |
+--------------+----------------+--------------+
```
## References
* [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)
{% hint style="success" %}
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)\
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ: [**HackTricks Training GCP Red Team Expert (GRTE)**](https://training.hacktricks.xyz/courses/grte)
HackTricks ์ง์ํ๊ธฐ
* [**๊ตฌ๋
๊ณํ**](https://github.com/sponsors/carlospolop) ํ์ธํ๊ธฐ!
* **๐ฌ [**Discord ๊ทธ๋ฃน**](https://discord.gg/hRep4RUj7f) ๋๋ [**ํ
๋ ๊ทธ๋จ ๊ทธ๋ฃน**](https://t.me/peass)์ ์ฐธ์ฌํ๊ฑฐ๋ **Twitter** ๐ฆ [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**๋ฅผ ํ๋ก์ฐํ์ธ์.**
* **[**HackTricks**](https://github.com/carlospolop/hacktricks) ๋ฐ [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํ์ ๊ณต์ ํ์ธ์.**
{% endhint %}