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)
|
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")
|
resource_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource")
|
||||||
config_dir_path = "./config/"
|
config_dir_path = "./config/"
|
||||||
client_config_path = config_dir_path + "client.json"
|
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)
|
os.mkdir(config_dir_path)
|
||||||
|
|
||||||
client_config = {
|
client_config = {
|
||||||
"initial": 1,
|
"initial": True,
|
||||||
"auth_host_url": "http://localhost",
|
"auth_host_url": "http://localhost",
|
||||||
"pc_number": 1,
|
"pc_number": 1,
|
||||||
"master_password_hash": "",
|
"master_password_hash": "",
|
||||||
"testing": 0,
|
"testing": False,
|
||||||
"eraser": 1,
|
"eraser": True,
|
||||||
"pc_uuid": "",
|
"pc_uuid": "",
|
||||||
"pc_token": ""
|
"pc_token": "",
|
||||||
|
"hard_lock": False
|
||||||
}
|
}
|
||||||
|
|
||||||
elif os.path.isfile(client_config_path):
|
elif os.path.isfile(client_config_path):
|
||||||
|
@ -99,9 +104,6 @@ def master_password_gen():
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def init(**kwargs):
|
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)
|
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:
|
if 'dislocker_client.exe' in task_exist.stdout:
|
||||||
task_count = task_exist.stdout.count("dislocker_client.exe")
|
task_count = task_exist.stdout.count("dislocker_client.exe")
|
||||||
|
@ -110,7 +112,7 @@ def init(**kwargs):
|
||||||
else:
|
else:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if client_config["initial"] == 1:
|
if client_config["initial"] == True:
|
||||||
pc_uuid = uuid.uuid4()
|
pc_uuid = uuid.uuid4()
|
||||||
client_config["pc_uuid"] = str(pc_uuid)
|
client_config["pc_uuid"] = str(pc_uuid)
|
||||||
|
|
||||||
|
@ -150,7 +152,7 @@ def init(**kwargs):
|
||||||
client_config["master_password_hash"] = master_password_hash
|
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")
|
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:
|
with open(client_config_path, "w") as w:
|
||||||
json.dump(client_config, w, indent=4)
|
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ワンタイムパスワードが間違っている可能性があります。")
|
msgbox = tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nワンタイムパスワードが間違っている可能性があります。")
|
||||||
return 2
|
return 2
|
||||||
else:
|
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
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,7 +177,7 @@ class App(customtkinter.CTk):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.title(f"{app_name} | ロック中")
|
self.title(f"{app_name} | ロック中")
|
||||||
self.iconbitmap(default=resource_path + '\\icon\\dislocker.ico')
|
self.iconbitmap(default=resource_path + '\\icon\\dislocker.ico')
|
||||||
if client_config["testing"] == 1:
|
if client_config["testing"] == True:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.attributes('-fullscreen', True)
|
self.attributes('-fullscreen', True)
|
||||||
|
@ -182,6 +192,11 @@ class App(customtkinter.CTk):
|
||||||
|
|
||||||
def exit(self):
|
def exit(self):
|
||||||
self.unlock_taskmgr()
|
self.unlock_taskmgr()
|
||||||
|
if client_config["hard_lock"] == True:
|
||||||
|
self.wake_explorer()
|
||||||
|
else:
|
||||||
|
pass
|
||||||
|
|
||||||
self.toast()
|
self.toast()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
@ -191,13 +206,17 @@ class App(customtkinter.CTk):
|
||||||
keyboard.block_key(i)
|
keyboard.block_key(i)
|
||||||
|
|
||||||
def block_taskmgr(self):
|
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)
|
print(block)
|
||||||
|
|
||||||
def unlock_taskmgr(self):
|
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)
|
print(unlock)
|
||||||
|
|
||||||
|
def wake_explorer(self):
|
||||||
|
wake_explorer = subprocess.Popen('explorer', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
|
||||||
|
|
||||||
|
|
||||||
def toast(self):
|
def toast(self):
|
||||||
success = Notification(
|
success = Notification(
|
||||||
app_id='Dislocker',
|
app_id='Dislocker',
|
||||||
|
@ -215,7 +234,7 @@ class App(customtkinter.CTk):
|
||||||
class Lock(customtkinter.CTkToplevel):
|
class Lock(customtkinter.CTkToplevel):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
if client_config["testing"] == 1:
|
if client_config["testing"] == True:
|
||||||
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | テストモード')
|
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | テストモード')
|
||||||
else:
|
else:
|
||||||
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | ロックされています')
|
self.title(f'{app_name} | PC番号 {client_config["pc_number"]} | ロックされています')
|
||||||
|
@ -349,7 +368,7 @@ class Lock(customtkinter.CTkToplevel):
|
||||||
except pythoncom.com_error as e:
|
except pythoncom.com_error as e:
|
||||||
print("Error:", e)
|
print("Error:", e)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def auth(self):
|
def auth(self):
|
||||||
self.button_disable()
|
self.button_disable()
|
||||||
password = str(self.password_entry.get())
|
password = str(self.password_entry.get())
|
||||||
|
@ -414,7 +433,7 @@ class Lock(customtkinter.CTkToplevel):
|
||||||
def signout(self):
|
def signout(self):
|
||||||
app.unlock_taskmgr()
|
app.unlock_taskmgr()
|
||||||
self.destroy()
|
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)
|
print(signout_command)
|
||||||
|
|
||||||
|
|
||||||
|
@ -434,7 +453,7 @@ class Lock(customtkinter.CTkToplevel):
|
||||||
class Help(customtkinter.CTkToplevel):
|
class Help(customtkinter.CTkToplevel):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
if client_config["testing"] == 1:
|
if client_config["testing"] == True:
|
||||||
self.title(f'{app_name} | ヘルプ | テストモード')
|
self.title(f'{app_name} | ヘルプ | テストモード')
|
||||||
else:
|
else:
|
||||||
self.title(f'{app_name} | ヘルプ')
|
self.title(f'{app_name} | ヘルプ')
|
||||||
|
@ -475,7 +494,7 @@ class Stop():
|
||||||
i += 1
|
i += 1
|
||||||
try:
|
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} を終了しました。")
|
print(f"{process_name} を終了しました。")
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
# ディレクトリの削除
|
# ディレクトリの削除
|
||||||
|
@ -503,11 +522,11 @@ class Stop():
|
||||||
|
|
||||||
|
|
||||||
def shutdown(self):
|
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):
|
def stop(self):
|
||||||
print("停止処理を実行。")
|
print("停止処理を実行。")
|
||||||
if client_config["eraser"] == 1:
|
if client_config["eraser"] == True:
|
||||||
appdata_local = os.path.expandvars("%LOCALAPPDATA%")
|
appdata_local = os.path.expandvars("%LOCALAPPDATA%")
|
||||||
appdata_roaming = os.path.expandvars("%APPDATA%")
|
appdata_roaming = os.path.expandvars("%APPDATA%")
|
||||||
epic_del = app.delete_appdata(process_name="EpicGamesLauncher.exe", dir_path=f"{appdata_local}\\EpicGamesLauncher\\Saved")
|
epic_del = app.delete_appdata(process_name="EpicGamesLauncher.exe", dir_path=f"{appdata_local}\\EpicGamesLauncher\\Saved")
|
||||||
|
|
Loading…
Reference in a new issue