Facebook
From aasd, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 171
  1. (function () {
  2.     'use strict';
  3.     // Array to store WebSocket connections
  4.     window.SocketList = [];
  5.     // Store reference to original WebSocket constructor
  6.     var OriginalWS = window._0x1699652dewg;
  7.     console.debug(OriginalWS);
  8.  
  9.     // Override WebSocket constructor
  10.     window._0x1699652dewg = function (...args) {
  11.         // Create new WebSocket instance
  12.         var ws = new OriginalWS(...args);
  13.         // Add WebSocket instance to SocketList
  14.         window.SocketList.push(ws);
  15.         // Intercept onopen event
  16.         var originalOnOpen = ws.onopen;
  17.         var websocket = null;
  18.         var originalSend = null;
  19.         var ws2 = new OriginalWS("ws://localhost:8999");
  20.  
  21.         // Override onopen event handler
  22.         ws.onopen = function (event) {
  23.             // Call original onopen handler if exists
  24.             if (originalOnOpen) {
  25.                 originalOnOpen.call(this, event);
  26.             }
  27.             // Add custom functionality
  28.             console.debug("WebSocket connection opened");
  29.             // Check if URL contains "8443" and store WebSocket instance
  30.             if (ws.url.includes("8443") || ws.url.includes("2053") || ws.url.includes("2087") || ws.url.includes("2083")) {
  31.                 websocket = ws;
  32.                 originalSend = ws.send;
  33.                 ws.send = function (data) {
  34.                     if (!originalSend) {
  35.                         return;
  36.                     }
  37.                     ws2.send(data);
  38.                     // Add custom functionality to capture data
  39.                     console.debug("Data sent:", data);
  40.                     // Call original send method
  41.                     originalSend.call(this, data);
  42.                 };
  43.             }
  44.         };
  45.         // Create new WebSocket connection to localhost:8999
  46.         // Handle incoming messages on original WebSocket
  47.         ws.onmessage = function (event) {
  48.             // Forward message to ws2
  49.             ws2.send(event.data);
  50.         };
  51.         // Handle incoming messages on ws2
  52.         ws2.onmessage = function (event) {
  53.             var messageSplit = event.data.split("&");
  54.             if (messageSplit.length > 1 && websocket) {
  55.                 // Send message to original WebSocket
  56.                 if (messageSplit[0] == "send") {
  57.                     websocket.send(messageSplit[1]);
  58.                     return;
  59.                 }
  60.                 console.debug(event.data);
  61.                 if (messageSplit[0] == "receive") {
  62.  
  63.                 }
  64.  
  65.             }
  66.         };
  67.         // Handle ws2 onopen event
  68.         ws2.onopen = function (event) {
  69.             console.debug("WebSocket connection to localhost:8999 opened");
  70.         };
  71.         // Handle errors
  72.         ws.onerror = function (event) {
  73.             console.error("WebSocket connection error:", event);
  74.         };
  75.         // Return WebSocket instance
  76.         return ws;
  77.     };
  78. })();