• Stars
    star
    124
  • Rank 287,363 (Top 6 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created over 1 year ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

gRPC-Web Pentesting Suite + Burp Suite Extension

gRPC Web Pentest Suite

gRPC-Pentest-Suite is set of tools for pentesting / hacking gRPC Web applications.

Available Content Types:

gRPC-Pentest-Suite contains these 2 tools:

  • grpc-scan scanning the gRPC-web javascript webpacked files to detect grpc endpoints, services, messages and field types
  • grpc-coder encoding and decoding gRPC-web payloads for pentesting (manipulating payloads)
  • grpc-coder-burp-extension extension for burp suite to easily using gRPC-Coder tool
  • big-string-chunker this tool chunks a big string into pieces of 80 characters, so that gRPC-coder can encode it (also reverse)

Hacking into gRPC-Web Article & YouTube Video

This article includes the methodology for pentesting gRPC-Web and a methodology for finding hidden servies and endpoints. Read Hacking into gRPC-Web article and for application/grpc-web+proto see this article Hacking into gRPC-Web : Part 2.

This video includes using both gRPC Scan tool and gRPC Coder Burp Suite Extension: How to manipulate gRPC-Web payloads and analyse the JavaScript webpacked files to find hidden endpoints, services and messages. Watch

Watch the video

Requirements

pip3 install -r requirements.txt

for grpc-coder.py you need to install protoscope in system gloablly.

go install github.com/protocolbuffers/protoscope/cmd/protoscope...@latest

for gRPC Coder Burp Extension you need to have these requirements:

  • download the whole repository (because the script needs grpc.coder.py)
  • jython must be installed and configured in burp
  • protoscope must be installed globally on system (because the extension runs a protoscope command)
  • python3 must be installed to run the grpc-coder.py script (because the gRPC-Coder is written in python3)
  • in windows python 3 binary name is python and in linux and mac the binary name is python3

the extension runs two safe commands to work with grpc-coder.py and protoscope tools.

gRPC Coder Extension Usage

after installing the extension it adds to menu items into extensions menu item:

  • gRPC Coder Decode
  • gRPC Coder Encode

Steps:

  1. select the gRPC-Web base64 payload in burp interceptor or repeater and click on Decode item for decoding to human-readable format
  2. edit the text and select the new edited text and click on Encode item for encoding to gRPC-Web base64 format

Watch the Extension Usage Video on YouTube

Watch

Watch the video

gRPC Coder Extension Installation

  1. Download the Whole Repository (the extension needs some files in this repo)
  2. add grpc-coder-burp-extension.py in Burp Extensions.

Note: protoscope and python3 must be system globally installed.

gRPC-Coder Usage

GRPC-Coder.py has two options:

grpc-coder.py

python3 grpc-coder.py --help

echo payload | python3 grpc-coder.py [--encode OR --decode]

General Arguments:
  --encode       encode protoscope binary output to application/grpc-web-text
  --decode       decode application/grpc-web-text base64 encoded payload to protoscope format
  --type         content-type of payload [default: grpc-web-text] available types: [grpc-web-text, grpc-web+proto]

Input Arguments:
Default Input is Standard Input
  --file        to get input from a file 

Help:
  --help        print help message

Decoding

In Burp Suite when you intercept the request, get the gRPC-Web base64 encoded payload and give it to the script as standard input:

echo "AAAAABYSC0FtaW4gTmFzaXJpGDY6BVhlbm9u" | python3 grpc-coder.py --decode --type grpc-web-text | protoscope > out.txt
cat out.txt

content of out.txt:

2: {"Amin Nasiri"}
3: 54
7: {"Xenon"}

vim out.txt
... edit the file

content of edited out.txt:

cat out.txt
2: {"Amin Nasiri Xenon GRPC"}
3: 54
7: {"<script>alert(origin)</script>"}

now you have to encode the new payload: Encode

Encoding

after editing decoded payload you have to encode it:

protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text

Output:

AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+

Then you put the new base64 payload into Burp Suite intercepted request.

Big String Chunker Tool

When you have a big string that you want to put it into a value in protobuf fields, you have to make that string into some pieces of characters using big-string-chunker.py.

For Example:

This String is big:
  "T2dnUwACAAAAAAAAAABzFQAAAAAAAAAJCzcBE09wdXNIZWFkAQE4AYC7AAAAAABPZ2dTAAAAAAAAAAAAAHMVAAABAAAAo2rOoQE3T3B1c1RhZ3MPAAAAbGlib3B1cyB1bmtub3duAQAAABQAAABFTkNPREVSPU1vemlsbGExMjQuME9nZ1MAAMAwAAAAAAAAcxUAAAIAAAD1DN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0BkOTT4q2"
  "YhAygIak+pZZu654kaBYG+9Hag=="
}
  • Note: Do not forget to change the field number. The tool uses field number 1 by default.

