Advertisement
FlyFar

Krunker.IO Aimbot & ESP

Jan 7th, 2024
4,966
3
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 10.31 KB | Gaming | 3 0
  1. // ==UserScript==
  2. // @name         Krunker.IO Aimbot & ESP
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.2.6
  5. // @description  Locks aim to the nearest player in krunker.io and shows players behind walls. Also shows a line between you and them.
  6. // @author       Zertalious (Zert)
  7. // @match        *://krunker.io/*
  8. // @match        *://browserfps.com/*
  9. // @exclude      *://krunker.io/social*
  10. // @exclude      *://krunker.io/editor*
  11. // @icon         https://www.google.com/s2/favicons?domain=krunker.io
  12. // @grant        none
  13. // @run-at       document-start
  14. // @require      https://unpkg.com/three@latest/build/three.min.js
  15. // @antifeature  ads
  16. // @downloadURL https://update.greasyfork.org/scripts/432453/KrunkerIO%20Aimbot%20%20ESP.user.js
  17. // @updateURL https://update.greasyfork.org/scripts/432453/KrunkerIO%20Aimbot%20%20ESP.meta.js
  18. // ==/UserScript==
  19.  
  20. const THREE = window.THREE;
  21. Object.defineProperty( window, 'THREE', {
  22.     get() {
  23.  
  24.         return undefined;
  25.  
  26.     }
  27. } );
  28.  
  29. let scene;
  30.  
  31. const x = {
  32.     window: window,
  33.     document: document,
  34.     querySelector: document.querySelector,
  35.     consoleLog: console.log,
  36.     ReflectApply: Reflect.apply,
  37.     ArrayPrototype: Array.prototype,
  38.     ArrayPush: Array.prototype.push,
  39.     ObjectPrototype: Object.prototype,
  40.     clearInterval: window.clearInterval,
  41.     setTimeout: window.setTimeout,
  42.     reToString: RegExp.prototype.toString,
  43.     indexOf: String.prototype.indexOf
  44. };
  45.  
  46. x.consoleLog( 'Waiting to inject...' );
  47.  
  48. const proxied = function ( object ) {
  49.  
  50.     // [native code]
  51.  
  52.     try {
  53.  
  54.         if ( typeof object === 'object' &&
  55.             typeof object.parent === 'object' &&
  56.             object.parent.type === 'Scene' &&
  57.             object.parent.name === 'Main' ) {
  58.  
  59.             x.consoleLog( 'Found Scene!' )
  60.             scene = object.parent;
  61.             x.ArrayPrototype.push = x.ArrayPush;
  62.  
  63.         }
  64.  
  65.     } catch ( error ) {}
  66.  
  67.     return x.ArrayPush.apply( this, arguments );
  68.  
  69. }
  70.  
  71. /*
  72.  
  73. // This inject method gets detected now.
  74.  
  75. const _test = RegExp.prototype.test;
  76.  
  77. RegExp.prototype.test = function ( str ) {
  78.  
  79.     // [native code]
  80.  
  81.     if ( typeof str === 'string' ) {
  82.  
  83.         const re = x.reToString.call( this );
  84.  
  85.         if ( x.indexOf.call( re, 'native' ) > - 1 ) {
  86.  
  87.             x.consoleLog( 'test native:', this, str );
  88.  
  89.             x.setTimeout.call( x.window, function () {
  90.  
  91.                 x.consoleLog( 'Injecting!' );
  92.                 x.ArrayPrototype.push = proxied;
  93.  
  94.             }, 0 );
  95.  
  96.         }
  97.  
  98.     }
  99.  
  100.     return _test.apply( this, arguments );
  101.  
  102. }*/
  103.  
  104. let espEnabled = true;
  105. let aimbotEnabled = true;
  106. let aimbotOnRightMouse = false;
  107. let espLinesEnabled = true;
  108.  
  109. const tempVector = new THREE.Vector3();
  110.  
  111. const tempObject = new THREE.Object3D();
  112. tempObject.rotation.order = 'YXZ';
  113.  
  114. const geometry = new THREE.EdgesGeometry( new THREE.BoxGeometry( 5, 15, 5 ).translate( 0, 7.5, 0 ) );
  115.  
  116. const material = new THREE.RawShaderMaterial( {
  117.     vertexShader: `
  118.  
  119.     attribute vec3 position;
  120.  
  121.     uniform mat4 projectionMatrix;
  122.     uniform mat4 modelViewMatrix;
  123.  
  124.     void main() {
  125.  
  126.         gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  127.         gl_Position.z = 1.0;
  128.  
  129.     }
  130.  
  131.     `,
  132.     fragmentShader: `
  133.  
  134.     void main() {
  135.  
  136.         gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  137.  
  138.     }
  139.  
  140.     `
  141. } );
  142.  
  143. const line = new THREE.LineSegments( new THREE.BufferGeometry(), material );
  144.  
  145. line.frustumCulled = false;
  146.  
  147. const linePositions = new THREE.BufferAttribute( new Float32Array( 100 * 2 * 3 ), 3 );
  148. line.geometry.setAttribute( 'position', linePositions );
  149.  
  150. let injectTimer = null;
  151.  
  152. function animate() {
  153.  
  154.     window.requestAnimationFrame( animate );
  155.  
  156.     if ( ! scene && ! injectTimer ) {
  157.  
  158.         const el = x.querySelector.call( x.document, '#loadingBg' );
  159.  
  160.         if ( el && el.style.display === 'none' ) {
  161.  
  162.             x.consoleLog( 'Inject timer started!' );
  163.  
  164.             injectTimer = x.setTimeout.call( x.window, () => {
  165.  
  166.                 x.consoleLog( 'Injected!' );
  167.                 x.ArrayPrototype.push = proxied;
  168.  
  169.             }, 2e3 );
  170.  
  171.         }
  172.  
  173.     }
  174.  
  175.     if ( typeof shouldShowAd === 'undefined' || shouldShowAd === true || scene === undefined || ! scene.children ) {
  176.  
  177.         return;
  178.  
  179.     }
  180.  
  181.     const players = [];
  182.  
  183.     let myPlayer;
  184.  
  185.     for ( let i = 0; i < scene.children.length; i ++ ) {
  186.  
  187.         const child = scene.children[ i ];
  188.  
  189.         if ( child.type === 'Object3D' ) {
  190.  
  191.             try {
  192.  
  193.                 if ( child.children[ 0 ].children[ 0 ].type === 'PerspectiveCamera' ) {
  194.  
  195.                     myPlayer = child;
  196.  
  197.                 } else {
  198.  
  199.                     players.push( child );
  200.  
  201.                 }
  202.  
  203.             } catch ( err ) {}
  204.  
  205.         }
  206.  
  207.     }
  208.  
  209.     if ( ! myPlayer ) {
  210.  
  211.         x.consoleLog( 'Player not found, finding new scene.' );
  212.         x.ArrayPrototype.push = proxied;
  213.         return;
  214.  
  215.     }
  216.  
  217.     let counter = 0;
  218.  
  219.     let targetPlayer;
  220.     let minDistance = Infinity;
  221.  
  222.     tempObject.matrix.copy( myPlayer.matrix ).invert()
  223.  
  224.     for ( let i = 0; i < players.length; i ++ ) {
  225.  
  226.         const player = players[ i ];
  227.  
  228.         if ( ! player.box ) {
  229.  
  230.             const box = new THREE.LineSegments( geometry, material );
  231.             box.frustumCulled = false;
  232.  
  233.             player.add( box );
  234.  
  235.             player.box = box;
  236.  
  237.         }
  238.  
  239.         if ( player.position.x === myPlayer.position.x && player.position.z === myPlayer.position.z ) {
  240.  
  241.             player.box.visible = false;
  242.  
  243.             if ( line.parent !== player ) {
  244.  
  245.                 player.add( line );
  246.  
  247.             }
  248.  
  249.             continue;
  250.  
  251.         }
  252.  
  253.         linePositions.setXYZ( counter ++, 0, 10, - 5 );
  254.  
  255.         tempVector.copy( player.position );
  256.  
  257.         tempVector.y += 9;
  258.  
  259.         tempVector.applyMatrix4( tempObject.matrix );
  260.  
  261.         linePositions.setXYZ(
  262.             counter ++,
  263.             tempVector.x,
  264.             tempVector.y,
  265.             tempVector.z
  266.         );
  267.  
  268.         player.visible = espEnabled || player.visible;
  269.  
  270.         player.box.visible = espEnabled;
  271.  
  272.         const distance = player.position.distanceTo( myPlayer.position );
  273.  
  274.         if ( distance < minDistance ) {
  275.  
  276.             targetPlayer = player;
  277.  
  278.             minDistance = distance;
  279.  
  280.         }
  281.  
  282.     }
  283.  
  284.     linePositions.needsUpdate = true;
  285.     line.geometry.setDrawRange( 0, counter );
  286.  
  287.     line.visible = espLinesEnabled;
  288.  
  289.     if ( aimbotEnabled === false || ( aimbotOnRightMouse && ! rightMouseDown ) || targetPlayer === undefined ) {
  290.  
  291.         return;
  292.  
  293.     }
  294.  
  295.     tempVector.setScalar( 0 );
  296.  
  297.     targetPlayer.children[ 0 ].children[ 0 ].localToWorld( tempVector );
  298.  
  299.     tempObject.position.copy( myPlayer.position );
  300.  
  301.     tempObject.lookAt( tempVector );
  302.  
  303.     myPlayer.children[ 0 ].rotation.x = - tempObject.rotation.x;
  304.     myPlayer.rotation.y = tempObject.rotation.y + Math.PI;
  305.  
  306. }
  307.  
  308. const value = parseInt( new URLSearchParams( window.location.search ).get( 'showAd' ), 16 );
  309.  
  310. const shouldShowAd = isNaN( value ) || Date.now() - value < 0 || Date.now() - value > 10 * 60 * 1000;
  311.  
  312. const el = document.createElement( 'div' );
  313.  
  314. el.innerHTML = `<style>
  315.  
  316. .dialog {
  317.     position: absolute;
  318.     left: 50%;
  319.     top: 50%;
  320.     padding: 20px;
  321.     background: rgba(0, 0, 0, 0.8);
  322.     border: 6px solid rgba(0, 0, 0, 0.2);
  323.     color: #fff;
  324.     transform: translate(-50%, -50%);
  325.     text-align: center;
  326.     z-index: 999999;
  327. }
  328.  
  329. .dialog * {
  330.     color: #fff;
  331. }
  332.  
  333. .close {
  334.     position: absolute;
  335.     right: 5px;
  336.     top: 5px;
  337.     width: 20px;
  338.     height: 20px;
  339.     opacity: 0.5;
  340.     cursor: pointer;
  341. }
  342.  
  343. .close:before, .close:after {
  344.     content: ' ';
  345.     position: absolute;
  346.     left: 50%;
  347.     top: 50%;
  348.     width: 100%;
  349.     height: 20%;
  350.     transform: translate(-50%, -50%) rotate(-45deg);
  351.     background: #fff;
  352. }
  353.  
  354. .close:after {
  355.     transform: translate(-50%, -50%) rotate(45deg);
  356. }
  357.  
  358. .close:hover {
  359.     opacity: 1;
  360. }
  361.  
  362. .btn {
  363.     cursor: pointer;
  364.     padding: 0.5em;
  365.     background: red;
  366.     border: 3px solid rgba(0, 0, 0, 0.2);
  367. }
  368.  
  369. .btn:active {
  370.     transform: scale(0.8);
  371. }
  372.  
  373. .msg {
  374.     position: absolute;
  375.     left: 10px;
  376.     bottom: 10px;
  377.     color: #fff;
  378.     background: rgba(0, 0, 0, 0.6);
  379.     font-weight: bolder;
  380.     padding: 15px;
  381.     animation: msg 0.5s forwards, msg 0.5s reverse forwards 3s;
  382.     z-index: 999999;
  383.     pointer-events: none;
  384. }
  385.  
  386. @keyframes msg {
  387.     from {
  388.         transform: translate(-120%, 0);
  389.     }
  390.  
  391.     to {
  392.         transform: none;
  393.     }
  394. }
  395.  
  396. </style>
  397. <div class="msg" style="display: none;"></div>
  398. <div class="dialog">${shouldShowAd ? `<big>Loading ad...</big>` : `<div class="close" onclick="this.parentNode.style.display='none';"></div>
  399.     <big>== Aimbot & ESP ==</big>
  400.     <br>
  401.     <br>
  402.     [B] to toggle aimbot
  403.     <br>
  404.     [V] to toggle ESP
  405.     <br>
  406.     [N] to toggle ESP Lines
  407.     <br>
  408.     [L] to toggle aimbot on <br>right mouse hold
  409.     <br>
  410.     [H] to show/hide help
  411.     <br>
  412.     <br>
  413.     By Zertalious
  414.     <br>
  415.     <br>
  416.     <div style="display: grid; grid-template-columns: 1fr 1fr; grid-gap: 5px;">
  417.         <div class="btn" onclick="window.open('https://discord.gg/K24Zxy88VM', '_blank')">Discord</div>
  418.         <div class="btn" onclick="window.open('https://www.instagram.com/zertalious/', '_blank')">Instagram</div>
  419.         <div class="btn" onclick="window.open('https://twitter.com/Zertalious', '_blank')">Twitter</div>
  420.         <div class="btn" onclick="window.open('https://greasyfork.org/en/users/662330-zertalious', '_blank')">More scripts</div>
  421.     </div>
  422.     ` }
  423. </div>`;
  424.  
  425. const msgEl = el.querySelector( '.msg' );
  426. const dialogEl = el.querySelector( '.dialog' );
  427.  
  428. window.addEventListener( 'DOMContentLoaded', function () {
  429.  
  430.     while ( el.children.length > 0 ) {
  431.  
  432.         document.body.appendChild( el.children[ 0 ] );
  433.  
  434.     }
  435.  
  436. } );
  437.  
  438. if ( shouldShowAd ) {
  439.  
  440.     const url = new URL( window.location.href );
  441.  
  442.     url.searchParams.set( 'showAd', Date.now().toString( 16 ) );
  443.     url.searchParams.set( 'scriptVersion', GM.info.script.version );
  444.  
  445.     window.location.href = 'https://zertalious.xyz?ref=' + new TextEncoder().encode( url.href ).toString();
  446.  
  447. }
  448.  
  449. let rightMouseDown = false;
  450.  
  451. function handleMouse( event ) {
  452.  
  453.     if ( event.button === 2 ) {
  454.  
  455.         rightMouseDown = event.type === 'pointerdown' ? true : false;
  456.  
  457.     }
  458.  
  459. }
  460.  
  461. window.addEventListener( 'pointerdown', handleMouse );
  462. window.addEventListener( 'pointerup', handleMouse );
  463.  
  464. window.addEventListener( 'keyup', function ( event ) {
  465.  
  466.     switch ( event.code ) {
  467.  
  468.         case 'KeyV' :
  469.  
  470.             espEnabled = ! espEnabled;
  471.  
  472.             showMsg( 'ESP', espEnabled );
  473.  
  474.             break;
  475.  
  476.         case 'KeyB' :
  477.  
  478.             aimbotEnabled = ! aimbotEnabled;
  479.  
  480.             showMsg( 'Aimbot', aimbotEnabled );
  481.  
  482.             break;
  483.  
  484.         case 'KeyH' :
  485.  
  486.             dialogEl.style.display = dialogEl.style.display === '' ? 'none' : '';
  487.  
  488.             break;
  489.  
  490.         case 'KeyL' :
  491.  
  492.             aimbotOnRightMouse = ! aimbotOnRightMouse;
  493.  
  494.             showMsg( 'Aimbot On Right Mouse Hold', aimbotOnRightMouse );
  495.  
  496.             break;
  497.  
  498.         case 'KeyN' :
  499.  
  500.             espLinesEnabled = ! espLinesEnabled;
  501.  
  502.             showMsg( 'ESP Lines', espLinesEnabled );
  503.  
  504.             break;
  505.  
  506.     }
  507.  
  508. } );
  509.  
  510. function showMsg( name, bool ) {
  511.  
  512.     msgEl.innerText = name + ': ' + ( bool ? 'ON' : 'OFF' );
  513.  
  514.     msgEl.style.display = 'none';
  515.  
  516.     void msgEl.offsetWidth;
  517.  
  518.     msgEl.style.display = '';
  519.  
  520. }
  521.  
  522. animate();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement