gRPC-Web Pentest

htARTE (HackTricks AWS Red Team Expert)를 통해 AWS 해킹을 처음부터 전문가까지 배워보세요!

HackTricks를 지원하는 다른 방법:

gRPC-Web 페이로드 조작

gRPC-Web은 요청에서 Content-Type: application/grpc-web-text를 사용하며, 이는 base64로 인코딩된 protobuf와 유사합니다. gprc-coder 도구를 사용하여 페이로드를 디코딩할 수 있으며, Burp Suite 확장 프로그램도 설치할 수 있습니다.

gGRPC Coder 도구를 사용한 수동 방법

  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+

gRPC-Web Coder Burp Suite 확장 프로그램을 사용한 매뉴얼

gRPC-Web Pentest Suite에서 gRPC-Web Coder Burp Suite 확장 프로그램을 사용할 수 있습니다. 이는 더욱 간편합니다. 설치 및 사용 방법은 해당 저장소에서 확인할 수 있습니다.

gRPC-Web 자바스크립트 파일 분석

gRPC-Web 애플리케이션에는 적어도 하나의 자바스크립트 파일이 있습니다. 이 파일을 분석하여 새로운 메시지, 엔드포인트 및 서비스를 찾을 수 있습니다. gRPC-Scan 도구를 사용해 보세요.

  1. 자바스크립트 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            |
+--------------+----------------+--------------+

참고 자료

htARTE (HackTricks AWS Red Team Expert)로 AWS 해킹을 처음부터 전문가까지 배워보세요 !

HackTricks를 지원하는 다른 방법:

Last updated