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

162 lines
8.1 KiB
Markdown
Raw Normal View History

# Pentesting gRPC-Web
2024-02-11 01:46:25 +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-11 01:46:25 +00:00
<details>
2024-02-11 01:46:25 +00:00
<summary>Support HackTricks</summary>
2024-02-11 01:46:25 +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-11 01:46:25 +00:00
</details>
{% endhint %}
2024-02-11 01:46:25 +00:00
## **Manipulowanie ładunkami gRPC-Web**
gRPC-Web używa Content-Type: `application/grpc-web-text` w żądaniach, co jest rodzajem protobuf w formie zakodowanej w base64, możesz użyć narzędzia [gprc-coder](https://github.com/nxenon/grpc-pentest-suite), a także możesz zainstalować jego [rozszerzenie Burp Suite](https://github.com/nxenon/grpc-pentest-suite).
2024-02-11 01:46:25 +00:00
### **Ręcznie z narzędziem gGRPC Coder**
1. Najpierw zdekoduj ładunek:
2024-02-11 01:46:25 +00:00
```bash
echo "AAAAABYSC0FtaW4gTmFzaXJpGDY6BVhlbm9u" | python3 grpc-coder.py --decode --type grpc-web-text | protoscope > out.txt
```
2. Edytuj zawartość zdekodowanego ładunku
2024-02-11 01:46:25 +00:00
```
nano out.txt
2: {"Amin Nasiri Xenon GRPC"}
3: 54
7: {"<script>alert(origin)</script>"}
```
3. Zakoduj nowy ładunek
2024-02-11 01:46:25 +00:00
```bash
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
```
4. Użyj wyjścia w przechwytywaczu Burp:
2024-02-11 01:46:25 +00:00
```
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+
```
### **Podręcznik z rozszerzeniem gRPC-Web Coder Burp Suite**
Możesz użyć rozszerzenia gRPC-Web Coder Burp Suite w [gRPC-Web Pentest Suite](https://github.com/nxenon/grpc-pentest-suite), co jest łatwiejsze. Możesz przeczytać instrukcje instalacji i użytkowania w jego repozytorium.
2024-02-11 01:46:25 +00:00
## **Analiza plików Javascript gRPC-Web**
W każdej aplikacji gRPC-Web znajduje się przynajmniej jeden plik Javascript. Możesz przeanalizować ten plik, aby znaleźć nowe wiadomości, punkty końcowe i usługi. Spróbuj użyć narzędzia [gRPC-Scan](https://github.com/nxenon/grpc-pentest-suite).
2024-02-11 01:46:25 +00:00
1. Pobierz plik Javascript gRPC-Web
2. Skanuj go za pomocą grpc-scan.py:
2024-02-11 01:46:25 +00:00
```bash
python3 grpc-scan.py --file main.js
```
3. Analizuj wyniki i testuj nowe punkty końcowe oraz nowe usługi:
2024-02-11 01:46:25 +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-11 01:46:25 +00:00
* [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)
2024-02-11 01:46:25 +00:00
{% hint style="success" %}
Ucz się i ćwicz Hacking AWS:<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">\
Ucz się i ćwicz Hacking GCP: <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-11 01:46:25 +00:00
<details>
2024-02-11 01:46:25 +00:00
<summary>Wsparcie dla HackTricks</summary>
2024-02-11 01:46:25 +00:00
* Sprawdź [**plany subskrypcyjne**](https://github.com/sponsors/carlospolop)!
* **Dołącz do** 💬 [**grupy Discord**](https://discord.gg/hRep4RUj7f) lub [**grupy telegramowej**](https://t.me/peass) lub **śledź** nas na **Twitterze** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Dziel się trikami hackingowymi, przesyłając PR-y do** [**HackTricks**](https://github.com/carlospolop/hacktricks) i [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) repozytoriów na githubie.
2024-02-11 01:46:25 +00:00
</details>
{% endhint %}