2024-06-06 19:40:41 +09:00
|
|
|
import os
|
|
|
|
import json
|
2024-06-10 13:27:21 +09:00
|
|
|
import tkinter.messagebox
|
2024-06-06 19:40:41 +09:00
|
|
|
import customtkinter
|
|
|
|
from winotify import Notification, audio
|
2024-06-06 23:08:15 +09:00
|
|
|
import keyboard
|
2024-06-07 22:28:51 +09:00
|
|
|
import subprocess
|
2024-06-08 19:18:50 +09:00
|
|
|
import requests
|
|
|
|
import hashlib
|
2024-06-10 13:27:21 +09:00
|
|
|
import string
|
|
|
|
import random
|
|
|
|
import tkinter
|
2024-06-16 17:03:15 +09:00
|
|
|
import threading
|
2024-07-23 15:15:44 +09:00
|
|
|
import signal
|
|
|
|
import sys
|
2024-07-26 11:45:13 +09:00
|
|
|
import shutil
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-25 19:57:38 +09:00
|
|
|
app_name = "Dislocker"
|
2024-07-25 20:19:03 +09:00
|
|
|
dislocker_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
2024-07-25 19:57:38 +09:00
|
|
|
|
|
|
|
os.chdir(dislocker_dir)
|
|
|
|
|
|
|
|
config_dir_path = "./config/"
|
|
|
|
client_config_path = config_dir_path + "client.json"
|
|
|
|
if not os.path.isfile(client_config_path):
|
|
|
|
if not os.path.isdir(config_dir_path):
|
|
|
|
os.mkdir(config_dir_path)
|
|
|
|
|
|
|
|
client_config = {
|
|
|
|
"initial": 1,
|
|
|
|
"auth_host_url": "http://localhost",
|
|
|
|
"pc_number": 1,
|
|
|
|
"master_password_hash": "",
|
|
|
|
"testing": 0
|
|
|
|
}
|
|
|
|
|
|
|
|
elif os.path.isfile(client_config_path):
|
|
|
|
with open(client_config_path, "r") as r:
|
|
|
|
client_config = json.load(r)
|
|
|
|
|
2024-07-25 19:25:47 +09:00
|
|
|
def init(**kwargs):
|
2024-08-14 00:03:47 +09:00
|
|
|
#sp_startupinfo = subprocess.STARTUPINFO()
|
|
|
|
#sp_startupinfo.dwFlags = subprocess.STARTF_USESHOWWINDOW
|
|
|
|
#sp_startupinfo.wShowWindow = subprocess.SW_HIDE
|
|
|
|
#task_exist = subprocess.run('tasklist /fi "IMAGENAME eq dislocker_client.exe"', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
|
|
|
#if 'dislocker_client.exe' in task_exist.stdout:
|
|
|
|
#return 1
|
|
|
|
|
|
|
|
if client_config["initial"] == 1:
|
|
|
|
master_password = master_password_gen()
|
|
|
|
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 初回起動を検出", message=f"初回起動のようです。\nマスターパスワードを記録しておいてください。\nこれ以降二度と表示されることはないでしょう。\n\n{master_password["password"]}\n\nまた、認証先サーバーの接続先を指定してください。ロックを解除できなくなります。")
|
|
|
|
client_config["master_password_hash"] = master_password["password_hash"]
|
|
|
|
client_config["initial"] = 0
|
|
|
|
if "pc_number" in kwargs:
|
|
|
|
client_config["pc_number"] = int(kwargs["pc_number"])
|
2024-08-07 11:37:23 +09:00
|
|
|
else:
|
2024-08-14 00:03:47 +09:00
|
|
|
client_config["pc_number"] = 1
|
|
|
|
with open(client_config_path, "w") as w:
|
|
|
|
json.dump(client_config, w, indent=4)
|
|
|
|
return 0
|
|
|
|
else:
|
|
|
|
return 0
|
2024-08-07 11:37:23 +09:00
|
|
|
|
2024-07-25 19:25:47 +09:00
|
|
|
|
|
|
|
|
2024-06-06 19:40:41 +09:00
|
|
|
class App(customtkinter.CTk):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2024-06-10 13:27:21 +09:00
|
|
|
self.title(f"{app_name} | ロック中")
|
2024-06-10 13:46:42 +09:00
|
|
|
if client_config["testing"] == 1:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
self.attributes('-fullscreen', True)
|
|
|
|
self.attributes('-topmost', True)
|
2024-07-04 20:40:03 +09:00
|
|
|
self.block_taskmgr()
|
|
|
|
self.block_key()
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-06-06 23:08:15 +09:00
|
|
|
self.frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
|
|
|
self.frame.grid(row=0, column=0, sticky='nsew')
|
2024-06-16 17:03:15 +09:00
|
|
|
|
2024-06-06 23:08:15 +09:00
|
|
|
lock = Lock()
|
|
|
|
|
2024-06-06 19:40:41 +09:00
|
|
|
def exit(self):
|
2024-06-08 09:33:54 +09:00
|
|
|
self.unlock_taskmgr()
|
2024-06-06 19:40:41 +09:00
|
|
|
self.toast()
|
|
|
|
self.destroy()
|
|
|
|
|
2024-08-09 11:30:03 +09:00
|
|
|
def delete_appdata(self, **kwargs):
|
2024-07-26 11:45:13 +09:00
|
|
|
process_name = kwargs["process_name"]
|
|
|
|
dir_path = kwargs["dir_path"]
|
|
|
|
|
|
|
|
if not os.path.exists(dir_path):
|
|
|
|
print(f"エラー: 指定されたディレクトリ {dir_path} が存在しません。")
|
|
|
|
return 1
|
|
|
|
|
|
|
|
try:
|
|
|
|
# プロセスの終了
|
|
|
|
subprocess.run(['taskkill', '/f', '/t', '/im', process_name])
|
|
|
|
print(f"{process_name} を終了しました。")
|
|
|
|
|
|
|
|
# ディレクトリの削除
|
|
|
|
shutil.rmtree(dir_path)
|
|
|
|
print(f"{dir_path} を削除しました。")
|
|
|
|
|
|
|
|
return 0
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
print(f"プロセス終了エラー: {e}")
|
|
|
|
return 1
|
|
|
|
except PermissionError as e:
|
|
|
|
print(f"権限エラー: {e}")
|
|
|
|
return 1
|
|
|
|
except Exception as error:
|
|
|
|
print("エラーが発生しました。\nエラー内容:")
|
|
|
|
print(f"エラータイプ: {error.__class__.__name__}")
|
|
|
|
print(f"エラー引数: {error.args}")
|
|
|
|
print(f"エラーメッセージ: {str(error)}")
|
|
|
|
return 1
|
|
|
|
|
2024-06-06 23:08:15 +09:00
|
|
|
def block_key(self):
|
|
|
|
block_keys = ['ctrl', 'alt', 'windows', 'shift', 'delete']
|
|
|
|
for i in block_keys:
|
|
|
|
keyboard.block_key(i)
|
|
|
|
|
2024-06-08 09:33:54 +09:00
|
|
|
def block_taskmgr(self):
|
2024-07-25 19:25:47 +09:00
|
|
|
block = subprocess.run(['reg', 'add', 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System', '/v', 'DisableTaskMgr', '/t', 'REG_DWORD', '/d', '1', '/f'])
|
2024-06-08 09:46:24 +09:00
|
|
|
print(block)
|
2024-06-08 09:33:54 +09:00
|
|
|
|
|
|
|
def unlock_taskmgr(self):
|
2024-06-08 09:46:24 +09:00
|
|
|
unlock = subprocess.run(['reg', 'delete', 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System', '/v', 'DisableTaskMgr', '/f'])
|
|
|
|
print(unlock)
|
2024-06-08 09:33:54 +09:00
|
|
|
|
2024-06-06 19:40:41 +09:00
|
|
|
def toast(self):
|
|
|
|
resource_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource")
|
|
|
|
success = Notification(
|
|
|
|
app_id='Dislocker',
|
|
|
|
title='ご協力ありがとうございます!',
|
|
|
|
msg='パスワード認証に成功しました。\n現在使われたパスワードは削除されます。',
|
|
|
|
icon=resource_path + r'\success.png'
|
|
|
|
)
|
|
|
|
success.set_audio(audio.Default, loop=False)
|
|
|
|
success.show()
|
|
|
|
|
2024-06-06 23:08:15 +09:00
|
|
|
def handler_close(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2024-06-06 19:40:41 +09:00
|
|
|
class Lock(customtkinter.CTkToplevel):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
2024-07-04 20:40:03 +09:00
|
|
|
if client_config["testing"] == 1:
|
|
|
|
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | テストモード')
|
|
|
|
else:
|
|
|
|
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | ロックされています')
|
2024-07-25 10:44:07 +09:00
|
|
|
|
|
|
|
self.window_width = 600
|
2024-07-25 21:32:08 +09:00
|
|
|
self.window_height = 320
|
2024-07-25 10:44:07 +09:00
|
|
|
self.screen_width = self.winfo_screenwidth()
|
|
|
|
self.screen_height = self.winfo_screenheight()
|
|
|
|
self.center_x = int(self.screen_width/2 - self.window_width/2)
|
|
|
|
self.center_y = int(self.screen_height/2 - self.window_height/2)
|
|
|
|
self.geometry(f"{str(self.window_width)}x{str(self.window_height)}+{str(self.center_x)}+{str(self.center_y)}")
|
2024-06-06 19:40:41 +09:00
|
|
|
self.resizable(height=False, width=False)
|
2024-06-06 23:08:15 +09:00
|
|
|
self.attributes('-topmost', True)
|
2024-06-08 22:38:53 +09:00
|
|
|
self.grab_set()
|
2024-06-06 19:40:41 +09:00
|
|
|
self.lift()
|
2024-06-06 23:08:15 +09:00
|
|
|
self.protocol("WM_DELETE_WINDOW", self.handler_close)
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-04 20:40:03 +09:00
|
|
|
self.emoji_font = customtkinter.CTkFont(family="Segoe UI Emoji", size=32)
|
|
|
|
self.title_font = customtkinter.CTkFont(family="meiryo", size=32, weight="bold")
|
2024-07-25 21:32:08 +09:00
|
|
|
self.pc_number_font = customtkinter.CTkFont(family="meiryo", size=64, weight="bold")
|
2024-07-04 20:40:03 +09:00
|
|
|
self.title_small_font = customtkinter.CTkFont(family="meiryo", size=16)
|
|
|
|
self.general_font = customtkinter.CTkFont(family="meiryo", size=18)
|
2024-06-16 17:03:15 +09:00
|
|
|
self.general_small_font = customtkinter.CTkFont(family="meiryo", size=12)
|
2024-07-04 20:40:03 +09:00
|
|
|
self.textbox_font = customtkinter.CTkFont(family="meiryo", size=14)
|
|
|
|
self.button_font = customtkinter.CTkFont(family="meiryo", size=14)
|
2024-07-25 21:32:08 +09:00
|
|
|
|
2024-06-16 17:03:15 +09:00
|
|
|
|
2024-06-06 19:40:41 +09:00
|
|
|
self.msg_title_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
2024-07-04 20:40:03 +09:00
|
|
|
self.msg_title_frame.grid(row=0, column=0, padx=10, pady=10, sticky="nsew")
|
|
|
|
|
|
|
|
self.icon_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text='😎', font=self.emoji_font, justify="left")
|
|
|
|
self.icon_title_1.grid(row=0, column=0, padx=10, sticky="w")
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-25 21:32:08 +09:00
|
|
|
self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text=f'ちょっと待って!! PC番号 | {client_config["pc_number"]}', font=self.title_font, justify="left")
|
2024-07-04 20:40:03 +09:00
|
|
|
self.msg_title_1.grid(row=0, column=1, padx=10, sticky="w")
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-04 20:40:03 +09:00
|
|
|
self.msg_title_2 = customtkinter.CTkLabel(self.msg_title_frame, text="本当にあなたですか?", font=self.title_small_font, justify="left")
|
|
|
|
self.msg_title_2.grid(row=1, column=1, padx=10, sticky="w")
|
2024-07-01 12:51:17 +09:00
|
|
|
|
2024-06-06 19:40:41 +09:00
|
|
|
self.msg_subtitle_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
2024-07-04 20:40:03 +09:00
|
|
|
self.msg_subtitle_frame.grid(row=1, column=0, padx=10, pady=10, sticky="nsew")
|
|
|
|
self.msg_subtitle_frame.grid_columnconfigure(0, weight=1)
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-04 20:40:03 +09:00
|
|
|
self.msg_subtitle_1 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='サインインするには、Discordのダイレクトメッセージに送信された\nパスワードを入力してください。', font=self.general_font, justify="left")
|
|
|
|
self.msg_subtitle_1.grid(row=0, column=0, padx=10, sticky="ew")
|
2024-07-01 12:51:17 +09:00
|
|
|
|
2024-07-04 20:40:03 +09:00
|
|
|
self.msg_subtitle_2 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='※ パスワードの有効期限は23:59までです。', font=self.general_small_font, justify="left")
|
|
|
|
self.msg_subtitle_2.grid(row=1, column=0, padx=10, sticky="w")
|
2024-07-01 12:51:17 +09:00
|
|
|
|
2024-07-04 20:40:03 +09:00
|
|
|
self.input_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
|
|
|
self.input_frame.grid(row=2, column=0, padx=10, pady=10, sticky="nsew")
|
|
|
|
self.input_frame.columnconfigure(0, weight=1)
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-04 20:40:03 +09:00
|
|
|
self.password_entry = customtkinter.CTkEntry(self.input_frame, placeholder_text='パスワード', show='*', font=self.textbox_font)
|
|
|
|
self.password_entry.grid(row=0, column=0, padx=10, sticky="ew")
|
2024-07-25 16:17:33 +09:00
|
|
|
self.password_entry.bind("<Return>", self.auth_start_ev)
|
2024-06-06 19:40:41 +09:00
|
|
|
|
|
|
|
self.button_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
|
2024-07-04 20:40:03 +09:00
|
|
|
self.button_frame.grid(row=3, column=0, padx=10, pady=10, sticky="nsew")
|
|
|
|
self.button_frame.columnconfigure(0, weight=3)
|
|
|
|
self.button_frame.columnconfigure(1, weight=1)
|
|
|
|
self.button_frame.columnconfigure(2, weight=1)
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-22 11:57:50 +09:00
|
|
|
self.signin_button = customtkinter.CTkButton(self.button_frame, text='サインイン', command=self.auth_start, font=self.button_font)
|
2024-07-04 20:40:03 +09:00
|
|
|
self.signin_button.grid(row=0, column=2, padx=10, sticky="e")
|
2024-07-01 12:51:17 +09:00
|
|
|
|
2024-08-21 12:59:45 +09:00
|
|
|
self.signout_button = customtkinter.CTkButton(self.button_frame, text='サインアウト', command=self.signout, font=self.button_font)
|
|
|
|
self.signout_button.grid(row=0, column=1, padx=10, sticky="e")
|
2024-07-01 12:51:17 +09:00
|
|
|
|
2024-08-21 12:59:45 +09:00
|
|
|
self.help_button = customtkinter.CTkButton(self.button_frame, text='ヘルプ', command=self.help_dummy, font=self.button_font)
|
|
|
|
self.help_button.grid(row=0, column=0, padx=10, sticky="w")
|
2024-07-25 16:17:33 +09:00
|
|
|
|
2024-06-16 17:03:15 +09:00
|
|
|
self.keyboard_listener_thread = threading.Thread(target=self.keyboard_listener)
|
|
|
|
self.keyboard_listener_thread.daemon = True
|
|
|
|
self.keyboard_listener_thread.start()
|
|
|
|
|
2024-07-08 11:41:38 +09:00
|
|
|
def help_wakeup(self):
|
|
|
|
help = Help()
|
|
|
|
|
2024-06-16 17:03:15 +09:00
|
|
|
def keyboard_listener(self):
|
|
|
|
keyboard.add_hotkey('ctrl+shift+q', self.exit)
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-06-08 19:18:50 +09:00
|
|
|
def hash_genarate(self, source):
|
|
|
|
hashed = hashlib.md5(source.encode())
|
|
|
|
return hashed.hexdigest()
|
|
|
|
|
2024-07-22 11:57:50 +09:00
|
|
|
def auth_start(self):
|
|
|
|
auth_thread = threading.Thread(target=self.auth)
|
2024-07-23 15:15:44 +09:00
|
|
|
auth_thread.daemon = True
|
2024-07-22 11:57:50 +09:00
|
|
|
auth_thread.start()
|
|
|
|
|
2024-07-25 16:17:33 +09:00
|
|
|
def auth_start_ev(self, event):
|
|
|
|
auth_thread = threading.Thread(target=self.auth)
|
|
|
|
auth_thread.daemon = True
|
|
|
|
auth_thread.start()
|
|
|
|
|
|
|
|
|
2024-06-06 19:40:41 +09:00
|
|
|
def auth(self):
|
2024-08-21 12:59:45 +09:00
|
|
|
self.help_button.configure(state="disabled", fg_color="gray")
|
|
|
|
self.signin_button.configure(state="disabled", fg_color="gray")
|
|
|
|
self.signout_button.configure(state="disabled", fg_color="gray")
|
2024-07-22 11:57:50 +09:00
|
|
|
password = str(self.password_entry.get())
|
|
|
|
if len(password) == 10:
|
|
|
|
print("マスターパスワードで認証を試行します。")
|
|
|
|
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
|
|
|
|
if client_config["master_password_hash"] == master_password_hash:
|
|
|
|
print("マスターパスワードで認証しました。")
|
|
|
|
self.exit()
|
|
|
|
else:
|
|
|
|
print("マスターパスワードで認証できませんでした。")
|
2024-08-21 12:59:45 +09:00
|
|
|
self.help_button.configure(state="normal", fg_color="blue")
|
|
|
|
self.signin_button.configure(state="normal", fg_color="blue")
|
|
|
|
self.signout_button.configure(state="normal", fg_color="blue")
|
2024-07-22 11:57:50 +09:00
|
|
|
|
|
|
|
|
2024-07-04 20:40:03 +09:00
|
|
|
print("認証サーバーにアクセスします。")
|
2024-06-08 19:18:50 +09:00
|
|
|
auth_url = client_config["auth_host_url"] + "/verify"
|
|
|
|
auth_json = {
|
2024-06-08 22:07:51 +09:00
|
|
|
"pc_number": int(client_config["pc_number"]),
|
|
|
|
"password": self.hash_genarate(str(self.password_entry.get()))
|
2024-06-08 19:18:50 +09:00
|
|
|
}
|
2024-06-10 13:34:22 +09:00
|
|
|
try:
|
|
|
|
responce = requests.post(auth_url, json=auth_json)
|
2024-07-04 20:40:03 +09:00
|
|
|
if responce.status_code == 200:
|
|
|
|
print("認証サーバー経由で認証しました。")
|
2024-06-16 17:03:15 +09:00
|
|
|
self.exit()
|
2024-07-22 11:57:50 +09:00
|
|
|
else:
|
|
|
|
print("認証サーバー経由での認証に失敗しました。")
|
2024-07-25 10:44:07 +09:00
|
|
|
self.withdraw()
|
2024-07-22 11:57:50 +09:00
|
|
|
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 誤ったパスワード", message=f"パスワードが間違っています!")
|
|
|
|
self.msg_subtitle_1.configure(text='パスワードが間違っています! ')
|
2024-08-21 12:59:45 +09:00
|
|
|
self.help_button.configure(state="normal", fg_color="blue")
|
|
|
|
self.signin_button.configure(state="normal", fg_color="blue")
|
|
|
|
self.signout_button.configure(state="normal", fg_color="blue")
|
2024-07-25 10:44:07 +09:00
|
|
|
self.deiconify()
|
2024-07-04 20:40:03 +09:00
|
|
|
except:
|
|
|
|
print("認証サーバーにアクセスできません。マスターパスワードで認証を試行します。")
|
2024-06-10 13:34:22 +09:00
|
|
|
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
|
|
|
|
if client_config["master_password_hash"] == master_password_hash:
|
2024-07-04 20:40:03 +09:00
|
|
|
print("マスターパスワードで認証しました。")
|
2024-06-16 17:03:15 +09:00
|
|
|
self.exit()
|
2024-06-10 13:34:22 +09:00
|
|
|
else:
|
2024-07-04 20:40:03 +09:00
|
|
|
print("マスターパスワードで認証できませんでした。")
|
2024-07-25 10:44:07 +09:00
|
|
|
self.withdraw()
|
2024-07-22 11:57:50 +09:00
|
|
|
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | ネットワークエラー", message=f"認証サーバーにアクセスできませんでした。\n続行するには、マスターパスワードを入力してください。")
|
2024-07-04 20:40:03 +09:00
|
|
|
self.msg_subtitle_1.configure(text='ネットワークエラーが発生しています。\n続行するには、マスターパスワードを入力して下さい。 ')
|
2024-08-21 12:59:45 +09:00
|
|
|
self.help_button.configure(state="normal", fg_color="blue")
|
|
|
|
self.signin_button.configure(state="normal", fg_color="blue")
|
|
|
|
self.signout_button.configure(state="normal", fg_color="blue")
|
2024-07-25 10:44:07 +09:00
|
|
|
self.deiconify()
|
2024-07-04 20:40:03 +09:00
|
|
|
|
2024-08-21 12:59:45 +09:00
|
|
|
def signout(self):
|
2024-07-22 12:00:40 +09:00
|
|
|
app.unlock_taskmgr()
|
2024-07-08 11:41:38 +09:00
|
|
|
self.destroy()
|
2024-08-21 12:59:45 +09:00
|
|
|
signout_command = subprocess.run(['shutdown', '/l', '/f'])
|
|
|
|
print(signout_command)
|
2024-07-08 11:41:38 +09:00
|
|
|
|
|
|
|
|
2024-06-06 23:08:15 +09:00
|
|
|
def handler_close(self):
|
|
|
|
pass
|
|
|
|
|
2024-07-22 11:57:50 +09:00
|
|
|
def help_dummy(self):
|
2024-07-25 10:44:07 +09:00
|
|
|
self.withdraw()
|
2024-07-22 11:57:50 +09:00
|
|
|
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 未実装", message=f"ヘルプページは製作途中です。\nDiscordサーバーの指示に従って、認証を進めてください。")
|
2024-07-25 10:44:07 +09:00
|
|
|
self.deiconify()
|
2024-07-22 11:57:50 +09:00
|
|
|
|
2024-06-06 23:08:15 +09:00
|
|
|
def exit(self):
|
|
|
|
self.destroy()
|
2024-06-16 17:03:15 +09:00
|
|
|
app.exit()
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-08 11:41:38 +09:00
|
|
|
|
|
|
|
class Help(customtkinter.CTkToplevel):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
if client_config["testing"] == 1:
|
|
|
|
self.title(f'{app_name} | ヘルプ | テストモード')
|
|
|
|
else:
|
|
|
|
self.title(f'{app_name} | ヘルプ')
|
2024-07-25 10:44:07 +09:00
|
|
|
self.iconbitmap("./resource/icon/dislocker.ico")
|
2024-07-08 11:41:38 +09:00
|
|
|
self.geometry("600x400")
|
|
|
|
self.resizable(height=False, width=False)
|
|
|
|
self.attributes('-topmost', True)
|
|
|
|
self.grab_set()
|
|
|
|
self.lift()
|
|
|
|
self.protocol("WM_DELETE_WINDOW", self.handler_close)
|
2024-07-22 11:57:50 +09:00
|
|
|
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 未実装", message=f"ヘルプページは製作途中です。\nDiscordサーバーの指示に従って、認証を進めてください。")
|
|
|
|
self.destroy()
|
2024-07-08 11:41:38 +09:00
|
|
|
|
|
|
|
def handler_close(self):
|
|
|
|
self.destroy()
|
|
|
|
|
2024-07-23 15:15:44 +09:00
|
|
|
class Monitor():
|
|
|
|
def __init__(self) -> None:
|
|
|
|
pass
|
2024-07-08 11:41:38 +09:00
|
|
|
|
2024-07-23 15:15:44 +09:00
|
|
|
def start(self):
|
|
|
|
monitor_thread = threading.Thread(target=self.run)
|
|
|
|
monitor_thread.start()
|
2024-07-08 11:41:38 +09:00
|
|
|
|
2024-07-24 23:34:49 +09:00
|
|
|
def signal_handler(self):
|
|
|
|
print("停止処理を実行。")
|
2024-07-26 11:45:13 +09:00
|
|
|
appdata_local = os.path.expandvars("%LOCALAPPDATA%")
|
|
|
|
appdata_roaming = os.path.expandvars("%APPDATA%")
|
|
|
|
epic_del = app.delete_appdata(process_name="EpicGamesLauncher.exe", dir_path=f"{appdata_local}\\EpicGamesLauncher\\Saved")
|
|
|
|
chrome_del = app.delete_appdata(process_name="chrome.exe", dir_path=f"{appdata_local}\\Google\\Chrome\\User Data")
|
|
|
|
discord_del = app.delete_appdata(process_name="discord.exe", dir_path=f"{appdata_roaming}\\discord")
|
2024-08-07 10:42:43 +09:00
|
|
|
steam_del = app.delete_appdata(process_name="steam.exe", dir_path=f"{appdata_local}\\Steam")
|
|
|
|
ea_del = app.delete_appdata(process_name="EADesktop.exe", dir_path=f"{appdata_local}\\Electronic Arts")
|
2024-08-09 11:09:06 +09:00
|
|
|
riot_del = app.delete_appdata(process_name="RiotClientServices.exe", dir_path=f"{appdata_local}\\Riot Games\\Riot Client")
|
2024-07-23 15:15:44 +09:00
|
|
|
stop_url = client_config["auth_host_url"] + "/stop"
|
|
|
|
stop_json = {
|
|
|
|
"pc_number": int(client_config["pc_number"])
|
|
|
|
}
|
|
|
|
try:
|
|
|
|
responce = requests.post(stop_url, json=stop_json)
|
|
|
|
if responce.status_code == 200:
|
|
|
|
print("停止処理は成功しました。")
|
|
|
|
else:
|
|
|
|
print("内部エラーにより停止処理に失敗しました。")
|
2024-07-24 23:34:49 +09:00
|
|
|
result_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | エラー", message=f"内部エラーにより停止処理に失敗しました。\nDiscordサーバーの指示に従って、停止処理を自身で行ってください。")
|
2024-07-23 15:15:44 +09:00
|
|
|
except:
|
|
|
|
print("ネットワークエラーにより停止処理に失敗しました。")
|
2024-07-24 23:34:49 +09:00
|
|
|
result_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | エラー", message=f"ネットワークエラーにより停止処理に失敗しました。\nDiscordサーバーの指示に従って、停止処理を自身で行ってください。")
|
2024-07-23 15:15:44 +09:00
|
|
|
finally:
|
2024-07-24 23:34:49 +09:00
|
|
|
self.shutdown()
|
|
|
|
|
|
|
|
def shutdown(self):
|
2024-08-21 12:59:45 +09:00
|
|
|
shutdown_command = subprocess.run(['shutdown', '/s', '/t', '1'])
|
2024-07-24 23:34:49 +09:00
|
|
|
|
2024-07-23 15:15:44 +09:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
signal.signal(signal.SIGTERM, self.signal_handler)
|
|
|
|
|
2024-07-08 11:41:38 +09:00
|
|
|
|
2024-06-10 13:27:21 +09:00
|
|
|
def master_password_gen():
|
|
|
|
numbers = string.digits # (1)
|
|
|
|
password = ''.join(random.choice(numbers) for _ in range(10)) # (2)
|
|
|
|
password_hash = hashlib.md5(password.encode()).hexdigest()
|
|
|
|
result = {"password": password, "password_hash": password_hash}
|
|
|
|
return result
|
|
|
|
|
2024-06-06 19:40:41 +09:00
|
|
|
|
2024-07-25 19:25:47 +09:00
|
|
|
if __name__ == '__main__':
|
|
|
|
args = sys.argv
|
|
|
|
if len(args) >= 2:
|
|
|
|
if args[1] == "stop":
|
2024-08-07 11:37:23 +09:00
|
|
|
init_result = init()
|
|
|
|
if init_result == 1:
|
|
|
|
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"もう終了処理を行っています。\nPCがシャットダウンするまで、もう少しお待ちください。")
|
|
|
|
else:
|
2024-08-09 10:49:48 +09:00
|
|
|
app = App()
|
2024-08-07 11:37:23 +09:00
|
|
|
monitor = Monitor()
|
|
|
|
monitor.signal_handler()
|
2024-07-25 19:25:47 +09:00
|
|
|
elif args[1] == "setup":
|
2024-08-07 11:37:23 +09:00
|
|
|
init_result = init(pc_number=args[2])
|
|
|
|
if init_result == 1:
|
|
|
|
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"すでに {app_name} は実行されています。\n正常に起動しない場合は、既に起動しているプロセスを終了してから、もう一度起動してみてください。")
|
|
|
|
else:
|
|
|
|
pass
|
2024-07-24 23:34:49 +09:00
|
|
|
else:
|
2024-07-25 19:25:47 +09:00
|
|
|
print("引数エラー。")
|
|
|
|
else:
|
2024-08-07 11:37:23 +09:00
|
|
|
init_result = init()
|
|
|
|
if init_result == 1:
|
|
|
|
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"すでに {app_name} は実行されています。\n正常に起動しない場合は、既に起動しているプロセスを終了してから、もう一度起動してみてください。")
|
2024-07-24 23:34:49 +09:00
|
|
|
else:
|
|
|
|
app = App()
|
|
|
|
app.protocol("WM_DELETE_WINDOW", app.handler_close)
|
|
|
|
app.mainloop()
|