Skip to content

Commit 94239f6

Browse files
feat: modifiable device information
1 parent d0d9eb2 commit 94239f6

4 files changed

Lines changed: 77 additions & 19 deletions

File tree

cmdline.c

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ const char *gengetopt_args_info_versiontext = "";
3434
const char *gengetopt_args_info_description = "";
3535

3636
const char *gengetopt_args_info_help[] = {
37-
" -h, --help Print help and exit",
38-
" -V, --version Print version and exit",
39-
" -H, --host=STRING (default=`127.0.0.1')",
40-
" -D, --decrypt-port=INT (default=`10020')",
41-
" -M, --m3u8-port=INT (default=`20020')",
42-
" -P, --proxy=STRING (default=`')",
43-
" -L, --login=STRING username:password",
44-
" -F, --code-from-file (default=off)",
45-
" -B, --base-dir=STRING \n (default=`/data/data/com.apple.android.music/files')",
37+
" -h, --help Print help and exit",
38+
" -V, --version Print version and exit",
39+
" -H, --host=STRING (default=`127.0.0.1')",
40+
" -D, --decrypt-port=INT (default=`10020')",
41+
" -M, --m3u8-port=INT (default=`20020')",
42+
" -P, --proxy=STRING (default=`')",
43+
" -L, --login=STRING username:password",
44+
" -F, --code-from-file (default=off)",
45+
" -B, --base-dir=STRING \n (default=`/data/data/com.apple.android.music/files')",
46+
" -I, --device-info=STRING \n ClientIdentifier/VersionIdentifier/PlatformIdentifier/ProductVersion/DeviceModel/BuildVersion/LocaleIdentifier/LanguageIdentifier/AndroidID\n (default=`Music/4.9/Android/10/Samsung\n S9/7663313/en-US/en-US/dc28071e981c439e')",
4647
0
4748
};
4849

@@ -77,6 +78,7 @@ void clear_given (struct gengetopt_args_info *args_info)
7778
args_info->login_given = 0 ;
7879
args_info->code_from_file_given = 0 ;
7980
args_info->base_dir_given = 0 ;
81+
args_info->device_info_given = 0 ;
8082
}
8183

8284
static
@@ -96,6 +98,8 @@ void clear_args (struct gengetopt_args_info *args_info)
9698
args_info->code_from_file_flag = 0;
9799
args_info->base_dir_arg = gengetopt_strdup ("/data/data/com.apple.android.music/files");
98100
args_info->base_dir_orig = NULL;
101+
args_info->device_info_arg = gengetopt_strdup ("Music/4.9/Android/10/Samsung S9/7663313/en-US/en-US/dc28071e981c439e");
102+
args_info->device_info_orig = NULL;
99103

100104
}
101105

@@ -113,6 +117,7 @@ void init_args_info(struct gengetopt_args_info *args_info)
113117
args_info->login_help = gengetopt_args_info_help[6] ;
114118
args_info->code_from_file_help = gengetopt_args_info_help[7] ;
115119
args_info->base_dir_help = gengetopt_args_info_help[8] ;
120+
args_info->device_info_help = gengetopt_args_info_help[9] ;
116121

117122
}
118123

@@ -212,6 +217,8 @@ cmdline_parser_release (struct gengetopt_args_info *args_info)
212217
free_string_field (&(args_info->login_orig));
213218
free_string_field (&(args_info->base_dir_arg));
214219
free_string_field (&(args_info->base_dir_orig));
220+
free_string_field (&(args_info->device_info_arg));
221+
free_string_field (&(args_info->device_info_orig));
215222

216223

217224

@@ -260,6 +267,8 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
260267
write_into_file(outfile, "code-from-file", 0, 0 );
261268
if (args_info->base_dir_given)
262269
write_into_file(outfile, "base-dir", args_info->base_dir_orig, 0);
270+
if (args_info->device_info_given)
271+
write_into_file(outfile, "device-info", args_info->device_info_orig, 0);
263272

264273

265274
i = EXIT_SUCCESS;
@@ -529,10 +538,11 @@ cmdline_parser_internal (
529538
{ "login", 1, NULL, 'L' },
530539
{ "code-from-file", 0, NULL, 'F' },
531540
{ "base-dir", 1, NULL, 'B' },
541+
{ "device-info", 1, NULL, 'I' },
532542
{ 0, 0, 0, 0 }
533543
};
534544

