From 358657c3d8638d60a792d4e6b0498f9abc90ae05 Mon Sep 17 00:00:00 2001 From: katboi01 Date: Fri, 24 Jan 2025 13:31:49 +0100 Subject: [PATCH] fixes --- .gitignore | 2 ++ dmmBypass.py | 22 +++++++++++----------- dmmUpdater.py | 7 +++++-- run_KF3.bat | 1 - update_and_run_KF3.bat | 1 - 5 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2dd3fb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.cfg +*__pycache__* \ No newline at end of file diff --git a/dmmBypass.py b/dmmBypass.py index 119e476..b83a87d 100644 --- a/dmmBypass.py +++ b/dmmBypass.py @@ -3,9 +3,9 @@ import sys import wmi import hashlib import requests +import dmmUpdater import subprocess import urllib.parse -import dmmUpdater from uuid import getnode from bs4 import BeautifulSoup from pypasser import reCaptchaV3 @@ -28,12 +28,12 @@ def retrieve_login_token(session : requests.Session): print("Retrieving login form") url = "https://accounts.dmm.com/service/login/password" result = session.get(url) + result.raise_for_status() page = BeautifulSoup(result.content, 'html.parser') token = page.find('input', attrs={"name":"token"}).get("value") return token except Exception as e: print("Failed to retrieve login form:", e) - return None def retrieve_captcha_token(): try: @@ -41,7 +41,6 @@ def retrieve_captcha_token(): return captcha except Exception as e: print("Failed to solve captcha:", e) - return None def retrieve_auth_keys(login, password, token, captcha, session : requests.Session): try: @@ -50,11 +49,11 @@ def retrieve_auth_keys(login, password, token, captcha, session : requests.Sessi data = f"token={token}&login_id={login}&password={password}&prompt=&device=games-player&recaptchaToken={captcha}" headers = {"Content-Type": "application/x-www-form-urlencoded"} result = session.post(url, data, headers=headers) + result.raise_for_status() cookies = result.cookies.get_dict() return cookies["login_secure_id"], cookies["login_session_id"] except Exception as e: print("Failed to log in:", e) - return None, None def retrieve_update_params(game_id, login_secure, login_session, use_proxy): try: @@ -64,7 +63,7 @@ def retrieve_update_params(game_id, login_secure, login_session, use_proxy): cookies = {"login_secure_id":login_secure, "login_session_id":login_session} url = "https://katworks.sytes.net/KF/Api/DMM/filelist" if use_proxy else "https://apidgp-gameplayer.games.dmm.com/v5/r2/filelist/cl" result = requests.post(url, cookies=cookies, headers=headers, json=data) - + result.raise_for_status() data = result.json()["data"] game_version = data["latest_version"] print("Latest version:", game_version) @@ -74,7 +73,6 @@ def retrieve_update_params(game_id, login_secure, login_session, use_proxy): return file_list_url, file_list_params except Exception as e: print("Failed to retrieve update file list:", e) - return def retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_secure, login_session, use_proxy): try: @@ -84,12 +82,11 @@ def retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_sec cookies = {"login_secure_id":login_secure, "login_session_id":login_session} url = "https://katworks.sytes.net/KF/Api/DMM/launch" if use_proxy else "https://apidgp-gameplayer.games.dmm.com/v5/r2/launch/cl" result = requests.post(url, cookies=cookies, headers=headers, json=data) - + result.raise_for_status() data = result.json()["data"] return data["execute_args"] except Exception as e: print("Failed to retrieve launch arguments:", e) - return None def main(args): if len(args) != 7: @@ -120,7 +117,6 @@ def main(args): if token == None or captcha == None: return - #auth keys are also saved as cookies in session login_secure, login_session = retrieve_auth_keys(login, password, token, captcha, session) if not use_proxy: input("Enable VPN now and press Enter") @@ -129,12 +125,16 @@ def main(args): file_list_url, file_access_params = retrieve_update_params(game_id, login_secure, login_session, use_proxy) if file_list_url == None or file_access_params == None: return - dmmUpdater.update_game(os.path.dirname(exe_location), file_list_url, file_access_params) execute_args = retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_secure, login_session, use_proxy) - + if execute_args == None: + return + if not use_proxy: input("Disable VPN now and press Enter") + if update_game: + dmmUpdater.update_game(os.path.dirname(exe_location), file_list_url, file_access_params) + print("Starting game") args = [exe_location] + execute_args.split() print(args) diff --git a/dmmUpdater.py b/dmmUpdater.py index b30ca07..fac0053 100644 --- a/dmmUpdater.py +++ b/dmmUpdater.py @@ -22,7 +22,9 @@ def progressbar(it, prefix="", size=60, out=sys.stdout): # Python3.3+ def get_file_list(url): url = "https://apidgp-gameplayer.games.dmm.com" + url print("Retrieving file list from " + url) - data = requests.get(url).json()["data"] + result = requests.get(url) + result.raise_for_status() + data = result.json()["data"] return data["domain"], data["file_list"] def get_file_hash(file_path): @@ -37,11 +39,12 @@ def get_file_hash(file_path): return file_hash.hexdigest() def update_game(game_path, files_url, files_param): + print("Updating game") server_url, server_files = get_file_list(files_url) server_file_dict = {file["local_path"]: file for file in server_files} local_files = [os.path.join(dp, f).replace("\\", "/") for dp, dn, filenames in os.walk(game_path) for f in filenames] - local_file_dict = {"/" + os.path.relpath(r, game_path).replace("\\", "/"): {"abs_path":r, "hash":""} for r in local_files if not "BepInEx" in r} + local_file_dict = {"/" + os.path.relpath(r, game_path).replace("\\", "/"): {"abs_path":r, "hash":""} for r in local_files} files_to_download = [] files_to_delete = [] diff --git a/run_KF3.bat b/run_KF3.bat index 7233642..1981673 100644 --- a/run_KF3.bat +++ b/run_KF3.bat @@ -11,7 +11,6 @@ IF NOT EXIST %file_name% ( set /p dmm_login=DMM Login: set /p dmm_password=DMM Password: set /p confirm="Your login tokens will be sent through Katboi's VPN machine, is that ok? Personal VPN is required if not (yes/no):" - echo !confirm! if /i "!confirm!"=="yes" ( set use_proxy=true ) else ( diff --git a/update_and_run_KF3.bat b/update_and_run_KF3.bat index 27ea157..e49a872 100644 --- a/update_and_run_KF3.bat +++ b/update_and_run_KF3.bat @@ -11,7 +11,6 @@ IF NOT EXIST %file_name% ( set /p dmm_login=DMM Login: set /p dmm_password=DMM Password: set /p confirm="Your login tokens will be sent through Katboi's VPN machine, is that ok? Personal VPN is required if not (yes/no):" - echo !confirm! if /i "!confirm!"=="yes" ( set use_proxy=true ) else (