-
Notifications
You must be signed in to change notification settings - Fork 3
/
ios4.sh
executable file
·221 lines (221 loc) · 5.26 KB
/
ios4.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
#!/bin/bash
set -e
IP=$1
cd support_files/4.3/File_System
./pzb -g 038-0688-006.dmg https://secure-appldnld.apple.com/iPhone4/041-0330.20110311.Cswe3/iPhone3,1_4.3_8F190_Restore.ipsw
./dmg extract 038-0688-006.dmg decrypted.dmg -k 34904e749a8c5cfabecc6c3340816d85e7fc4de61c968ca93be621a9b9520d6466a1456a
./dmg build decrypted.dmg UDZO.dmg
echo "Preparing Filesystems..."
/usr/bin/expect <(cat << EOF
set timeout -1
spawn ssh -o StrictHostKeyChecking=no -p 22 root@$IP
expect "root@$IP's password:"
send "alpine\r"
expect "#"
send "mkdir /mnt1\r"
expect "#"
send "mkdir /mnt2\r"
expect "#"
send "/sbin/newfs_hfs -s -v System -J -b 8192 -n a=8192,c=8192,e=8192 /dev/disk0s3\r"
expect "#"
send "/sbin/newfs_hfs -s -v Data -J -b 8192 -n a=8192,c=8192,e=8192 /dev/disk0s4\r"
expect "#"
send "mount_hfs /dev/disk0s4 /mnt2\r"
expect "#"
send "exit\r"
expect eof
)
echo "Sending Filesystem, This Will Take Long Time..."
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no UDZO.dmg root@$IP:/mnt2
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Restoring Filesystem, This Will Take A Long Time..."
/usr/bin/expect <(cat << EOF
set timeout -1
spawn ssh -o StrictHostKeyChecking=no -p 22 root@$IP
expect "root@$IP's password:"
send "alpine\r"
expect "#"
send "asr restore --source /mnt2/UDZO.dmg --target /dev/disk0s3 --erase\r"
expect ":"
send "y\r"
expect "#"
send "exit\r"
expect eof
)
echo "Patching Filesystem..."
/usr/bin/expect <(cat << EOF
set timeout -1
spawn ssh -o StrictHostKeyChecking=no -p 22 root@$IP
expect "root@$IP's password:"
send "alpine\r"
expect "#"
send "fsck_hfs -f /dev/disk0s3\r"
expect "#"
send "umount /mnt1\r"
expect "#"
send "umount /mnt2\r"
expect "#"
send "mount_hfs /dev/disk0s4 /mnt2\r"
expect "#"
send "mount_hfs /dev/disk0s3 /mnt1\r"
expect "#"
send "mv -v /mnt1/private/var/* /mnt2\r"
expect "#"
send "mkdir /mnt2/keybags\r"
expect "#"
send "exit\r"
expect eof
)
cd ../Patches
echo "Patching Fstab..."
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no fstab root@$IP:/mnt1/etc
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Patching Keybag"
/usr/bin/expect <(cat << EOF
set timeout -1
spawn ssh -o StrictHostKeyChecking=no -p 22 root@$IP
expect "root@$IP's password:"
send "alpine\r"
expect "#"
send "ttbthingy\r"
expect "#"
send "fixkeybag -v2\r"
expect "#"
send "cp -a /tmp/systembag.kb /mnt2/keybags\r"
expect "#"
send "umount /mnt1\r"
expect "#"
send "umount /mnt2\r"
expect "#"
send "exit\r"
expect eof
)
echo "Patching Boot Files (1/6)"
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no applelogo root@$IP:/
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Patching Boot Files (2/6)"
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no devicetree root@$IP:/
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Patching Boot Files (3/6)"
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no kernelcache root@$IP:/
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Patching Boot Files (4/6)"
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no ramdisk root@$IP:/
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Patching Boot Files (5/6)"
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no iBEC.img3 root@$IP:/
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Patching Boot Files (6/6)"
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no iBSS.patched root@$IP:/
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Sending runasroot "
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no runasroot root@$IP:/usr/bin
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Sending Boot..."
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no boot.sh root@$IP:/
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
cd ../App
echo "Sending App..."
/usr/bin/expect <(cat << EOF
set timeout -1
spawn scp -P 22 -o StrictHostKeyChecking=no -r 4tify.app root@$IP:/Applications
expect "root@$IP's password:"
send "alpine\r"
expect eof
)
echo "Moving Everything Into Place..."
sleep 2
/usr/bin/expect <(cat << EOF
set timeout -1
spawn ssh -o StrictHostKeyChecking=no -p 22 root@$IP
expect "root@$IP's password:"
send "alpine\r"
expect "#"
send "chmod 6755 /Applications/4tify.app/4tify\r"
expect "#"
send "chmod 4755 /usr/bin/runasroot\r"
expect "#"
send "chown root:wheel /usr/bin/runasroot\r"
expect "#"
send "chmod 6755 /usr/bin/runasroot\r"
expect "#"
send "chmod 6755 /boot.sh\r"
expect "#"
send "exit\r"
expect eof
)
sleep 2
/usr/bin/expect <(cat << EOF
set timeout -1
spawn ssh -o StrictHostKeyChecking=no -p 22 mobile@$IP
expect "mobile@$IP's password:"
send "alpine\r"
expect "mobile"
send "uicache\r"
expect "mobile"
send "exit\r"
expect eof
)
sleep 2
/usr/bin/expect <(cat << EOF
set timeout -1
spawn ssh -o StrictHostKeyChecking=no -p 22 root@$IP
expect "root@$IP's password:"
send "alpine\r"
expect "#"
send "killall -9 SpringBoard\r"
expect "#"
send "exit\r"
expect eof
)
echo "Done!"