configファイルの値をわかりやすく etc...
hard_lockモードの実装 subprocessの実行コマンドの入力をリストから文字列に変更
This commit is contained in:
parent
7b75da62a3
commit
20b46e8c40
1 changed files with 38 additions and 19 deletions
|
@ -23,6 +23,10 @@ dislocker_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|||
|
||||
os.chdir(dislocker_dir)
|
||||
|
||||
sp_startupinfo = subprocess.STARTUPINFO()
|
||||
sp_startupinfo.dwFlags = subprocess.STARTF_USESHOWWINDOW
|
||||
sp_startupinfo.wShowWindow = subprocess.SW_HIDE
|
||||
|
||||
resource_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource")
|
||||
config_dir_path = "./config/"
|
||||
client_config_path = config_dir_path + "client.json"
|
||||
|
@ -31,14 +35,15 @@ if not os.path.isfile(client_config_path):
|
|||
os.mkdir(config_dir_path)
|
||||
|
||||
client_config = {
|
||||
"initial": 1,
|
||||
"initial": True,
|
||||
"auth_host_url": "http://localhost",
|
||||
"pc_number": 1,
|
||||
"master_password_hash": "",
|
||||
"testing": 0,
|
||||
"eraser": 1,
|
||||
"testing": False,
|
||||
"eraser": True,
|
||||
"pc_uuid": "",
|
||||
"pc_token": ""
|
||||
"pc_token": "",
|
||||
"hard_lock": False
|
||||
}
|
||||
|
||||
elif os.path.isfile(client_config_path):
|
||||
|
@ -99,9 +104,6 @@ def master_password_gen():
|
|||
return result
|
||||
|
||||
def init(**kwargs):
|
||||
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:
|
||||
task_count = task_exist.stdout.count("dislocker_client.exe")
|
||||
|
@ -110,7 +112,7 @@ def init(**kwargs):
|
|||
else:
|
||||
return 1
|
||||
|
||||
if client_config["initial"] == 1:
|
||||
if client_config["initial"] == True:
|
||||
pc_uuid = uuid.uuid4()
|
||||
client_config["pc_uuid"] = str(pc_uuid)
|
||||
|
||||
|
@ -150,7 +152,7 @@ def init(**kwargs):
|
|||
client_config["master_password_hash"] = master_password_hash
|
||||
|
||||
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 初回起動を検出", message=f"初回起動のようです。\nマスターパスワードを記録しておいてください。\nBotが起動している場合は、管理者がDiscordから確認することもできます。\n\n{master_password}\n\n")
|
||||
client_config["initial"] = 0
|
||||
client_config["initial"] = False
|
||||
|
||||
with open(client_config_path, "w") as w:
|
||||
json.dump(client_config, w, indent=4)
|
||||
|
@ -159,6 +161,14 @@ def init(**kwargs):
|
|||
msgbox = tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nワンタイムパスワードが間違っている可能性があります。")
|
||||
return 2
|
||||
else:
|
||||
if client_config["hard_lock"] == True:
|
||||
exit_explorer = subprocess.run('taskkill /f /im explorer.exe', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||
if exit_explorer.returncode == 0:
|
||||
pass
|
||||
else:
|
||||
signout_session = subprocess.run('shutdown /l /f /t 3', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||
error_msgbox = tkinter.messagebox.showerror(title=f"{app_name} | 初回処理のエラー", message=f"初回処理の実行にエラーが発生しました。\n自動的にサインアウトされます。")
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
|
@ -167,7 +177,7 @@ class App(customtkinter.CTk):
|
|||
super().__init__()
|
||||
self.title(f"{app_name} | ロック中")
|
||||
self.iconbitmap(default=resource_path + '\\icon\\dislocker.ico')
|
||||
if client_config["testing"] == 1:
|
||||
if client_config["testing"] == True:
|
||||
pass
|
||||
else:
|
||||
self.attributes('-fullscreen', True)
|
||||
|
@ -182,6 +192,11 @@ class App(customtkinter.CTk):
|
|||
|
||||
def exit(self):
|
||||
self.unlock_taskmgr()
|
||||
if client_config["hard_lock"] == True:
|
||||
self.wake_explorer()
|
||||
else:
|
||||
pass
|
||||
|
||||
self.toast()
|
||||
self.destroy()
|
||||
|
||||
|
@ -191,13 +206,17 @@ class App(customtkinter.CTk):
|
|||
keyboard.block_key(i)
|
||||
|
||||
def block_taskmgr(self):
|
||||
block = subprocess.run(['reg', 'add', 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System', '/v', 'DisableTaskMgr', '/t', 'REG_DWORD', '/d', '1', '/f'])
|
||||
block = subprocess.run('reg add HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System /v DisableTaskMgr /t REG_DWORD /d 1 /f', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||
print(block)
|
||||
|
||||
def unlock_taskmgr(self):
|
||||
unlock = subprocess.run(['reg', 'delete', 'HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System', '/v', 'DisableTaskMgr', '/f'])
|
||||
unlock = subprocess.run('reg delete HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System /v DisableTaskMgr /f', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||
print(unlock)
|
||||
|
||||
def wake_explorer(self):
|
||||
wake_explorer = subprocess.Popen('explorer', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||
|
||||
|
||||
def toast(self):
|
||||
success = Notification(
|
||||
app_id='Dislocker',
|
||||
|
@ -215,7 +234,7 @@ class App(customtkinter.CTk):
|
|||
class Lock(customtkinter.CTkToplevel):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
if client_config["testing"] == 1:
|
||||
if client_config["testing"] == True:
|
||||
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | テストモード')
|
||||
else:
|
||||
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | ロックされています')
|
||||
|
@ -414,7 +433,7 @@ class Lock(customtkinter.CTkToplevel):
|
|||
def signout(self):
|
||||
app.unlock_taskmgr()
|
||||
self.destroy()
|
||||
signout_command = subprocess.run(['shutdown', '/l', '/f'])
|
||||
signout_command = subprocess.run('shutdown /l /f', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||
print(signout_command)
|
||||
|
||||
|
||||
|
@ -434,7 +453,7 @@ class Lock(customtkinter.CTkToplevel):
|
|||
class Help(customtkinter.CTkToplevel):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
if client_config["testing"] == 1:
|
||||
if client_config["testing"] == True:
|
||||
self.title(f'{app_name} | ヘルプ | テストモード')
|
||||
else:
|
||||
self.title(f'{app_name} | ヘルプ')
|
||||
|
@ -475,7 +494,7 @@ class Stop():
|
|||
i += 1
|
||||
try:
|
||||
# プロセスの終了
|
||||
subprocess.run(['taskkill', '/f', '/t', '/im', process_name])
|
||||
subprocess.run(f'taskkill /f /t /im {process_name}', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||
print(f"{process_name} を終了しました。")
|
||||
time.sleep(0.1)
|
||||
# ディレクトリの削除
|
||||
|
@ -503,11 +522,11 @@ class Stop():
|
|||
|
||||
|
||||
def shutdown(self):
|
||||
shutdown_command = subprocess.run(['shutdown', '/s', '/t', '1'])
|
||||
shutdown_command = subprocess.run('shutdown /s /f /t 0', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||
|
||||
def stop(self):
|
||||
print("停止処理を実行。")
|
||||
if client_config["eraser"] == 1:
|
||||
if client_config["eraser"] == True:
|
||||
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")
|
||||
|
|
Loading…
Reference in a new issue