/
unkilled_toolkit.sh
597 lines (549 loc) · 18.6 KB
/
unkilled_toolkit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
#!/system/bin/sh
# Unkilled Toolkit v1.0.1 by Deic
title(){
red='\033[0;31m'
nc='\033[0m'
echo "${red}-= Unkilled Toolkit =-${nc}
"
}
wait_input(){
$script_dir/busybox stty cbreak -echo
i=$($script_dir/busybox dd bs=1 count=1 2>/dev/null)
$script_dir/busybox stty -cbreak echo
}
wait_input_two(){
$script_dir/busybox stty cbreak -echo
j=$($script_dir/busybox dd bs=1 count=1 2>/dev/null)
$script_dir/busybox stty -cbreak echo
}
main_menu(){
while clear; do
title
echo 'Menu:
1|Boost performance & Play
2|Unlock free treasure chest/energy button
3|Backup/Restore Android ID
E|xit'
if [ "$non_root" == 1 ]; then
read i
else
wait_input
fi
case $i in
1)
game_boost
;;
2)
restore_button
;;
3)
backup_restore
;;
e|E)
clear
exit
;;
*)
echo Unknown option.
sleep 1
;;
esac
done
}
game_boost(){
while clear; do
title
if [ "$non_root" == 1 ]; then
echo Need a rooted device.
sleep 1
return 1
fi
echo '- Game Boost -
Resolution:
1|1920x1080
2|1280x720
3|960x540
4|640x360
5|Nothing
B|ack'
wait_input
if [ "$i" == 1 ] || [ "$i" == 2 ] || [ "$i" == 3 ] || [ "$i" == 4 ] || [ "$i" == 5 ]; then
break
fi
if [ "$i" == b ] || [ "$i" == B ]; then
return 1
fi
echo Unknown option.
sleep 1
done
while clear; do
title
if [ "$i" == 1 ] || [ "$i" == 2 ] || [ "$i" == 3 ] || [ "$i" == 4 ]; then
echo 'Smartphone or tablet? [S/T]'
if [ "$i" == 1 ]; then
wait_input_two
if [ "$j" == s ] || [ "$j" == S ]; then
resolution=1080x1920
break
elif [ "$j" == t ] || [ "$j" == T ]; then
resolution=1920x1080
break
fi
fi
if [ "$i" == 2 ]; then
wait_input_two
if [ "$j" == s ] || [ "$j" == S ]; then
resolution=720x1280
break
elif [ "$j" == t ] || [ "$j" == T ]; then
resolution=1280x720
break
fi
fi
if [ "$i" == 3 ]; then
wait_input_two
if [ "$j" == s ] || [ "$j" == S ]; then
resolution=540x960
break
elif [ "$j" == t ] || [ "$j" == T ]; then
resolution=960x540
break
fi
fi
if [ "$i" == 4 ]; then
wait_input_two
if [ "$j" == s ] || [ "$j" == S ]; then
resolution=360x640
break
elif [ "$j" == t ] || [ "$j" == T ]; then
resolution=640x360
break
fi
fi
echo Unknown option.
sleep 1
fi
if [ "$i" == 5 ]; then
break
fi
done
if [ "$i" == 1 ] || [ "$i" == 2 ] || [ "$i" == 3 ] || [ "$i" == 4 ]; then
echo Changing resolution...
wm size $resolution
sleep 1
echo Done.
sleep 1
fi
echo Boosting performance...
$script_dir/busybox chmod 660 /sys/module/lowmemorykiller/parameters/minfree
$script_dir/busybox cat /sys/module/lowmemorykiller/parameters/minfree > /data/local/tmp/minfree
echo 10393,14105,18188,27468,31552,37120 > /sys/module/lowmemorykiller/parameters/minfree
$script_dir/busybox chmod 220 /sys/module/lowmemorykiller/parameters/minfree
if $script_dir/busybox mv /dev/random /dev/random.orig; then
$script_dir/busybox ln -s /dev/urandom /dev/random
fi
$script_dir/busybox cat /proc/sys/kernel/random/read_wakeup_threshold > /data/local/tmp/read_wakeup_threshold
$script_dir/busybox cat /proc/sys/kernel/random/write_wakeup_threshold > /data/local/tmp/write_wakeup_threshold
$script_dir/busybox cat /proc/sys/kernel/randomize_va_space > /data/local/tmp/randomize_va_space
$script_dir/busybox sysctl -qw kernel.random.read_wakeup_threshold=4096
$script_dir/busybox sysctl -qw kernel.random.write_wakeup_threshold=4096
$script_dir/busybox sysctl -qw kernel.randomize_va_space=0
am kill-all 2>/dev/null
sleep 1
echo Running Unkilled...
am start com.madfingergames.unkilled/com.madfingergames.unityplayer.MFUnityPlayerNativeActivity >/dev/null 2>&1
sleep 1
echo Done.
sleep 1
unset j
while clear; do
if [ "$j" == c ] || [ "$j" == C ]; then
$script_dir/busybox cat /data/local/tmp/minfree > /sys/module/lowmemorykiller/parameters/minfree
if $script_dir/busybox rm -f /dev/random; then
$script_dir/busybox mv /dev/random.orig /dev/random
fi
$script_dir/busybox sysctl -qw kernel.random.read_wakeup_threshold=$($script_dir/busybox cat /data/local/tmp/read_wakeup_threshold)
$script_dir/busybox sysctl -qw kernel.random.write_wakeup_threshold=$($script_dir/busybox cat /data/local/tmp/write_wakeup_threshold)
$script_dir/busybox sysctl -qw kernel.randomize_va_space=$($script_dir/busybox cat /data/local/tmp/randomize_va_space)
break
else
echo 'Write [C] and press [ENTER] to stop boost...'
$script_dir/busybox sysctl -qw vm.drop_caches=3
read -t 60 j
fi
done
if [ "$i" == 1 ] || [ "$i" == 2 ] || [ "$i" == 3 ] || [ "$i" == 4 ]; then
wm size reset
fi
$script_dir/busybox kill -9 $($script_dir/busybox pgrep com.madfingergames.unkilled)
sleep 1
echo Done.
sleep 1
}
restore_button(){
while clear; do
title
progress_file=$EXTERNAL_STORAGE/Android/data/com.madfingergames.unkilled/files/users/*/.progress
echo Restore free treasure chest/energy button...
sleep 1
if [ -f $progress_file ]; then
rm -f $progress_file
if [ ! -f $progress_file ]; then
echo Done.
else
echo Fail.
fi
else
echo Skipping...
fi
sleep 1
echo Running Unkilled...
am start --user 0 com.madfingergames.unkilled/com.madfingergames.unityplayer.MFUnityPlayerNativeActivity >/dev/null 2>&1
sleep 1
echo Done.
sleep 1
if [ "$non_root" == 1 ]; then
echo 'Press [ENTER] key to continue...'
read i
else
echo Press any key to continue...
wait_input
fi
am force-stop com.madfingergames.unkilled 2>/dev/null
break
done
}
backup_restore(){
clear
title
if [ "$non_root" == 1 ]; then
echo Need a rooted device.
sleep 1
return 1
elif [ "$arch" == x86 ]; then
echo x86 arch is not supported.
sleep 1
return 1
fi
settings_db=/data/data/com.android.providers.settings/databases/settings.db
android_id_file=$EXTERNAL_STORAGE/unkilled_android_id
if [ ! -f $android_id_file ]; then
echo Backing up Android ID...
$script_dir/sqlite3 "$settings_db" 'SELECT value FROM secure WHERE name = "android_id";' > $android_id_file
sleep 1
echo "Backup complete.
A file called \'unkilled_android_id\' was created in your internal or external memory.
Move that file to main memory storage of your other device to restore your Unkilled progress.
Press any key to continue..."
wait_input
else
get_android_id=$($script_dir/busybox cat $android_id_file)
$script_dir/busybox cat > /data/local/tmp/unkilled_restore_android_id.sh <<-EOF
#!/system/bin/sh
#Script to restore Android ID
red='\033[0;31m'
nc='\033[0m'
echo Restoring Android ID...
$script_dir/sqlite3 "$settings_db" 'UPDATE secure SET value = "$get_android_id" WHERE name = "android_id";'
sleep 1
echo Done.
sleep 1
while clear; do
echo "${red}-= Unkilled Toolkit =-${nc}
Reboot to apply changes. Reboot now? [Y/N]"
$script_dir/busybox stty cbreak -echo
i=replace1
$script_dir/busybox stty -cbreak echo
case replace2 in
y|Y)
reboot
echo Rebooting...
;;
n|N)
exit
;;
*)
echo Unknown option.
sleep 1
;;
esac
done
EOF
$script_dir/busybox sed -i 's/replace1/$(\/data\/local\/unkilled_toolkit\/busybox dd bs=1 count=1 2>\/dev\/null)/' /data/local/tmp/unkilled_restore_android_id.sh
$script_dir/busybox sed -i 's/replace2/$i/' /data/local/tmp/unkilled_restore_android_id.sh
sh /data/local/tmp/unkilled_restore_android_id.sh
fi
}
sh_ota(){ # v2.1_custom By Deic
# Configuration
version=v1.0.1
cloud=https://github.com/DeicPro/Download/releases/download/cloud/unkilled_toolkit.version
# Optional
changelog_cloud=https://github.com/DeicPro/Download/releases/download/cloud/unkilled_toolkit.changelog
# 0/1 = Disabled/Enabled
show_version=1
show_changelog=1
# Don't touch from here
if [ "$arch" == x86 ]; then
while clear; do
title
echo 'Want check for update? (Y/N)'
wait_input
case $i in
y|Y )
check_update=1
break
;;
n|N )
check_update=0
break
;;
* )
echo 'Press [Y] or [N] key...'
sleep 1
;;
esac
done
fi
clear
title
echo Checking updates...
sleep 1
if [ "$check_update" == 0 ]; then
main_menu
elif [ "$check_update" == 1 ]; then
am start -a android.intent.action.VIEW $cloud >/dev/null 2>&1
else
$script_dir/curl -k -L -s -o /data/local/tmp/unkilled_toolkit.version $cloud
fi
if [ "$show_changelog" == 1 ]; then
if [ "$arch" == x86 ]; then
file_location=$EXTERNAL_STORAGE/download
else
$script_dir/curl -k -L -s -o /data/local/tmp/unkilled_toolkit.changelog $changelog_cloud
file_location=/data/local/tmp
fi
fi
while clear; do
if [ "$($script_dir/busybox grep https $file_location/unkilled_toolkit.version 2>/dev/null)" ]; then
title
if [ "$($script_dir/busybox grep $version $file_location/unkilled_toolkit.version 2>/dev/null)" ]; then
echo You have the latest version.
sleep 1
install=0
break
else
if [ "$show_version" == 1 ]; then
version_opt=": $($script_dir/busybox cat $file_location/unkilled_toolkit.version 2>/dev/null | $script_dir/busybox tr '\n' ',' | $script_dir/busybox cut -d ',' -f1)"
else
version_opt=...
fi
echo "A new version of the script was found$version_opt
"
if [ "$show_changelog" == 1 ] && [ -f $file_location/unkilled_toolkit.changelog ]; then
$script_dir/busybox cat $file_location/unkilled_toolkit.changelog
echo
fi
echo 'Want install it? (Y/N)'
wait_input
case $i in
y|Y )
install=1
break
;;
n|N )
install=0
break
;;
* )
echo 'Press [Y] or [N] key...'
sleep 1
;;
esac
fi
fi
done
if [ "$install" == 1 ]; then
clear
title
echo Downloading...
if [ "$arch" == x86 ]; then
am start -a android.intent.action.VIEW $($script_dir/busybox cat $file_location/unkilled_toolkit.version | $script_dir/busybox tr '\n' ',' | $script_dir/busybox cut -d ',' -f2) >/dev/null 2>&1
else
$script_dir/curl -k -L -s -o $file_location/unkilled_toolkit.sh $($script_dir/busybox cat $file_location/unkilled_toolkit.version | $script_dir/busybox tr '\n' ',' | $script_dir/busybox cut -d ',' -f2)
fi
sleep 1
fi
while :; do
if [ "$install" == 0 ]; then
$script_dir/busybox rm -f $file_location/unkilled_toolkit.version
$script_dir/busybox rm -f $file_location/unkilled_toolkit.changelog
break
fi
if [ "$($script_dir/busybox grep "#!/system/bin/sh" $file_location/unkilled_toolkit.sh 2>/dev/null)" ]; then
am force-stop com.android.browser 2>/dev/null
am force-stop com.android.chrome 2>/dev/null
echo Installing...
$script_dir/busybox cp -f $file_location/unkilled_toolkit.sh $0
sleep 1
$script_dir/busybox chmod 755 $0
$script_dir/busybox rm -f $file_location/unkilled_toolkit.sh
echo Installed.
sleep 1
$script_dir/busybox rm -f $file_location/unkilled_toolkit.version
$script_dir/busybox rm -f $file_location/unkilled_toolkit.changelog
sh $0
clear
exit
fi
done
}
clear
title
script_dir=/data/local/unkilled_toolkit
if [ "$USER" == root ]; then
mount -w -o remount rootfs
mount -w -o remount /system
mkdir -p $script_dir 2>/dev/null
else
if [ -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh ]; then
echo Installing Unkilled Toolkit...
cp -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh $EXTERNAL_STORAGE/utk
sleep 1
echo Clean up downloaded file...
rm -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh
sleep 1
echo Done.
sleep 1
clear
echo Now write \'sh /sdcard/utk\' only to run Unkilled Toolkit.
exit
fi
non_root=1
main_menu
fi
if [ "$(getprop ro.product.cpu.abi)" == x86 ] || [ "$(getprop ro.product.cpu.abilist)" == x86 ]; then
arch=x86
else
arch=arm
fi
if [ -f $script_dir/busybox ]; then
echo '' >/dev/null 2>&1
else
if [ "$arch" == x86 ]; then
busybox_cloud=https://github.com/DeicPro/Download/releases/download/cloud/busybox.x86
#busybox_size=883644
else
busybox_cloud=https://github.com/DeicPro/Download/releases/download/cloud/busybox.arm
#busybox_size=1469764
fi
echo BusyBox binary not found. Downloading...
sleep 1
am start -a android.intent.action.VIEW $busybox_cloud >/dev/null 2>&1
while true; do
if [ "$(grep "BusyBox v1.23.2.YDS" $EXTERNAL_STORAGE/download/busybox.$arch 2>/dev/null)" ]; then
am force-stop com.android.browser 2>/dev/null
am force-stop com.android.chrome 2>/dev/null
echo Copying BusyBox...
cp -f $EXTERNAL_STORAGE/download/busybox.$arch /data/local/unkilled_toolkit/busybox
sleep 1
echo Setting up permissions...
chmod -R 755 /data/local/unkilled_toolkit
sleep 1
echo Clean up downloaded file...
rm -f $EXTERNAL_STORAGE/download/busybox.$arch
sleep 1
echo Done.
sleep 1
break
fi
done
fi
if [ "$arch" == x86 ] && [ -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh ]; then
echo Installing Unkilled Toolkit...
$script_dir/busybox cp -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh /system/xbin/utk
sleep 1
echo Setting up permissions...
$script_dir/busybox chmod 755 /system/xbin/utk
sleep 1
echo Clean up downloaded file...
$script_dir/busybox rm -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh
sleep 1
echo Done.
sleep 1
clear
echo Now write \'utk\' only to run Unkilled Toolkit.
exit
fi
if [ "$arch" == x86 ]; then
sh_ota
main_menu
fi
if [ -f $script_dir/curl ]; then
echo '' >/dev/null 2>&1
else
curl_cloud=https://github.com/DeicPro/Download/releases/download/cloud/curl.arm
echo cURL binary not found. Downloading...
sleep 1
am start -a android.intent.action.VIEW $curl_cloud >/dev/null 2>&1
while true; do
if [ "$($script_dir/busybox wc -c $EXTERNAL_STORAGE/download/curl.arm 2>/dev/null | $script_dir/busybox awk '{print $1}')" == 345616 ]; then
$script_dir/busybox kill -9 $(pgrep com.android.browser) 2>/dev/null
$script_dir/busybox kill -9 $(pgrep com.android.chrome) 2>/dev/null
sleep 1
echo Copying cURL...
sleep 1
$script_dir/busybox cp -f $EXTERNAL_STORAGE/download/curl.arm $script_dir/curl
sleep 1
echo Setting up permissions...
$script_dir/busybox chmod 755 $script_dir/curl
sleep 1
echo Cleaning up downloaded file...
$script_dir/busybox rm -f $EXTERNAL_STORAGE/download/curl.arm
sleep 1
echo Done.
sleep 1
break
fi
done
fi
if [ -f $script_dir/sqlite3 ]; then
echo '' >/dev/null 2>&1
else
sqlite_cloud=https://github.com/DeicPro/Download/releases/download/cloud/sqlite3.arm
echo SQLite3 binary not found. Downloading...
$script_dir/curl -k -L -s -o /data/local/tmp/sqlite3 $sqlite_cloud 2>/dev/null
while true; do
if [ "$($script_dir/busybox wc -c /data/local/tmp/sqlite3 2>/dev/null | $script_dir/busybox awk '{print $1}')" == 877144 ]; then
sleep 1
echo Copying SQLite3...
sleep 1
$script_dir/busybox cp -f /data/local/tmp/sqlite3 /data/local/unkilled_toolkit
sleep 1
echo Setting up permissions...
$script_dir/busybox chmod 755 $script_dir/sqlite3
sleep 1
echo Done.
sleep 1
break
fi
done
fi
if [ -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh ]; then
echo Installing Unkilled Toolkit...
$script_dir/busybox cp -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh /system/xbin/utk
sleep 1
echo Setting up permissions...
$script_dir/busybox chmod 755 /system/xbin/utk
sleep 1
echo Clean up downloaded file...
$script_dir/busybox rm -f $EXTERNAL_STORAGE/download/unkilled_toolkit.sh
sleep 1
echo Done.
sleep 1
clear
echo Now write \'utk\' only to run Unkilled Toolkit.
exit
fi
sh_ota
main_menu