forked from MatthewPierson/checkm8-nonce-setter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
executable file
·212 lines (176 loc) · 5.02 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
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
#!/bin/bash
rm -rf ipwndfu_public
rm -rf ipwndfu
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 desiered 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"
files/igetnonce | grep 'n53ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPhone6,2"
echo $device
fi
files/igetnonce | grep 'n51ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPhone6,1"
echo $device
fi
files/igetnonce | grep 'j71ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPad4,1"
echo $device
fi
files/igetnonce | grep 'j72ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPad4,2"
echo $device
fi
files/igetnonce | grep 'j85ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPad4,4"
echo $device
fi
files/igetnonce | grep 'j86ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPad4,5"
echo $device
fi
files/igetnonce | grep 'd11ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPhone9,2"
echo $device
fi
files/igetnonce | grep 'd10ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPhone9,1"
echo $device
fi
files/igetnonce | grep 'd101ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPhone9,3"
echo $device
fi
files/igetnonce | grep 'd111ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPhone9,4"
echo $device
fi
files/igetnonce | grep 'd22ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPhone10,3"
echo $device
fi
files/igetnonce | grep 'd221ap' &> /dev/null
if [ $? == 0 ]; then
echo "Supported Device"
device="iPhone10,6"
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 pwned DFU mode. Press enter when ready to continue"
read randomIrrelevant
echo "Device is now in PWNDFU mode with signature checks removed (Thanks to Linus Henze & akayn)"
echo "Entering PWNREC mode"
cd files
if [ $device == iPhone10,3 ] || [ $device == iPhone10,6 ]; then
./irecovery -f junk.txt
fi
./irecovery -f ibss."$device".img4
sleep 2
./irecovery -f ibss."$device".img4
if [ $device = iPhone6,1 ] || [ $device = iPhone6,2 ] || [ $device = iPad4,1 ] || [ $device = iPad4,2 ] || [ $device = iPad4,3 ] || [ $device = iPad4,4 ] || [ $device = iPad4,5 ] || [ $device = iPad4,6 ] || [ $device = iPad4,7 ] || [ $device = iPad4,8 ] || [ $device = iPad4,9 ];
then
./irecovery -f ibec."$device".img4
fi
echo "Entered PWNREC mode"
sleep 4
echo "Current nonce"
./irecovery -q | grep NONC
echo "Setting nonce to $generator"
./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"