535-
c = getopt_long (argc, argv, "hVH:D:M:P:L:FB:", long_options, &option_index);
545+
c = getopt_long (argc, argv, "hVH:D:M:P:L:FB:I:", long_options, &option_index);
536546

537547
if (c == -1) break; /* Exit from `while (1)' loop. */
538548

@@ -630,6 +640,18 @@ cmdline_parser_internal (
630640
goto failure;
631641

632642
break;
643+
case 'I': /* ClientIdentifier/VersionIdentifier/PlatformIdentifier/ProductVersion/DeviceModel/BuildVersion/LocaleIdentifier/LanguageIdentifier/AndroidID. */
644+
645+
646+
if (update_arg( (void *)&(args_info->device_info_arg),
647+
&(args_info->device_info_orig), &(args_info->device_info_given),
648+
&(local_args_info.device_info_given), optarg, 0, "Music/4.9/Android/10/Samsung S9/7663313/en-US/en-US/dc28071e981c439e", ARG_STRING,
649+
check_ambiguity, override, 0, 0,
650+
"device-info", 'I',
651+
additional_error))
652+
goto failure;
653+
654+
break;
633655

634656
case 0: /* Long option with no short option */
635657
case '?': /* Invalid option. */

cmdline.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ struct gengetopt_args_info
5959
char * base_dir_arg; /**< @brief (default='/data/data/com.apple.android.music/files'). */
6060
char * base_dir_orig; /**< @brief original value given at command line. */
6161
const char *base_dir_help; /**< @brief help description. */
62+
char * device_info_arg; /**< @brief ClientIdentifier/VersionIdentifier/PlatformIdentifier/ProductVersion/DeviceModel/BuildVersion/LocaleIdentifier/LanguageIdentifier/AndroidID (default='Music/4.9/Android/10/Samsung S9/7663313/en-US/en-US/dc28071e981c439e'). */
63+
char * device_info_orig; /**< @brief ClientIdentifier/VersionIdentifier/PlatformIdentifier/ProductVersion/DeviceModel/BuildVersion/LocaleIdentifier/LanguageIdentifier/AndroidID original value given at command line. */
64+
const char *device_info_help; /**< @brief ClientIdentifier/VersionIdentifier/PlatformIdentifier/ProductVersion/DeviceModel/BuildVersion/LocaleIdentifier/LanguageIdentifier/AndroidID help description. */
6265

6366
unsigned int help_given ; /**< @brief Whether help was given. */
6467
unsigned int version_given ; /**< @brief Whether version was given. */
@@ -69,6 +72,7 @@ struct gengetopt_args_info
6972
unsigned int login_given ; /**< @brief Whether login was given. */
7073
unsigned int code_from_file_given ; /**< @brief Whether code-from-file was given. */
7174
unsigned int base_dir_given ; /**< @brief Whether base-dir was given. */
75+
unsigned int device_info_given ; /**< @brief Whether device-info was given. */
7276

7377
} ;
7478

main.c

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct gengetopt_args_info args_info;
2727
char *amUsername, *amPassword;
2828
struct shared_ptr GUID;
2929
int decryptCount = 1000;
30+
char *device_infos[9];
3031

3132
#ifndef MyRelease
3233
int32_t CURLOPT_SSL_VERIFYPEER = 64;
@@ -118,6 +119,33 @@ char *strcat_b(char *dest, char* src) {
118119
return result;
119120
}
120121

