forked from MatthewPierson/checkm8-nonce-setter
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.sh
executable file
·178 lines (140 loc) · 3.89 KB
/
main.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
#!/bin/bash
clear
echo "*** Matty's Checkm8 APNonce Setter ***"
echo "Do you want to input a generator? (y,n)"
read input
if [ $input = y ];
then
echo "Please enter your desired generator."
read generator
echo "Your generator is $generator"
elif [ $input = n ];
then
echo "Please drag and drop the SHSH file that you want to downgrade with into this terminal window then press enter"
read shsh
echo "Is $shsh the correct location and file name of your SHSH? (y/n)"
read pass
if [ $pass == yes ] || [ $pass == Yes ] || [ $pass == y ] || [ $pass == Y ];
then
echo "Continuing with given SHSH"
elif [ $pass == no ] || [ $pass == No ] || [ $pass == n ] || [ $pass == n ];
then
echo "Please restart script and give the correct location and file name"
echo "Exiting..."
exit
else
echo "Unrecognised input"
echo "Exiting..."
exit
fi
if [ ${shsh: -6} == ".shsh2" ] || [ ${shsh: -5} == ".shsh" ];
then
echo "File verified as SHSH2 file, continuing"
else
echo "Please ensure that the file extension is either .shsh or .shsh2 and retry"
echo "Exiting..."
exit
fi
echo "Getting generator from SHSH"
getGenerator() {
echo $1 | grep "<string>0x" $shsh | cut -c10-27
}
generator=$(getGenerator $shsh)
if [ -z "$generator" ]
then
echo "[ERROR] SHSH does not contain a generator!"
echo "[ERROR] Please use a different SHSH with a generator!"
echo "[ERROR] SHSH saved with shsh.host (will show generator) or tsssaver.1conan.com (in noapnonce folder) are acceptable"
echo "Exiting..."
exit
else
echo "Your generator is: $generator"
fi
else
echo "Input not recognized, Exiting..."
exit
fi
echo "$generator"
echo "getting device model"
files/igetnonce | grep 'n69ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="n69ap"
echo $device
fi
files/igetnonce | grep 'n69uap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="n69uap"
echo $device
fi
files/igetnonce | grep 'n71ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="n71ap"
echo $device
fi
files/igetnonce | grep 'n71map' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="n71map"
echo $device
fi
files/igetnonce | grep 'n66ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="n66ap"
echo $device
fi
files/igetnonce | grep 'n66map' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="n66map"
echo $device
fi
if [ -z "$device" ]
then
echo "Either unsupported device or no device found."
echo "Exiting.."
exit
else
echo "Supported device found."
fi
echo "Please connect device in DFU mode. Press enter when ready to continue"
read randomIrrelevant
echo "Starting ipwnder-lite"
cd files
./ipwnder_macosx -p
sleep 2
echo "Uploading bootchain"
iBSS="iBSS.$device.img4"
iBEC="iBEC.$device.img4"
echo "Uploading $iBSS"
./irecovery -f $iBSS
sleep 2
echo "Uploading $iBEC"
./irecovery -f $iBEC
sleep 2
echo "We should be in pwned recovery mode now"
echo "Current nonce"
./irecovery -q | grep NONC
echo "Setting nonce to $generator"
./irecovery -c "bgcolor 255 0 0"
sleep 1
./irecovery -c "setenv com.apple.System.boot-nonce $generator"
sleep 1
./irecovery -c "saveenv"
sleep 1
./irecovery -c "setenv auto-boot false"
sleep 1
./irecovery -c "saveenv"
sleep 1
./irecovery -c "reset"
echo "Waiting for device to restart into recovery mode"
sleep 7
echo "New nonce"
./irecovery -q | grep NONC
echo "We are done!"
echo ""
echo "You can now futurerestore to the firmware that this SHSH is vaild for"
echo "Assuming that signed SEP and Baseband are compatible"