forked from RossDarker/A5-A6X-Blobs-Dumper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatchipsw
executable file
·155 lines (143 loc) · 3.29 KB
/
patchipsw
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
#!/bin/bash
if [ $# -lt 2 ]; then
echo ""
echo "[DESCRIPTION]"
echo "Extracts baseband, builds custom IPSW, and extracts iBEC & iBSS"
echo ""
echo "[USAGE]"
echo "./patchipsw <device model> <device IP>"
echo ""
echo "[EXAMPLES]"
echo "./patchipsw iPad3,5 192.168.1.88"
echo "./patchipsw iPod5,1 192.168.1.201"
echo "./patchipsw iPhone4,1 192.168.1.14"
echo ""
exit
fi
if [ $# -gt 2 ]; then
echo "[ERROR] Too many arguments"
exit
fi
if [ $OSTYPE = msys ]; then
echo "WINDOWS DETECTED"
path="/c/Users/`whoami`/Downloads"
platform="win"
elif [[ $OSTYPE == "darwin"* ]]; then
echo "MAC OS DETECTED"
path="/Users/`whoami`/Downloads"
platform="macos"
else
echo "Not supported"
exit
fi
cd "$path/blobs"
if [ $1 = "iPhone4,1" ]; then
buildid="10B329"
fi
if [ $1 = "iPhone5,1" ]; then
buildid="10B329"
fi
if [ $1 = "iPhone5,2" ]; then
buildid="10B329"
fi
if [ $1 = "iPhone5,3" ]; then
buildid="11B511"
fi
if [ $1 = "iPhone5,4" ]; then
buildid="11B651"
fi
if [ $1 = "iPod5,1" ]; then
buildid="10B329"
fi
if [ $1 = "iPad2,1" ]; then
buildid="10B329"
fi
if [ $1 = "iPad2,2" ]; then
buildid="11D257"
fi
if [ $1 = "iPad2,3" ]; then
buildid="12H321"
fi
if [ $1 = "iPad2,4" ]; then
buildid="10B329"
fi
if [ $1 = "iPad2,5" ]; then
buildid="10B329"
fi
if [ $1 = "iPad2,6" ]; then
buildid="12H321"
fi
if [ $1 = "iPad2,7" ]; then
buildid="12H321"
fi
if [ $1 = "iPad3,1" ]; then
buildid="10B146"
fi
if [ $1 = "iPad3,2" ]; then
buildid="12H321"
fi
if [ $1 = "iPad3,3" ]; then
buildid="10B329"
fi
if [ $1 = "iPad3,4" ]; then
buildid="10B329"
fi
if [ $1 = "iPad3,5" ]; then
buildid="12H321"
fi
if [ $1 = "iPad3,6" ]; then
buildid="10B329"
fi
model=$1
ip=$2
mainbdid=`cat mainbdid`
echo "Build ID: $buildid"
echo "Model: $model"
echo "Devcice IP: $ip"
mv "$buildid.ipsw" odysseus-0.999.0/$platform/downloaded.ipsw
if [ ! $buildid = $mainbdid ]; then
mv "$mainbdid.ipsw" odysseus-0.999.0/$platform/current.ipsw
fi
cd "$path/blobs/odysseus-0.999.0/$platform/"
if [ $2 != "skip" ]; then
echo "Will attempt to extract baseband from device"
echo ""
echo "If asked, type yes, then the default password is \"alpine\""
echo ""
./sshtool -s baseband.tar -p 22 $ip
echo ""
if [ -e "baseband.tar" ]; then
echo "Successfully received baseband from device, if it has one"
else
echo "Couldn't connect to device, install OpenSSH from Cydia, or run: rm ~/.ssh/known_hosts, then try again."
exit
fi
fi
echo ""
echo "Patching IPSW"
if [ $2 != "skip" ]; then
./ipsw downloaded.ipsw custom.ipsw -memory baseband.tar
else
./ipsw downloaded.ipsw custom.ipsw -memory
fi
if [ -e "custom.ipsw" ]; then
echo ""
echo "Successfully created custom IPSW"
else
echo ""
echo "Did not succeed, trying without baseband.tar..."
./ipsw downloaded.ipsw custom.ipsw -memory
fi
if [ ! -e "custom.ipsw" ]; then
echo "Did not succeed, trying without -memory..."
./ipsw downloaded.ipsw custom.ipsw
fi
echo ""
echo "Extracting pwned iBSS..."
./xpwntool `unzip -j custom.ipsw 'Firmware/dfu/iBSS*' | awk '/inflating/{print $2}'` pwnediBSS
echo "Extracting pwned iBEC..."
mv `unzip -j custom.ipsw 'Firmware/dfu/iBEC*' | awk '/inflating/{print $2}'` pwnediBEC
if [ $buildid = $mainbdid ]; then
mv "downloaded.ipsw" "current.ipsw"
fi
echo "Done"