Merge branch 'testing'

This commit is contained in:
suti7yk5032 2024-10-06 19:46:56 +09:00
commit 2861c9ffd4
27 changed files with 4358 additions and 679 deletions

2
.gitignore vendored
View file

@ -50,7 +50,6 @@ coverage.xml
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
@ -166,3 +165,4 @@ test.py
data/
export/
temp/
log/

View file

@ -28,7 +28,7 @@ services:
- dislocker_network
db:
image: postgres:alpine3.20
image: postgres:16-alpine3.20
restart: always
environment:
- TZ=Asia/Tokyo

View file

@ -1,6 +1,6 @@
services:
db:
image: postgres:alpine3.20
image: postgres:16-alpine3.20
restart: always
environment:
- TZ=Asia/Tokyo

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,14 @@ import psycopg2
import os
import json
from flask import Flask, request, jsonify, render_template
import uuid
import string
import random
import hashlib
config_dir_path = "./config/"
server_config_path = config_dir_path + "server.json"
onetime_config_path = config_dir_path + "onetime.json"
if not os.path.isfile(server_config_path):
if not os.path.isdir(config_dir_path):
os.mkdir(config_dir_path)
@ -40,85 +45,439 @@ class Auth():
def __init__(self, host, db, port, user, password):
self.db = psycopg2.connect(f"host={host} dbname={db} port={port} user={user} password={password}")
def check(self, pc_number, password):
def token_generate(self, length):
letters = string.ascii_letters + string.digits
token = ''.join(random.choice(letters) for _ in range(length))
return token
def master_password_generate(self, length):
characters = string.ascii_letters + string.digits + string.punctuation
master_password = ''.join(random.choice(characters) for _ in range(length))
return master_password
def hash_genarate(self, source):
hashed = hashlib.sha256(source.encode())
return hashed.hexdigest()
def check(self, **kwargs):
try:
cursor = self.db.cursor()
cursor.execute("SELECT * FROM pc_list WHERE pc_number = %s AND password_hash = %s", (pc_number, password))
pc_info = cursor.fetchall()
if not pc_info:
return 1
pc_number = int(kwargs["pc_number"])
pc_uuid = str(kwargs["pc_uuid"])
pc_token = str(kwargs["pc_token"])
if "device_list" in kwargs:
if kwargs["device_list"] == []:
device_list = None
else:
return 0
device_list = kwargs["device_list"]
else:
device_list = None
keyboard_number = 0
mouse_number = 0
if "password_hash" in kwargs:
password_hash = str(kwargs["password_hash"])
cursor.execute("SELECT * FROM pc_list WHERE pc_number = %s AND password_hash = %s AND pc_uuid = %s AND pc_token = %s", (pc_number, password_hash, pc_uuid, pc_token))
pc_info = cursor.fetchall()
if pc_info:
if device_list == None:
pass
else:
for device in device_list:
cursor.execute("SELECT * FROM keyboard_list WHERE device_instance_path = %s", (device["device_instance_path"],))
keyboard_record = cursor.fetchall()
if keyboard_record:
keyboard_number = int(keyboard_record[0][0])
break
else:
pass
for device in device_list:
cursor.execute("SELECT * FROM mouse_list WHERE device_instance_path = %s", (device["device_instance_path"],))
mouse_record = cursor.fetchall()
if mouse_record:
mouse_number = int(mouse_record[0][0])
break
else:
pass
return {"result": 0, "about": "ok", "output_dict": {"keyboard_number": keyboard_number, "mouse_number": mouse_number}}
else:
return {"result": 1, "about": "incorrect_password"}
else:
cursor.execute("SELECT * FROM pc_list WHERE pc_number = %s AND pc_uuid = %s AND pc_token = %s", (pc_number, pc_uuid, pc_token))
pc_info = cursor.fetchall()
if pc_info:
return {"result": 0, "about": "ok"}
else:
return {"result": 1, "about": "unregistered_pc"}
except Exception as error:
print("PCの登録状況を調査中にエラーが発生しました。\nエラー内容")
print(str(error.__class__.__name__))
print(str(error.args))
print(str(error))
return {"result": 1, "about": "error"}
finally:
cursor.close()
def device_use_register(self, **kwargs):
try:
pc_number = int(kwargs["pc_number"])
if kwargs["keyboard_number"] == "own":
keyboard_number = 0
else:
keyboard_number = int(kwargs["keyboard_number"])
if kwargs["mouse_number"] == "own":
mouse_number = 0
else:
mouse_number = int(kwargs["mouse_number"])
cursor = self.db.cursor()
cursor.execute("SELECT * FROM pc_list WHERE pc_number = %s", (pc_number,))
pc_list_record = cursor.fetchall()
pc_using_member_id = pc_list_record[0][1]
if pc_using_member_id == None:
return {"result": 1, "about": "not_used"}
else:
cursor.execute("SELECT * FROM pc_usage_history WHERE member_id = %s AND pc_number = %s ORDER BY id DESC LIMIT 1", (pc_using_member_id, pc_number))
pc_usage_history_record = cursor.fetchall()
pc_usage_history_record_id = pc_usage_history_record[0][0]
cursor.execute("UPDATE pc_usage_history SET keyboard_number = %s, mouse_number = %s WHERE id = %s", (keyboard_number, mouse_number, pc_usage_history_record_id))
if keyboard_number == 0:
pass
else:
cursor.execute("UPDATE keyboard_list SET using_member_id = %s WHERE keyboard_number = %s", (pc_using_member_id, keyboard_number))
if mouse_number == 0:
pass
else:
cursor.execute("UPDATE mouse_list SET using_member_id = %s WHERE mouse_number = %s", (pc_using_member_id, mouse_number))
self.db.commit()
return {"result": 0, "about": "ok"}
except Exception as error:
print("デバイスの使用登録中にエラーが発生しました。\nエラー内容")
print(str(error.__class__.__name__))
print(str(error.args))
print(str(error))
return {"result": 1, "about": "error"}
def device_register(self, **kwargs):
try:
cursor = self.db.cursor()
mode = kwargs["mode"]
number = kwargs["number"]
device_instance_path = kwargs["device_instance_path"]
device_name = kwargs["device_name"]
if mode == "keyboard":
keyboard_number = int(kwargs["number"])
cursor.execute("SELECT * FROM keyboard_list WHERE keyboard_number = %s", (keyboard_number,))
keyboard_record = cursor.fetchall()
if keyboard_record:
cursor.execute("UPDATE keyboard_list SET device_instance_path = %s, device_name = %s WHERE keyboard_number = %s", (device_instance_path, device_name, keyboard_number))
self.db.commit()
return {"result": 0, "about": "ok"}
else:
cursor.execute("INSERT INTO keyboard_list (keyboard_number, device_instance_path, device_name) VALUES (%s, %s, %s)", (keyboard_number, device_instance_path, device_name))
return {"result": 0, "about": "ok"}
elif mode == "mouse":
mouse_number = int(kwargs["number"])
cursor.execute("SELECT * FROM mouse_list WHERE mouse_number = %s", (mouse_number,))
mouse_record = cursor.fetchall()
if mouse_record:
cursor.execute("UPDATE mouse_list SET device_instance_path = %s, device_name = %s WHERE mouse_number = %s", (device_instance_path, device_name, mouse_number))
self.db.commit()
return {"result": 0, "about": "ok"}
else:
cursor.execute("INSERT INTO mouse_list (mouse_number, device_instance_path, device_name) VALUES (%s, %s, %s)", (mouse_number, device_instance_path, device_name))
return {"result": 0, "about": "ok"}
except Exception as error:
print("停止処理中にエラーが発生しました。\nエラー内容")
print(str(error.__class__.__name__))
print(str(error.args))
print(str(error))
return {"result": 1, "about": "error"}
def delete(self, pc_number):
try:
cursor = self.db.cursor()
cursor.execute("UPDATE pc_list SET password_hash = NULL WHERE pc_number = %s", (pc_number,))
self.db.commit()
return {"result": 0, "about": "ok"}
except Exception as error:
print("パスワードの削除中にエラーが発生しました。\nエラー内容")
print(str(error.__class__.__name__))
print(str(error.args))
print(str(error))
return {"result": 1, "about": "error"}
finally:
cursor.close()
def user_register_check(self, **kwargs):
try:
discord_user_id = str(kwargs["discord_user_id"])
cursor = self.db.cursor()
cursor.execute("SELECT * FROM club_member WHERE discord_user_id = %s", (discord_user_id,))
user_record = cursor.fetchall()
#ユーザーデータが見つかった場合(登録済みの場合)
if user_record:
member_id = user_record[0][0]
name = user_record[0][1]
discord_user_name = user_record[0][2]
return {"result": 0, "about": "exist", "user_info": {"member_id": member_id, "name": name, "discord_user_name": discord_user_name}}
#ユーザーデータがなかったら(未登録の場合)
else:
return {"result": 1, "about": "user_data_not_found"}
except Exception as error:
print("ユーザーの登録状況を調査中にエラーが発生しました。\nエラー内容")
print(str(error.__class__.__name__))
print(str(error.args))
print(str(error))
return {"result": 1, "about": "error"}
finally:
cursor.close()
def stop(self, **kwargs):
# bot側のfstopを基に
try:
pc_number = int(kwargs["pc_number"])
pc_number = kwargs["pc_number"]
cursor = self.db.cursor()
cursor.execute("SELECT * FROM pc_list WHERE pc_number = %s", (pc_number,))
pc_list_record = cursor.fetchall()
if not pc_list_record[0][1] == None:
cursor.execute("UPDATE pc_list SET using_user_id = NULL WHERE pc_number = %s", (pc_number,))
if not pc_list_record[0][2] == None:
cursor.execute("UPDATE pc_list SET password_hash = NULL WHERE pc_number = %s", (pc_number,))
cursor.execute("SELECT * FROM pc_usage_history WHERE member_id = %s AND pc_number = %s ORDER BY id DESC LIMIT 1", (pc_list_record[0][1], pc_number))
pc_usage_history_record = cursor.fetchall()
cursor.execute("UPDATE pc_usage_history SET end_use_time = current_timestamp WHERE id = %s", (pc_usage_history_record[0][0],))
self.db.commit()
result = {"result": "ok"}
pc_using_member_id = pc_list_record[0][1]
pc_password_hash = pc_list_record[0][2]
if pc_using_member_id == None:
return {"result": 1, "about": "not_used"}
else:
result = {"result": "not_used"}
cursor.execute("UPDATE pc_list SET using_member_id = NULL WHERE pc_number = %s", (pc_number,))
if pc_password_hash == None:
pass
else:
cursor.execute("UPDATE pc_list SET password_hash = NULL WHERE pc_number = %s", (pc_number,))
cursor.execute("SELECT * FROM pc_usage_history WHERE member_id = %s AND pc_number = %s ORDER BY id DESC LIMIT 1", (pc_using_member_id, pc_number))
pc_usage_history_record = cursor.fetchall()
pc_usage_history_record_id = pc_usage_history_record[0][0]
keyboard_number = pc_usage_history_record[0][3]
mouse_number = pc_usage_history_record[0][4]
if keyboard_number == None:
pass
else:
# keyboard_listの使用中ユーザーを消す
cursor.execute("UPDATE keyboard_list SET using_member_id = NULL WHERE keyboard_number = %s", (keyboard_number,))
if mouse_number == None:
pass
else:
# mouse_listの使用中ユーザーを消す
cursor.execute("UPDATE mouse_list SET using_member_id = NULL WHERE mouse_number = %s", (mouse_number,))
cursor.execute("UPDATE pc_usage_history SET end_use_time = clock_timestamp() WHERE id = %s", (pc_usage_history_record_id,))
self.db.commit()
return {"result": 0, "about": "ok"}
except:
result = {"result": "error"}
except Exception as error:
print("停止処理中にエラーが発生しました。\nエラー内容")
print(str(error.__class__.__name__))
print(str(error.args))
print(str(error))
return {"result": 1, "about": "error"}
finally:
cursor.close()
return result
def register(self, **kwargs):
try:
cursor = self.db.cursor()
pc_number = int(kwargs["pc_number"])
pc_uuid = str(kwargs["pc_uuid"])
cursor.execute("SELECT pc_number FROM pc_list WHERE pc_number = %s", (pc_number,))
pc_record_number_source = cursor.fetchall()
if pc_record_number_source == []:
pc_token = self.token_generate(36)
master_password = self.master_password_generate(16)
master_password_hash = self.hash_genarate(master_password)
cursor.execute("INSERT INTO pc_list (pc_number, pc_uuid, pc_token, master_password) VALUES (%s, %s, %s, %s)", (pc_number, pc_uuid, pc_token, master_password))
self.db.commit()
return {"result": 0, "about": "ok", "output_dict": {"pc_token": pc_token, "master_password": master_password, "master_password_hash": master_password_hash}}
else:
cursor.execute("SELECT pc_uuid FROM pc_list WHERE pc_number = %s", (pc_number,))
pc_record_uuid_source = cursor.fetchall()
pc_record_uuid = pc_record_uuid_source[0][0]
if pc_record_uuid == None:
pc_token = self.token_generate(36)
master_password = self.master_password_generate(16)
master_password_hash = self.hash_genarate(master_password)
cursor.execute("UPDATE pc_list SET pc_uuid = %s, pc_token = %s, master_password = %s WHERE pc_number = %s", (pc_uuid, pc_token, master_password, pc_number))
self.db.commit()
return {"result": 0, "about": "ok", "output_dict": {"pc_token": pc_token, "master_password": master_password, "master_password_hash": master_password_hash}}
else:
return {"result": 1, "about": "exist"}
except Exception as error:
print("PCの登録処理中にエラーが発生しました。\nエラー内容")
print(str(error.__class__.__name__))
print(str(error.args))
print(str(error))
return {"result": 1, "about": "error"}
finally:
cursor.close()
app = Flask(__name__, static_folder="./resource/")
auth = Auth(server_config["db"]["host"], server_config["db"]["db_name"], server_config["db"]["port"], server_config["db"]["username"], server_config["db"]["password"])
@app.route('/register', methods=['POST'])
def register():
pc_number = int(request.json.get('pc_number'))
pc_uuid = str(request.json.get('pc_uuid'))
onetime_password = str(request.json.get('onetime'))
if os.path.isfile(onetime_config_path):
with open(onetime_config_path, "r") as r:
onetime_config = json.load(r)
if onetime_password == onetime_config["onetime"]["pc_register"]["password"]:
register_result = auth.register(pc_number=pc_number, pc_uuid=pc_uuid)
if register_result["result"] == 0:
pc_token = register_result["output_dict"]["pc_token"]
master_password = register_result["output_dict"]["master_password"]
master_password_hash = register_result["output_dict"]["master_password_hash"]
onetime_config["onetime"]["pc_register"]["current_count"] += 1
if onetime_config["onetime"]["pc_register"]["current_count"] == onetime_config["onetime"]["pc_register"]["max_count"]:
onetime_config["onetime"]["pc_register"]["password"] = None
with open(onetime_config_path, "w") as w:
json.dump(onetime_config, w, indent=4)
return jsonify({'message': 'ok', 'pc_token': pc_token, 'master_password': master_password, 'master_password_hash': master_password_hash}), 200
else:
with open(onetime_config_path, "w") as w:
json.dump(onetime_config, w, indent=4)
return jsonify({'message': 'ok', 'pc_token': pc_token, 'master_password': master_password, 'master_password_hash': master_password_hash}), 200
elif register_result["result"] == 1:
if register_result["about"] == "exist":
return jsonify({'message': 'exist'}), 400
else:
return jsonify({'message': 'damedesu'}), 500
else:
return jsonify({'message': 'damedesu'}), 401
else:
return jsonify({'message': 'damedesu'}), 401
@app.route('/verify', methods=['POST'])
def verify():
pc_number = int(request.json.get('pc_number'))
password = request.json.get('password')
print(str(pc_number) + "の認証処理を開始...")
password_hash = request.json.get('password')
pc_uuid = request.json.get('pc_uuid')
pc_token = request.json.get('pc_token')
devices = request.json.get('devices')
if auth.check(pc_number, password) == 0:
print(str(pc_number) + "の認証処理を開始...")
pc_auth = auth.check(pc_number=pc_number, password_hash=password_hash, pc_uuid=pc_uuid, pc_token=pc_token, device_list=devices)
if pc_auth["result"] == 0:
auth.delete(pc_number)
auth.device_use_register(pc_number=pc_number, keyboard_number=pc_auth["output_dict"]["keyboard_number"], mouse_number=pc_auth["output_dict"]["mouse_number"])
print(str(pc_number) + "の認証処理は成功しました.")
return jsonify({'message': 'ok'}), 200
elif pc_auth["result"] == 1:
if pc_auth["about"] == "incorrect_password":
print(str(pc_number) + "の認証処理はパスワードが正しくないため失敗しました.")
return jsonify({'message': 'incorrect_password'}), 401
else:
print(str(pc_number) + "の認証処理は失敗しました.")
return jsonify({'message': 'damedesu'}), 401
return jsonify({'message': 'damedesu'}), 500
@app.route('/stop', methods=['POST'])
def stop():
pc_number = int(request.json.get('pc_number'))
pc_uuid = str(request.json.get('pc_uuid'))
pc_token = str(request.json.get('pc_token'))
print(str(pc_number) + "の使用停止処理を開始...")
pc_auth = auth.check(pc_number=pc_number, pc_uuid=pc_uuid, pc_token=pc_token)
if pc_auth["result"] == 0:
pc_stop = auth.stop(pc_number=pc_number)
if pc_stop["result"] == "ok":
if pc_stop["result"] == 0:
print(str(pc_number) + "の使用停止処理は成功しました.")
return jsonify({'message': 'ok'}), 200
else:
print(str(pc_number) + "の使用停止処理は失敗しました.")
return jsonify({'message': 'error'}), 500
else:
return jsonify({'message': 'damedesu'}), 401
@app.route('/device_register', methods=['POST'])
def device_register():
onetime_password = str(request.json.get('onetime'))
mode = str(request.json.get('mode'))
number = int(request.json.get('number'))
device_instance_path = str(request.json.get('device_instance_path'))
device_name = str(request.json.get('device_name'))
if os.path.isfile(onetime_config_path):
with open(onetime_config_path, "r") as r:
onetime_config = json.load(r)
if onetime_password == onetime_config["onetime"]["device_register"]:
if mode == "keyboard":
print("キーボードの登録処理を開始...")
device_register = auth.device_register(mode="keyboard", number=number, device_instance_path=device_instance_path, device_name=device_name)
if device_register["result"] == 0:
print(f"キーボード {number} 番の登録処理は成功しました.")
onetime_config["onetime"]["device_register"]["current_count"] += 1
if onetime_config["onetime"]["device_register"]["current_count"] == onetime_config["onetime"]["device_register"]["max_count"]:
onetime_config["onetime"]["device_register"] = None
with open(onetime_config_path, "w") as w:
json.dump(onetime_config, w, indent=4)
return jsonify({'message': 'ok'}), 200
else:
with open(onetime_config_path, "w") as w:
json.dump(onetime_config, w, indent=4)
return jsonify({'message': 'ok'}), 200
else:
print(f"キーボード {number} 番の登録処理は失敗しました.")
return jsonify({'message': 'error'}), 500
elif mode == "mouse":
print("マウスの登録処理を開始...")
device_register = auth.device_register(mode="mouse", number=number, device_instance_path=device_instance_path, device_name=device_name)
if device_register["result"] == 0:
print(f"マウス {number} 番の登録処理は成功しました.")
onetime_config["onetime"]["device_register"]["current_count"] += 1
if onetime_config["onetime"]["device_register"]["current_count"] == onetime_config["onetime"]["device_register"]["max_count"]:
onetime_config["onetime"]["device_register"] = None
with open(onetime_config_path, "w") as w:
json.dump(onetime_config, w, indent=4)
return jsonify({'message': 'ok'}), 200
else:
with open(onetime_config_path, "w") as w:
json.dump(onetime_config, w, indent=4)
return jsonify({'message': 'ok'}), 200
else:
print(f"マウス {number} 番の登録処理は失敗しました.")
return jsonify({'message': 'error'}), 500
else:
return jsonify({'message': 'damedesu'}), 401
if __name__ == '__main__':

