Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.67 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AgarUnlimited
  3. // @version 3.0
  4. // @description AgarUnlimited Revive by Neon
  5. // @author Neon - Sizrex - MrSonicMaster - NuclearC
  6. // @match *://agar.io/*
  7. // @grant none
  8. // @run-at document-start
  9. // ==/UserScript==
  10.  
  11. /*
  12. Special thanks to NuclearC - MrSonicMaster i wouldn't be here without them
  13. Thanks to Sizrex for making AgarUnlimited v2.5 Possible / Famous
  14. Check OP-Bots.com For Premium Bots
  15. */
  16.  
  17. /*
  18. The MIT License (MIT)
  19. Copyright (c) 2019 Neon
  20. Permission is hereby granted, free of charge, to any person obtaining a copy
  21. of this software and associated documentation files (the "Software"), to deal
  22. in the Software without restriction, including without limitation the rights
  23. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  24. copies of the Software, and to permit persons to whom the Software is
  25. furnished to do so, subject to the following conditions:
  26. The above copyright notice and this permission notice shall be included in all
  27. copies or substantial portions of the Software.
  28. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  29. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  30. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  31. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  33. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  34. SOFTWARE.
  35. */
  36.  
  37. window.bots = [];
  38.  
  39. window.client = {
  40. collectPellets: false,
  41. startedBots: false,
  42. ready: false,
  43. clientX: 0,
  44. clientY: 0,
  45. botID: 1,
  46. bots: 0
  47. };
  48.  
  49. function addListener() {
  50. document.addEventListener('mousemove', event => {
  51. window.client.clientX = event.clientX;
  52. window.client.clientY = event.clientY;
  53. });
  54. }
  55.  
  56. function loadGUI() {
  57. $('.agario-promo-container').replaceWith(`
  58. <input onchange="localStorage.setItem('botNick', this.value);" id="botNick" maxlength="15" class="form-control" placeholder="Bot Name" value="Bot"></input>
  59. <input onchange="localStorage.setItem('botAmount', this.value);" id="BotAmount" maxlength="3" class="form-control" placeholder="Bot Amount" value="10"></input>
  60. <center><button id="toggleButton" onclick="window.newBot(localStorage.getItem('botAmount'));" class="btn btn-success">Start Bots</button></center>
  61. `);
  62. if (!localStorage.getItem('botAmount')) localStorage.setItem('botAmount', 50);
  63. if (!localStorage.getItem('botNick')) localStorage.setItem('botNick', 'Bot');
  64. console.log('[AgarUnlimited] Ready!');
  65. window.client.ready = true;
  66. }
  67.  
  68. function loadBootsTrapCSS() {
  69. $('head').append(`<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">`);
  70. }
  71.  
  72. function editCore(core) {
  73. core = core.replace(/;if\((\w)<1\.0\){/i, ';if($1<0){');
  74. core = core.replace(/([\w]+\s*=\s*[\w]+\s*\+\s*16\s*\|\s*0;\s*([\w=]+)\s*=\s*\+[\w\[\s*><\]]+;)/, '$1 $2*=0.75;');
  75. core = core.replace(
  76. /([\w$]+\(\d+,\w\[\w>>2\]\|0,(\+\w),(\+\w)\)\|0;[\w$]+\(\d+,\w\[\w>>2\]\|0,\+-(\+\w\[\w\+\d+>>3\]),\+-(\+\w\[\w\+\d+>>3\])\)\|0;)/i,
  77. '$1 window.viewScale=$2; if (window.coordOffsetFixed) { window.playerX=$4+window.offsetX; window.playerY=$5+window.offsetY;} if(window.draw){window.draw();}'
  78. );
  79. core = core.replace(
  80. /(\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\[\w\+(\d+)>>3]=(\w);\w\=\w\+(\d+)\|(\d+);)/i,
  81. '$1 function setMapCoords(_0x7e8bx1, _0x7e8bx2, _0x7e8bx3, _0x7e8bx4, _0x7e8bx5, _0x7e8bx6) { if (_0x7e8bx6 - _0x7e8bx5 == 24) { if (_0x7e8bx3 - _0x7e8bx1 > 14E3) { if (_0x7e8bx4 - _0x7e8bx2 > 14E3) { window.offsetX = 7071.067811865476 - _0x7e8bx3; window.offsetY = 7071.067811865476 - _0x7e8bx4; window.minX = _0x7e8bx1;window.minY=_0x7e8bx2;window.maxX=_0x7e8bx3;window.maxY=_0x7e8bx4; window.coordOffsetFixed = true; } } } } setMapCoords($3,$5,$7,$9,$2,$8);'
  82. );
  83. console.log('core_edited');
  84. return core;
  85. }
  86.  
  87. let observer = new MutationObserver((mutations) => {
  88. mutations.forEach((mutation) => {
  89. mutation.addedNodes.forEach((node) => {
  90. if (/agario\.core\.js/i.test(node.src)) {
  91. observer.disconnect();
  92. node.parentNode.removeChild(node);
  93. let request = new XMLHttpRequest();
  94. request.open('get', node.src, true);
  95. request.send();
  96. request.onload = function () {
  97. let coretext = this.responseText;
  98. let newscript = document.createElement('script');
  99. newscript.type = 'text/javascript';
  100. newscript.async = true;
  101. newscript.textContent = editCore(coretext);
  102. document.body.appendChild(newscript);
  103. setTimeout(() => {
  104. loadBootsTrapCSS();
  105. addListener();
  106. loadGUI();
  107. }, 3500);
  108. }
  109. }
  110. });
  111. });
  112. });
  113.  
  114. observer.observe(document, { attributes: true, characterData: true, childList: true, subtree: true });
  115.  
  116. window.newBot = function (amount) {
  117. if (!window.client.ready) return;
  118. if (amount) {
  119. amount > 200 ? amount = 200 : amount = amount;
  120. for (let i = 0; i < amount; i++) {
  121. window.bots.push(new Bot(window.client.botID, `wss://${window.MC.getHost()}:443?party_id=${window.MC.getPartyToken()}`));
  122. window.client.botID++;
  123. }
  124. } else {
  125. window.bots.push(new Bot(window.client.botID, `wss://${window.MC.getHost()}:443?party_id=${window.MC.getPartyToken()}`));
  126. window.client.botID++;
  127. }
  128. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick='window.stopBots();' class='btn btn-danger'>Stop Bots</button>`);
  129. window.client.startedBots = true;
  130. }
  131.  
  132. window.stopBots = function () {
  133. if (!window.client.startedBots) return;
  134. window.bots.forEach(bot => {
  135. bot.ws.close();
  136. });
  137. console.log('[AgarUnlimited] Stopped bots!');
  138. window.client.startedBots = false;
  139. $('#toggleButton').replaceWith(`<button id='toggleButton' onclick="window.newBot(localStorage.getItem('botAmount'));" class='btn btn-success'>Start Bots</button>`);
  140. }
  141.  
  142. class Bot {
  143.  
  144. constructor(id, server) {
  145. this.botNick = localStorage.getItem('botNick');
  146. this.borders = new Object();
  147. this.protocolVersion = 22;
  148. this.nodes = new Array();
  149. this.node = new Object();
  150. this.protocolKey = 31002;
  151. this.encryptionKey = 0;
  152. this.decryptionKey = 0;
  153. this.serverIP = server;
  154. this.cellsIDs = [];
  155. this.offsetX = 0;
  156. this.offsetY = 0;
  157. this.id = id;
  158. this.connect(server);
  159. }
  160.  
  161. connect(server) {
  162. this.ws = new WebSocket(server);
  163. this.ws.binaryType = 'arraybuffer';
  164. this.ws.onmessage = this.onMessage.bind(this);
  165. this.ws.onerror = this.onError.bind(this);
  166. this.ws.onclose = this.onClose.bind(this);
  167. this.ws.onopen = this.onOpen.bind(this);
  168. }
  169.  
  170. onOpen() {
  171. console.log(`Bot_${this.id}: Connected`);
  172.  
  173. let buf = this.Buffer(5);
  174.  
  175. buf.setUint8(0, 254);
  176. buf.setUint32(1, this.protocolVersion, true);
  177.  
  178. this.send(buf);
  179.  
  180. buf = this.Buffer(5);
  181. buf.setUint8(0, 255);
  182. buf.setUint32(1, this.protocolKey, true);
  183.  
  184. this.send(buf);
  185. }
  186.  
  187. onClose() {
  188. console.log(`Bot_${this.id}: Disconnected (Closed)`);
  189. window.client.botID--;
  190. }
  191.  
  192. onError() {
  193. console.log(`Bot_${this.id}: Disconnected (Error)`);
  194. }
  195.  
  196. onMessage(msg) {
  197. let offset = 0;
  198. let oldMsg = msg.data;
  199. msg = this.Buffer(msg.data, true);
  200.  
  201. if (this.decryptionKey) msg = this.xorBuffer(msg, this.decryptionKey ^ this.protocolKey);
  202.  
  203. switch (msg.getUint8(offset++)) {
  204.  
  205. case 241:
  206. this.decryptionKey = msg.getUint32(offset, true);
  207. oldMsg = Array.from(new Uint8Array(oldMsg)).splice(5, 11);
  208. this.encryptionKey = this.clientKey(this.serverIP, new Uint8Array(oldMsg));
  209. break;
  210.  
  211. case 242:
  212. console.log(`Bot_${this.id}: Spawning`);
  213. window.agarApp.recaptcha.requestCaptchaV3('play', token => this.spawn(this.botNick + 'x', token));
  214. break;
  215.  
  216. case 85:
  217. console.log(`Bot_${this.id}: Captcha failed Disconnecting...`);
  218. window.client.bots--;
  219. this.ws.close();
  220. break;
  221.  
  222. case 32:
  223. this.cellsIDs.push(msg.getUint32(offset, true));
  224. console.log(`Bot_${this.id}: Spawned`);
  225. window.client.bots++;
  226. this.isAlive = true;
  227. break;
  228.  
  229. case 255:
  230. let buf = msg.getUint32(1, true);
  231. let out = new Uint8Array(buf)
  232. out = this.decompressBuffer(new Uint8Array(msg.buffer.slice(5)), out);
  233. let data = new DataView(out.buffer);
  234.  
  235. switch (data.getUint8(0)) {
  236.  
  237. case 16:
  238. var off = 1;
  239.  
  240. let eatQueueLength = data.getUint16(off, true);
  241. off += 2;
  242.  
  243. for (let i = 0; i < eatQueueLength; i++) off += 8;
  244.  
  245. while (true) {
  246. this.node.id = data.getUint32(off, true);
  247. off += 4;
  248.  
  249. if (this.node.id == 0) break;
  250.  
  251. this.node.x = data.getInt32(off, true);
  252. off += 4;
  253.  
  254. this.node.y = data.getInt32(off, true);
  255. off += 4;
  256.  
  257. this.node.size = data.getUint16(off, true);
  258. off += 2;
  259.  
  260. this.node.flags = data.getUint8(off++);
  261. this.node.extendedFlags = 0;
  262.  
  263. if (this.node.flags & 128) this.node.extendedFlags = data.getUint8(off++);
  264. if (this.node.flags & 1) this.node.isVirus = true;
  265. if (this.node.flags & 2) off += 3;
  266. if (this.node.flags & 4) while (data.getInt8(off++) !== 0) { }
  267. if (this.node.flags & 8) while (data.getInt8(off++) !== 0) { }
  268. if (this.node.extendedFlags & 1) this.node.isFood = true;
  269. if (this.node.extendedFlags & 4) off += 4;
  270.  
  271. this.nodes[this.node.id] = this.node;
  272. }
  273.  
  274. let removeQueueLength = data.getUint16(off, true);
  275.  
  276. off += 2;
  277.  
  278. for (let i = 0; i < removeQueueLength; i++) {
  279. let removedEntityID = data.getUint32(off, true);
  280. off += 4;
  281.  
  282. if (this.nodes.hasOwnProperty(removedEntityID)) delete this.nodes[removedEntityID];
  283. if (this.cellsIDs.includes(removedEntityID)) this.cellsIDs = this.cellsIDs.filter(x => x != removedEntityID);
  284. }
  285.  
  286. if (this.isAlive && this.cellsIDs.length == 0) {
  287. window.client.bots--;
  288. this.isAlive = false;
  289. window.agarApp.recaptcha.requestCaptchaV3('play', token => this.spawn(this.botNick + 'x', token));
  290. }
  291. break;
  292.  
  293. case 64:
  294. off = 1;
  295. this.borders.minX = data.getFloat64(off, true);
  296. off += 8;
  297. this.borders.minY = data.getFloat64(off, true);
  298. off += 8;
  299. this.borders.maxX = data.getFloat64(off, true);
  300. off += 8;
  301. this.borders.maxY = data.getFloat64(off, true);
  302. if (this.borders.maxX - this.borders.minX > 14E3) this.offsetX = (this.borders.maxX + this.borders.minX) / 2;
  303. if (this.borders.maxY - this.borders.minY > 14E3) this.offsetY = (this.borders.maxY + this.borders.minY) / 2;
  304.  
  305. if (this.isAlive && !window.client.collectPellets)
  306. this.moveTo((window.client.clientX - window.innerWidth / 2) / window.viewScale + window.playerX, (window.client.clientY - window.innerHeight / 2) / window.viewScale + window.playerY);
  307. break;
  308. }
  309. break;
  310. }
  311. }
  312.  
  313. send(buf, runEncryption) {
  314. if (this.ws && this.ws.readyState == 1) {
  315. if (runEncryption) {
  316. buf = this.xorBuffer(buf, this.encryptionKey);
  317. this.encryptionKey = this.rotateKey(this.encryptionKey);
  318. }
  319. this.ws.send(buf);
  320. }
  321. }
  322.  
  323. moveTo(x, y) {
  324. let buf = this.Buffer(13);
  325. buf.setUint8(0, 16);
  326. buf.setUint32(1, x + this.offsetX, true);
  327. buf.setUint32(5, y + this.offsetY, true);
  328. buf.setUint32(9, this.decryptionKey, true);
  329. this.send(buf, true);
  330. }
  331.  
  332. spawn(name, token) {
  333. let buf = this.Buffer(2 + name.length + token.length);
  334. buf.setUint8(0, 0);
  335. for (let i = 0; i < name.length; i++) buf.setUint8(i + 1, name.charCodeAt(i));
  336. buf.setUint8(name.length, 0);
  337. for (let i = 0; i < token.length; i++) buf.setUint8(name.length + 1 + i, token.charCodeAt(i));
  338. this.send(buf, true);
  339. }
  340.  
  341. split() {
  342. let buf = this.Buffer();
  343. buf.setUint8(0, 17);
  344. this.send(buf, true);
  345. }
  346.  
  347. eject() {
  348. let buf = this.Buffer();
  349. buf.setUint8(0, 21);
  350. this.send(buf, true);
  351. }
  352.  
  353. xorBuffer(buf, key) {
  354. for (let i = 0; i < buf.byteLength; i++) {
  355. buf.setUint8(i, buf.getUint8(i) ^ (key >> ((i % 4) * 8)) & 255);
  356. }
  357. return buf;
  358. }
  359.  
  360. rotateKey(key) {
  361. key = Math.imul(key, 1540483477) >> 0;
  362. key = (Math.imul(key >>> 24 ^ key, 1540483477) >> 0) ^ 114296087;
  363. key = Math.imul(key >>> 13 ^ key, 1540483477) >> 0;
  364. return key >>> 15 ^ key;
  365. }
  366.  
  367. Buffer(buf, msg) {
  368. if (msg) {
  369. buf = new Uint8Array(buf);
  370. let fixedbuffer = new DataView(new ArrayBuffer(buf.byteLength));
  371. for (let i = 0; i < buf.byteLength; i++) {
  372. fixedbuffer.setUint8(i, buf[i]);
  373. }
  374. return fixedbuffer;
  375. }
  376. return new DataView(new ArrayBuffer(!buf ? 1 : buf));
  377. }
  378.  
  379. decompressBuffer(input, output) {
  380. for (let i = 0, j = 0; i < input.length;) {
  381. const byte = input[i++]
  382. let literalsLength = byte >> 4
  383. if (literalsLength > 0) {
  384. let length = literalsLength + 240
  385. while (length === 255) {
  386. length = input[i++]
  387. literalsLength += length
  388. }
  389. const end = i + literalsLength
  390. while (i < end) output[j++] = input[i++]
  391. if (i === input.length) return output
  392. }
  393. const offset = input[i++] | (input[i++] << 8)
  394. if (offset === 0 || offset > j) return -(i - 2)
  395. let matchLength = byte & 15
  396. let length = matchLength + 240
  397. while (length === 255) {
  398. length = input[i++]
  399. matchLength += length
  400. }
  401. let pos = j - offset
  402. const end = j + matchLength + 4
  403. while (j < end) output[j++] = output[pos++]
  404. }
  405. return output
  406. }
  407.  
  408. clientKey(ip, buf) {
  409. for (var e = null, p = ip.match(/(ws+:\/\/)([^:]*)(:\d+)/)[2], s = p.length + buf.byteLength, o = new Uint8Array(s), a = 0; a < p.length; a++)
  410. o[a] = p.charCodeAt(a);
  411. o.set(buf, p.length);
  412. for (var m = new DataView(o.buffer), r = s - 1, g = 0 | 4 + (-4 & r - 4), h = 255 ^ r, f = 0; 3 < r;)
  413. e = 0 | Math.imul(m.getInt32(f, !0), 1540483477), h = (0 | Math.imul(e >>> 24 ^ e, 1540483477)) ^ (0 | Math.imul(h, 1540483477)), r -= 4, f += 4;
  414. switch (r) {
  415. case 3:
  416. h = o[g + 2] << 16 ^ h, h = o[g + 1] << 8 ^ h;
  417. break;
  418. case 2:
  419. h = o[g + 1] << 8 ^ h;
  420. break;
  421. case 1:
  422. break;
  423. default:
  424. e = h;
  425. }
  426. e != h && (e = 0 | Math.imul(o[g] ^ h, 1540483477)), e ^= h = e >>> 13, e = 0 | Math.imul(e, 1540483477), e ^= h = e >>> 15;
  427. return e;
  428. }
  429. }
  430.  
  431. document.addEventListener('keydown', event => {
  432. let key = String.fromCharCode(event.keyCode);
  433. if (key == 'X') {
  434. if (bots.length > 0 && window.client.startedBots) {
  435. bots.forEach(bot => bot.split());
  436. }
  437. }
  438. else if (key == 'C') {
  439. if (bots.length > 0 && window.client.startedBots) {
  440. bots.forEach(bot => bot.eject());
  441. }
  442. }
  443. else if (key == 'P') {
  444. window.client.collectPellets = !window.client.collectPellets;
  445. console.log(`Collect Pellets: ${window.client.collectPellets}`);
  446. }
  447. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement