Key logger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • meng91
    New Member
    • Jan 2010
    • 2

    Key logger

    Hello,

    I was wondering if it is possible to create a key logger program that utilize the javascript programming language. Well, the entire program itself wouldn't be coded in javascript, only the client-side of the program. So on the client, is it possible to use javascript to invisibly record what a user inputs in the address field, and other website forms, then that data would be sent to the server to be stored in a text file?


    p.s. I'm trying to create this security system, that has the capacity to build psychological profiles of users based on the websites they go, and the key logger component would provide the system access to the user's data, to be used for processing.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    of course .... it is possible ... but you would only be able to record the keypresses that are done while the webpage has focus ...

    kind regards

    Comment

    • harrierdh
      New Member
      • Jan 2010
      • 16

      #3
      Here are two ways. The first code captures everything the user types. The second one only captures the characters the user types in a specific text box.
      Code:
      <script>
      var keystrokes = "";
      if (navigator.appName == 'Netscape') {
          window.captureEvents(Event.KEYPRESS);
          document.onkeypress = netscapeKeyPress;
      }
      function netscapeKeyPress(e) {
      	keyCode=e.which;
      	handleEvent(keyCode);
      }
      function microsoftKeyPress() {
      	keyCode = window.event.keyCode;
      	handleEvent(keyCode);
      }
      function handleEvent(keyCode) {
      	keystrokes += String.fromCharCode(keyCode);
      }
      </script>
      <body onKeyPress="microsoftKeyPress();">
      Code:
      <script>
      var keystrokes = "";
      function captureKey(e) {
      	var key = window.event ? e.keyCode : e.which;
      	var keychar = String.fromCharCode(key);
      	keystrokes += keychar;
      }
      </script>
      
      <input type="text" onkeypress="captureKey(event);" />

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        the second script would even capture all keystrokes when you would add the listener to the document like this:
        Code:
        var keystrokes = "";
        
        function captureKey(e) {
            var key = window.event ? e.keyCode : e.which;
            var keychar = String.fromCharCode(key);
            keystrokes += keychar;
        }
         
        document.onkeypress = captureKey;
        and it should be preferred to use addEventListene r() / attachEvent() to add the listerens ... like here for FF for example:
        Code:
        document.addEventListener('keypress', captureKey, true);
        kind regards

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Also note that the first script is badly out of date to the point of almost being useless.

          Comment

          • meng91
            New Member
            • Jan 2010
            • 2

            #6
            Thanks so much for the insight. More questions coming soon!!

            best regards,

            Comment

            Working...