View file

@ -13,14 +13,21 @@ import tkinter
import threading
import sys
import shutil
import uuid
import time
import win32com.client
import pythoncom
from PIL import Image
app_name = "Dislocker"
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"
@ -29,22 +36,81 @@ 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,
"erase_data": {
"example": {
"process_name": "example.exe",
"dir_path": "example"
}
},
"pc_uuid": "",
"pc_token": "",
"hard_lock": False
}
elif os.path.isfile(client_config_path):
with open(client_config_path, "r") as r:
client_config = json.load(r)
def get_input_devices():
str_computer = "."
obj_wmi_service = win32com.client.Dispatch("WbemScripting.SWbemLocator")
obj_swem_services = obj_wmi_service.ConnectServer(str_computer, "root\\cimv2")
col_items = obj_swem_services.ExecQuery("Select * from Win32_PnPEntity where PNPDeviceID like 'HID%'")
input_devices = []
for obj_item in col_items:
input_devices.append({
"device_id": obj_item.DeviceID,
"PNPDeviceID": obj_item.PNPDeviceID,
"Description": obj_item.Description,
"device_name": obj_item.Name,
"Manufacturer": obj_item.Manufacturer,
"Service": obj_item.Service,
"FriendlyName": obj_item.Name, # デバイスとプリンターで表示される名前
"device_instance_path": obj_item.DeviceID # デバイスインスタンスパス
})
return input_devices
def device_register(**kwargs):
onetime = str(kwargs["onetime"])
mode = str(kwargs["mode"])
number = int(kwargs["number"])
device_instance_path = str(kwargs["device_instance_path"])
device_name = str(kwargs["device_name"])
device_register_json = {
"number": number,
"device_instance_path": device_instance_path,
"device_name": device_name,
"mode": mode,
"onetime": onetime
}
register_url = client_config["auth_host_url"] + "/device_register"
responce = requests.post(register_url, json=device_register_json)
if responce.status_code == 200:
print("デバイスの登録に成功しました。")
return {"result": 0, "about": "ok"}
elif responce.status_code == 401:
print("認証に失敗しました。")
return {"result": 1, "about": "auth_failed"}
else:
print("内部エラーによりデバイスの登録に失敗しました。")
return {"result": 1, "about": "error"}
def master_password_gen():
numbers = string.digits # (1)
password = ''.join(random.choice(numbers) for _ in range(10)) # (2)
password_hash = hashlib.sha256(password.encode()).hexdigest()
result = {"password": password, "password_hash": password_hash}
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")
@ -53,18 +119,63 @@ def init(**kwargs):
else:
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 client_config["initial"] == True:
pc_uuid = uuid.uuid4()
client_config["pc_uuid"] = str(pc_uuid)
if "pc_number" in kwargs:
client_config["pc_number"] = int(kwargs["pc_number"])
else:
client_config["pc_number"] = 1
tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nPC番号が指定されていません。1個目の引数にPC番号、2個目の引数にワンタイムパスワードを指定して、もう一度お試しください。")
return 2
if "onetime" in kwargs:
onetime = str(kwargs["onetime"])
else:
tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nワンタイムパスワードが指定されていません。1個目の引数にPC番号、2個目の引数にワンタイムパスワードを指定して、もう一度お試しください。")
return 2
if "host_url" in kwargs:
client_config["auth_host_url"] = str(kwargs["host_url"])
else:
pass
register_url = client_config["auth_host_url"] + "/register"
register_json = {
"pc_number": int(client_config["pc_number"]),
"pc_uuid": str(pc_uuid),
"onetime": onetime
}
responce = requests.post(register_url, json=register_json)
if responce.status_code == 200:
print("PCの情報が登録されました。")
responce_json = responce.json()
pc_token = str(responce_json["pc_token"])
master_password_hash = str(responce_json["master_password_hash"])
master_password = str(responce_json["master_password"])
client_config["pc_token"] = pc_token
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"] = False
with open(client_config_path, "w") as w:
json.dump(client_config, w, indent=4)
return 2
elif responce.status_code == 400:
msgbox = tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\n指定されたPC番号には既に登録されています。PCを置き換えたい場合は、Botから登録を解除してください。")
return 2
elif responce.status_code == 401:
msgbox = tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nワンタイムパスワードが間違っている可能性があります。")
return 2
elif responce.status_code == 500:
msgbox = tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nサーバーで内部エラーが発生しています。")
return 2
else:
return 0
@ -72,16 +183,26 @@ def init(**kwargs):
class App(customtkinter.CTk):
def __init__(self):
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)
self.attributes('-topmost', True)
self.block_taskmgr()
self.block_key()
shutup_window = keyboard.press_and_release('windows + d')
self.attributes('-fullscreen', True)
self.attributes('-topmost', True)
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自動的にサインアウトされます。")
self.title(f"{app_name} | ロック中")
self.iconbitmap(default=resource_path + '\\icon\\dislocker.ico')
self.frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.frame.grid(row=0, column=0, sticky='nsew')
@ -89,62 +210,31 @@ 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()
def delete_appdata(self, **kwargs):
process_name = kwargs["process_name"]
dir_path = kwargs["dir_path"]
if not os.path.exists(dir_path):
print(f"エラー: 指定されたディレクトリ {dir_path} が存在しません。")
return 1
i = 0
i_max = 10
result = 1
while i != i_max:
i += 1
try:
# プロセスの終了
subprocess.run(['taskkill', '/f', '/t', '/im', process_name])
print(f"{process_name} を終了しました。")
time.sleep(0.1)
# ディレクトリの削除
shutil.rmtree(dir_path)
if os.path.isdir(dir_path):
pass
else:
print(f"{dir_path} を削除しました。")
result = 0
i = i_max
except subprocess.CalledProcessError as e:
print(f"プロセス終了エラー: {e}")
except PermissionError as e:
print(f"権限エラー: {e}")
except Exception as e:
print("エラーが発生しました。\nエラー内容:")
print(f"エラータイプ: {e.__class__.__name__}")
print(f"エラー引数: {e.args}")
print(f"エラーメッセージ: {str(e)}")
def block_key(self):
block_keys = ['ctrl', 'alt', 'windows', 'shift', 'delete']
for i in block_keys:
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',
@ -162,13 +252,13 @@ 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"]} | ロックされています')
self.iconbitmap(default=resource_path + '\\icon\\dislocker.ico')
self.window_width = 600
self.window_width = 760
self.window_height = 320
self.screen_width = self.winfo_screenwidth()
self.screen_height = self.winfo_screenheight()
@ -190,31 +280,44 @@ class Lock(customtkinter.CTkToplevel):
self.textbox_font = customtkinter.CTkFont(family="meiryo", size=14)
self.button_font = customtkinter.CTkFont(family="meiryo", size=14)
self.cover_img = customtkinter.CTkImage(light_image=Image.open(resource_path + '\\cover\\dislocker_light.png'), dark_image=Image.open(resource_path + '\\cover\\dislocker_dark.png'), size=(160, 320))
self.grid_columnconfigure(0, weight=1)
self.grid_columnconfigure(1, weight=6)
self.cover_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.cover_frame.grid(row=0, column=0, padx=0, pady=0, sticky="nsew", rowspan=4)
self.cover_img_label = customtkinter.CTkLabel(self.cover_frame, image=self.cover_img, text="")
self.cover_img_label.grid(row=0, column=0, padx=0, pady=0, sticky="w")
self.msg_title_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.msg_title_frame.grid(row=0, column=0, padx=10, pady=10, sticky="nsew")
self.msg_title_frame.grid(row=0, column=1, 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")
#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")
self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text=f'ちょっと待って!! PC番号 | {client_config["pc_number"]}', font=self.title_font, justify="left")
self.msg_title_1.grid(row=0, column=1, padx=10, sticky="w")
self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text=f'ちょっと待って!! ', font=self.title_font, justify="left")
self.msg_title_1.grid(row=0, column=0, padx=10, sticky="we")
self.pc_number_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text=f'PC番号 | {client_config["pc_number"]}', font=self.title_font, justify="right")
self.pc_number_title_1.grid(row=0, column=1, padx=10, sticky="e")
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")
self.msg_title_2.grid(row=1, column=0, padx=10, columnspan=2, sticky="w")
self.msg_subtitle_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.msg_subtitle_frame.grid(row=1, column=0, padx=10, pady=10, sticky="nsew")
self.msg_subtitle_frame.grid(row=1, column=1, padx=10, pady=0, sticky="nsew")
self.msg_subtitle_frame.grid_columnconfigure(0, weight=1)
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")
self.msg_subtitle_1 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='サインインするには、Discordを開き、Dislockerから送信された\nパスワードを入力してください。', font=self.general_font, justify="left")
self.msg_subtitle_1.grid(row=0, column=0, padx=10, sticky="w")
self.msg_subtitle_2 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='※ パスワードの有効期限は23:59までです', font=self.general_small_font, justify="left")
self.msg_subtitle_2 = customtkinter.CTkLabel(self.msg_subtitle_frame, text='※ パスワードの有効期限は発行から5分間です。期限が切れた場合は、もう一度発行してください', font=self.general_small_font, justify="left")
self.msg_subtitle_2.grid(row=1, column=0, padx=10, sticky="w")
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.grid(row=2, column=1, padx=10, pady=0, sticky="nsew")
self.input_frame.columnconfigure(0, weight=1)
self.password_entry = customtkinter.CTkEntry(self.input_frame, placeholder_text='パスワード', show='*', font=self.textbox_font)
@ -222,7 +325,7 @@ class Lock(customtkinter.CTkToplevel):
self.password_entry.bind("<Return>", self.auth_start_ev)
self.button_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.button_frame.grid(row=3, column=0, padx=10, pady=10, sticky="nsew")
self.button_frame.grid(row=3, column=1, 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)
@ -247,7 +350,7 @@ class Lock(customtkinter.CTkToplevel):
keyboard.add_hotkey('ctrl+shift+q', self.exit)
def hash_genarate(self, source):
hashed = hashlib.md5(source.encode())
hashed = hashlib.sha256(source.encode())
return hashed.hexdigest()
def auth_start(self):
@ -270,10 +373,39 @@ class Lock(customtkinter.CTkToplevel):
self.signin_button.configure(state="normal", fg_color="#3c8dd0")
self.signout_button.configure(state="normal", fg_color="#3c8dd0")
def get_input_devices(self):
try:
pythoncom.CoInitialize()
str_computer = "."
obj_wmi_service = win32com.client.Dispatch("WbemScripting.SWbemLocator")
obj_swem_services = obj_wmi_service.ConnectServer(str_computer, "root\\cimv2")
col_items = obj_swem_services.ExecQuery("Select * from Win32_PnPEntity where PNPDeviceID like 'HID%'")
input_devices = []
for obj_item in col_items:
input_devices.append({
"device_id": obj_item.DeviceID,
"PNPDeviceID": obj_item.PNPDeviceID,
"Description": obj_item.Description,
"device_name": obj_item.Name,
"Manufacturer": obj_item.Manufacturer,
"Service": obj_item.Service,
"FriendlyName": obj_item.Name, # デバイスとプリンターで表示される名前
"device_instance_path": obj_item.DeviceID # デバイスインスタンスパス
})
pythoncom.CoUninitialize()
return input_devices
except pythoncom.com_error as e:
print("Error:", e)
return []
def auth(self):
self.button_disable()
password = str(self.password_entry.get())
#devices = self.get_input_devices()
devices = []
if len(password) == 10:
print("マスターパスワードで認証を試行します。")
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
@ -288,11 +420,13 @@ class Lock(customtkinter.CTkToplevel):
self.button_enable()
self.deiconify()
print("認証サーバーにアクセスします。")
auth_url = client_config["auth_host_url"] + "/verify"
auth_json = {
"pc_number": int(client_config["pc_number"]),
"pc_uuid": str(client_config["pc_uuid"]),
"pc_token": str(client_config["pc_token"]),
"devices": devices,
"password": self.hash_genarate(str(self.password_entry.get()))
}
try:
@ -300,13 +434,20 @@ class Lock(customtkinter.CTkToplevel):
if responce.status_code == 200:
print("認証サーバー経由で認証しました。")
self.exit()
else:
elif responce.status_code == 401:
print("認証サーバー経由での認証に失敗しました。")
self.withdraw()
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 誤ったパスワード", message=f"パスワードが間違っています!")
self.msg_subtitle_1.configure(text='パスワードが間違っています! ')
self.button_enable()
self.deiconify()
elif responce.status_code == 500:
print("内部エラーにより認証に失敗しました。")
self.withdraw()
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 内部エラー", message=f"サーバーの内部エラーにより認証に失敗しました。")
self.msg_subtitle_1.configure(text='内部エラーにより認証に失敗しました。 ')
self.button_enable()
self.deiconify()
except:
print("認証サーバーにアクセスできません。マスターパスワードで認証を試行します。")
master_password_hash = self.hash_genarate(str(self.password_entry.get()))
@ -324,7 +465,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)
@ -336,7 +477,15 @@ class Lock(customtkinter.CTkToplevel):
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 未実装", message=f"ヘルプページは製作途中です。\nDiscordサーバーの指示に従って、認証を進めてください。")
self.deiconify()
def wakeup_shutdown_background(self):
wakeup = subprocess.Popen(f'{dislocker_dir}\\dislocker_client_shutdown.exe', startupinfo=sp_startupinfo)
def exit(self):
try:
self.wakeup_shutdown_background()
except:
pass
self.destroy()
app.exit()
@ -344,7 +493,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} | ヘルプ')
@ -385,7 +534,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)
# ディレクトリの削除
@ -413,29 +562,33 @@ 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")
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")
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")
riot_del = app.delete_appdata(process_name="RiotClientServices.exe", dir_path=f"{appdata_local}\\Riot Games\\Riot Client")
epic_del = self.delete_appdata(process_name="EpicGamesLauncher.exe", dir_path=f"{appdata_local}\\EpicGamesLauncher\\Saved")
chrome_del = self.delete_appdata(process_name="chrome.exe", dir_path=f"{appdata_local}\\Google\\Chrome\\User Data")
discord_del = self.delete_appdata(process_name="discord.exe", dir_path=f"{appdata_roaming}\\discord")
steam_del = self.delete_appdata(process_name="steam.exe", dir_path=f"{appdata_local}\\Steam")
ea_del = self.delete_appdata(process_name="EADesktop.exe", dir_path=f"{appdata_local}\\Electronic Arts")
riot_del = self.delete_appdata(process_name="RiotClientServices.exe", dir_path=f"{appdata_local}\\Riot Games\\Riot Client")
else:
print("削除処理をスキップ。")
stop_url = client_config["auth_host_url"] + "/stop"
stop_json = {
"pc_number": int(client_config["pc_number"])
"pc_number": int(client_config["pc_number"]),
"pc_uuid": str(client_config["pc_uuid"]),
"pc_token": str(client_config["pc_token"])
}
try:
responce = requests.post(stop_url, json=stop_json)
if responce.status_code == 200:
print("停止処理は成功しました。")
elif responce.status_code == 401:
print("認証に失敗しました。")
else:
print("内部エラーにより停止処理に失敗しました。")
except:
@ -444,34 +597,67 @@ class Stop():
self.shutdown()
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
if __name__ == '__main__':
args = sys.argv
if len(args) >= 2:
if args[1] == "stop":
init_result = init()
if init_result == 1:
print("多重起動エラー")
print("多重起動を検出。")
elif init_result == 2:
pass
else:
stop = Stop()
stop.run()
elif args[1] == "setup":
init_result = init(pc_number=args[2])
if len(args) == 4:
init_result = init(pc_number=args[2], onetime=args[3])
elif len(args) == 5:
init_result = init(pc_number=args[2], onetime=args[3], host_url=args[4])
else:
print("引数エラー。")
error_msgbox = tkinter.messagebox.showerror(title=f"{app_name} | 引数エラー", message=f"引数が多すぎるか、少なすぎます。\n引数がPC番号、ワンタイムパスワード、ホストURLの順で正しく指定されているか確認してください。")
if init_result == 1:
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"すでに {app_name} は実行されています。\n正常に起動しない場合は、既に起動しているプロセスを終了してから、もう一度起動してみてください。")
elif init_result == 2:
pass
else:
pass
elif args[1] == "deviceregister":
init_result = init()
if init_result == 1:
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"すでに {app_name} は実行されています。\n正常に起動しない場合は、既に起動しているプロセスを終了してから、もう一度起動してみてください。")
elif init_result == 2:
pass
else:
mode = input('登録するデバイスはキーボードとマウスのどちらですか?(keyboard/mouse): ')
input_devices = get_input_devices()
i = 0
for device in input_devices:
print(f"{str(i + 1)} 番目 | デバイス名: {device['device_name']} \n製造元: {device['Manufacturer']} \nデバイスインスタンスパス: {device['device_instance_path']}")
print("-" * 20)
i += 1
device_num = input('どのデバイスを登録しますか?番号で指定してください: ')
device_register_num = input('そのデバイスは何番目のデバイスとして登録しますか?番号で指定してください: ')
onetime = input('ワンタイムパスワードを入力してください: ')
device_register_result = device_register(onetime=onetime, mode=mode, number=int(device_register_num), device_instance_path=input_devices[int(device_num) - 1]["device_instance_path"], device_name=input_devices[int(device_num) - 1]["device_name"])
if device_register_result["result"] == 0:
print("登録されました。")
elif device_register_result["result"] == 1:
if device_register_result["about"] == "auth_failed":
print("認証に失敗しました。")
else:
print("エラーが発生しました。")
elif args[1] == "guitest":
init_result = init()
client_config["testing"] = True
app = App()
app.mainloop()
else:
print("引数エラー。")
else:

