-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboot.sh
1406 lines (1042 loc) · 45.7 KB
/
boot.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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <https://www.gnu.org/licenses/>.
#yes i know this code is bad, but it mostly works
#start of script
#!/usr/bin/env bash
#colours
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
CYAN="\033[0;36m"
NC="\e[0m"
ICyan='\033[0;96m'
IGreen='\033[0;92m'
#Background
On_Black='\033[40m'
# trap ctrl-c and call ctrl_c()
trap ctrl_c INT
function ctrl_c() {
if [[ $(date "+%e %m") == "01 04" ]]; then
echo -e "\n\nlmao you thought you can exit"
sleep 3
echo -e "\nApril Fools!"
echo -e "$ICyan\nExiting...$NC"
exit 1
else
echo -e "$ICyan\nExiting...$NC"
exit 1
fi
}
linelength=$(tput lines)
if [[ $linelength == 24 ]]; then
line_length="-------------------------------------------------------------------------------"
else
if [[ $linelength -gt 24 ]]; then
line_length="---------------------------------------------------------------------------------------------------------------------"
else
line_length="-----------------------------------------------------------"
fi
fi
pwd=$(pwd)
usage="Boot script by Moneymoney122 (Twitter: @chandler_hacker)\nhttps://github.com/Moneymoney122/boot-script\nSubmit/check currently submitted issues: https://github.com/Moneymoney122/boot-script/issues\nGNU Bourne Again SHell script (https://www.gnu.org/software/bash/)\nProudly written in gedit\n2023\n\nUsage: ./boot.sh [Options]\n\nOptions:\n-h, --help or an invalid option: display this help menu\n-v, --version: print version information\n-d, --debug: output extra information (coming soon).\n-s, --save: save device information to file: $pwd/deviceinfo.txt\nssh: ssh into a root shell for your device, your device must be jailbroken and have OpenSSH installed.\ncheckra1n: run the commands to jailbreak with checkra1n, the checkra1n executable must be in your home directory.\nOwO: OwO\n${line_length}\nNo options: run normally\n***Cannot proccess more than one argument at a time at the moment***${NC}"
Version="Version: $(date -d @$(git log -1 --format="%at") +%d-%m-%Y) (DD-MM-YYYY) $(git rev-parse HEAD | cut -c -7) Stable Release"
#check terminal size
terminallines=$(tput lines)
terminalcols=$(tput cols)
if [[ $terminallines -lt 24 ]]; then
echo -e "${ICyan}Terminal size is ${terminallines}x${terminalcols}, it is recommended that you make you make your terminal larger.\n(Recommended size is 80x24)"
sleep 3
terminalwarningsent=yes
fi
if [[ $terminalcols -lt 80 ]]; then
if test -z "$terminalwarningsent"
then
echo -e "${ICyan}Terminal size is ${terminallines}x${terminalcols}, it is recommended that you make you make your terminal larger.\n(Recommended size is 80x24)"
sleep 3
fi
fi
case $1 in
OwO) echo -e "${ICyan}OwO${NC}" && exit ;;
ssh)
echo -e "${ICyan}${line_length}"
echo -e "ssh into a root shell for your device, your device must be jailbroken and have OpenSSH installed.\nYour device and computer must be on the same WiFi network,\nand there must not be anything stopping your devices from connecting to each other.\nThe default password for your device if you have not changed it is: alpine (recommended to change it).\nEnter your device's local IP Address.\nYou can find this in Settings > WiFi > Click on your WiFi Network and scroll down and find your local IP Address.\nWhen you have finished in the shell type \"exit\" or \"logout\".\nRemember, you are logging in as root, the most powerfull user and it can be dangerous if you don't know what you're doing.\nProcceed at your own risk, I am not responsible for any damage you may cause. To exit at anytime press Ctrl+C.\nWhen entering your password it will be hidden but will still be registered."
echo "$line_length"
echo "Checking Internet connection..."
ping -c 3 208.67.222.222 >/dev/null 2>/dev/null
if [[ $? != 0 ]]; then
echo "No internet connection."
echo "You might encounter issues connecting via ssh to your device."
echo "$line_length"
else
echo -e "You have an internet connection."
echo "$line_length"
fi
read -p "Enter local IP Address: " IPADDRESS
read -sp "Enter Password: " PASSWORD
echo -e "${NC}"
sshpass -v -p "$PASSWORD" ssh root@$IPADDRESS
if [[ $? != 0 ]]; then
echo -e "${ICyan}An error occured connecting to your device, if you need help please check online for a solution\nto your specific error or contact me if you need to. Some common errors include:"
echo -e "\n\"ssh: connect to host *your device's IP Address* port 22: Connection refused\":\nYour device doesn't have OpenSSH installed or the password is incorrect.\n\n\"ssh: connect to host *your device's IP Address* port 22: No route to host\":\nYour device could not be found on your network.\n\n\"ssh: Could not resolve hostname *your device's IP Address*: Name or service not known.\":\nThe IP Address you typed for your device is invalid.\n\n\"SSHPASS: detected host authentication prompt. Exiting.\":\nThis is the first time connecting to your device via ssh, please run:\n\"ssh root@*your IP Address*\" (without the quotes) and confirm the host authentication prompt,\nand then enter your device's password (default is alpine) and then logout then run the script again.$NC"
fi
exit ;;
-h)
echo "hello" | lolcat >/dev/null
if [[ $? != 0 ]]; then
echo -e "${ICyan}\nlolcat is not installed, printing art in regular colours.\n"
echo -e "$ICyan ___ ___ ___ _____ ___ ___ ___ ___ ___ _____ "
echo "| _ )/ _ \ / _ \_ _| / __|/ __| _ \_ _| _ \_ _| "
echo "| _ \ (_) | (_) || | \__ \ (__| /| || _/ | | "
echo -e "|___/\___/ \___/ |_| |___/\___|_|_\___|_| |_| \n"
echo -e "${ICyan}${Version}"
echo -e "${ICyan}$usage"
exit
else
echo -e "$ICyan ___ ___ ___ _____ ___ ___ ___ ___ ___ _____ " | lolcat -p 0.1
echo "| _ )/ _ \ / _ \_ _| / __|/ __| _ \_ _| _ \_ _| " | lolcat -p 0.1
echo "| _ \ (_) | (_) || | \__ \ (__| /| || _/ | | " | lolcat -p 0.1
echo -e "|___/\___/ \___/ |_| |___/\___|_|_\___|_| |_| \n" | lolcat -p 0.1
echo -e "${ICyan}${Version}"
echo -e "${ICyan}$usage"
fi
exit ;;
checkra1n)
echo -e -n "$ICyan"
while true; do
read -p 'Do you want to run checkra1n in GUI or CLI mode (if your device is in DFU mode you will need to run checkra1n in CLI mode)? (Ctrl+C to exit ant any time). g/c: ' input
case $input in
[c]*)
read -p "Do you want to add any arguments to checkra1n? if yes then please type them here, if you don't know what these are or you don't want to add any then just press enter to leave this blank: " ARGUMENTS
echo -e "Running checkra1n in CLI mode. Please ensure your device is in DFU mode and that the checkra1n executable is in your home directory..."
echo "When checkra1n has finished please press Ctrl+C to exit checkra1n and exit this script"
echo "$line_length"
echo "Searching for devices in DFU/Recovery mode..."
sudo irecovery -q
echo "$line_length"
echo -e "${NC}"
sudo ~/checkra1n -c $ARGUMENTS
break
;;
[g]*)
echo "$line_length"
read -p "Do you want to add any arguments to checkra1n? if yes then please type them here, if you don't know what these are or you don't want to add any then just press enter to leave this blank: " ARGUMENTS
echo -e "Running checkra1n in GUI mode. Please ensure your device is in normal or recovery mode and that the checkra1n executable is in your home directory..."
echo -e "When checkra1n has finished it should exit automatically and then the script will return to the jailbreak with checkra1n option\nso you can run checkra1n again if it failed or if you want to run it again, if it did not exit automatically then please press Ctrl+C to exit checkra1n and exit this script and then you can run the script again if you want to."
echo "$line_length"
read -n 1 -s -r -p "--------------Press any key to start checkra1n or Ctrl+C to Exit-----------"
echo -e "$NC"
sudo ~/checkra1n $ARGUMENTS
echo -e "$ICyan"
break
;;
*)
echo 'Invalid input' >&2
esac
done
echo -e "Exiting...$NC"
exit ;;
--help)
echo "hello" | lolcat >/dev/null
if [[ $? != 0 ]]; then
echo -e "${ICyan}\nlolcat is not installed, printing art in regular colours.\n"
echo -e "$ICyan ___ ___ ___ _____ ___ ___ ___ ___ ___ _____ "
echo "| _ )/ _ \ / _ \_ _| / __|/ __| _ \_ _| _ \_ _| "
echo "| _ \ (_) | (_) || | \__ \ (__| /| || _/ | | "
echo -e "|___/\___/ \___/ |_| |___/\___|_|_\___|_| |_| \n"
echo -e "${ICyan}${Version}"
echo -e "${ICyan}$usage"
exit
else
echo -e "$ICyan ___ ___ ___ _____ ___ ___ ___ ___ ___ _____ " | lolcat -p 0.1
echo "| _ )/ _ \ / _ \_ _| / __|/ __| _ \_ _| _ \_ _| " | lolcat -p 0.1
echo "| _ \ (_) | (_) || | \__ \ (__| /| || _/ | | " | lolcat -p 0.1
echo -e "|___/\___/ \___/ |_| |___/\___|_|_\___|_| |_| \n" | lolcat -p 0.1
echo -e "${ICyan}${Version}"
echo -e "${ICyan}$usage"
fi
exit ;;
-s)
echo -e "${ICyan}Device infomation will be saved to deviceinfo.txt in the boot-script directory.\nPlease ensure your device is in normal mode and connected to your computer.\n"
while true; do
read -p 'Do you want to save just basic info to the file or all info? (Or press Ctrl+C to cancel and exit). B/A: ' INPUT
case $INPUT in
[bB]*)
#get device info
ActivationState=$(ideviceinfo | grep ActivationState: | awk '{print $NF}')
DeviceName=$(ideviceinfo | grep DeviceName | awk '{print $NF}')
UniqueDeviceID=$(ideviceinfo | grep UniqueDeviceID | awk '{print $NF}')
SerialNumber=$(ideviceinfo | grep -w SerialNumber | awk '{print $NF}')
ProductType=$(ideviceinfo | grep ProductType | awk '{print $NF}')
ProductVersion=$(ideviceinfo | grep ProductVersion | awk '{print $NF}')
UniqueChipID=$(ideviceinfo | grep UniqueChipID | awk '{print $NF}')
HardwareModel=$(ideviceinfo | grep HardwareModel | awk '{print $NF}')
CPUArchitecture=$(ideviceinfo | grep CPUArchitecture | awk '{print $NF}')
HardwarePlatform=$(ideviceinfo | grep HardwarePlatform | awk '{print $NF}')
Hex=$(printf '%x\n' $UniqueChipID)
#save device info to file
touch $pwd/deviceinfo.txt
echo "Activation State: $ActivationState Name: $DeviceName UDID: $UniqueDeviceID Serial Number: $SerialNumber iOS Version: $ProductVersion ECID (Decimal/Hexadecimal): $UniqueChipID / $Hex Model: $HardwareModel CPU Architecture: $CPUArchitecture Hardware Platform: $HardwarePlatform" > $pwd/deviceinfo.txt
echo -e "Done, your device infomation text file is located at $pwd/boot-script/deviceinfo.txt${NC}"
exit
;;
[aA]*)
#get device info
Deviceinfo=$(ideviceinfo)
touch $pwd/deviceinfo.txt
#save device info to file
echo $Deviceinfo > $pwd/deviceinfo.txt
echo -e "Done, your device infomation text file is located at $pwd/deviceinfo.txt${NC}"
exit
;;
*)
echo 'Invalid input' >&2
esac
done
exit ;;
--save)
echo -e "${ICyan}Device infomation will be saved to deviceinfo.txt in the boot-script directory.\nPlease ensure your device is in normal mode and connected to your computer.\n"
while true; do
read -p 'Do you want to save just basic info to the file or all info? (Or press Ctrl+C to cancel and exit). B/A: ' INPUT
case $INPUT in
[bB]*)
#get device info
ActivationState=$(ideviceinfo | grep ActivationState: | awk '{print $NF}')
DeviceName=$(ideviceinfo | grep DeviceName | awk '{print $NF}')
UniqueDeviceID=$(ideviceinfo | grep UniqueDeviceID | awk '{print $NF}')
SerialNumber=$(ideviceinfo | grep -w SerialNumber | awk '{print $NF}')
ProductType=$(ideviceinfo | grep ProductType | awk '{print $NF}')
ProductVersion=$(ideviceinfo | grep ProductVersion | awk '{print $NF}')
UniqueChipID=$(ideviceinfo | grep UniqueChipID | awk '{print $NF}')
HardwareModel=$(ideviceinfo | grep HardwareModel | awk '{print $NF}')
CPUArchitecture=$(ideviceinfo | grep CPUArchitecture | awk '{print $NF}')
HardwarePlatform=$(ideviceinfo | grep HardwarePlatform | awk '{print $NF}')
Hex=$(printf '%x\n' $UniqueChipID)
#save device info to file
touch $pwd/deviceinfo.txt
echo "Activation State: $ActivationState Name: $DeviceName UDID: $UniqueDeviceID Serial Number: $SerialNumber iOS Version: $ProductVersion ECID (Decimal/Hexadecimal): $UniqueChipID / $Hex Model: $HardwareModel CPU Architecture: $CPUArchitecture Hardware Platform: $HardwarePlatform" > $pwd/deviceinfo.txt
echo -e "Done, your device infomation text file is located at $pwd/deviceinfo.txt${NC}"
exit
;;
[aA]*)
#get device info
Deviceinfo=$(ideviceinfo)
touch $pwd/deviceinfo.txt
#save device info to file
echo $Deviceinfo > $pwd/deviceinfo.txt
echo -e "Done, your device infomation text file is located at $pwd/deviceinfo.txt${NC}"
exit
;;
*)
echo 'Invalid input' >&2
esac
done
exit ;;
-v)
echo -e "${ICyan}Boot-script by Moneymoney122\nhttps://github.com/Moneymoney122/boot-script\n\n${Version}${NC}"
exit ;;
--version)
echo -e "${ICyan}Boot-script by Moneymoney122\nhttps://github.com/Moneymoney122/boot-script\n\n${Version}${NC}"
exit ;;
esac
if test -n "$1"
then
echo "hello" | lolcat >/dev/null
if [[ $? != 0 ]]; then
echo -e "${ICyan}\nlolcat is not installed, printing art in regular colours.\n"
echo -e "${ICyan}Invalid option: \"$1\""
echo -e "$ICyan ___ ___ ___ _____ ___ ___ ___ ___ ___ _____ "
echo "| _ )/ _ \ / _ \_ _| / __|/ __| _ \_ _| _ \_ _| "
echo "| _ \ (_) | (_) || | \__ \ (__| /| || _/ | | "
echo -e "|___/\___/ \___/ |_| |___/\___|_|_\___|_| |_| \n"
echo -e "${ICyan}${Version}"
echo -e "${ICyan}$usage"
exit
else
echo -e "${ICyan}Invalid option: \"$1\""
echo -e "$ICyan ___ ___ ___ _____ ___ ___ ___ ___ ___ _____ " | lolcat -p 0.1
echo "| _ )/ _ \ / _ \_ _| / __|/ __| _ \_ _| _ \_ _| " | lolcat -p 0.1
echo "| _ \ (_) | (_) || | \__ \ (__| /| || _/ | | " | lolcat -p 0.1
echo -e "|___/\___/ \___/ |_| |___/\___|_|_\___|_| |_| \n" | lolcat -p 0.1
echo -e "${ICyan}${Version}"
echo -e "${ICyan}$usage"
exit
fi
fi
clear
echo -e "$ICyan ____ ____ ____ _______ _____ _____ _____ _____ _____ _______"
echo "| _ \ / __ \ / __ \__ __| / ____|/ ____| __ \|_ _| __ \__ __|"
echo "| |_) | | | | | | | | | | (___ | | | |__) | | | | |__) | | | "
echo "| _ <| | | | | | | | | \___ \| | | _ / | | | ___/ | | "
echo "| |_) | |__| | |__| | | | ____) | |____| | \ \ _| |_| | | | "
echo "|____/ \____/ \____/ |_| |_____/ \_____|_| \_\_____|_| |_| "
echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo " _ __ ___ _____ __ __ "
echo "| ' \/ -_) _ \ V V /"
echo "|_|_|_\___\___/\_/\_/ "
sleep 1.5
clear
echo "$line_length"
echo "Boot script for tethered downgraded A8/A9 devices, this script is made by Moneymoney122 (@chandler_hacker on twitter)."
echo "$line_length"
echo "this script is a modified version of the boot script from the sunst0rm tether downgrade tool made by mineek. (https://github.com/mineek/sunst0rm)"
echo "$line_length"
echo "verbose output is enabled by default in this script, so you will see a lot of text in the terminal."
echo "$line_length"
echo "this script will also ask for your user's password, it is completly safe and you can check the code if you want to be sure."
echo "$line_length"
echo "if you have any issues with this script please read the README.md file included with this script or on the github repo before opening an issue on github or contacting me."
echo "$line_length"
echo "if you see any commands in quotes and you want to run them then please copy the commands without the quotes and then run them."
echo "$line_length"
echo "this script will be changing directory into the folder with your boot files, please change this command to match the name of the folder with your boot files by opening this script with a text editor and pressing Ctrl+F to search for \"cd into the folder with your boot files\" and changing the cd command to match the location of your boot files, if you have not already."
echo "$line_length"
echo "please ensure that the ipwndfu and gaster folders are in the home directory and that python2 is installed before continuing,"
echo "$line_length"
echo "if your device is in DFU mode at any time and you want to exit it, hold the power button and home button for 15 seconds."
echo "$line_length"
echo "it is recommended that you maximise your terminal window to ensure all text is displayed correctly."
echo "$line_length"
echo "you can use Ctrl+C to exit the script at any time."
echo "$line_length"
echo "this script can also run checkra1n commands to jailbreak your device for any checkra1n compatible device. if you want to use checkra1n with this script please ensure that the checkra1n executable file is in your home directory (get checkra1n at https://checkra.in)"
echo "$line_length"
echo "Please connect your device before running the script and keep your device connected at all times while this running this script, unless asked otherwise."
echo "$line_length"
read -n 1 -s -r -p "----------------Press any key to continue (Or Ctrl+C to Exit)----------------"
clear
if [[ $EUID == 0 ]]; then
while true; do
read -p 'The script is currently running as root, (If this message is incorrect then you can just ignore it and type yes.) this is not recommended but you can still continue if you want? yes/no: ' input
case $input in
[yY]*)
echo 'Continuing the script...'
sleep 3
clear
break
;;
[nN]*)
echo 'Exiting...$NC'
exit 1
;;
*)
echo 'Invalid input' >&2
esac
done
fi
name=$(whoami)
date=$(date "+%A, %d %B %Y %H:%M:%S")
uptime=$(uptime -p | sed 's/u//' | sed 's/p//')
hour=$(date +%H)
greet="It's"
if [ $hour -le 11 ] && [ $hour -gt 6 ]; then
timeofday=morning
elif [ $hour -eq 12 ]; then
timeofday=noon
elif [ $hour -le 17 ] && [ $hour -gt 12 ]; then
timeofday=afternoon
elif [ $hour -le 19 ] && [ $hour -gt 17 ]; then
timeofday=evening
else
timeofday=night
fi
echo "$line_length"
echo -e "${On_Black}Welcome $name, $greet $timeofday. The current date and time is: $date. Uptime is$uptime.${NC}" | lolcat -a -d 60
echo -e "${ICyan}${line_length}"
echo "Detecting what Operating System and Hardware this script is running on..."
echo "$line_length"
case "$OSTYPE" in
solaris*) echo "Running on Solaris" ;;
darwin*) echo "Running on Mac OS/iOS/iPad OS" ;;
linux*) echo "Running on Linux" ;;
bsd*) echo "Running on BSD" ;;
msys*) echo "Running on Windows" ;;
cygwin*) echo "Running on Windows" ;;
*) echo "Unknown: $OSTYPE" ;;
esac
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
HardwareModel=$(hostnamectl | grep "Hardware Model")
if test -z "$HardwareModel"
then
sudo /usr/sbin/dmidecode -s system-product-name
else
echo $HardwareModel
fi
OSNAME=$(lsb_release -d | cut -f 2-)
if [[ $OSNAME == "Arch Linux" ]]; then
echo "You use Arch Linux btw"
else
echo "You do not use Arch Linux btw"
echo $OSNAME
fi
OS=`lowercase \`uname\``
KERNEL=`uname -r`
MACH=`uname -m`
if [ "{$OS}" == "windowsnt" ]; then
OS=windows
elif [ "{$OS}" == "darwin" ]; then
OS=mac
else
OS=`uname`
if [ "${OS}" = "SunOS" ] ; then
OS=Solaris
ARCH=`uname -p`
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif [ "${OS}" = "AIX" ] ; then
OSSTR="${OS} `oslevel` (`oslevel -r`)"
elif [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DistroBasedOn='RedHat'
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
PSUEDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/SuSE-release ] ; then
DistroBasedOn='SuSe'
PSUEDONAME=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
elif [ -f /etc/mandrake-release ] ; then
DistroBasedOn='Mandrake'
PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DistroBasedOn='Debian'
DIST=`cat /etc/lsb-release 2>/dev/null | grep '^DISTRIB_ID' | awk -F= '{ print $2 }'`
PSUEDONAME=`cat /etc/lsb-release 2>/dev/null | grep '^DISTRIB_CODENAME' | awk -F= '{ print $2 }'`
REV=`cat /etc/lsb-release 2>/dev/null | grep '^DISTRIB_RELEASE' | awk -F= '{ print $2 }'`
fi
if [ -f /etc/UnitedLinux-release ] ; then
DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
fi
OS=`lowercase $OS`
DistroBasedOn=`lowercase $DistroBasedOn`
readonly OS
readonly DIST
readonly DistroBasedOn
readonly PSUEDONAME
readonly REV
readonly KERNEL
readonly MACH
fi
fi
echo $OS
echo $KERNEL
echo $MACH
if [[ $(uname -m) != "x86_64" ]]; then
echo "$line_length"
echo "Non x86_64 system detected, you might encounter issues"
fi
echo "$line_length"
echo -e -n "Please connect your device now"
sleep 3
echo " Searching for devices in normal mode..."
ActivationState=$(ideviceinfo | grep ActivationState: | awk '{print $NF}')
DeviceName=$(ideviceinfo | grep DeviceName | cut -d " " -f2-)
UniqueDeviceID=$(ideviceinfo | grep UniqueDeviceID | awk '{print $NF}')
SerialNumber=$(ideviceinfo | grep -w SerialNumber | awk '{print $NF}')
ProductType=$(ideviceinfo | grep ProductType | awk '{print $NF}')
ProductVersion=$(ideviceinfo | grep ProductVersion | awk '{print $NF}')
UniqueChipID=$(ideviceinfo | grep UniqueChipID | awk '{print $NF}')
HardwareModel=$(ideviceinfo | grep HardwareModel | awk '{print $NF}')
CPUArchitecture=$(ideviceinfo | grep CPUArchitecture | awk '{print $NF}')
HardwarePlatform=$(ideviceinfo | grep HardwarePlatform | awk '{print $NF}')
Hex=$(printf '%x\n' $UniqueChipID)
if test -z "$ActivationState"
then
echo "$line_length"
echo -e "$RED*******unable to connect to any devices in normal mode*******$NC"
echo -e "${ICyan}${line_length}"
echo "Searching for devices in DFU/Recovery mode..."
devicemode=$(irecovery -q 2>/dev/null | grep MODE: | awk '{print $NF}')
echo -e "$line_length $IGreen"
if test -z "$devicemode"
then
echo -e "$RED*******unable to connect to any devices in Recovery/DFU mode*******$ICyan"
echo "$line_length"
while true; do
read -p 'No devices have been detected, do you want to restart usbmuxd? (this might fix your computer not detecting your device in normal mode). (If this message is incorrect then you can just ignore it and type no.) yes/no: ' input
case $input in
[yY]*)
echo 'Continuing the script...'
echo -e "Running \"sudo systemctl restart usbmuxd\", this might take a while..."
T="$(date +%s)"
sudo systemctl restart usbmuxd
T="$(($(date +%s)-T))"
echo "Completed, It took ${T} seconds."
echo "$line_length"
echo "Please disconnect and reconnect your device..."
for i in {1..3}
do
sleep 1
echo -n "$i "
done
echo -e "\n$line_length"
echo "Searching for devices in normal mode..."
sleep 1
unset ActivationState
unset DeviceName
unset UniqueDeviceID
unset SerialNumber
unset ProductType
unset ProductVersion
unset UniqueChipID
unset HardwareModel
unset CPUArchitecture
unset HardwarePlatform
sleep 1
ActivationState=$(ideviceinfo | grep ActivationState: | awk '{print $NF}')
DeviceName=$(ideviceinfo | grep DeviceName | cut -d " " -f2-)
UniqueDeviceID=$(ideviceinfo | grep UniqueDeviceID | awk '{print $NF}')
SerialNumber=$(ideviceinfo | grep -w SerialNumber | awk '{print $NF}')
ProductType=$(ideviceinfo | grep ProductType | awk '{print $NF}')
ProductVersion=$(ideviceinfo | grep ProductVersion | awk '{print $NF}')
UniqueChipID=$(ideviceinfo | grep UniqueChipID | awk '{print $NF}')
HardwareModel=$(ideviceinfo | grep HardwareModel | awk '{print $NF}')
CPUArchitecture=$(ideviceinfo | grep CPUArchitecture | awk '{print $NF}')
HardwarePlatform=$(ideviceinfo | grep HardwarePlatform | awk '{print $NF}')
Hex=$(printf '%x\n' $UniqueChipID)
if test -z "$ActivationState"
then
echo "$line_length"
echo -e "$RED*******still unable to connect to any devices in normal mode*******$ICyan"
echo "$line_length"
while true; do
read -p 'Do you still want to continue? yes/no: ' input
case $input in
[yY]*)
echo 'Continuing the script...'
break
;;
[nN]*)
echo "Please run the script again"
echo 'Exiting...'
exit 1
;;
*)
echo 'Invalid input' >&2
esac
done
else
echo -e "${line_length}${IGreen}"
echo -e "Device found in normal mode, not going to search for devices in DFU/Recovery mode:\n"
echo -e "${IGreen}Serial Number: $SerialNumber | Device: $ProductType | Firmware: $ProductVersion | UDID: $UniqueDeviceID\n"
echo -e -n "Name: $DeviceName | Activation State: $ActivationState | ECID (Decimal/Hexadecimal): $UniqueChipID / $Hex\n\nBoard ID: $HardwareModel "
echo -e "| CPU Arch: $CPUArchitecture | Hardware Platform: ${HardwarePlatform}${ICyan}"
fi
break
;;
[nN]*)
echo 'Skipping...'
break
;;
*)
echo 'Invalid input' >&2
esac
done
else
unset CPID
unset CPRV
unset BDID
unset ECID
unset CPFM
unset SCEP
unset IBFL
unset SRTG
unset SRNM
unset IMEI
unset NONC
unset SNON
unset MODE
unset PWND
CPID=$(irecovery -q | grep CPID: | awk '{print $NF}')
CPRV=$(irecovery -q | grep CPRV: | awk '{print $NF}')
BDID=$(irecovery -q | grep BDID: | awk '{print $NF}')
ECID=$(irecovery -q | grep ECID: | awk '{print $NF}')
CPFM=$(irecovery -q | grep CPFM: | awk '{print $NF}')
SCEP=$(irecovery -q | grep SCEP: | awk '{print $NF}')
IBFL=$(irecovery -q | grep IBFL: | awk '{print $NF}')
SRTG=$(irecovery -q | grep SRTG: | awk '{print $NF}')
SRNM=$(irecovery -q | grep SRNM: | awk '{print $NF}')
IMEI=$(irecovery -q | grep IMEI: | awk '{print $NF}')
NONC=$(irecovery -q | grep NONC: | awk '{print $NF}')
SNON=$(irecovery -q | grep SNON: | awk '{print $NF}')
MODE=$(irecovery -q | grep MODE: | awk '{print $NF}')
PWND=$(irecovery -q | grep PWND: | awk '{print $NF}')
Decimal=$(printf '%d\n' $ECID)
if [[ "$SRTG" == N/A ]]; then
SRTG="Not Available"
elif [[ "$SRNM" == N/A ]]; then
SRNM="Not Available"
elif [[ "$IMEI" == N/A ]]; then
IMEI="Not Available"
elif [[ "$NONC" == N/A ]]; then
NONC="Not Available"
elif [[ "$SNON" == N/A ]]; then
SNON="Not Available"
fi
if [[ $MODE == DFU ]]; then
echo -e "Device found in DFU mode:\n"
if test -n "$PWND"
then
PWND="| Pwned: $PWND"
else
PWND="| Pwned: Not Pwned"
fi
else
echo -e "Device found in Recovery Mode:\n"
PWND="| Recovery Mode, so unable to check whether Pwned or not."
fi
echo -e "Chip ID: $CPID | Chip Revision: $CPRV | Board ID: $BDID | ECID (Decimal/Hexadecimal): $Decimal / $ECID\n\nSRTG: $SRTG $PWND | Serial Number: $SRNM | IMEI: $IMEI\n\nNonce: $NONC | SEP Nonce: $SNON"
fi
else
echo -e "${line_length}${IGreen}"
echo -e "Device found in normal mode, not going to search for devices in DFU/Recovery mode:\n"
echo -e "${IGreen}Serial Number: $SerialNumber | Device: $ProductType | Firmware: $ProductVersion | UDID: $UniqueDeviceID\n"
echo -e -n "Name: $DeviceName | Activation State: $ActivationState | ECID (Decimal/Hexadecimal): $UniqueChipID / $Hex\n\nBoard ID: $HardwareModel "
echo -e "| CPU Arch: $CPUArchitecture | Hardware Platform: ${HardwarePlatform}${ICyan}"
#why did i write this all out manually...
ProductType=$(ideviceinfo | grep ProductType | awk '{print $NF}')
if [[ $ProductType == iPhone4,1 || $ProductType == iPhone5,1 || $ProductType == iPhone5,2 || $ProductType == iPhone5,3 || $ProductType == iPhone5,4 || $ProductType == iPhone6,1 || $ProductType == iPhone6,2 || $ProductType == iPhone7,1 || $ProductType == iPhone7,2 || $ProductType == iPhone8,1 || $ProductType == iPhone8,2 || $ProductType == iPhone8,4 || $ProductType == iPhone9,1 || $ProductType == iPhone9,2 || $ProductType == iPhone9,3 || $ProductType == iPhone9,4 || $ProductType == iPhone10,1 || $ProductType == iPhone10,2 || $ProductType == iPhone10,3 || $ProductType == iPhone10,4 || i$ProductType == iPhone10,5 || $ProductType == iPhone10,6 ||$ProductType = iPod5,1 || $ProductType == iPod6,1 || $ProductType == iPod7,1 || $ProductType == iPad2,1 || $ProductType == iPad2,2 || $ProductType == iPad2,3 || $ProductType == iPad2,4 || $ProductType == iPad3,1 || $ProductType == iPad3,2 || $ProductType == iPad3,3 || $ProductType == iPad3,4 || $ProductType == iPad3,5 || $ProductType == iPad3,6 || $ProductType == iPad6,11 || $ProductType == iPad6,12 || $ProductType == iPad7,5 || $ProductType == iPad7,6 || $ProductType == iPad7,11 || $ProductType == iPad7,12 || $ProductType == iPad2,5 || $ProductType == iPad2,6 || $ProductType == iPad2,7 || $ProductType == iPad4,4 || $ProductType == iPad4,5 || $ProductType == iPad4,6 || $ProductType == iPad4,7 || $ProductType == iPad4,8 || $ProductType == iPad4,9 || $ProductType == iPad5,1 || $ProductType == iPad5,2 || $ProductType == iPad6,7 || $ProductType == iPad6,8 || $ProductType == iPad6,3 || $ProductType == iPad6,4 || $ProductType == iPad7,1 || $ProductType == iPad7,2 || $ProductType == iPad7,3 || $ProductType == iPad7,4 || $ProductType == iPad4,1 || $ProductType == iPad4,2 || $ProductType == iPad4,3 || $ProductType == iPad5,3 || $ProductType == iPad5,4 ]]; then
echo -e "${line_length}\n${YELLOW}Your device is compatible with checkm8${ICyan}"
checkm8compatible=yes
else
echo "$line_length"
echo -e "${YELLOW}checkm8 incompatible device detected, you won't be able to use parts of this script that require checkm8 to be used. Your device may be compatible with other BootROM exploits, please check online${ICyan}"
checkm8compatible=no
fi
fi
echo -e "${ICyan}${line_length}"
echo "Checking Internet connection... (You don't need an internet connection for this script, I'm just checking becuase I can lmao)"
ping -c 3 208.67.222.222 >/dev/null 2>/dev/null
if [[ $? != 0 ]]; then
echo "No internet connection."
else
echo "You have an internet connection."
fi
echo "$line_length"
read -n 1 -s -r -p "----------------Press any key to continue (Or Ctrl+C to Exit)----------------"
clear
#cd into the folder with your boot files, change this command to cd into the folder with your boot files.
echo -e "${ICyan}${line_length}"
echo "Changing into the folder with your boot files..."
cd *insert folder name here*
pwd
if test -n "$ActivationState"
then
echo "$line_length"
read -p "Your device is currently in normal mode, this script can enter recovery mode (it will be a black screen but it will be in recovery mode.) for you and then you can enter DFU mode from there, this is a safer option if your device is already in normal mode. Do you want to enter recovery mode? yes/no: " CHECK
if [[ "$CHECK" = "Y" || "$CHECK" = "y" || "$CHECK" = "Yes" || "$CHECK" = "yes" || "$CHECK" = "YES" ]]; then
echo 'Entering recovery mode...'
var=`ideviceinfo | grep "UniqueDeviceID" | grep -wv "UniqueDeviceID: "`
sudo ideviceenterrecovery $var
echo "$line_length"
sleep 7
echo "Searching for devices in Recovery Mode..."
sleep 1
RECOVERYMODE=$(sudo irecovery -q 2>/dev/null | grep MODE: | awk '{print $NF}')
if [[ $RECOVERYMODE == "Recovery" ]]; then
echo "Device found in Recovery Mode."
echo "Continuing..."
unset RECOVERYMODE
sleep 3
else
echo -e "No devices found in Recovery Mode\n$line_length"
echo -e "if you device did not enter recovery mode (black screen if your device is tether downgraded) from normal mode then your device probably was not detected by the computer, you could try to run \"sudo systemctl restart usbmuxd\" in the terminal to restart usbmuxd and then try running the script again or if that fails then you could try to run sudo \"systemctl stop usbmuxd\" and then \"sudo usbmuxd -p -f\" or you could put your device into DFU mode manually, if you want to do that please power off your device and then power it back on by holding the power button like normal but you will see a black screen until you have tether booted your device if your device is tether downgraded and then run the script again until you reach the entering DFU mode tutorial (input no when asked if you want to enter recovery mode from normal mode) and then follow the tutorial to enter DFU mode\n$line_length"
echo -e "Exiting...$NC"
exit 1
fi
else
echo -e "Skipping..."
fi
clear
fi
unset MODE
echo -e "$line_length\nSearching for devices in DFU mode..."
MODE=$(irecovery -q 2>/dev/null | grep MODE: | awk '{print $NF}')
if [[ $MODE == "DFU" ]]; then
echo "Device found in DFU mode, Skipping entering DFU mode tutorial."
else
echo "No devices in DFU mode found."
echo "$line_length"
echo -e "${ICyan}if you chose to put your device into recovery mode from normal mode, please now put your device into DFU mode"
echo "Please make sure your device is in DFU mode now, and make sure you are curently in the directory where the boot files are stored"
echo -e "If you device is in normal mode and the script did not recognise it please pres Ctrl+C and run the script again,\nor you can put your device in DFU mode manually (unsafe)."
unset CHECK
echo "$line_length"
read -p 'Do you want help entering DFU mode? yes/no: ' CHECK
if [[ "$CHECK" = "Y" || "$CHECK" = "y" || "$CHECK" = "Yes" || "$CHECK" = "yes" || "$CHECK" = "YES" ]]; then
echo 'Continuing to the entering DFU tutorial...'
echo "Get ready to hold the power button and home button for 10 seconds..."
for i in {1..3}
do
sleep 1
echo -n "$i "
done
echo -e "\nHold the power button and home button for 10 seconds..."
for i in {1..5}
do
sleep 1
echo -n "$i "
done
irecovery -n 2>/dev/null
for i in {6..10}
do
sleep 1
echo -n "$i "
done
echo -e "\nRelease the power button without releasing the home button and continue to hold the home button for another 10 seconds..."
for i in {1..10}
do
sleep 1
echo -n "$i "
done
echo -e "\nYour device should now be in DFU mode"
echo "$line_length"
mode=$(irecovery -q 2>/dev/null | grep MODE: | awk '{print $NF}')
if [[ $mode == DFU ]]; then
echo -e "Your device is now in DFU mode.\nContinuing..."
else
echo -e "Your device is not in DFU mode, Please run the script again.\nExiting...$NC"