122+
int split_string_safe(const char *str, const char *delim, char **components,
123+
int max_components, char **out_copy_to_free)
124+
{
125+
*out_copy_to_free = NULL;
126+
127+
char *copy = strdup(str);
128+
if (copy == NULL) {
129+
return -1;
130+
}
131+
132+
*out_copy_to_free = copy;
133+
134+
int count = 0;
135+
char *saveptr;
136+
char *token;
137+
138+
token = strtok_r(copy, delim, &saveptr);
139+
140+
while (token != NULL && count < max_components) {
141+
components[count] = token;
142+
count++;
143+
token = strtok_r(NULL, delim, &saveptr);
144+
}
145+
146+
return count;
147+
}
148+
121149
static void dialogHandler(long j, struct shared_ptr *protoDialogPtr,
122150
struct shared_ptr *respHandler) {
123151
const char *const title = std_string_data(
@@ -249,7 +277,7 @@ static inline void init() {
249277
// for (int i = 0; i < 16; ++i) {
250278
// android_id[i] = "0123456789abcdef"[rand() % 16];
251279
// }
252-
union std_string conf1 = new_std_string(android_id);
280+
union std_string conf1 = new_std_string(device_infos[8]);
253281
union std_string conf2 = new_std_string("");
254282
_ZN14FootHillConfig6configERKNSt6__ndk112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE(
255283
&conf1);
@@ -289,27 +317,28 @@ static inline struct shared_ptr init_ctx() {
289317
// _ZN17storeservicescore20RequestContextConfig9setCPFlagEb(reqCtx.obj, 1);
290318
_ZN17storeservicescore20RequestContextConfig20setBaseDirectoryPathERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
291319
reqCtxCfg.obj, &strBuf);
292-
strBuf = new_std_string("Music");
320+
strBuf = new_std_string(device_infos[0]);
293321
_ZN17storeservicescore20RequestContextConfig19setClientIdentifierERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
294322
reqCtxCfg.obj, &strBuf);
295-
strBuf = new_std_string("4.9");
323+
strBuf = new_std_string(device_infos[1]);
296324
_ZN17storeservicescore20RequestContextConfig20setVersionIdentifierERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
297325
reqCtxCfg.obj, &strBuf);
298-
strBuf = new_std_string("Android");
326+
strBuf = new_std_string(device_infos[2]);
299327
_ZN17storeservicescore20RequestContextConfig21setPlatformIdentifierERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
300328
reqCtxCfg.obj, &strBuf);
301-
strBuf = new_std_string("10");
329+
strBuf = new_std_string(device_infos[3]);
302330
_ZN17storeservicescore20RequestContextConfig17setProductVersionERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
303331
reqCtxCfg.obj, &strBuf);
304-
strBuf = new_std_string("Samsung S9");
332+
strBuf = new_std_string(device_infos[4]);
305333
_ZN17storeservicescore20RequestContextConfig14setDeviceModelERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
306334
reqCtxCfg.obj, &strBuf);
307-
strBuf = new_std_string("7663313");
335+
strBuf = new_std_string(device_infos[5]);
308336
_ZN17storeservicescore20RequestContextConfig15setBuildVersionERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
309337
reqCtxCfg.obj, &strBuf);
310-
strBuf = new_std_string("en-US");
338+
strBuf = new_std_string(device_infos[6]);
311339
_ZN17storeservicescore20RequestContextConfig19setLocaleIdentifierERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
312340
reqCtxCfg.obj, &strBuf);
341+
strBuf = new_std_string(device_infos[7]);
313342
_ZN17storeservicescore20RequestContextConfig21setLanguageIdentifierERKNSt6__ndk112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE(
314343
reqCtxCfg.obj, &strBuf);
315344

@@ -838,6 +867,8 @@ void write_music_token(struct shared_ptr reqCtx) {
838867

839868
int main(int argc, char *argv[]) {
840869
cmdline_parser(argc, argv, &args_info);
870+
char *copy_that_needs_to_be_freed = NULL;
871+
int count = split_string_safe(args_info.device_info_arg, "/", device_infos, 9, &copy_that_needs_to_be_freed);
841872

842873
#ifndef MyRelease
843874
subhook_install(subhook_new(_ZN13mediaplatform26DebugLogEnabledForPriorityENS_11LogPriorityE, allDebug, SUBHOOK_64BIT_OFFSET));

wrapper.ggo

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ option "m3u8-port" M "" int optional default="20020"
77
option "proxy" P "" string optional default=""
88
option "login" L "username:password" string optional
99
option "code-from-file" F "" flag off
10-
option "base-dir" B "" string optional default="/data/data/com.apple.android.music/files"
10+
option "base-dir" B "" string optional default="/data/data/com.apple.android.music/files"
11+
option "device-info" I "ClientIdentifier/VersionIdentifier/PlatformIdentifier/ProductVersion/DeviceModel/BuildVersion/LocaleIdentifier/LanguageIdentifier/AndroidID" string optional default="Music/4.9/Android/10/Samsung S9/7663313/en-US/en-US/dc28071e981c439e"

0 commit comments

Comments
 (0)