View file

@ -0,0 +1,166 @@
import os
import json
import tkinter.messagebox
import tkinter
import subprocess
import requests
import tkinter
import sys
import time
import shutil
app_name = "Dislocker"
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"
if not os.path.isfile(client_config_path):
msgbox = tkinter.messagebox.showerror(title=f"{app_name} | エラー", message=f"設定ファイルが正しく構成されていません。")
elif os.path.isfile(client_config_path):
with open(client_config_path, "r") as r:
client_config = json.load(r)
def init(**kwargs):
task_exist = subprocess.run('tasklist /fi "IMAGENAME eq dislocker_shutdown.exe"', startupinfo=sp_startupinfo, stdout=subprocess.PIPE, text=True)
if 'dislocker_shutdown.exe' in task_exist.stdout:
task_count = task_exist.stdout.count("dislocker_shutdown.exe")
if task_count == 1:
pass
else:
return 1
if client_config["initial"] == True:
msgbox = tkinter.messagebox.showerror(title=f"{app_name} | エラー", message=f"設定ファイルが正しく構成されていません。")
return 2
else:
return 0
class App(tkinter.Tk):
def __init__(self):
super().__init__()
if client_config["testing"] == True:
pass
else:
pass
self.geometry("160x100")
self.title(f"{app_name} | シャットダウンを監視")
self.iconbitmap(default=resource_path + '\\icon\\dislocker_shutdown.ico')
self.protocol("WM_SAVE_YOURSELF", self.handler_close)
self.frame = tkinter.Frame(self)
self.frame.grid(row=0, column=0, sticky='nsew')
self.withdraw()
def delete_appdata(self, **kwargs):
process_name = kwargs["process_name"]
dir_path = kwargs["dir_path"]
if not os.path.exists(dir_path):
print(f"エラー: 指定されたディレクトリ {dir_path} が存在しません。")
return 1
i = 0
i_max = 10
result = 1
while i != i_max:
i += 1
try:
# プロセスの終了
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)
# ディレクトリの削除
shutil.rmtree(dir_path)
if os.path.isdir(dir_path):
pass
else:
print(f"{dir_path} を削除しました。")
result = 0
i = i_max
except subprocess.CalledProcessError as e:
print(f"プロセス終了エラー: {e}")
except PermissionError as e:
print(f"権限エラー: {e}")
except Exception as e:
print("エラーが発生しました。\nエラー内容:")
print(f"エラータイプ: {e.__class__.__name__}")
print(f"エラー引数: {e.args}")
print(f"エラーメッセージ: {str(e)}")
def handler_close(self):
print("停止処理を実行。")
stop_url = client_config["auth_host_url"] + "/stop"
stop_json = {
"pc_number": int(client_config["pc_number"]),
"pc_uuid": str(client_config["pc_uuid"]),
"pc_token": str(client_config["pc_token"])
}
try:
responce = requests.post(stop_url, json=stop_json)
if responce.status_code == 200:
print("停止処理は成功しました。")
elif responce.status_code == 401:
print("認証に失敗しました。")
else:
print("内部エラーにより停止処理に失敗しました。")
except:
print("ネットワークエラーにより停止処理に失敗しました。")
print("データ削除を実行。")
try:
if client_config["eraser"] == True:
appdata_local = os.path.expandvars("%LOCALAPPDATA%")
appdata_roaming = os.path.expandvars("%APPDATA%")
epic_del = self.delete_appdata(process_name="EpicGamesLauncher.exe", dir_path=f"{appdata_local}\\EpicGamesLauncher\\Saved")
chrome_del = self.delete_appdata(process_name="chrome.exe", dir_path=f"{appdata_local}\\Google\\Chrome\\User Data")
discord_del = self.delete_appdata(process_name="discord.exe", dir_path=f"{appdata_roaming}\\discord")
steam_del = self.delete_appdata(process_name="steam.exe", dir_path=f"{appdata_local}\\Steam")
ea_del = self.delete_appdata(process_name="EADesktop.exe", dir_path=f"{appdata_local}\\Electronic Arts")
riot_del = self.delete_appdata(process_name="RiotClientServices.exe", dir_path=f"{appdata_local}\\Riot Games\\Riot Client")
"""
for i in client_config['erase_data'].keys():
if i == 'example':
pass
else:
erase_process_name = client_config['erase_data'][i]['process_name']
erase_dir_path = client_config['erase_data'][i]['dir_path']
erase_del = self.delete_appdata(process_name=erase_process_name, dir_path=erase_dir_path)
"""
else:
print("削除処理をスキップ。")
except:
print("データ削除に失敗しました。")
self.destroy()
def icon(self):
self.iconify()
if __name__ == '__main__':
init_result = init()
if init_result == 1:
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"すでに {app_name} は実行されています。\n正常に起動しない場合は、既に起動しているプロセスを終了してから、もう一度起動してみてください。")
elif init_result == 2:
pass
else:
app = App()
app.mainloop()