Big String Chunker in gRPC Coder Burp Extension [Chunk]

  • Big String Big String Chunker in gRPC Coder Burp Extension Chunk
  • Result Big String Chunker Result Chunk

Big String Chunker CLI Usage [Chunk]

cat bigString.txt | python3 big-string-chunker.py --stdin --chunk
python3 big-string-chunker.py --file bigString.txt --chunk

Big String Chunker in gRPC Coder Burp Extension [Un-Chunk]

  • Big String Big String Chunker in gRPC Coder Burp Extension Un-Chunk
  • Result: Big String Chunker Result Un-Chunk

Big String Chunker CLI Usage [Un-Chunk]

cat chunkedString.txt | python3 big-string-chunker.py --stdin --un-chunk
python3 chunkedString.py --file bigString.txt --un-chunk

gRPC-Scan Usage

grpc-scan.py

python3 grpc-scan.py --file main.js
OR
cat main.js | python3 grpc-scan.py --stdin

gRPC-Scan Javascript Files Note

For saving javascript files, you have to open them in browser and save the file or download it directly.

Do not copy and paste the javascript content.

ProtoBuf Version Support:

  • Version 3 [OK]
  • Version 2 [Some Features do not work]

gRPC-Scan Help

python3 grpc-scan.py --help

python3 grpc-scan.py [INPUT]
Input Arguments:
  --file      file name of js file
  --stdin     get input from standard input
Help:
  --help      print help message

gRPC-Scan Output Example

python3 grpc-scan.py --file main.js

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            |
+--------------+----------------+--------------+

gRPC Lab

For testing this tool and getting familiar with gRPC-Web, I made a lab for gRPC & gRPC-Web.

More Repositories

1

h2spacex

HTTP/2 Single Packet Attack low level library / Tool based on Scapy
Python
64
star
2

python-messenger

Python GUI Multi User Messenger
Python
30
star
3

DevSecOps

♾️ Collection of DevSecOps Notes + Resources + Courses + Tools
17
star
4

403-byebye

403 Forbidden Error Bypasser
Python
14
star
5

c2x

C2X - C2/Post-Exploitation Tool on (Raw Socket Traffic)
Python
13
star
6

c2x-http

C2X-HTTP - C2/Post-Exploitation Tool on HTTP(S)
Python
13
star
7

port-scanner-go

TCP Port Scanner in GO lang
Go
9
star
8

cve-2023-44487

Examples for Implementing cve-2023-44487 ( HTTP/2 Rapid Reset Attack ) Concept
Python
5
star
9

grpc-lab

gRPC / gRPC-Web Pentest Practicing Lab
5
star
10

c2x-client-go

Client of C2X project in Go lang
Go
4
star
11

hash-cracker

python hash cracker
Python
4
star
12

network-device-configurer

Cisco device configuration automation
Python
4
star
13

ip-calculator

An ip calculator
Python
3
star
14

c2x-http-client-py

Client of C2X-HTTP project in Python lang
Python
2
star
15

c2x-http-client-go

Client of C2X-HTTP project in Go lang
Go
2
star
16

c2x-client-py

Client of C2X project in Python lang
Python
2
star
17

hash-generator

Generate hashes simply
Python
2
star
18

text-replacer

A text file replacer
Python
2
star
19

port-go-port

Port-Go-Port forwards two sockets data to each other
Go
2
star
20

unimiler

Unicode Normalizer
Python
2
star
21

active-security-headers

OWASP Active Security Headers Graph
2
star
22

psobfus

Powershell Code Obfuscator
Python
1
star
23

pyobfus

Python Code Obfuscator
Python
1
star
24

ip-information

Get IP Information
Python
1
star
25

paramx

Create a Parameters Wordlist from Javascript Files
Python
1
star
26

arp-spoof

Pythom script written with Scapy for MITM attack (Arp Cache Poisoning)
Python
1
star
27

port2port

port2port forwards two sockets data to each other
Python
1
star
28

403-bb

403 Forbidden Error Bypasser
Go
1
star