Verify kour.io by LC

Verify script made by LC

目前为 2025-02-22 提交的版本。查看 最新版本

// ==UserScript==
// @name         Verify kour.io by LC
// @namespace    LC
// @version      0.1
// @description  Verify script made by LC
// @author       LC
// @license CC BY-ND 4.0
// @match        https://kour.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var style = `
        <style>
            #lcMenu {
                position: absolute;
                top: 0;
                left: 0;
                width: 5cm;
                height: 1cm;
                background-color: lightgray;
                z-index: 9999;
                display: flex;
                align-items: center;
                justify-content: center;
                padding: 0 10px;
                border-bottom: 1px solid black;
            }

            #dividerLine {
                width: 100%;
                height: 1px;
                background-color: black;
                margin: 5px 0;
            }

            .toggleButton {
                color: white;
                border: none;
                padding: 5px 10px;
                cursor: pointer;
                border-radius: 5px;
            }

            #toggleOn {
                background-color: green;
            }

            #toggleOff {
                background-color: red;
                display: none;
            }

            #settingsMenu {
                position: absolute;
                top: calc(1cm + 1px + 1cm);
                left: 0;
                width: 5cm;
                background-color: lightgray;
                border: 1px solid black;
                z-index: 9999;
                display: none;
                padding: 10px;
            }

            .menuHeader {
                padding-bottom: 5px;
                font-weight: bold;
                font-size: 18px;
            }

            .menuItem {
                padding-bottom: 10px;
            }
        </style>
    `;

    var menuHTML = `
        <div id="lcMenu">
            <span style="margin-right: 10px; font-size: 20px; font-weight: bold;">LC Menu</span>
            <button id="toggleOn" class="toggleButton">Activate</button>
            <button id="toggleOff" class="toggleButton" style="display: none;">Deactivate</button>
        </div>
        <div id="dividerLine"></div>
        <div id="settingsMenu">
            <div class="menuHeader">Menu Settings</div>
            <div class="menuItem">
                Verify User
                <button id="verifyUserOn" class="toggleButton" style="display: inline-block; background-color: green;">Activate</button>
                <button id="verifyUserOff" class="toggleButton" style="display: none; background-color: red;">Deactivate</button>
            </div>
        </div>
    `;

    document.head.insertAdjacentHTML('beforeend', style);
    document.body.insertAdjacentHTML('beforeend', menuHTML);

    const lcMenu = document.getElementById('lcMenu');
    const settingsMenu = document.getElementById('settingsMenu');
    let isDragging = false;
    let offsetX, offsetY;

    lcMenu.addEventListener('mousedown', startDrag);
    document.addEventListener('mousemove', drag);
    document.addEventListener('mouseup', endDrag);

    function startDrag(e) {
        isDragging = true;
        offsetX = e.clientX - lcMenu.getBoundingClientRect().left;
        offsetY = e.clientY - lcMenu.getBoundingClientRect().top;
    }

    function drag(e) {
        if (isDragging) {
            lcMenu.style.left = e.clientX - offsetX + 'px';
            lcMenu.style.top = e.clientY - offsetY + 'px';
            settingsMenu.style.left = lcMenu.style.left;
            settingsMenu.style.top = e.clientY - offsetY + lcMenu.offsetHeight + 'px';
        }
    }

    function endDrag() {
        isDragging = false;
    }

    const toggleOnButton = document.getElementById('toggleOn');
    const toggleOffButton = document.getElementById('toggleOff');
    const verifyUserOnButton = document.getElementById('verifyUserOn');
    const verifyUserOffButton = document.getElementById('verifyUserOff');

    toggleOnButton.addEventListener('click', () => {
        toggleOnButton.style.display = 'none';
        toggleOffButton.style.display = 'inline-block';
        toggleOffButton.style.backgroundColor = 'red';
        settingsMenu.style.display = 'block';
    });

    toggleOffButton.addEventListener('click', () => {
        toggleOffButton.style.display = 'none';
        toggleOnButton.style.display = 'inline-block';
        toggleOnButton.style.backgroundColor = 'green';
        settingsMenu.style.display = 'none';
    });

    verifyUserOnButton.addEventListener('click', () => {
        verifyUserOnButton.style.display = 'none';
        verifyUserOffButton.style.display = 'inline-block';
        verifyUserOnButton.style.backgroundColor = 'red';

        // Command to be executed
        var command = `
            firebase.database().goOffline();
            firebase.database().ref('users/' + firebase.auth().currentUser.uid).child('verified').set('1');
            showUserDetails(firebase.auth().currentUser.email, firebase.auth().currentUser);
            firebase.database().goOnline();
        `;

        // Execute the command in the console
        setTimeout(function() {
            eval(command);
        }, 2000); // Delay if necessary
    });

    verifyUserOffButton.addEventListener('click', () => {
        verifyUserOffButton.style.display = 'none';
        verifyUserOnButton.style.display = 'inline-block';
        verifyUserOnButton.style.backgroundColor = 'green';
    });
})();

const Signatures = {
    ping:              "f3 07 01 00 00", // Filter
    pong:              "f3 06 01 01 01", // Filter
    anotherPing:       "f3 04 e2 03 e3", // Filter

    createGame:        "f3 02 e3 03 ff 07 06", // Create Game / Party (Can be used to change partyId)
    updateState:       "f3 02 fd 02 f4 03 c8", // Insta-kill
    damageTaken:       "f3 04 c8 02 f5 15 04", // Invisibility

    connectStarts:     "f3 02 e", // Connect (start)
    connectEnds:       "f1 1c e8 1c bf 0b 23" // Connect (end)
}

class Kour {
    constructor() {
        // sockets: list of WebSocket
        this.sockets = [];

        // What features you want enabled
        this.config = {
            Invisible: false,
            InstantKill: true
        }

        // Current packet count (not used, just visually)
        this.packets = 0;

        // Hook window.WebSocket
        unsafeWindow.WebSocket = class extends WebSocket {
            constructor() {
                super(...arguments);

                this.addEventListener("open", event => {
                    // Add to this.sockets list.
                    kourInstance.sockets.push(this);

                    // Hook send/onmessage
                    kourInstance.hook(this);
                });
            }
        }
    }

    hexArrayToString(hexArray) {
        let str = '';

        for (let i = 0; i < hexArray.length; i++) {
            let hex = hexArray[i];
            let decimalValue = parseInt(hex, 16);

            str += String.fromCharCode(decimalValue);
        }

        return str;
    }

    hook(socket) {
        console.debug("%c !! ", "background:#7aadff;color:#000", `Intercepted WebSocket (${socket.url})`);

        const send = socket.send;
        const onmessage = socket.onmessage;

        socket.onmessage = (event) => {
            if (event.data == null) {
                return onmessage.call(socket, event);
            }

            this.packets += 1;

            let hexArray = Array.from(new Uint8Array(event.data)).map(byte => byte.toString(16).padStart(2, '0'));
            let uint8Array = new Uint8Array(event.data);
            let stringHexArray = hexArray.join(" ");

            if (stringHexArray == "") return onmessage.call(socket, event);
            if (stringHexArray.startsWith(Signatures.ping)) return onmessage.call(socket, event);
            if (stringHexArray.startsWith(Signatures.pong)) return onmessage.call(socket, event);

            if (stringHexArray.startsWith(Signatures.createGame)) {
                let packet = uint8Array;
                let command = Kour.hexArrayToString(packet.slice(3, 7));
                console.debug('Game Created:', command);
            }

            if (stringHexArray.startsWith(Signatures.updateState)) {
                let packet = uint8Array;
                let command = Kour.hexArrayToString(packet.slice(3, 8));
                console.debug('Update State:', command);
            }

            if (stringHexArray.startsWith(Signatures.damageTaken)) {
                let packet = uint8Array;
                let command = Kour.hexArrayToString(packet.slice(3, 5));
                console.debug('Damage Taken:', command);
            }

            if (stringHexArray.startsWith(Signatures.connectStarts)) {
                let packet = uint8Array;
                let command = Kour.hexArrayToString(packet.slice(3, 7));
                console.debug('Connect Starts:', command);
            }

            if (stringHexArray.startsWith(Signatures.connectEnds)) {
                let packet = uint8Array;
                let command = Kour.hexArrayToString(packet.slice(3, 7));
                console.debug('Connect Ends:', command);
            }
        };

        socket.send = (data) => {
            let hexArray = Array.from(new Uint8Array(data)).map(byte => byte.toString(16).padStart(2, '0')).join(" ");
            if (hexArray.startsWith(Signatures.anotherPing)) {
                return send.call(socket, data);
            }
        }
    }
}