View file

@ -0,0 +1,441 @@
import os
import json
import tkinter.messagebox
import customtkinter
import subprocess
import requests
import hashlib
import string
import random
import tkinter
import threading
import sys
import shutil
import uuid
import time
app_name = "Dislocker"
dislocker_dir = os.path.dirname(os.path.abspath(sys.argv[0]))
os.chdir(dislocker_dir)
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"
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,
"eraser": 1,
"pc_uuid": "",
"pc_token": ""
}
elif os.path.isfile(client_config_path):
with open(client_config_path, "r") as r:
client_config = json.load(r)
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
def init(**kwargs):
if client_config["initial"] == 1:
pc_uuid = uuid.uuid4()
client_config["pc_uuid"] = str(pc_uuid)
if "pc_number" in kwargs:
client_config["pc_number"] = int(kwargs["pc_number"])
else:
tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nPC番号が指定されていません。1個目の引数にPC番号、2個目の引数にワンタイムパスワードを指定して、もう一度お試しください。")
return 2
if "onetime" in kwargs:
onetime = str(kwargs["onetime"])
else:
tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nワンタイムパスワードが指定されていません。1個目の引数にPC番号、2個目の引数にワンタイムパスワードを指定して、もう一度お試しください。")
return 2
register_url = client_config["auth_host_url"] + "/register"
register_json = {
"pc_number": int(client_config["pc_number"]),
"pc_uuid": str(pc_uuid),
"onetime": onetime
}
responce = requests.post(register_url, json=register_json)
if responce.status_code == 200:
print("PCの情報が登録されました。")
responce_json = responce.json()
pc_token = str(responce_json["pc_token"])
client_config["pc_token"] = pc_token
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
with open(client_config_path, "w") as w:
json.dump(client_config, w, indent=4)
return 2
else:
msgbox = tkinter.messagebox.showerror(title=f"{app_name} | 登録時にエラー", message=f"登録時にエラーが発生しました。\nワンタイムパスワードが間違っている可能性があります。")
return 2
else:
return 0
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.title(f"{app_name} | ロック中")
if client_config["testing"] == 1:
pass
else:
self.attributes('-fullscreen', True)
self.attributes('-topmost', True)
self.frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.frame.grid(row=0, column=0, sticky='nsew')
lock = Lock()
def exit(self):
self.unlock_taskmgr()
self.toast()
self.destroy()
def handler_close(self):
pass
class Lock(customtkinter.CTkToplevel):
def __init__(self):
super().__init__()
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"]} | ロックされています')
self.window_width = 600
self.window_height = 320
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)}")
self.resizable(height=False, width=False)
self.attributes('-topmost', True)
self.grab_set()
self.lift()
self.protocol("WM_DELETE_WINDOW", self.handler_close)
self.emoji_font = customtkinter.CTkFont(family="Noto Color Emoji", size=32)
self.title_font = customtkinter.CTkFont(family="Noto Sans CJK JP", size=32, weight="bold")
self.pc_number_font = customtkinter.CTkFont(family="Noto Sans CJK JP", size=64, weight="bold")
self.title_small_font = customtkinter.CTkFont(family="Noto Sans CJK JP", size=16)
self.general_font = customtkinter.CTkFont(family="Noto Sans CJK JP", size=18)
self.general_small_font = customtkinter.CTkFont(family="Noto Sans CJK JP", size=12)
self.textbox_font = customtkinter.CTkFont(family="Noto Sans CJK JP", size=14)
self.button_font = customtkinter.CTkFont(family="Noto Sans CJK JP", size=14)
self.msg_title_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
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")
self.msg_title_1 = customtkinter.CTkLabel(self.msg_title_frame, text=f'ちょっと待って!! PC番号 | {client_config["pc_number"]}', font=self.title_font, justify="left")
self.msg_title_1.grid(row=0, column=1, padx=10, sticky="w")
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")
self.msg_subtitle_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
self.msg_subtitle_frame.grid(row=1, column=0, padx=10, pady=10, sticky="nsew")
self.msg_subtitle_frame.grid_columnconfigure(0, weight=1)
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")
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")
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)
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")
self.password_entry.bind("<Return>", self.auth_start_ev)
self.button_frame = customtkinter.CTkFrame(self, corner_radius=0, fg_color='transparent')
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)
self.signin_button = customtkinter.CTkButton(self.button_frame, text='サインイン', command=self.auth_start, font=self.button_font)
self.signin_button.grid(row=0, column=2, padx=10, sticky="e")
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")
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")
def help_wakeup(self):
help = Help()
def hash_genarate(self, source):
hashed = hashlib.md5(source.encode())
return hashed.hexdigest()
def auth_start(self):
auth_thread = threading.Thread(target=self.auth)
auth_thread.daemon = True
auth_thread.start()
def auth_start_ev(self, event):
auth_thread = threading.Thread(target=self.auth)
auth_thread.daemon = True
auth_thread.start()
def button_disable(self):
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")
def button_enable(self):
self.help_button.configure(state="normal", fg_color="#3c8dd0")
self.signin_button.configure(state="normal", fg_color="#3c8dd0")
self.signout_button.configure(state="normal", fg_color="#3c8dd0")
def auth(self):
self.button_disable()
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("マスターパスワードで認証できませんでした。")
self.withdraw()
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 誤ったパスワード", message=f"パスワードが間違っています!")
self.msg_subtitle_1.configure(text='パスワードが間違っています! ')
self.button_enable()
self.deiconify()
print("認証サーバーにアクセスします。")
auth_url = client_config["auth_host_url"] + "/verify"
auth_json = {
"pc_number": int(client_config["pc_number"]),
"pc_uuid": str(client_config["pc_uuid"]),
"pc_token": str(client_config["pc_token"]),
"password": self.hash_genarate(str(self.password_entry.get()))
}
try:
responce = requests.post(auth_url, json=auth_json)
if responce.status_code == 200:
print("認証サーバー経由で認証しました。")
self.exit()
else:
print("認証サーバー経由での認証に失敗しました。")
self.withdraw()
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 誤ったパスワード", message=f"パスワードが間違っています!")
self.msg_subtitle_1.configure(text='パスワードが間違っています! ')
self.button_enable()
self.deiconify()
except:
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("マスターパスワードで認証できませんでした。")
self.withdraw()
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | ネットワークエラー", message=f"認証サーバーにアクセスできませんでした。\n続行するには、マスターパスワードを入力してください。")
self.msg_subtitle_1.configure(text='ネットワークエラーが発生しています。\n続行するには、マスターパスワードを入力して下さい。 ')
self.button_enable()
self.deiconify()
def signout(self):
self.withdraw()
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 未実装", message=f"ログアウトは未実装です。")
self.deiconify()
def handler_close(self):
pass
def help_dummy(self):
self.withdraw()
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 未実装", message=f"ヘルプページは製作途中です。\nDiscordサーバーの指示に従って、認証を進めてください。")
self.deiconify()
def exit(self):
self.destroy()
app.exit()
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} | ヘルプ')
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)
msgbox = tkinter.messagebox.showinfo(title=f"{app_name} | 未実装", message=f"ヘルプページは製作途中です。\nDiscordサーバーの指示に従って、認証を進めてください。")
self.destroy()
def handler_close(self):
self.destroy()
class Stop():
def __init__(self) -> None:
pass
def run(self):
print("停止処理を実行中...")
stop_thread = threading.Thread(target=self.stop)
stop_thread.run()
def delete_appdata(self, **kwargs):
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} を終了しました。")
time.sleep(0.1)
# ディレクトリの削除
i = 1
ic = 0
while i == 1:
shutil.rmtree(dir_path)
if os.path.isdir(dir_path):
ic += 1
if ic == 10:
i = 0
else:
i = 0
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
def shutdown(self):
shutdown_command = subprocess.run(['shutdown', '/s', '/t', '1'])
def stop(self):
print("停止処理を実行。")
if client_config["eraser"] == 1:
#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")
#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")
#riot_del = app.delete_appdata(process_name="RiotClientServices.exe", dir_path=f"{appdata_local}\\Riot Games\\Riot Client")
pass
else:
print("削除処理をスキップ。")
stop_url = client_config["auth_host_url"] + "/stop"
stop_json = {
"pc_number": int(client_config["pc_number"]),
"pc_uuid": str(client_config["pc_uuid"]),
"pc_token": str(client_config["pc_token"])
}
try:
responce = requests.post(stop_url, json=stop_json)
if responce.status_code == 200:
print("停止処理は成功しました。")
elif responce.status_code == 401:
print("認証に失敗しました。")
tkinter.messagebox.showwarning(title=f"{app_name} | エラー", message=f"認証に失敗しました。\nDiscordサーバーの指示に従って、停止処理を自身で行ってください。")
else:
print("内部エラーにより停止処理に失敗しました。")
result_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | エラー", message=f"内部エラーにより停止処理に失敗しました。\nDiscordサーバーの指示に従って、停止処理を自身で行ってください。")
except:
print("ネットワークエラーにより停止処理に失敗しました。")
result_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | エラー", message=f"ネットワークエラーにより停止処理に失敗しました。\nDiscordサーバーの指示に従って、停止処理を自身で行ってください。")
finally:
self.shutdown()
if __name__ == '__main__':
args = sys.argv
if len(args) >= 2:
if args[1] == "stop":
init_result = init()
if init_result == 1:
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"もう終了処理を行っています。\nPCがシャットダウンするまで、もう少しお待ちください。")
elif init_result == 2:
pass
else:
stop = Stop()
stop.run()
elif args[1] == "setup":
init_result = init(pc_number=args[2], onetime=args[3])
if init_result == 1:
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"すでに {app_name} は実行されています。\n正常に起動しない場合は、既に起動しているプロセスを終了してから、もう一度起動してみてください。")
elif init_result == 2:
pass
else:
pass
else:
print("引数エラー。")
else:
init_result = init()
if init_result == 1:
warning_msgbox = tkinter.messagebox.showwarning(title=f"{app_name} | 多重起動エラー", message=f"すでに {app_name} は実行されています。\n正常に起動しない場合は、既に起動しているプロセスを終了してから、もう一度起動してみてください。")
elif init_result == 2:
pass
else:
app = App()
app.protocol("WM_DELETE_WINDOW", app.handler_close)
app.mainloop()

