55import json
66import glob
77import win32crypt
8+ import random
9+ import hashlib
810
911requests .packages .urllib3 .disable_warnings ()
1012
2426argpar .add_argument ("--non-kill" , action = "store_true" )
2527argpar .add_argument ("--debug" , action = "store_true" )
2628argpar .add_argument ("--login-force" , action = "store_true" )
29+ argpar .add_argument ("--anonymous" , action = "store_true" )
2730arg = argpar .parse_args ()
2831
29- headers = {
30- "Host" : "apidgp-gameplayer.games.dmm.com" ,
31- "Connection" : "keep-alive" ,
32- "User-Agent" : "DMMGamePlayer5-Win/17.1.2 Electron/17.1.2" ,
33- "Client-App" : "DMMGamePlayer5" ,
34- "Client-version" : "17.1.2" ,
35- }
3632
37- params = {
38- "product_id" : arg .product_id ,
39- "game_type" : "GCL" ,
40- "game_os" : "win" ,
41- "launch_type" : "LIB" ,
42- "mac_address" : "00:11:22:33:44:55" ,
43- "hdd_serial" : "0000000011111111222222223333333344444444555555556666666677777777" ,
44- "motherboard" : "0000000011111111222222223333333344444444555555556666666677777777" ,
45- "user_os" : "win" ,
46- }
33+ def gen_rand_hex ():
34+ return hashlib .sha256 (str (random .random ()).encode ()).hexdigest ()
35+
36+
37+ def gen_rand_address ():
38+ hex = gen_rand_hex ()
39+ address = ""
40+ for x in range (12 ):
41+ address += hex [x ]
42+ if x % 2 == 1 :
43+ address += ":"
44+ return address [:- 1 ]
4745
4846
4947class dgp5_process :
@@ -66,6 +64,16 @@ def get_install_data(self):
6664 return install_data
6765 self ._end_stdout ()
6866
67+ def get_client_data (self ):
68+ for line in self .process .stdout :
69+ text = self ._decode (line )
70+ if (
71+ "https://apidgp-gameplayer.games.dmm.com/v5/gameplayer/agreement/check"
72+ in text
73+ ):
74+ return self ._req_body_to_dict (text )
75+ self ._end_stdout ()
76+
6977 def get_cookie (self ):
7078 for line in self .process .stdout :
7179 text = self ._decode (line )
@@ -81,6 +89,9 @@ def wait(self):
8189 def kill (self ):
8290 self .process .terminate ()
8391
92+ def _req_body_to_dict (self , line ):
93+ return json .loads (line .split (" :: Request body is " )[1 ][:- 1 ])
94+
8495 def _decode (self , line ):
8596 text = line .decode ("utf-8" ).strip ()
8697 if self .debug :
@@ -91,6 +102,30 @@ def _end_stdout(self):
91102 raise Exception ("DMMGamePlayerの実行中にエラーが発生しました\n 既に実行されているか実行中に終了した可能性があります" )
92103
93104
105+ headers = {
106+ "Host" : "apidgp-gameplayer.games.dmm.com" ,
107+ "Connection" : "keep-alive" ,
108+ "User-Agent" : "DMMGamePlayer5-Win/17.1.2 Electron/17.1.2" ,
109+ "Client-App" : "DMMGamePlayer5" ,
110+ "Client-version" : "17.1.2" ,
111+ }
112+
113+ params = {
114+ "product_id" : arg .product_id ,
115+ "game_type" : "GCL" ,
116+ "game_os" : "win" ,
117+ "launch_type" : "LIB" ,
118+ }
119+
120+ if arg .anonymous :
121+ client_data = {
122+ "mac_address" : gen_rand_address (),
123+ "hdd_serial" : gen_rand_hex (),
124+ "motherboard" : gen_rand_hex (),
125+ "user_os" : "win" ,
126+ }
127+
128+
94129open ("cookie.bytes" , "a+" )
95130with open ("cookie.bytes" , "rb" ) as f :
96131 blob = f .read ()
@@ -99,6 +134,9 @@ def _end_stdout(self):
99134process .debug = arg .debug
100135install_data = process .get_install_data ()
101136
137+ if not arg .anonymous :
138+ client_data = process .get_client_data ()[0 ]
139+
102140if blob == b"" or arg .login_force :
103141 cookie = process .get_cookie ()
104142 new_blob = win32crypt .CryptProtectData (cookie .encode (), "DMMGamePlayerFastLauncher" )
@@ -107,8 +145,6 @@ def _end_stdout(self):
107145else :
108146 _ , cookie = win32crypt .CryptUnprotectData (blob )
109147
110- headers ["cookie" ] = cookie
111-
112148if not arg .game_path :
113149 for contents in install_data ["contents" ]:
114150 if contents ["productId" ] == arg .product_id :
@@ -137,6 +173,11 @@ def _end_stdout(self):
137173 + " " .join ([contents ["productId" ] for contents in install_data ["contents" ]])
138174 + "から選択して下さい"
139175 )
176+
177+ headers ["cookie" ] = cookie
178+ params .update (client_data )
179+ print (params )
180+
140181response = requests .post (
141182 "https://apidgp-gameplayer.games.dmm.com/v5/launch/cl" ,
142183 headers = headers ,
@@ -156,4 +197,4 @@ def _end_stdout(self):
156197if arg .non_kill :
157198 process .wait ()
158199else :
159- process .kill ()
200+ process .kill ()
0 commit comments