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

162 lines
8.1 KiB
Markdown
Raw Normal View History

# Pentesting gRPC-Web
2024-02-10 13:11:20 +00:00
{% hint style="success" %}
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2024-02-10 13:11:20 +00:00
<details>
2024-02-10 13:11:20 +00:00
<summary>Support HackTricks</summary>
2024-02-10 13:11:20 +00:00
* 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.
2024-02-10 13:11:20 +00:00
</details>
{% endhint %}
2024-02-10 13:11:20 +00:00
## **Manipulacija gRPC-Web Payloads**
gRPC-Web koristi Content-Type: `application/grpc-web-text` u zahtevima, što je neka vrsta protobuf u base64 kodiranom obliku, možete koristiti [gprc-coder](https://github.com/nxenon/grpc-pentest-suite) alat, a takođe možete instalirati njegov [Burp Suite Extension](https://github.com/nxenon/grpc-pentest-suite).
2024-02-10 13:11:20 +00:00
### **Manual sa gGRPC Coder Alatom**
2024-02-10 13:11:20 +00:00
1. Prvo dekodirajte payload:
```bash
echo "AAAAABYSC0FtaW4gTmFzaXJpGDY6BVhlbm9u" | python3 grpc-coder.py --decode --type grpc-web-text | protoscope > out.txt
```
2. Izmenite sadržaj dekodirane payload.
2024-02-10 13:11:20 +00:00
```
nano out.txt
2: {"Amin Nasiri Xenon GRPC"}
3: 54
7: {"<script>alert(origin)</script>"}
```
3. Kodirajte novi payload
2024-02-10 13:11:20 +00:00
```bash
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
```
4. Koristite izlaz u Burp interceptoru:
```
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+
```
### **Priručnik sa gRPC-Web Coder Burp Suite Ekstenzijom**
Možete koristiti gRPC-Web Coder Burp Suite Ekstenziju u [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite) koja je lakša. Možete pročitati uputstva za instalaciju i korišćenje u njenom repozitorijumu.
2024-02-10 13:11:20 +00:00
## **Analiza gRPC-Web Javascript Fajlova**
U svakoj gRPC-Web aplikaciji postoji barem jedan Javascript fajl. Možete analizirati fajl da pronađete nove poruke, krajnje tačke i usluge. Pokušajte koristiti alat [gRPC-Scan](https://github.com/nxenon/grpc-pentest-suite).
1. Preuzmite Javascript gRPC-Web Fajl
2. Skenerite ga sa grpc-scan.py:
2024-02-10 13:11:20 +00:00
```bash
python3 grpc-scan.py --file main.js
```
3. Анализирајте излаз и тестирајте нове крајње тачке и нове услуге:
2024-02-10 13:11:20 +00:00
```
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
2024-02-10 13:11:20 +00:00
* [Hacking into gRPC-Web članak od Amina Nasirija](https://infosecwriteups.com/hacking-into-grpc-web-a54053757a45)
2024-02-10 13:11:20 +00:00
* [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite)
{% hint style="success" %}
Učite i vežbajte AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Učite i vežbajte GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2024-02-10 13:11:20 +00:00
<details>
2024-02-10 13:11:20 +00:00
<summary>Podržite HackTricks</summary>
2024-02-10 13:11:20 +00:00
* Proverite [**planove pretplate**](https://github.com/sponsors/carlospolop)!
* **Pridružite se** 💬 [**Discord grupi**](https://discord.gg/hRep4RUj7f) ili [**telegram grupi**](https://t.me/peass) ili **pratite** nas na **Twitteru** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Podelite hakerske trikove slanjem PR-ova na** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repozitorijume.
2024-02-10 13:11:20 +00:00
</details>
{% endhint %}