1
0
Fork 0

Compare commits

..

1 Commits

Author SHA1 Message Date
katboi01 39f7539621 added debug prints 2025-01-24 13:54:25 +01:00
6 changed files with 131 additions and 115 deletions

View File

@ -1,23 +0,0 @@
# Japari Bypass
Efficient KF3/DMM game launcher.
## Requirements
Python 3 and pip.
KF3 installed from DMM. DMM itself does not need to be running.
## Instructions
Download the files from this repo. Unzip them to a safe place.
Run `run_KF3.bat`, it will ask you for some information.
It will ask for the location of the KF3 executable. Generally this will be `C:\users\[your name]\KFP2G\けもフレ3.exe`.
Input your DMM email and then password when prompted, and `yes` if you want to use the public VPN to connect to DMM's server. If you choose not to use the public VPN, then you will need to enable your own Japanese VPN while logging in to the game.
If you make a mistake or you want to change login details, edit the `kfp2g.cfg` config file, or delete it to run the configuration again.
If KF3 needs to update, use `update_and_run_KF3.bat` and it will install any new updates.
## Known issues
Retrieving launch arguments - error 308: Every once in a while, DMM games may have updated terms of service that need to be accepted. This can only be done via the official DMM app.

View File

@ -1,42 +1,22 @@
import os import os
import sys import sys
import wmi
import json import json
import hashlib import hashlib
import argparse
import requests import requests
import dmmUpdater
import subprocess import subprocess
import urllib.parse import urllib.parse
from uuid import getnode from uuid import getnode
parser = argparse.ArgumentParser(description='DMM bypass script')
parser.add_argument('-g', '--game', type=str, help="DMM code name of the game", default="kfp2g")
parser.add_argument('-u', '--update', help="Check for game update before launching", action='store_true')
args = parser.parse_args()
config_name = args.game + '.cfg'
if not os.path.exists(config_name):
subprocess.check_call([sys.executable, "-m", "pip", "install", "requests", "beautifulsoup4", "PyPasser"])
config = {
"game_id" : args.game,
"file_path" : input('Enter full file path to KF3 .exe: ').strip('\"'),
"dmm_login" : input('DMM Login (email): '),
"dmm_password" : input('DMM Password: '),
"use_proxy" : input('Your login tokens will be sent through my VPN machine.\nIs that okay? (yes/no): ').lower() == "yes"
}
with open(config_name, 'wt', encoding="utf-8") as f:
json.dump(config, f, indent=1, ensure_ascii=False)
else:
with open(config_name, "rt", encoding="utf-8") as f:
config = json.load(f)
print(f'Loaded settings from {config_name}')
config["update_game"] = args.update
import dmmUpdater
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from pypasser import reCaptchaV3 from pypasser import reCaptchaV3
def print_request(url, data : str, headers, cookies_dict):
print("Sending to", url)
vars = {"headers":headers, "cookies":cookies_dict, "data":data}
print(json.dumps(vars, ensure_ascii=False, indent=1))
pass
def get_hash(data): def get_hash(data):
sha_obj = hashlib.sha256() sha_obj = hashlib.sha256()
sha_obj.update(str(data).encode()) sha_obj.update(str(data).encode())
@ -47,11 +27,16 @@ def get_mac():
mac = getnode() mac = getnode()
return ':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2)).lower() return ':'.join(("%012X" % mac)[i:i+2] for i in range(0, 12, 2)).lower()
def get_motherboard():
return wmi.WMI().Win32_BaseBoard()[0].SerialNumber
def retrieve_login_token(session : requests.Session): def retrieve_login_token(session : requests.Session):
try: try:
print("Retrieving login form") print("Retrieving login form")
url = "https://accounts.dmm.com/service/login/password" url = "https://accounts.dmm.com/service/login/password"
print_request(url, "", dict(session.headers), session.cookies.get_dict())
result = session.get(url) result = session.get(url)
print(result.status_code, result.text)
result.raise_for_status() result.raise_for_status()
page = BeautifulSoup(result.content, 'html.parser') page = BeautifulSoup(result.content, 'html.parser')
token = page.find('input', attrs={"name":"token"}).get("value") token = page.find('input', attrs={"name":"token"}).get("value")
@ -72,13 +57,14 @@ def retrieve_auth_keys(login, password, token, captcha, session : requests.Sessi
url = "https://accounts.dmm.com/service/login/password/authenticate" url = "https://accounts.dmm.com/service/login/password/authenticate"
data = f"token={token}&login_id={login}&password={password}&prompt=&device=games-player&recaptchaToken={captcha}" data = f"token={token}&login_id={login}&password={password}&prompt=&device=games-player&recaptchaToken={captcha}"
headers = {"Content-Type": "application/x-www-form-urlencoded"} headers = {"Content-Type": "application/x-www-form-urlencoded"}
print_request(url, data, headers, session.cookies.get_dict())
result = session.post(url, data, headers=headers) result = session.post(url, data, headers=headers)
print(result.status_code, result.text)
result.raise_for_status() result.raise_for_status()
cookies = result.cookies.get_dict() cookies = result.cookies.get_dict()
return cookies["login_secure_id"], cookies["login_session_id"] return cookies["login_secure_id"], cookies["login_session_id"]
except Exception as e: except Exception as e:
print("Failed to log in:", e) print("Failed to log in:", e)
return None, None
def retrieve_update_params(game_id, login_secure, login_session, use_proxy): def retrieve_update_params(game_id, login_secure, login_session, use_proxy):
try: try:
@ -87,12 +73,11 @@ def retrieve_update_params(game_id, login_secure, login_session, use_proxy):
headers = {"User-Agent": "DMMGamePlayer5-Win/5.3.12 Electron/32.1.0", "Client-App": "DMMGamePlayer5", "Client-version": "5.3.12", "Content-Type": "application/json"} headers = {"User-Agent": "DMMGamePlayer5-Win/5.3.12 Electron/32.1.0", "Client-App": "DMMGamePlayer5", "Client-version": "5.3.12", "Content-Type": "application/json"}
cookies = {"login_secure_id":login_secure, "login_session_id":login_session} 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" url = "https://katworks.sytes.net/KF/Api/DMM/filelist" if use_proxy else "https://apidgp-gameplayer.games.dmm.com/v5/r2/filelist/cl"
print_request(url, data, headers, cookies)
result = requests.post(url, cookies=cookies, headers=headers, json=data) result = requests.post(url, cookies=cookies, headers=headers, json=data)
print(result.status_code, result.text)
result.raise_for_status() result.raise_for_status()
result_json = result.json() data = result.json()["data"]
if result_json["result_code"] != 100:
raise Exception(f'{result_json["result_code"]}: {result_json["error"]}')
data = result_json["data"]
game_version = data["latest_version"] game_version = data["latest_version"]
print("Latest version:", game_version) print("Latest version:", game_version)
file_list_url = data["file_list_url"] file_list_url = data["file_list_url"]
@ -101,7 +86,6 @@ def retrieve_update_params(game_id, login_secure, login_session, use_proxy):
return file_list_url, file_list_params return file_list_url, file_list_params
except Exception as e: except Exception as e:
print("Failed to retrieve update file list:", e) print("Failed to retrieve update file list:", e)
return None, None
def retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_secure, login_session, use_proxy): def retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_secure, login_session, use_proxy):
try: try:
@ -110,27 +94,36 @@ def retrieve_launch_params(game_id, mac_addr, hdd_serial, motherboard, login_sec
headers = {"User-Agent": "DMMGamePlayer5-Win/5.3.12 Electron/32.1.0", "Client-App": "DMMGamePlayer5", "Client-version": "5.3.12", "Content-Type": "application/json"} headers = {"User-Agent": "DMMGamePlayer5-Win/5.3.12 Electron/32.1.0", "Client-App": "DMMGamePlayer5", "Client-version": "5.3.12", "Content-Type": "application/json"}
cookies = {"login_secure_id":login_secure, "login_session_id":login_session} 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" url = "https://katworks.sytes.net/KF/Api/DMM/launch" if use_proxy else "https://apidgp-gameplayer.games.dmm.com/v5/r2/launch/cl"
print_request(url, data, headers, cookies)
result = requests.post(url, cookies=cookies, headers=headers, json=data) result = requests.post(url, cookies=cookies, headers=headers, json=data)
print(result.status_code, result.text)
result.raise_for_status() result.raise_for_status()
result_json = result.json() data = result.json()["data"]
if result_json["result_code"] != 100:
raise Exception(f'{result_json["result_code"]}: {result_json["error"]}')
data = result_json["data"]
return data["execute_args"] return data["execute_args"]
except Exception as e: except Exception as e:
print("Failed to retrieve launch arguments:", e) print("Failed to retrieve launch arguments:", e)
def main(config): def main(args):
game_id = config["game_id"] if len(args) != 7:
exe_location = config["file_path"] print("Usage:",
login = urllib.parse.quote_plus(config["dmm_login"]) "\tpython dmmBypass.py game_id game_path email password update_game use_proxy",
password = urllib.parse.quote_plus(config["dmm_password"]) "\t- game_id: DMM code name of the game",
update_game = config["update_game"] if "update_game" in config else False "\t- game_path: full path to the game .exe. Wrap in \" if there are spaces in the path",
use_proxy = config["use_proxy"] if "use_proxy" in config else False "\t- email, password: dmm credentials",
"\t- update_game: \"true\" to check for game update before launching",
"\t- use_proxy: \"true\" to send required request through Katboi VPN. Otherwise use your own VPN",
"\texample: python dmmBypass.py kfp2g \"D:\Games\KFP2G\けもフレ3.exe\" kat@email.com abc123 true", sep="\n")
return
game_id = args[1]
exe_location = args[2]
login = urllib.parse.quote_plus(args[3])
password = urllib.parse.quote_plus(args[4])
update_game = args[5].lower() == "true"
use_proxy = args[6].lower() == "true"
mac_addr = get_mac() mac_addr = get_mac()
hdd_serial = get_hash('') hdd_serial = get_hash('')
#actual moterboard serial is unknown, but this works motherboard = get_hash(get_motherboard())
motherboard = get_hash(getnode())
with requests.Session() as session: with requests.Session() as session:
token = retrieve_login_token(session) token = retrieve_login_token(session)
@ -140,8 +133,6 @@ def main(config):
return return
login_secure, login_session = retrieve_auth_keys(login, password, token, captcha, session) login_secure, login_session = retrieve_auth_keys(login, password, token, captcha, session)
if login_secure == None or login_session == None:
return
if not use_proxy: input("Enable VPN now and press Enter") if not use_proxy: input("Enable VPN now and press Enter")
@ -163,6 +154,7 @@ def main(config):
args = [exe_location] + execute_args.split() args = [exe_location] + execute_args.split()
print(args) print(args)
subprocess.Popen(args, start_new_session=True) subprocess.Popen(args, start_new_session=True)
input("Done. Press enter to exit (this will close the game)") input("Done. Press enter to exit")
main(config) args = sys.argv
main(args)

View File

@ -1,10 +1,24 @@
import os import os
import sys
import hashlib import hashlib
import requests import requests
import urllib.parse import urllib.parse
from urllib.request import urlretrieve from urllib.request import urlretrieve
import sys
def progressbar(it, prefix="", size=60, out=sys.stdout): # Python3.3+
"""https://stackoverflow.com/questions/3160699/python-progress-bar"""
count = len(it)
if count == 0: return
def show(j):
x = int(size*j/count)
print("{}[{}{}] {}/{}".format(prefix, "#"*x, "."*(size-x), j, count),
end='\r', file=out, flush=True)
show(0)
for i, item in enumerate(it):
yield item
show(i+1)
print("\n", flush=True, file=out)
def get_file_list(url): def get_file_list(url):
url = "https://apidgp-gameplayer.games.dmm.com" + url url = "https://apidgp-gameplayer.games.dmm.com" + url
print("Retrieving file list from " + url) print("Retrieving file list from " + url)
@ -57,44 +71,10 @@ def update_game(game_path, files_url, files_param):
print("Files to download:", len(files_to_download)) print("Files to download:", len(files_to_download))
count = len(files_to_download) for file in progressbar(files_to_download, "Downloading: ", 40):
if count > 0: url, path = file["url"], file["path"]
index = 0 os.makedirs(os.path.dirname(path), exist_ok=True)
max_len = 0 urlretrieve(url, path)
def show(j, downloaded, total_size):
nonlocal max_len
x = int(40*j/count)
string = "Downloading: [{}{}] {}/{} ({}/{})".format("#"*x, "."*(40-x), j, count, min(downloaded,total_size), total_size)
max_len = max(len(string), max_len)
print(string.ljust(max_len, ' '), end='\r', file=sys.stdout, flush=True)
retries = 3
show(0, 0, 0)
while index < len(files_to_download):
try:
file = files_to_download[index]
url, path = file["url"], file["path"]
response = requests.get(url, timeout=10, stream=True)
total_size = int(response.headers.get("content-length", 0))
block_size = 1024 * 1024
downloaded = 0
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, 'wb') as out_file:
for data in response.iter_content(block_size):
out_file.write(data)
downloaded += len(data)
show(index + 1, downloaded, total_size)
index += 1
retries = 3
except Exception as e:
print(e, "retrying")
retries -= 1
if retries == 0:
print(f'Retry for file {file["url"]} failed 3 times')
return False
print("\n", flush=True, file=sys.stdout)
# #files_to_delete is unused until fully tested # #files_to_delete is unused until fully tested
# for file in files_to_delete: # for file in files_to_delete:

3
requirements.txt Normal file
View File

@ -0,0 +1,3 @@
beautifulsoup4
PyPasser
wmi

View File

@ -1,3 +1,35 @@
@echo off @echo off
python dmmBypass.py -g kfp2g chcp 65001
setlocal enabledelayedexpansion
set file_name="kfp2g.cfg"
IF NOT EXIST %file_name% (
set /p null="Make sure python is installed. In next step, required packages will be installed. Press Enter to continue"
pip install -r requirements.txt
set /p file_path=Enter full file path to KF3 .exe:
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):"
if /i "!confirm!"=="yes" (
set use_proxy=true
) else (
set use_proxy=false
)
echo !file_path!> %file_name%
echo !dmm_login!>> %file_name%
echo !dmm_password!>> %file_name%
echo !use_proxy!>> %file_name%
) ELSE (
< %file_name% (
set /p file_path=
set /p dmm_login=
set /p dmm_password=
set /p use_proxy=
)
echo Loaded settings from %file_name%
)
python dmmBypass.py kfp2g %file_path% %dmm_login% %dmm_password% false %use_proxy%
pause pause

View File

@ -1,3 +1,35 @@
@echo off @echo off
python dmmBypass.py -g kfp2g -u chcp 65001
setlocal enabledelayedexpansion
set file_name="kfp2g.cfg"
IF NOT EXIST %file_name% (
set /p null="Make sure python is installed. In next step, required packages will be installed. Press Enter to continue"
pip install -r requirements.txt
set /p file_path=Enter full file path to KF3 .exe:
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):"
if /i "!confirm!"=="yes" (
set use_proxy=true
) else (
set use_proxy=false
)
echo !file_path!> %file_name%
echo !dmm_login!>> %file_name%
echo !dmm_password!>> %file_name%
echo !use_proxy!>> %file_name%
) ELSE (
< %file_name% (
set /p file_path=
set /p dmm_login=
set /p dmm_password=
set /p use_proxy=
)
echo Loaded settings from %file_name%
)
python dmmBypass.py kfp2g %file_path% %dmm_login% %dmm_password% true %use_proxy%
pause pause