Skip to content

Commit e4c82c6

Browse files
authored
Merge pull request #53 from fa0311/develop-v4
Develop v4
2 parents 4c544c6 + e04d25b commit e4c82c6

File tree

5 files changed

+85
-14
lines changed

5 files changed

+85
-14
lines changed

.vscode/launch.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
// IntelliSense を使用して利用可能な属性を学べます。
3+
// 既存の属性の説明をホバーして表示します。
4+
// 詳細情報は次を確認してください: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "DMMGamePlayerFastLauncher",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "DMMGamePlayerFastLauncher.py",
12+
"console": "integratedTerminal",
13+
"justMyCode": true,
14+
"args": ["umamusume", "--non-bypass-uac"]
15+
}
16+
]
17+
}

DMMGamePlayerFastLauncher.py

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from urllib.parse import urlparse
1414
import win32security
1515
import sys
16+
import base64
17+
from Crypto.Cipher import AES
1618

1719

1820
class DgpSession:
@@ -65,20 +67,28 @@ def gen_rand_address(self):
6567
return address[:-1]
6668

6769
def write(self):
70+
aes_key = self.get_aes_key()
6871
for cookie_row in self.db.cursor().execute("select * from cookies"):
69-
name = cookie_row[3]
70-
value = self.session.cookies.get(name)
71-
if value != None:
72-
self.db.execute(
73-
f"update cookies set value = '{value}' where name = '{name}'"
74-
)
72+
value = self.session.cookies.get(cookie_row[3])
73+
v10, nonce, _, _ = self.split_encrypted_data(cookie_row[5])
74+
cipher = AES.new(aes_key, AES.MODE_GCM, nonce)
75+
decrypt_data, mac = cipher.encrypt_and_digest(value.encode())
76+
data = self.join_encrypted_data(v10, nonce, decrypt_data, mac)
77+
self.db.execute(
78+
"update cookies set encrypted_value = ? where name = ?",
79+
(memoryview(data), cookie_row[3]),
80+
)
7581
self.db.commit()
7682

