Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name AgarPacketSniffer
  3. // @namespace agar.io
  4. // @version v2
  5. // @description Packet sniffer for Agar.io packets
  6. // @author StrikerJS
  7. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
  8. // @require http://code.jquery.com/jquery-latest.js
  9. // @require https://jimboy3100.github.io/ExampleScripts/AgarPacketSniffer/socket.io_agar.js
  10. // @require https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js
  11. // @require http://altrekker.de/agarlibs/vue.min.js
  12. // @resource https://raw.githubusercontent.com/necolas/css3-github-buttons/master/gh-buttons.css
  13. // @resource https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css
  14. // @resource https://raw.githubusercontent.com/necolas/css3-github-buttons/master/gh-icons.png
  15. // @match *agar.io/*
  16. // @grant none
  17. // ==/UserScript==
  18. _WebSocket = window.WebSocket;
  19. window.key255 = null;
  20. window.key254 = null;
  21. window.encryptionKey = 0;
  22. window.decryptionKey = 0;
  23. $.ajax('https://agar.io/agario.core.js', {
  24.     success: core => {
  25.         core = core.replace(/function\((\w)\)\{/i, '$& console.log($1);');
  26.         core = core.replace(/;if\((\w)<1\.0\){/i, `;if($1<!true){`); //
  27.         core = core.replace(/function tm\((w)\){/i, '$& console.log($1);')
  28.         core = core.replace(/c\[h>>2\]=d;d/, 'c\[h>>2\]=d;if(window.gotKey == false || window.gotKey == undefined || window.gotKey == null){window.encryptionKey = d; window.gotKey = true; console.log("Encryption key (host):"+d)}d');
  29.         eval(core);
  30.     },
  31.     dataType: 'text',
  32.     method: 'GET',
  33.     cache: false,
  34.     crossDomain: true
  35. });
  36.  
  37. function refer(master, slave, prop) {
  38.     Object.defineProperty(master, prop, {
  39.         get: function() {
  40.             return slave[prop];
  41.         },
  42.         set: function(val) {
  43.             slave[prop] = val;
  44.         },
  45.         enumerable: true,
  46.         configurable: true
  47.     });
  48. };
  49. window.WebSocket = function(url, protocols) {
  50.     console.log('Listen');
  51.     if (protocols === undefined) {
  52.         protocols = [];
  53.     }
  54.     var ws = new _WebSocket(url, protocols);
  55.     refer(this, ws, 'binaryType');
  56.     refer(this, ws, 'bufferedAmount');
  57.     refer(this, ws, 'extensions');
  58.     refer(this, ws, 'protocol');
  59.     refer(this, ws, 'readyState');
  60.     refer(this, ws, 'url');
  61.     this.send = function(data) {
  62.         let buf = new Uint8Array(data);
  63.         if (buf[0] == 255) {
  64.             window.key255 = buf;
  65.             console.log(`client key:${window.MC.CLIENT_VERSION}`);
  66.         } else if (buf[0] == 254) {
  67.             console.log(`Protocol version:${buf[1]}`);
  68.         } else {
  69.             buf = window.decryptPacket(buf) console.log(buf);
  70.         }
  71.         return ws.send.call(ws, data);
  72.     };
  73.     this.close = function() {
  74.         return ws.close.call(ws);
  75.     };
  76.     t
  77.     his.onopen = function(event) {};
  78.     this.onclose = function(event) {};
  79.     this.onerror = function(event) {};
  80.     this.onmessage = function(event) {};
  81.     ws.onopen = function(event) {
  82.         console.log(url);
  83.         if (this.onopen) return this.onopen.call(ws, event);
  84.     }.bind(this);
  85.     ws.onmessage = function(event) {
  86.         if (this.onmessage)
  87.             return this.onmessage.call(ws, event);
  88.     }.bind(this);
  89.     ws.onclose = function(event) {
  90.         if (this.onclose) return this.onclose.call(ws, event);
  91.     }.bind(this);
  92.     ws.onerror = function(event) {
  93.         if (this.onerror) return this.onerror.call(ws, event);
  94.     }.bind(this);
  95. };
  96. window.WebSocket.prototype = _WebSocket;
  97. window.decryptPacket = function(data) {
  98.     for (var i = 0; i < data.length; i++) {
  99.         data[i] = data[i] ^ window.encryptionKey >>> i % 4 * 8 & 255;
  100.     }
  101.     window.encryptionKey = window.rotateKey(window.encryptionKey);
  102.     return data;
  103. };
  104. window.xorBuf = function(data, key) {
  105.     for (var i = 0; i < data.length; i++) {
  106.         data[i] = data[i] ^ key >>> i % 4 * 8 & 255;
  107.     }
  108.     return data;
  109. };
  110. window.rotateKey = function(key) {
  111.     key = Math.imul(key, 1540483477) >> 0;
  112.     key = Math.imul(key >>> 24 ^ key, 1540483477) >> 0 ^ 114296087;
  113.     key = Math.imul(key >>> 13 ^ key, 1540483477) >> 0;
  114.     return key >>> 15 ^ key;
  115. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement