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

7.1 KiB

Pentesting gRPC-Web

{{#include ../banners/hacktricks-training.md}}

gRPC-Web Payloads में हेरफेर करना

gRPC-Web अनुरोधों में Content-Type: application/grpc-web-text का उपयोग करता है, जो कि बेस64 एन्कोडेड फॉर्म में एक प्रकार का protobuf है, आप gprc-coder टूल का उपयोग कर सकते हैं, और आप इसका Burp Suite Extension भी इंस्टॉल कर सकते हैं।

gGRPC Coder Tool के साथ मैनुअल

  1. सबसे पहले पेलोड को डिकोड करें:
echo "AAAAABYSC0FtaW4gTmFzaXJpGDY6BVhlbm9u" | python3 grpc-coder.py --decode --type grpc-web-text | protoscope > out.txt
  1. डिकोडेड पेलोड की सामग्री संपादित करें
nano out.txt
2: {"Amin Nasiri Xenon GRPC"}
3: 54
7: {"<script>alert(origin)</script>"}
  1. नए पेलोड को एन्कोड करें
protoscope -s out.txt | python3 grpc-coder.py --encode --type grpc-web-text
  1. Burp इंटरसेप्टर में आउटपुट का उपयोग करें:
AAAAADoSFkFtaW4gTmFzaXJpIFhlbm9uIEdSUEMYNjoePHNjcmlwdD5hbGVydChvcmlnaW4pPC9zY3JpcHQ+

Manual with gRPC-Web Coder Burp Suite Extension

आप gRPC-Web Pentest Suite में gRPC-Web Coder Burp Suite Extension का उपयोग कर सकते हैं जो आसान है। आप इसके रिपॉजिटरी में स्थापना और उपयोग के निर्देश पढ़ सकते हैं।

Analysing gRPC-Web Javascript Files

हर gRPC-Web एप्लिकेशन में कम से कम एक Javascript फ़ाइल होती है। आप नए संदेश, एंडपॉइंट और सेवाओं को खोजने के लिए फ़ाइल का विश्लेषण कर सकते हैं। gRPC-Scan टूल का उपयोग करने की कोशिश करें।

  1. Javascript gRPC-Web फ़ाइल डाउनलोड करें
  2. इसे grpc-scan.py के साथ स्कैन करें:
python3 grpc-scan.py --file main.js
  1. आउटपुट का विश्लेषण करें और नए एंडपॉइंट्स और नई सेवाओं का परीक्षण करें:
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            |
+--------------+----------------+--------------+

संदर्भ

{{#include ../banners/hacktricks-training.md}}