This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpatchipsw
executable file
·94 lines (83 loc) · 2.23 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
#!/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 == "darwin"* ]]; then
echo "macOS Detected"
path="/Users/`whoami`/Downloads"
platform="macos"
else
echo "Not supported"
exit
fi
cd "$path/blobs"
model=$1
ip=$2
mainbdid=`cat mainbdid`
buildid=`cat extbdid`
echo "Build ID: $mainbdid"
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"