7783
def read(self):
84+
aes_key = self.get_aes_key()
7885
for cookie_row in self.db.cursor().execute("select * from cookies"):
86+
_, nonce, data, mac = self.split_encrypted_data(cookie_row[5])
87+
cipher = AES.new(aes_key, AES.MODE_GCM, nonce)
88+
value = cipher.decrypt_and_verify(data, mac).decode()
7989
cookie_data = {
8090
"name": cookie_row[3],
81-
"value": cookie_row[4],
91+
"value": value,
8292
"domain": cookie_row[1],
8393
"path": cookie_row[6],
8494
"secure": cookie_row[8],
@@ -149,6 +159,28 @@ def open(self):
149159
self.session = requests.session()
150160
self.cookies = self.session.cookies
151161

162+
def get_aes_key(self):
163+
with open(self.DGP5_PATH + "\\Local State", "r") as f:
164+
local_state = json.load(f)
165+
encrypted_key = base64.b64decode(
166+
local_state["os_crypt"]["encrypted_key"].encode()
167+
)[5:]
168+
key = win32crypt.CryptUnprotectData(encrypted_key, None, None, None, 0)[1]
169+
return key
170+
171+
def split_encrypted_data(self, encrypted_data: bytes) -> bytes:
172+
return (
173+
encrypted_data[0:3],
174+
encrypted_data[3:15],
175+
encrypted_data[15:-16],
176+
encrypted_data[-16:],
177+
)
178+
179+
def join_encrypted_data(
180+
self, v10: bytes, nonce: bytes, data: bytes, mac: bytes
181+
) -> bytes:
182+
return v10 + nonce + data + mac
183+
152184
def close(self):
153185
self.db.close()
154186

@@ -327,6 +359,7 @@ def run_bypass_uac():
327359
argpar.add_argument("--https-proxy-uri", default=None)
328360
argpar.add_argument("--non-request-admin", action="store_true")
329361
argpar.add_argument("--non-bypass-uac", action="store_true")
362+
argpar.add_argument("--force-bypass-uac", action="store_true")
330363
argpar.add_argument("--schtasks-path", default="schtasks.exe")
331364

332365
try:
@@ -414,7 +447,12 @@ def run_bypass_uac():
414447
dmm_args = response["data"]["execute_args"].split(" ")
415448
if arg.game_args is not None:
416449
dmm_args = dmm_args + arg.game_args.split(" ")
417-
print(game_path)
450+
if (
451+
arg.force_bypass_uac
452+
and not arg.non_bypass_uac
453+
and response["data"]["is_administrator"]
454+
):
455+
run_bypass_uac()
418456
start_time = time.time()
419457
process = process_manager.run([game_path] + dmm_args)
420458
for line in process.stdout:

docs/README-advance.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@
2929
| --https-proxy-uri | | None | String | None | |
3030
| --non-request-admin | | False | Bool | deprecated |
3131
| --non-bypass-uac | | False | Bool | |
32+
| --force-bypass-uac | | False | Bool | |
3233
| --schtasks-path | | schtasks.exe | String | |
3334

3435
```mermaid
3536
graph TD;
36-
ゲームのプロセスを開始 --権限不備で起動しない--> non-bypass-uac;
37-
ゲームのプロセスを開始 --Start/Error--> 続行;
37+
ゲームが権限を要求 --> force-bypass-uac;
38+
force-bypass-uac --true--> non-bypass-uac
39+
force-bypass-uac --false--> 権限与えずゲームを開始
40+
権限与えずゲームを開始 --起動しない--> non-bypass-uac;
41+
権限与えずゲームを開始 --起動--> 続行;
3842
non-bypass-uac --false--> 最初のリクエスト;
3943
最初のリクエスト --no-->ゲームに権限与える
4044
最初のリクエスト --yes--> non-request-admin
@@ -43,15 +47,16 @@
4347
non-request-admin --false--> UAC;
4448
UAC --allow--> ゲームに権限与える
4549
UAC --disabled--> 続行
46-
skip-exception --true--> 続行
50+
skip-exception --true--> ゲームに権限与えにず続行
4751
skip-exception --false--> エラー
4852
```
4953

5054
**最初のリクエスト** - 最初のリクエストは、管理者権限を要求します
5155
これは、タスクスケジューラーに自動的に権限を昇格させるプログラムを登録するために必要です
5256

5357
特にこだわりが無ければ product_id 以外の引数は不要です
54-
ゲームや環境によっては`game-path` `https-proxy-uri` `schtasks-path` などが必要です
58+
ゲームや環境によっては`game-path` `https-proxy-uri` `schtasks-path` などが必要です
59+
更に高速化を求めるのであれば `--force-bypass-uac` などが必要ですが不安定になる可能性があります
5560

5661
### game-path
5762

@@ -112,7 +117,9 @@ Socks5
112117

113118
### non-bypass-uac
114119

115-
この引数を使用すると UAC の自動昇格を行わなくなります
120+
この引数を使用すると UAC の自動昇格を行わなくなります
121+
環境によってUACの自動昇格が行われなかったり起動速度を優先したい人はこれを付けてください
122+
(開発者向けヒント; ビルド前の開発環境ではこの引数は必須です)
116123

117124
指定していない場合はタスクスケジューラを使った権限の自動昇格を行います
118125
タスクの詳細はこのコマンドで確認できます
@@ -123,6 +130,15 @@ Socks5
123130
`Get-ScheduledTask | where TaskPath -eq "\Microsoft\Windows\DMMGamePlayerFastLauncher" | Unregister-ScheduledTask -Confirm:$false`
124131
または `.\tools\refresh.ps1`
125132

133+
### force-bypass-uac
134+
135+
ゲームが管理者権限を求めた際に必ずUACの自動昇格を行います
136+
管理者権限でないと起動できないゲーム(non-bypass-uacを付けた際に必ずUACを要求するゲーム)はこれを付けると早く起動できます
137+
ウマ娘やプリコネRなどの稀に要求するゲームは無い方が早いかもしれません
138+
139+
例:
140+
`%AppData%\DMMGamePlayerFastLauncher\DMMGamePlayerFastLauncher.exe umamusume --force-bypass-uac`
141+
126142
### schtasks-path
127143

128144
`schtasks.exe`のパスを指定します

requirements.txt

40 Bytes
Binary file not shown.

setup.iss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "DMMGamePlayerFastLauncher"
5-
#define MyAppVersion "4.6.0"
5+
#define MyAppVersion "4.7.0"
66
#define MyAppPublisher "yuki"
77
#define MyAppURL "https://github.com/fa0311/DMMGamePlayerFastLauncher"
88
#define MyAppExeName "DMMGamePlayerFastLauncher.exe"

0 commit comments

Comments
 (0)