-
Notifications
You must be signed in to change notification settings - Fork 54
/
installsubstrate.sh
executable file
·116 lines (103 loc) · 4.62 KB
/
installsubstrate.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
#!/usr/bin/env bash
set -e
if [ "$EUID" -ne 0 ]
then
echo "Error: This script must be run as root"
exit 1
fi
if [[ -z $1 ]]
then
echo "Error: Substrate type must be specified\n"
echo "If you target iOS 12+ (of Xcode 10+), you must run the following:\n"
echo "\tsudo ./installsubstrate.sh subst\n"
echo "This will install Substitute\n"
echo "Otherwise, you can run:\n"
echo "\tsudo ./installsubstrate.sh cs\n"
echo "This will install cycript's CydiaSubstrate\n"
echo "If you only want to symlink CydiaSubstrate.framework to new iOS runtimes, you can run:\n"
echo "\tsudo ./installsubstrate.sh link\n"
exit 1
fi
SJ_RUNTIME_ROOT_PREFIX=/Library/Developer/CoreSimulator/Profiles/Runtimes
SJ_RUNTIME_ROOT_10=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
SJ_RUNTIME_ROOT_10_BETA=/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
SJ_RUNTIME_ROOT_11=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
SJ_RUNTIME_ROOT_11_BETA=/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
SJ_FW_PATH=/opt/simject/Frameworks
mkdir -p ${SJ_FW_PATH}
cd ${SJ_FW_PATH}
if [[ $1 = "link" ]]
then
if [[ ! -d CydiaSubstrate.framework ]]
then
echo "Error: CydiaSubstrate.framework not found in ${SJ_FW_PATH}"
exit 1
fi
elif [[ $1 = "subst" ]]
then
echo "Installing Substitute..."
rm -rf substitute CydiaSubstrate.framework
git clone https://github.com/PoomSmart/substitute.git
cd substitute/
./configure --xcode-sdk=iphonesimulator --xcode-archs=$(uname -m) && make
mv out/libsubstitute.dylib out/CydiaSubstrate
codesign -f -s - out/CydiaSubstrate
mkdir -p ../CydiaSubstrate.framework
mv out/CydiaSubstrate ../CydiaSubstrate.framework/CydiaSubstrate
cd .. && rm -rf substitute
elif [[ $1 = "cs" ]]
then
echo "Installing CydiaSubstrate..."
rm -rf CydiaSubstrate.framework
curl -Lo /tmp/simject_cycript.zip https://cache.saurik.com/cycript/mac/cycript_0.9.594.zip
unzip /tmp/simject_cycript.zip -d /tmp/simject_cycript
mkdir -p CydiaSubstrate.framework
mv /tmp/simject_cycript/Cycript.lib/libsubstrate.dylib CydiaSubstrate.framework/CydiaSubstrate
rm -rf /tmp/simject_cycript /tmp/simject_cycript.zip
else
echo "Error: Unrecognized substrate type (${1}), exiting"
exit 1
fi
echo "Symlink CydiaSubstrate.framework for all installed iOS runtimes..."
if [[ -d "${SJ_RUNTIME_ROOT_10}" ]]
then
echo "Symlink to ${SJ_RUNTIME_ROOT_10}"
mkdir -p "${SJ_RUNTIME_ROOT_10}/Library/Frameworks"
rm -rf "${SJ_RUNTIME_ROOT_10}/Library/Frameworks/CydiaSubstrate.framework"
ln -s ${SJ_FW_PATH}/CydiaSubstrate.framework "${SJ_RUNTIME_ROOT_10}/Library/Frameworks/"
fi
if [[ -d "${SJ_RUNTIME_ROOT_10_BETA}" ]]
then
echo "Symlink to ${SJ_RUNTIME_ROOT_10_BETA}"
mkdir -p "${SJ_RUNTIME_ROOT_10_BETA}/Library/Frameworks"
rm -rf "${SJ_RUNTIME_ROOT_10_BETA}/Library/Frameworks/CydiaSubstrate.framework"
ln -s ${SJ_FW_PATH}/CydiaSubstrate.framework "${SJ_RUNTIME_ROOT_10_BETA}/Library/Frameworks/"
fi
if [[ -d "${SJ_RUNTIME_ROOT_11}" ]]
then
echo "Symlink to ${SJ_RUNTIME_ROOT_11}"
mkdir -p "${SJ_RUNTIME_ROOT_11}/Library/Frameworks"
rm -rf "${SJ_RUNTIME_ROOT_11}/Library/Frameworks/CydiaSubstrate.framework"
ln -s ${SJ_FW_PATH}/CydiaSubstrate.framework "${SJ_RUNTIME_ROOT_11}/Library/Frameworks/"
fi
if [[ -d "${SJ_RUNTIME_ROOT_11_BETA}" ]]
then
echo "Symlink to ${SJ_RUNTIME_ROOT_11_BETA}"
mkdir -p "${SJ_RUNTIME_ROOT_11_BETA}/Library/Frameworks"
rm -rf "${SJ_RUNTIME_ROOT_11_BETA}/Library/Frameworks/CydiaSubstrate.framework"
ln -s ${SJ_FW_PATH}/CydiaSubstrate.framework "${SJ_RUNTIME_ROOT_11_BETA}/Library/Frameworks/"
fi
if [[ -d "${SJ_RUNTIME_ROOT_PREFIX}" ]]
then
OIFS="$IFS"
IFS=$'\n'
for SJ_runtime in $(find ${SJ_RUNTIME_ROOT_PREFIX} -type d -maxdepth 1 -name "*.simruntime")
do
echo "Symlink to ${SJ_runtime}"
mkdir -p "${SJ_runtime}/Contents/Resources/RuntimeRoot/Library/Frameworks"
rm -rf "${SJ_runtime}/Contents/Resources/RuntimeRoot/Library/Frameworks/CydiaSubstrate.framework"
ln -s ${SJ_FW_PATH}/CydiaSubstrate.framework "${SJ_runtime}/Contents/Resources/RuntimeRoot/Library/Frameworks/"
done
IFS="$OIFS"
fi
cd ..