# 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 %}