@@ -2,8 +2,9 @@ import http from "http";
22import fs from "fs" ;
33import crypto from "crypto" ;
44import { WebStreamBuffer , getIPAddress , handleData , moduleConfigIsAvailable , redirect_post_golbat } from "./utils" ;
5- import { decodePayload , decodePayloadTraffic } from "./parser/proto-parser" ;
5+ import { decodePayload , decodePayloadTraffic , decodeProtoFromBytes } from "./parser/proto-parser" ;
66import SampleSaver from "./utils/sample-saver" ;
7+ import POGOProtos from "@na-ji/pogo-protos" ;
78
89// try looking if config file exists...
910let config = require ( "./config/example.config.json" ) ;
@@ -206,6 +207,85 @@ const httpServer = http.createServer(function (req, res) {
206207 }
207208 } ) ;
208209 break ;
210+ case "/PolygonX/PostProtos" :
211+ req . on ( "data" , function ( chunk ) {
212+ incomingData . push ( chunk ) ;
213+ } ) ;
214+ req . on ( "end" , function ( ) {
215+ try {
216+ const binaryData = Buffer . concat ( incomingData ) ;
217+ res . writeHead ( 200 , { "Content-Type" : "application/json" } ) ;
218+ res . end ( "" ) ;
219+
220+ if ( binaryData . length === 0 ) {
221+ console . error ( "Invalid PolygonX data: empty request body" ) ;
222+ return ;
223+ }
224+
225+ // Decode the RawProtoCollection from binary protobuf
226+ const decoded = POGOProtos . Rpc . AllTypesAndMessagesResponsesProto . Hexagon . RawProtoCollectionMessage . decode ( binaryData ) ;
227+
228+ // Process RawProto entries (have both request and response)
229+ if ( decoded . protos && Array . isArray ( decoded . protos ) ) {
230+ for ( const rawProto of decoded . protos ) {
231+ const identifier = rawProto . trainer_id || "unknown" ;
232+ const method = rawProto . method ?. valueOf ( ) || 0 ;
233+ const requestBytes = rawProto . request ;
234+ const responseBytes = rawProto . proto ;
235+
236+ // Decode request
237+ if ( requestBytes && requestBytes . length > 0 && method !== 0 ) {
238+ const parsedRequestData = decodeProtoFromBytes ( method , requestBytes , "request" ) ;
239+ if ( typeof parsedRequestData !== "string" ) {
240+ parsedRequestData . identifier = identifier ;
241+ outgoingProtoWebBufferInst . write ( parsedRequestData ) ;
242+ }
243+ }
244+
245+ // Decode response
246+ if ( responseBytes && responseBytes . length > 0 ) {
247+ const parsedResponseData = decodeProtoFromBytes ( method , responseBytes , "response" ) ;
248+ if ( typeof parsedResponseData !== "string" ) {
249+ parsedResponseData . identifier = identifier ;
250+ incomingProtoWebBufferInst . write ( parsedResponseData ) ;
251+ }
252+ }
253+
254+ // Save sample if enabled
255+ if ( sampleSaver && requestBytes && responseBytes ) {
256+ const requestB64 = Buffer . from ( requestBytes ) . toString ( "base64" ) ;
257+ const responseB64 = Buffer . from ( responseBytes ) . toString ( "base64" ) ;
258+ const parsedRequest = decodeProtoFromBytes ( method , requestBytes , "request" ) ;
259+ const parsedResponse = decodeProtoFromBytes ( method , responseBytes , "response" ) ;
260+ if ( typeof parsedRequest !== "string" && typeof parsedResponse !== "string" ) {
261+ sampleSaver . savePair ( parsedRequest , parsedResponse , requestB64 , responseB64 , "polygonx" ) ;
262+ }
263+ }
264+ }
265+ }
266+
267+ // Process RawPushGatewayProto entries (response only)
268+ if ( decoded . push_gateway_protos && Array . isArray ( decoded . push_gateway_protos ) ) {
269+ for ( const pushProto of decoded . push_gateway_protos ) {
270+ const identifier = pushProto . trainer_id || "unknown" ;
271+ const method = pushProto . method ?. valueOf ( ) || 0 ;
272+ const responseBytes = pushProto . proto ;
273+
274+ // Decode response
275+ if ( responseBytes && responseBytes . length > 0 ) {
276+ const parsedResponseData = decodeProtoFromBytes ( method , responseBytes , "response" ) ;
277+ if ( typeof parsedResponseData !== "string" ) {
278+ parsedResponseData . identifier = identifier ;
279+ incomingProtoWebBufferInst . write ( parsedResponseData ) ;
280+ }
281+ }
282+ }
283+ }
284+ } catch ( error ) {
285+ console . error ( "Error processing PolygonX request:" , error ) ;
286+ }
287+ } ) ;
288+ break ;
209289 case "/traffic" :
210290 req . on ( "data" , function ( chunk ) {
211291 incomingData . push ( chunk ) ;
@@ -387,7 +467,7 @@ Server start access of this in urls: http://localhost:${portBind} or WLAN mode h
387467
388468 - Clients MITM:
389469 1) --=FurtiF™=- Tools EndPoints: http://${ getIPAddress ( ) } :${ portBind } /traffic or http://${ getIPAddress ( ) } :${ portBind } /golbat (depending on the modes chosen)
390- 2) If Other set here...
470+ 2) PolygonX EndPoint: http:// ${ getIPAddress ( ) } : ${ portBind } /PolygonX/PostProtos (application/x-protobuf)
391471 3) ...
392472
393473ProtoDecoderUI is not responsible for your errors.
0 commit comments