1605
dislocker_slash.py Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,4 @@
discord.py
flask
flask-login
psycopg2-binary
winotify
customtkinter
keyboard
requests
openpyxl
flask

View file

@ -2,3 +2,4 @@ customtkinter
winotify
keyboard
requests
pywin32

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

16
script/download.cmd Normal file
View file

@ -0,0 +1,16 @@
@echo off
set dir=%~dp0
cd %dir%
set download_url=""
curl -L %download_url% -o %dir%\dislocker_client.zip
mkdir %dir%\temp_ds
tar -xf %dir%\dislocker_client.zip -C %dir%\temp_ds
mkdir C:\ProgramData\Dislocker
xcopy /e %dir%\temp_ds C:\ProgramData\Dislocker
rmdir /s /q %dir%\temp_ds
del %dir%\dislocker_client.zip
C:\ProgramData\Dislocker\setup.cmd

View file

@ -16,6 +16,11 @@ if %ERRORLEVEL% == 0 (
if %ERRORLEVEL% == 1 (
echo ショートカットの作成でエラーが発生しました。
)
set /P pc_number=PC番号を入力
start %dir%dislocker_client.exe setup %pc_number%
set /P onetime=ワンタイムパスワードを入力
set /P host_url=ホストURLを入力 (必要な場合のみ)
start %dir%dislocker_client.exe setup %pc_number% %onetime% %host_url%
pause

19
script/update.cmd Normal file
View file

@ -0,0 +1,19 @@
@echo off
set dir=%~dp0
cd %dir%
set update_package_path="0"
set /P update_package_path=アップデート元のzipファイルのパスを入力 :
if %update_package_path%=="0" (set update_package_path=C:%HOMEPATH%\Downloads\dislocker_client_latest.zip)
set dislocker_dir_path="0"
set /P dislocker_dir_path=Dislockerのディレクトリのパスを入力 :
if %dislocker_dir_path%=="0" (set dislocker_dir_path=C:\Dislocker)
mkdir %dir%\temp_ds
tar -xf %update_package_path% -C %dir%\temp_ds
rmdir /s /q %dislocker_dir_path%\_internal
mkdir %dislocker_dir_path%\_internal
xcopy /e %dir%\temp_ds\_internal %dislocker_dir_path%\_internal
xcopy /Y %dir%\temp_ds\dislocker_client.exe %dislocker_dir_path%\dislocker_client.exe
rmdir /s /q %dir%\temp_ds
echo アップデート完了。Defenderの警告を消すため、一度起動しておいてください。
pause

24
script/update_online.cmd Normal file
View file

@ -0,0 +1,24 @@
@echo off
set dir=%~dp0
cd %dir%
set download_url=""
taskkill /f /t /im dislocker_client_shutdown.exe
taskkill /f /t /im dislocker_client.exe
curl -L %download_url% -o %dir%\dislocker_client.zip
mkdir %dir%\temp_ds\
tar -xf %dir%\dislocker_client.zip -C %dir%\temp_ds\
rmdir /s /q C:\ProgramData\Dislocker\_internal\
xcopy /e %dir%\temp_ds\_internal\ C:\ProgramData\Dislocker\_internal\
xcopy /Y %dir%\temp_ds\dislocker_client.exe C:\ProgramData\Dislocker\dislocker_client.exe
xcopy /Y %dir%\temp_ds\dislocker_client_shutdown.exe C:\ProgramData\Dislocker\dislocker_client_shutdown.exe
xcopy /Y %dir%\temp_ds\shortcut.vbs C:\ProgramData\Dislocker\shortcut.vbs
xcopy /Y %dir%\temp_ds\setup.cmd C:\ProgramData\Dislocker\setup.cmd
rmdir /s /q %dir%\temp_ds\
del %dir%\dislocker_client.zip
echo アップデート完了。Defenderの警告を消すため、一度起動しておいてください。
pause