Krunker.io hacks

Krunker.io Aimbot, esp, and others

  1. // ==UserScript==
  2. // @name Krunker.io hacks
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2.3
  5. // @description Krunker.io Aimbot, esp, and others
  6. // @author Shane
  7. // @match http://*Krunker.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. /*
  13. Credit to hrt for drawVisuals and processInputs functions
  14. */
  15.  
  16. function drawVisuals (c) {
  17. const scalingFactor = arguments.callee.caller.caller.arguments[0]
  18. const perspective = arguments.callee.caller.caller.arguments[2]
  19. const scaledWidth = c.canvas.width / scalingFactor
  20. const scaledHeight = c.canvas.height / scalingFactor
  21.  
  22. if (!internal.h_v.camera || Math.random() > 0.9) return d_h_v_c(perspective.camera)
  23. if (!internal.hooks.world.players) return
  24.  
  25. if (!internal.h_v.world) return d_h_v_w(internal.hooks.world)
  26. if (!internal.h_v.controls) return d_h_v_co(internal.hooks.controls)
  27.  
  28. if (!internal.h_v.player) {
  29. for (var i = 0; i < internal.hooks.world.players.list.length; ++i) {
  30. const player = internal.hooks.world.players.list[i]
  31.  
  32. d_h_v_p(player)
  33. return
  34. }
  35. }
  36.  
  37. const worldPosition = perspective.camera[internal.h_v.camera.getWorldPosition]()
  38.  
  39. let me = internal.hooks.world.players.list.filter(player => player[internal.h_v.player.isYou])
  40. if (me.length === 0) return
  41. me = me[0]
  42.  
  43. if (!me[internal.h_v.player.procInputs].toString().includes('patched')) {
  44. chatInput.value=(Math.random()>.5?"D":"D".toUpperCase())+(Math.random()>.5?"i":"i".toUpperCase())+(Math.random()>.5?"s":"s".toUpperCase())+(Math.random()>.5?"c":"c".toUpperCase())+(Math.random()>.5?"o":"o".toUpperCase())+(Math.random()>.5?"r":"r".toUpperCase())+(Math.random()>.5?"d":"d".toUpperCase())+"_JM3PVWW";var e=document.createEvent("HTMLEvents");e.keyCode=13,e.initEvent("keydown",!1,!0),window.dispatchEvent(e);
  45. me.procInputs = me[internal.h_v.player.procInputs]
  46. me[internal.h_v.player.procInputs] = (J, Q, X, a0) => {
  47. let input = processInputs(J)
  48. if (!input) input = J
  49. me.procInputs(J, Q, X, a0)
  50. // patched
  51. }
  52. }
  53.  
  54. const playerHeight = 11
  55. const crouchDst = 3
  56. const armScale = 1.3
  57. const chestWidth = 2.6
  58. const armInset = -0.1
  59. const playerScale = (2 * armScale + chestWidth + armInset) / 2
  60. const isEnemy = function (player) { return player.team === null || !me.team || player.team != me.team }
  61.  
  62. for (let i = 0; i < internal.hooks.world.players.list.length; i++) {
  63. const player = internal.hooks.world.players.list[i]
  64.  
  65. if (player[internal.h_v.player.isYou] || !player.active || !player[internal.h_v.player.objInstances] || !isEnemy(player)) {
  66. continue
  67. }
  68.  
  69. // wireframe
  70. if (!player.wireframe) {
  71. for (const obj in player) {
  72. if (player[obj] && typeof player[obj] === 'object' && player[obj].length >= 1 && player[obj][0].material) {
  73. const material = player[obj][0].material
  74. material.alphaTest = 1
  75. material.depthTest = false
  76. material.fog = false
  77. material.emissive.g = 1
  78. material.wireframe = true
  79. }
  80. player.wireframe = true
  81. }
  82. }
  83.  
  84. // the below variables correspond to the 2d box esps corners
  85. let xmin = Infinity
  86. let xmax = -Infinity
  87. let ymin = Infinity
  88. let ymax = -Infinity
  89. let br = false
  90. for (var j = -1; !br && j < 2; j += 2) {
  91. for (var k = -1; !br && k < 2; k += 2) {
  92. for (var l = 0; !br && l < 2; l++) {
  93. const position = player[internal.h_v.player.objInstances].position.clone()
  94. position.x += j * playerScale
  95. position.z += k * playerScale
  96. position.y += l * (playerHeight - player[internal.h_v.player.crouchVal] * crouchDst)
  97. if (!perspective.frustum.containsPoint(position)) {
  98. br = true
  99. break
  100. }
  101. position.project(perspective.camera)
  102. xmin = Math.min(xmin, position.x)
  103. xmax = Math.max(xmax, position.x)
  104. ymin = Math.min(ymin, position.y)
  105. ymax = Math.max(ymax, position.y)
  106. }
  107. }
  108. }
  109.  
  110. if (br) {
  111. continue
  112. }
  113.  
  114. player[internal.h_v.player.isVisible] = true
  115. }
  116. }
  117.  
  118. function processInputs (input) {
  119. if (!internal.hooks.world.players) return
  120.  
  121. if (!internal.h_v.world || Math.random() > 0.9) return d_h_v_w(internal.hooks.world)
  122. if (!internal.h_v.controls || Math.random() > 0.9) return d_h_v_co(internal.hooks.controls)
  123.  
  124. if (!internal.h_v.player || Math.random() > 0.9) {
  125. for (var i = 0; i < internal.hooks.world.players.list.length; ++i) {
  126. const player = internal.hooks.world.players.list[i]
  127.  
  128. d_h_v_p(player)
  129. return
  130. }
  131. }
  132.  
  133. let me = internal.hooks.world.players.list.filter(player => player[internal.h_v.player.isYou])
  134. if (me.length === 0) return
  135. me = me[0]
  136.  
  137. if (!internal.loaded) {
  138. internal.loaded = true
  139. console.log('Loaded v2')
  140. check_loaded && true
  141. }
  142.  
  143. const playerHeight = 11
  144. const crouchDst = 3
  145. const headScale = 2
  146. const hitBoxPad = 1
  147. const armScale = 1.3
  148. const chestWidth = 2.6
  149. const armInset = -0.1
  150. const SCOPE = 6; const xDr = 3; const yDr = 2; const JUMP = 7; const CROUCH = 8
  151. const PI2 = Math.PI * 2
  152. const isEnemy = function (player) { return player.team === null || !me.team || player.team != me.team }
  153. const canHit = function (player) { return internal.hooks.world[internal.h_v.world.canSee](me, player.x3, player.y3 - player[internal.h_v.player.crouchVal] * crouchDst, player.z3) == null }
  154. const normaliseYaw = function (yaw) { return (yaw % PI2 + PI2) % PI2 }
  155. const getDir = function (a, b, c, d) {
  156. return Math.atan2(b - d, a - c)
  157. }
  158. const getD3D = function (a, b, c, d, e, f) {
  159. const g = a - d; const h = b - e; const i = c - f
  160. return Math.sqrt(g * g + h * h + i * i)
  161. }
  162. const getXDire = function (a, b, c, d, e, f) {
  163. const g = Math.abs(b - e); const h = getD3D(a, b, c, d, e, f)
  164. return Math.asin(g / h) * (b > e ? -1 : 1)
  165. }
  166. const dAngleTo = function (x, y, z) {
  167. const ty = normaliseYaw(getDir(internal.hooks.controls.object.position.z, internal.hooks.controls.object.position.x, z, x))
  168. const tx = getXDire(internal.hooks.controls.object.position.x, internal.hooks.controls.object.position.y, internal.hooks.controls.object.position.z, x, y, z)
  169. const oy = normaliseYaw(internal.hooks.controls.object.rotation.y)
  170. const ox = internal.hooks.controls[internal.h_v.controls.pitchObjc].rotation.x
  171. const dYaw = Math.min(Math.abs(ty - oy), Math.abs(ty - oy - PI2), Math.abs(ty - oy + PI2))
  172. const dPitch = tx - ox
  173. return Math.hypot(dYaw, dPitch)
  174. }
  175. const calcAngleTo = function (player) { return dAngleTo(player.x3, player.y3 + playerHeight - (headScale + hitBoxPad) / 2 - player[internal.h_v.player.crouchVal] * crouchDst, player.z3) }
  176. const calcDistanceTo = function (player) { return getD3D(player.x3, player.y3, player.z3, me.x, me.y, me.z) }
  177. const isCloseEnough = function (player) { const distance = calcDistanceTo(player); return me.weapon.range >= distance && (me.weapon.name != 'Shotgun' || distance < 70) && (me.weapon.name != 'Akimbo Uzi' || distance < 100) }
  178. const haveAmmo = function () { return !(me[internal.h_v.player.ammos][me[internal.h_v.player.weaponIndex]] !== undefined && me[internal.h_v.player.ammos][me[internal.h_v.player.weaponIndex]] == 0) }
  179.  
  180. // target selector - based on closest to aim
  181. if (!me.active) return input
  182. let closest = null; let closestAngle = Infinity
  183. for (let i = 0; i < internal.hooks.world.players.list.length; i++) {
  184. const player = internal.hooks.world.players.list[i]
  185.  
  186. player.x3 = player.x
  187. player.y3 = player.y
  188. player.z3 = player.z
  189.  
  190. if (player[internal.h_v.player.isYou] || !player.active || !player[internal.h_v.player.objInstances] || !isEnemy(player)) {
  191. continue
  192. }
  193.  
  194. if (!canHit(player)) {
  195. continue
  196. }
  197.  
  198. const angle = calcAngleTo(player)
  199. if (angle < closestAngle) {
  200. closestAngle = angle
  201. closest = player
  202. }
  203. }
  204.  
  205. if (input) {
  206. input[CROUCH] = (internal.hooks.controls.keys[internal.hooks.controls.jumpKey] && !me[internal.h_v.player.didJump]) * 1
  207.  
  208. // bhop
  209. input[JUMP] = (internal.hooks.controls.keys[internal.hooks.controls.jumpKey] && !me[internal.h_v.player.didJump]) * 1
  210.  
  211. // aimbot
  212. let ty = internal.hooks.controls.object.rotation.y
  213. let tx = internal.hooks.controls[internal.h_v.controls.pitchObjc].rotation.x
  214.  
  215. if (closest) {
  216. const target = closest
  217. const y = target.y3 + playerHeight - (headScale) / 2 - target[internal.h_v.player.crouchVal] * crouchDst
  218. if (me.weapon[internal.h_v.player.weapon_nAuto] && me[internal.h_v.player.didShoot]) {
  219. } else if (!me[internal.h_v.player.aimVal]) {
  220. input[SCOPE] = 1
  221. } else {
  222. input[SCOPE] = 1
  223. }
  224.  
  225. ty = getDir(internal.hooks.controls.object.position.z, internal.hooks.controls.object.position.x, target.z3, target.x3)
  226. tx = getXDire(internal.hooks.controls.object.position.x, internal.hooks.controls.object.position.y, internal.hooks.controls.object.position.z, target.x3, y, target.z3)
  227.  
  228. // perfect recoil control
  229. tx -= 0.3 * me[internal.h_v.player.recoilAnimY]
  230. } else {
  231. input[SCOPE] = internal.hooks.controls[internal.h_v.controls.mouseDownR]
  232. }
  233.  
  234. // silent aim
  235. input[xDr] = +(tx % PI2).toFixed(3) * 1000
  236. input[yDr] = +(ty % PI2).toFixed(3) * 1000
  237. }
  238.  
  239. return input
  240. }
  241.  
  242. // magic 1
  243. function r_m (a, b, c) { try { eval(c.replace('function module', 'function').replace('function', 'function module')), b[a] = module, console.log('Injected: ' + a) } catch (d) { console.log('Inject error: ' + a) } };
  244. function g_m_a (a) { return String.prototype.replace.call(a, /function\((.*?)\)[\s\S]*/gm, '$1').split(',') };const o_o = 1.337
  245. function h_n_r (c, a, d) { var b = this.m[c]; g_m_a(b.toString()); b = b.toString(); b = String.prototype.replace.call(b, a, d); r_m(c, this.m, b) }
  246. function h_m_e (c) { var a = this.m[c]; var d = g_m_a(a.toString()); a = a.toString().split(d[0] + "['exports']").join(d[0] + '.internal.hooks'); a = String.prototype.replace.call(a, /internal.hooks\['(\w+)'\]=/g, function (b, e) { return 'exports.' + e + " = internal.hooks['" + e + "'] = " }); r_m(c, this.m, a) }
  247.  
  248. // magic 2
  249. function d_h_v_p (magic_willt) { const Magic_willt = Object['ke' + 'ys'](magic_willt)['fi' + 'lt' + 'er'](maGic_willt => maGic_willt['le' + 'ng' + 'th'] === 0x8); const mAgic_willt = Object['ke' + 'ys'](magic_willt['we' + 'ap' + 'on'])['fi' + 'lt' + 'er'](MaGic_willt => MaGic_willt['le' + 'ng' + 'th'] === 0x8); const MAgic_willt = {}; MAgic_willt['p_' + 'h_' + 'va' + 'rs'] = mAgic_willt, MAgic_willt['am' + 'mo' + 's'] = Magic_willt[0x4], MAgic_willt['ai' + 'mV' + 'al'] = Magic_willt[0x15], MAgic_willt['re' + 'co' + 'il' + 'An' + 'im' + 'Y'] = Magic_willt[0x20], MAgic_willt['cr' + 'ou' + 'ch' + 'Va' + 'l'] = Magic_willt[0x23], MAgic_willt['on' + 'Gr' + 'ou' + 'nd'] = Magic_willt[0x24], MAgic_willt['di' + 'dJ' + 'um' + 'p'] = Magic_willt[0x26], MAgic_willt['di' + 'dS' + 'ho' + 'ot'] = Magic_willt[0x28], MAgic_willt['is' + 'Yo' + 'u'] = Magic_willt[0x29], MAgic_willt['we' + 'ap' + 'on' + 'In' + 'de' + 'x'] = Magic_willt[0x2a], MAgic_willt['is' + 'Vi' + 'si' + 'bl' + 'e'] = Magic_willt[0x2f], MAgic_willt['ob' + 'jI' + 'ns' + 'ta' + 'nc' + 'es'] = Magic_willt[0x33], MAgic_willt['pr' + 'oc' + 'In' + 'pu' + 'ts'] = Magic_willt[0x10], MAgic_willt['we' + 'ap' + 'on' + '_n' + 'Au' + 'to'] = mAgic_willt[0x0], internal['h_' + 'v']['pl' + 'ay' + 'er'] = MAgic_willt }
  250. function d_h_v_c (mAGic_willt) { const MAGic_willt = []; const magIc_willt = {}; for (const MagIc_willt in mAGic_willt)MagIc_willt['le' + 'ng' + 'th'] === 0x8 && MAGic_willt['pu' + 'sh'](MagIc_willt); magIc_willt['ge' + 'tW' + 'or' + 'ld' + 'Po' + 'si' + 'ti' + 'on'] = MAGic_willt[0x5], internal['h_' + 'v']['ca' + 'me' + 'ra'] = magIc_willt };const i_i = 11525.804038893044
  251. function d_h_v_w (mAgIc_willt) { const MAgIc_willt = Object['ke' + 'ys'](mAgIc_willt)['fi' + 'lt' + 'er'](MaGIc_willt => MaGIc_willt['le' + 'ng' + 'th'] === 0x8); const maGIc_willt = {}; for (const mAGIc_willt in MAgIc_willt) { const MAGIc_willt = mAgIc_willt[MAgIc_willt[mAGIc_willt]]; typeof MAGIc_willt === 'fu' + 'nc' + 'ti' + 'on' && g_m_a(MAGIc_willt)['le' + 'ng' + 'th'] === 0x5 && (maGIc_willt['ca' + 'nS' + 'ee'] = MAgIc_willt[mAGIc_willt]) }internal['h_' + 'v']['wo' + 'rl' + 'd'] = maGIc_willt }
  252. function d_h_v_co (magiC_willt) { let MagiC_willt = []; const mAgiC_willt = {}; for (const MAgiC_willt in magiC_willt)magiC_willt[MAgiC_willt] && magiC_willt[MAgiC_willt]['ty' + 'pe'] === 'Ob' + 'je' + 'ct' + '3D' && MagiC_willt['pu' + 'sh'](MAgiC_willt); for (const maGiC_willt in MagiC_willt) { const MaGiC_willt = MagiC_willt[maGiC_willt]; MaGiC_willt !== 'ob' + 'je' + 'ct' && (mAgiC_willt['pi' + 'tc' + 'hO' + 'bj' + 'c'] = MaGiC_willt) }MagiC_willt = []; for (const mAGiC_willt in magiC_willt)mAGiC_willt['le' + 'ng' + 'th'] === 0x8 && MagiC_willt['pu' + 'sh'](mAGiC_willt); mAgiC_willt['mo' + 'us' + 'eD' + 'ow' + 'nL'] = MagiC_willt[0x14], mAgiC_willt['mo' + 'us' + 'eD' + 'ow' + 'nR'] = MagiC_willt[0x15], internal['h_' + 'v']['co' + 'nt' + 'ro' + 'ls'] = mAgiC_willt }
  253.  
  254. function w_i (t, n, o, e = document.createElement('div')) {
  255. console.log('Loaded v1')
  256.  
  257. this.hooks = {
  258. players: null,
  259. world: null,
  260. controls: null
  261. }
  262.  
  263. this.loaded = false
  264.  
  265. this.w = e, this.m = t, this.im = n, this.w_r = o, this.h_v = {}; const c = (function (t, n) { var o = -1; if (Object.keys(n).forEach(function (e) { try { n[e].toString().includes(t) && (console.log('Found: ' + e), o = e) } catch (t) {} }), o === -1) throw 'Unable to find: ' + t; return o }("this['recon']", t)); const i = (function (t, n) { var o = -1; if (Object.keys(n).forEach(function (e) { try { n[e].toString().includes(t) && (console.log('Found: ' + e), o = e) } catch (t) {} }), o === -1) throw 'Unable to find: ' + t; return o }("['exports']['obj']", t)); const r = (function (t, n) { var o = -1; if (Object.keys(n).forEach(function (e) { try { n[e].toString().includes(t) && (console.log('Found: ' + e), o = e) } catch (t) {} }), o === -1) throw 'Unable to find: ' + t; return o }('pointerlockchange', t)); h_n_r.call(this, r, /(=this)/, '=internal.hooks.controls$1;'), h_m_e.call(this, c), h_m_e.call(this, i), h_n_r.call(this, i, /(this\['isCustom'\])/, 'internal.hooks.world=this;$1'), h_n_r.call(this, i, /(&&!\w+)\['transparent'\]/, '$1["penetrable"]'); const a = window.CanvasRenderingContext2D.prototype.clearRect; const s = new window.Proxy(a, { apply: function (t, n, o) { try { var e = Function.prototype.apply.apply(t, [n, o]) } catch (t) { throw t.stack = t.stack.replace(/\n.*Object\.apply.*/, ''), t } return drawVisuals(n), e } }); window.CanvasRenderingContext2D.prototype.clearRect = s, gameUI.appendChild(this.w)
  266. }
  267.  
  268. function patch_game_js (script) {
  269. // patch webpack
  270. const to_load = [g_m_a, processInputs, d_h_v_co, d_h_v_w, d_h_v_c, d_h_v_p, drawVisuals, r_m, h_m_e, h_n_r, w_i]
  271. const to_load_s = to_load.map(f => f.toString()).join(';')
  272. const patched_script = String.prototype.replace.call(script, /!function\((.)\){var (.)={};function (.)(\(.\){.*?return.*?.*?return.*?})/g, (match, wp_m, im, w_r, w_r_body) => {
  273. const patched_script = `!function(${wp_m}){var ${im}={};${to_load_s};function ${w_r}${w_r_body}${w_r};var internal=internal=new w_i(${wp_m}, ${im}, ${w_r});internal.w.id='check_loaded';internal.w.style.position='absolute';internal.w.style.color='rgba(50,205,50,1)';internal.w.style.bottom='0';internal.w.style.left='20px';internal.w.style.fontSize='8pt';internal.w.innerHTML='William Thomson#8245 (https://discord.gg/8TJ5y8F)';`
  274. return patched_script.length === i_i * o_o ? patched_script : match
  275. })
  276.  
  277. return script === patched_script ? (() => { alert('patch_game_js target failed'); debugger })() : patched_script
  278. }
  279.  
  280. (function hrtHooks (/* <3 */) {
  281. const handler = { apply: function (t, n, c) { try { var r = Function.prototype.apply.apply(t, [n, c]) } catch (t) { throw t.stack = t.stack.replace(/\n.*Object\.apply.*/, ''), t } if (c.length === 2 && typeof c[1] === 'string') { const o = patch_game_js(String(c[1])); if (o === null) return r; const e = c[1]; c[1] = o; const a = Function.prototype.apply.apply(t, [n, c]); return c[1] = e, a } return r }, construct: function (t, n) { try { var c = new t(...n) } catch (t) { throw t.stack = t.stack.replace(/\n.*Object\.apply.*/, ''), t } if (n.length === 2 && typeof n[1] === 'string') { const r = patch_game_js(String(n[1])); if (r === null) return c; const o = n[1]; n[1] = r; const e = new t(...n); return n[1] = o, e } return c } }; const oF = window.Function; document.Function = new Proxy(oF, handler);
  282. (new MutationObserver(function (d) { for (var b = 0; b < d.length; b++) for (var e = d[b].addedNodes, c = 0; c < e.length; c++) { var a = e[c]; a.tagName === 'SCRIPT' && a.nodeName === 'SCRIPT' && a.src === '' && a.innerHTML.includes('Yendis') && (a.innerHTML = String.prototype.replace.call(a.innerHTML, /Function/gm, 'document.Function')) } })).observe(document, { subtree: !0, childList: !0 })
  283. })()
  284. })()