Starve.io AIMBOT

try to take over the world!

  1. // ==UserScript==
  2. // @name Starve.io AIMBOT
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author Hunter Mikesell
  7. // @match https://starve.io/*
  8. // @run-at document-start
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. const injectInline = (data) => {
  16. let s = document.createElement('script');
  17. s.type = 'text/javascript';
  18. s.innerText = data;
  19. document.getElementsByTagName('head')[0].appendChild(s);
  20. }
  21.  
  22.  
  23.  
  24. const request = url => fetch(url).then(res => res.text());
  25.  
  26. const hack = `
  27. (function(){
  28. const canvas = document.getElementById('game_canvas');
  29. const ctx = canvas.getContext('2d');
  30. console.log('WHAT THE FUCK', CanvasRenderingContext2D.prototype.fillRect);
  31. const old = CanvasRenderingContext2D.prototype.fillRect;
  32. window.CanvasRenderingContext2D.prototype.fillRect = function(){
  33. old.apply(this,arguments);
  34. if(arguments.callee.caller.toString().length===19295 && window.Utils.hacks.ESP.enabled){
  35. if(r && r.oOol.length > 0){
  36. const myPlayer = r.oOol[p.olo0];
  37. const myPosition = {x: p.LOL.x + myPlayer.x, y: p.LOL.y + myPlayer.y};
  38. r.oOol.forEach(entity => {
  39. if(entity){
  40. if(entity.type === 0){
  41. if(entity!=myPlayer){
  42. console.log(entity);
  43. const theirPosition = {x:entity.x-myPlayer.x,y:entity.y-myPlayer.y};
  44. ctx.font = "15px Arial";
  45. ctx.strokeText(entity.oooo.loOO, myPosition.x+theirPosition.x-20, myPosition.y+theirPosition.y-50);
  46. ctx.beginPath();
  47. ctx.moveTo(myPosition.x, myPosition.y);
  48. ctx.strokeStyle = '#ff08c5';
  49. ctx.lineTo(myPosition.x+theirPosition.x, myPosition.y+theirPosition.y);
  50. ctx.stroke();
  51. };
  52. };
  53. };
  54. });
  55. };
  56. return;
  57. };
  58. };
  59. const dist2d=(p1, p2)=>{
  60. return Math.sqrt((p1.x-p2.x)**2 + (p1.y-p2.y)**2);
  61. };
  62. const calcAngle = (p1, p2) => {
  63. var dy = p2.y - p1.y;
  64. var dx = p2.x - p1.x;
  65. var theta = Math.atan2(dy, dx);
  66. return theta;
  67. };
  68. const getNearest=(us, them)=>{
  69. const nearestEntity = {player: null, dist:null};
  70. them.forEach(player=>{
  71. const dist = dist2d(us, player);
  72. if(!nearestEntity.dist || dist < nearestEntity.dist){
  73. nearestEntity.dist = dist;
  74. nearestEntity.player = player;
  75. };
  76. });
  77. if(nearestEntity.player){
  78. return nearestEntity.player;
  79. };
  80. return null;
  81. };
  82. let lastRefresh = performance.now();
  83. const oldAnimFrame = window.requestAnimationFrame;
  84. window.requestAnimationFrame = function(){
  85. const now = performance.now();
  86. if(now-lastRefresh > 1000/60 && p){
  87. lastRefresh = now;
  88. if(r && r.oOol.length > 0){
  89. let entities = [];
  90. const myPlayer = r.oOol[p.olo0];
  91. r.oOol.forEach(entity => {
  92. if(entity){
  93. if(entity.type === 0){
  94. if(entity!=myPlayer){
  95. entities.push(entity);
  96. };
  97. };
  98. };
  99. });
  100. if(myPlayer){
  101. const nearest = getNearest(myPlayer, entities);
  102. if(nearest){
  103. const angle = calcAngle(myPlayer, nearest);
  104. if(angle){
  105. myPlayer.angle = angle;
  106. window.overrideC= true;
  107. window.newC = angle;
  108. }else{
  109. window.overrideC= false;
  110. window.newC = null;
  111. };
  112. }else{
  113. window.overrideC= false;
  114. window.newC = null;
  115. };
  116. }else{
  117. window.overrideC= false;
  118. window.newC = null;
  119. };
  120. };
  121. };
  122. return oldAnimFrame.apply(this,arguments);
  123. };
  124. })();
  125. `
  126. const theme_ = {
  127. name: "Custom By Cryo",
  128. colors: {
  129. menuBarBackground: 'rgb(35, 35, 35)',
  130. menuBarText: 'rgb(197, 41, 156)',
  131. panelBackground: 'rgb(28, 28, 27)',
  132.  
  133. componentBackground: 'rgb(45, 41, 38)',
  134. componentBackgroundHover: 'rgb(233, 75, 60)',
  135. componentForeground: 'rgb(45, 168, 216)',
  136. componentActive: 'rgb(233, 75, 60)',
  137.  
  138. textPrimary: 'rgb(206, 74, 126)',
  139. textSecondary: 'rgb(252, 246, 245)',
  140. textHover: 'rgb(235, 235, 235)',
  141. textActive: 'rgb(233, 75, 60)',
  142. },
  143. }
  144.  
  145. window.Utils = {
  146. initUI: ()=>{
  147. let container = document.body;
  148. let gui = new guify({
  149. title: '🌜Cryogenic Client v0.1🌜',
  150. theme: theme_,
  151. align: 'right', // left, right
  152. width: 300,
  153. barMode: 'none',
  154. panelMode: 'none',
  155. opacity: 0.95,
  156. root: window.container,
  157. open: Utils.hacks.MENU.enabled
  158. });
  159.  
  160. gui.Register({
  161. type: 'folder',
  162. label: 'Hacks',
  163. open: true
  164. });
  165.  
  166. // Add to the folder example
  167. gui.Register([
  168.  
  169. {
  170. type: 'title',
  171. label: 'ESP'
  172. },
  173. {
  174. type: 'checkbox',
  175. label: 'ESP',
  176. object: Utils.hacks.ESP,
  177. property: 'enabled',
  178. onChange: (data) => {
  179. Utils.hacks.ESP.enabled = data;
  180. }
  181. },
  182.  
  183. {
  184. type: 'title',
  185. label: 'AIMBOT'
  186. },
  187.  
  188. {
  189. type: 'checkbox',
  190. label: 'Aimbot',
  191. object: Utils.hacks.AIMBOT,
  192. property: 'enabled',
  193. onChange: (data) => {
  194. Utils.hacks.AIMBOT.enabled = data;
  195. }
  196. },
  197.  
  198. {
  199. type: 'checkbox',
  200. label: 'Toggle on Press',
  201. object: Utils.hacks.AIMBOT,
  202. property: 'toggle',
  203. onChange: (data) => {
  204. Utils.hacks.AIMBOT.toggle = data;
  205. }
  206. },
  207.  
  208.  
  209. {
  210. type: 'title',
  211. label: 'Key Binds'
  212. },
  213.  
  214. { type: 'button', label: 'Set Aimbot Key', action: (data) => {
  215. Utils.controls.setKeyBind('AIMBOT');
  216. }},
  217.  
  218. { type: 'button', label: 'Set ESP Key', action: (data) => {
  219. Utils.controls.setKeyBind('ESP');
  220. }},
  221.  
  222. { type: 'text', label: 'Aimbot', object: Utils.hacks.AIMBOT, property: "key",
  223. onChange: (data) => {
  224. Utils.hacks.AIMBOT.key = data;
  225. } },
  226.  
  227. { type: 'text', label: 'ESP', object: Utils.hacks.ESP, property: "key",
  228. onChange: (data) => {
  229. Utils.hacks.ESP.key = data;
  230. } },
  231.  
  232. {
  233. type: 'title',
  234. label: 'Credits / Help'
  235. },
  236.  
  237. {
  238. type: 'button',
  239. label: 'My Discord',
  240. action: () => {
  241. }
  242. },
  243.  
  244. ], {
  245. folder: 'Hacks'
  246. });
  247. },
  248.  
  249.  
  250. controls: null,
  251.  
  252. controller: class{
  253.  
  254. constructor(){
  255.  
  256. document.addEventListener('keydown', (e)=>{
  257. const objectKeys = Object.keys(Utils.hacks);
  258. objectKeys.forEach(hackKEY=>{
  259. const hack = Utils.hacks[hackKEY];
  260. if(hack.key === e.code && hack.toggle == true){
  261. hack.enabled = !hack.enabled;
  262. }
  263. if(hack.key === e.code && hack.toggle != true){
  264. hack.enabled = true;
  265. }
  266. })
  267. });
  268.  
  269. document.addEventListener('keyup', (e)=>{
  270. const objectKeys = Object.keys(Utils.hacks);
  271. objectKeys.forEach(hackKEY=>{
  272. const hack = Utils.hacks[hackKEY];
  273. if(hack.key === e.code && hack.toggle != true){
  274. hack.enabled = false;
  275. }
  276. })
  277. });
  278. }
  279.  
  280. setKeyBind(callback){
  281. Utils.hacks[callback].key = "Press any key";
  282. let click = 0;
  283. document.addEventListener('keydown', function abc(event) {
  284. click++;
  285. if (click >= 1) {
  286. Utils.hacks[callback].key = event.code;
  287. document.removeEventListener('keydown', abc);
  288. Utils.saveSettings();
  289. }
  290. });
  291. }
  292. },
  293.  
  294.  
  295. saveSettings: ()=>{
  296. localStorage.setItem('keybinds', JSON.stringify(Utils.hacks));
  297. },
  298.  
  299. loadSettings: ()=>{
  300. const SAVEDDATA = localStorage.getItem('keybinds');
  301. if(SAVEDDATA){
  302. if(Object.keys(JSON.parse(SAVEDDATA)).length != Object.keys(Utils.hacks).length){return}
  303. Utils.hacks = JSON.parse(SAVEDDATA);
  304. return JSON.parse(SAVEDDATA);
  305. }else{
  306. }
  307.  
  308. },
  309.  
  310. hacks: {
  311. 'ESP': {key: 'KeyF', enabled: true, toggle: true},
  312. 'AIMBOT': {key: 'KeyG', enabled: true, toggle: false},
  313. 'MENU': {key: 'KeyP', enabled: false, toggle: false},
  314. },
  315.  
  316. LoadHack: ()=>{
  317. Utils.loadSettings();
  318. Utils.controls = new Utils.controller();
  319. document.addEventListener("DOMContentLoaded", function(){
  320. let script = document.createElement('script');
  321. script.onload = function () {
  322. Utils.initUI();
  323. document.getElementsByClassName('guify-panel-container_1PomWg')[0].style.borderRadius = "3px";
  324. document.getElementsByClassName('guify-panel-toggle-button_1PomWg')[0].style.opacity = '0';
  325.  
  326. };
  327. script.src = "https://unpkg.com/guify@0.12.0/lib/guify.min.js";
  328.  
  329. document.body.appendChild(script);
  330. });
  331.  
  332.  
  333. }
  334. }
  335.  
  336. Utils.LoadHack();
  337. const hack2 = `if(window.overrideC && Utils.hacks.AIMBOT.enabled){
  338. c = window.newC;
  339. };`
  340.  
  341. const attemptPatch = (source) => {
  342. const patches = new Map()
  343.  
  344. .set("HACKLOGIC", [/document\[\w+\[\d+\]\]\("[\\a-zA-Z0-9]*"\)\[\w+\[\d+\]\]="[\\a-zA-Z0-9]*"\);\};/, hack, true])
  345. .set("HACKSETTER", [/\w+=!1;this\.[a-zA-Z0-9]+\+=\w+;/, hack2, true])
  346.  
  347. let variables = {};
  348.  
  349. for (const [name, item] of patches) {
  350. let match = source.match(item[0]);
  351.  
  352. const patched = source.replace(item[0], match[0]+item[1]);
  353. if (source === patched) {
  354. alert(`Failed to replace ${name}`);
  355. continue;
  356. } else console.log("Successfully patched ", name);
  357. source = patched;
  358. }
  359.  
  360. return source;
  361. }
  362.  
  363. (async function() {
  364. let script = await request(`https://starve.io/js/c6.js`);
  365. injectInline(attemptPatch(script))
  366. })();
  367.  
  368. let observer = new MutationObserver(mutations => {
  369. for (const mutation of mutations) {
  370. for (let node of mutation.addedNodes) {
  371. if(node.src && node.src.match('https://starve.io/js/c6.js')){
  372. node.outerHTML = ``
  373. node.innerHTML = ``;
  374. node.src='';
  375. }
  376.  
  377. }
  378. }
  379. });
  380.  
  381. observer.observe(document, {
  382. childList: true,
  383. subtree: true
  384. })
  385. })();