2022-09-19 08:09:14 -04:00
|
|
|
|
#!/usr/bin/env bash
|
2022-10-08 21:00:46 -04:00
|
|
|
|
|
2022-10-03 16:16:06 -04:00
|
|
|
|
mkdir -p logs
|
2022-10-05 19:21:09 -04:00
|
|
|
|
set -e
|
2022-11-13 15:39:21 -05:00
|
|
|
|
set -o xtrace
|
2022-10-03 16:16:06 -04:00
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2022-10-08 21:00:46 -04:00
|
|
|
|
echo "[*] Command ran:`if [ $EUID = 0 ]; then echo " sudo"; fi` ./palera1n.sh $@"
|
2022-10-06 07:49:56 -04:00
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
# =========
|
2022-09-17 08:34:50 -04:00
|
|
|
|
# Variables
|
2022-09-24 15:08:17 -04:00
|
|
|
|
# =========
|
2022-09-30 21:44:29 -04:00
|
|
|
|
ipsw="" # IF YOU WERE TOLD TO PUT A CUSTOM IPSW URL, PUT IT HERE. YOU CAN FIND THEM ON https://appledb.dev
|
2022-11-13 11:41:34 -05:00
|
|
|
|
version="1.3.0"
|
2022-09-17 08:34:50 -04:00
|
|
|
|
os=$(uname)
|
|
|
|
|
|
dir="$(pwd)/binaries/$os"
|
2022-10-03 16:16:06 -04:00
|
|
|
|
commit=$(git rev-parse --short HEAD)
|
2022-10-08 21:00:46 -04:00
|
|
|
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
2022-09-17 08:34:50 -04:00
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
# =========
|
2022-09-17 08:34:50 -04:00
|
|
|
|
# Functions
|
2022-09-24 15:08:17 -04:00
|
|
|
|
# =========
|
2022-09-17 08:34:50 -04:00
|
|
|
|
step() {
|
|
|
|
|
|
for i in $(seq "$1" -1 1); do
|
|
|
|
|
|
printf '\r\e[1;36m%s (%d) ' "$2" "$i"
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
done
|
|
|
|
|
|
printf '\r\e[0m%s (0)\n' "$2"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
_wait() {
|
|
|
|
|
|
if [ "$1" = 'normal' ]; then
|
|
|
|
|
|
if [ "$os" = 'Darwin' ]; then
|
|
|
|
|
|
if ! (system_profiler SPUSBDataType 2> /dev/null | grep 'Manufacturer: Apple Inc.' >> /dev/null); then
|
|
|
|
|
|
echo "[*] Waiting for device in normal mode"
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
while ! (system_profiler SPUSBDataType 2> /dev/null | grep 'Manufacturer: Apple Inc.' >> /dev/null); do
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
done
|
|
|
|
|
|
else
|
|
|
|
|
|
if ! (lsusb 2> /dev/null | grep ' Apple, Inc.' >> /dev/null); then
|
|
|
|
|
|
echo "[*] Waiting for device in normal mode"
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
while ! (lsusb 2> /dev/null | grep ' Apple, Inc.' >> /dev/null); do
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
done
|
2022-09-17 12:26:09 -04:00
|
|
|
|
fi
|
2022-09-24 15:08:17 -04:00
|
|
|
|
elif [ "$1" = 'recovery' ]; then
|
|
|
|
|
|
if [ "$os" = 'Darwin' ]; then
|
|
|
|
|
|
if ! (system_profiler SPUSBDataType 2> /dev/null | grep ' Apple Mobile Device (Recovery Mode):' >> /dev/null); then
|
|
|
|
|
|
echo "[*] Waiting for device to reconnect in recovery mode"
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
while ! (system_profiler SPUSBDataType 2> /dev/null | grep ' Apple Mobile Device (Recovery Mode):' >> /dev/null); do
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
done
|
|
|
|
|
|
else
|
2022-10-02 10:21:02 -04:00
|
|
|
|
if ! (lsusb 2> /dev/null | grep 'Recovery Mode' >> /dev/null); then
|
2022-09-24 15:08:17 -04:00
|
|
|
|
echo "[*] Waiting for device to reconnect in recovery mode"
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2022-10-02 10:21:02 -04:00
|
|
|
|
while ! (lsusb 2> /dev/null | grep 'Recovery Mode' >> /dev/null); do
|
2022-09-24 15:08:17 -04:00
|
|
|
|
sleep 1
|
|
|
|
|
|
done
|
|
|
|
|
|
fi
|
2022-10-08 21:00:46 -04:00
|
|
|
|
|
2022-11-07 10:43:29 -05:00
|
|
|
|
if [ "$1" = "--tweaks" ]; then
|
2022-10-08 21:00:46 -04:00
|
|
|
|
"$dir"/irecovery -c "setenv auto-boot false"
|
|
|
|
|
|
"$dir"/irecovery -c "saveenv"
|
|
|
|
|
|
else
|
2022-10-03 17:55:40 +02:00
|
|
|
|
"$dir"/irecovery -c "setenv auto-boot true"
|
|
|
|
|
|
"$dir"/irecovery -c "saveenv"
|
|
|
|
|
|
fi
|
2022-11-07 14:32:03 -05:00
|
|
|
|
|
|
|
|
|
|
if [[ "$@" == *"--semi-tethered"* ]]; then
|
|
|
|
|
|
"$dir"/irecovery -c "setenv auto-boot true"
|
|
|
|
|
|
"$dir"/irecovery -c "saveenv"
|
|
|
|
|
|
fi
|
2022-09-17 12:26:09 -04:00
|
|
|
|
fi
|
2022-09-17 08:34:50 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
_check_dfu() {
|
2022-09-17 10:22:48 -04:00
|
|
|
|
if [ "$os" = 'Darwin' ]; then
|
|
|
|
|
|
if ! (system_profiler SPUSBDataType 2> /dev/null | grep ' Apple Mobile Device (DFU Mode):' >> /dev/null); then
|
2022-11-14 08:33:13 +13:00
|
|
|
|
echo "[-] Connected device is not in DFU mode, please rerun the script and try again"
|
2022-09-17 10:22:48 -04:00
|
|
|
|
exit
|
|
|
|
|
|
fi
|
|
|
|
|
|
else
|
2022-10-02 10:21:02 -04:00
|
|
|
|
if ! (lsusb 2> /dev/null | grep 'DFU Mode' >> /dev/null); then
|
2022-11-14 08:33:13 +13:00
|
|
|
|
echo "[-] Connected device is not in DFU mode, please rerun the script and try again"
|
2022-09-17 10:22:48 -04:00
|
|
|
|
exit
|
|
|
|
|
|
fi
|
2022-09-17 08:34:50 -04:00
|
|
|
|
fi
|
2022-09-24 15:08:17 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_info() {
|
|
|
|
|
|
if [ "$1" = 'recovery' ]; then
|
|
|
|
|
|
echo $("$dir"/irecovery -q | grep "$2" | sed "s/$2: //")
|
|
|
|
|
|
elif [ "$1" = 'normal' ]; then
|
|
|
|
|
|
echo $("$dir"/ideviceinfo | grep "$2: " | sed "s/$2: //")
|
|
|
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_pwn() {
|
|
|
|
|
|
pwnd=$(_info recovery PWND)
|
|
|
|
|
|
if [ "$pwnd" = "" ]; then
|
|
|
|
|
|
echo "[*] Pwning device"
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/gaster pwn
|
2022-09-24 15:08:17 -04:00
|
|
|
|
sleep 2
|
2022-11-13 14:52:03 -05:00
|
|
|
|
#"$dir"/gaster reset
|
|
|
|
|
|
#sleep 1
|
2022-09-24 15:08:17 -04:00
|
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-11-13 17:04:07 -05:00
|
|
|
|
_reset() {
|
|
|
|
|
|
echo "[*] Resetting DFU state"
|
|
|
|
|
|
"$dir"/gaster reset
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
_dfuhelper() {
|
|
|
|
|
|
echo "[*] Press any key when ready for DFU mode"
|
|
|
|
|
|
read -n 1 -s
|
|
|
|
|
|
step 3 "Get ready"
|
|
|
|
|
|
step 4 "Hold volume down + side button" &
|
|
|
|
|
|
sleep 3
|
|
|
|
|
|
"$dir"/irecovery -c "reset"
|
|
|
|
|
|
step 1 "Keep holding"
|
|
|
|
|
|
step 10 'Release side button, but keep holding volume down'
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
|
|
|
|
_check_dfu
|
2022-09-17 10:22:48 -04:00
|
|
|
|
echo "[*] Device entered DFU!"
|
2022-09-24 15:08:17 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-27 21:33:46 -04:00
|
|
|
|
_kill_if_running() {
|
|
|
|
|
|
if (pgrep -u root -xf "$1" &> /dev/null > /dev/null); then
|
|
|
|
|
|
# yes, it's running as root. kill it
|
|
|
|
|
|
sudo killall $1
|
|
|
|
|
|
else
|
|
|
|
|
|
if (pgrep -x "$1" &> /dev/null > /dev/null); then
|
|
|
|
|
|
killall $1
|
|
|
|
|
|
fi
|
|
|
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-05 19:27:06 -04:00
|
|
|
|
_beta_url() {
|
2022-10-08 15:53:39 -04:00
|
|
|
|
if [[ "$deviceid" == *"iPad"* ]]; then
|
2022-10-11 00:40:22 +02:00
|
|
|
|
json=$(curl -s 'https://api.appledb.dev/ios/iPadOS;19B5060d.json')
|
2022-10-08 15:53:39 -04:00
|
|
|
|
else
|
2022-10-11 00:40:22 +02:00
|
|
|
|
json=$(curl -s 'https://api.appledb.dev/ios/iOS;19B5060d.json')
|
2022-10-08 15:53:39 -04:00
|
|
|
|
fi
|
|
|
|
|
|
|
2022-10-05 19:27:06 -04:00
|
|
|
|
sources=$(echo "$json" | $dir/jq -r '.sources')
|
|
|
|
|
|
beta_url=$(echo "$sources" | $dir/jq -r --arg deviceid "$deviceid" '.[] | select(.type == "ota" and (.deviceMap | index($deviceid))) | .links[0].url')
|
|
|
|
|
|
echo "$beta_url"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
_exit_handler() {
|
|
|
|
|
|
if [ "$os" = 'Darwin' ]; then
|
|
|
|
|
|
if [ ! "$1" = '--dfu' ]; then
|
|
|
|
|
|
defaults write -g ignore-devices -bool false
|
|
|
|
|
|
defaults write com.apple.AMPDevicesAgent dontAutomaticallySyncIPods -bool false
|
|
|
|
|
|
killall Finder
|
|
|
|
|
|
fi
|
|
|
|
|
|
fi
|
|
|
|
|
|
[ $? -eq 0 ] && exit
|
|
|
|
|
|
echo "[-] An error occurred"
|
2022-10-03 16:16:06 -04:00
|
|
|
|
|
|
|
|
|
|
cd logs
|
|
|
|
|
|
for file in *.log; do
|
|
|
|
|
|
mv "$file" FAIL_${file}
|
|
|
|
|
|
done
|
|
|
|
|
|
cd ..
|
|
|
|
|
|
|
2022-10-05 19:27:06 -04:00
|
|
|
|
echo "[*] A failure log has been made. If you're going to make a GitHub issue, please attach the latest log."
|
2022-09-24 15:08:17 -04:00
|
|
|
|
}
|
|
|
|
|
|
trap _exit_handler EXIT
|
|
|
|
|
|
|
2022-09-27 15:22:11 -04:00
|
|
|
|
# ===========
|
|
|
|
|
|
# Fixes
|
|
|
|
|
|
# ===========
|
|
|
|
|
|
|
|
|
|
|
|
# Prevent Finder from complaning
|
|
|
|
|
|
if [ "$os" = 'Darwin' ]; then
|
|
|
|
|
|
defaults write -g ignore-devices -bool true
|
|
|
|
|
|
defaults write com.apple.AMPDevicesAgent dontAutomaticallySyncIPods -bool true
|
|
|
|
|
|
killall Finder
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
# ===========
|
|
|
|
|
|
# Subcommands
|
|
|
|
|
|
# ===========
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" = 'clean' ]; then
|
2022-10-08 21:00:46 -04:00
|
|
|
|
rm -rf boot* work .tweaksinstalled
|
2022-09-24 15:08:17 -04:00
|
|
|
|
echo "[*] Removed the created boot files"
|
|
|
|
|
|
exit
|
2022-10-04 14:19:50 -04:00
|
|
|
|
elif [ "$1" = 'dfuhelper' ]; then
|
|
|
|
|
|
echo "[*] Running DFU helper"
|
|
|
|
|
|
_dfuhelper
|
|
|
|
|
|
exit
|
2022-10-08 21:27:29 -04:00
|
|
|
|
elif [ "$1" = '--restorerootfs' ]; then
|
|
|
|
|
|
echo "[*] Restoring rootfs..."
|
|
|
|
|
|
"$dir"/irecovery -n
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
echo "[*] Done, your device will boot into iOS now."
|
|
|
|
|
|
# clean the boot files bcs we don't need them anymore
|
|
|
|
|
|
rm -rf boot-"$deviceid" work .tweaksinstalled
|
|
|
|
|
|
exit
|
2022-09-17 08:34:50 -04:00
|
|
|
|
fi
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
# ============
|
|
|
|
|
|
# Dependencies
|
|
|
|
|
|
# ============
|
|
|
|
|
|
|
|
|
|
|
|
# Download gaster
|
2022-10-20 18:14:04 -04:00
|
|
|
|
if [ -e "$dir"/gaster ]; then
|
2022-10-22 10:01:36 -04:00
|
|
|
|
"$dir"/gaster &> /dev/null > /dev/null | grep -q 'usb_timeout: 5' && rm "$dir"/gaster
|
2022-10-20 18:14:04 -04:00
|
|
|
|
fi
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
if [ ! -e "$dir"/gaster ]; then
|
2022-10-22 10:01:36 -04:00
|
|
|
|
curl -sLO https://nightly.link/palera1n/gaster/workflows/makefile/main/gaster-"$os".zip
|
2022-10-05 20:03:05 -04:00
|
|
|
|
unzip gaster-"$os".zip
|
2022-09-24 15:08:17 -04:00
|
|
|
|
mv gaster "$dir"/
|
|
|
|
|
|
rm -rf gaster gaster-"$os".zip
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Check for pyimg4
|
2022-11-13 15:52:38 -05:00
|
|
|
|
if ! python3 -c 'import pkgutil; exit(not pkgutil.find_loader("pyimg4"))'; then
|
2022-09-24 15:08:17 -04:00
|
|
|
|
echo '[-] pyimg4 not installed. Press any key to install it, or press ctrl + c to cancel'
|
|
|
|
|
|
read -n 1 -s
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pip install pyimg4
|
2022-09-24 15:08:17 -04:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# ============
|
|
|
|
|
|
# Prep
|
|
|
|
|
|
# ============
|
|
|
|
|
|
|
|
|
|
|
|
# Update submodules
|
2022-10-05 20:03:05 -04:00
|
|
|
|
git submodule update --init --recursive
|
2022-09-24 15:08:17 -04:00
|
|
|
|
|
|
|
|
|
|
# Re-create work dir if it exists, else, make it
|
|
|
|
|
|
if [ -e work ]; then
|
|
|
|
|
|
rm -rf work
|
|
|
|
|
|
mkdir work
|
|
|
|
|
|
else
|
|
|
|
|
|
mkdir work
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
chmod +x "$dir"/*
|
|
|
|
|
|
#if [ "$os" = 'Darwin' ]; then
|
|
|
|
|
|
# xattr -d com.apple.quarantine "$dir"/*
|
|
|
|
|
|
#fi
|
|
|
|
|
|
|
|
|
|
|
|
# ============
|
|
|
|
|
|
# Start
|
|
|
|
|
|
# ============
|
|
|
|
|
|
|
2022-10-08 21:00:46 -04:00
|
|
|
|
echo "palera1n | Version $version-$branch-$commit"
|
2022-10-03 16:16:06 -04:00
|
|
|
|
echo "Written by Nebula and Mineek | Some code and ramdisk from Nathan | Loader app by Amy"
|
2022-09-24 15:08:17 -04:00
|
|
|
|
echo ""
|
|
|
|
|
|
|
2022-11-12 15:28:38 -05:00
|
|
|
|
if [ ! "$1" = '--tweaks' ] && [[ "$@" == *"--semi-tethered"* ]]; then
|
|
|
|
|
|
echo "[!] --semi-tethered may not be used with rootless"
|
|
|
|
|
|
echo " Rootless is already semi-tethered"
|
|
|
|
|
|
exit
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2022-10-05 19:48:37 -04:00
|
|
|
|
if [ "$1" = '--tweaks' ]; then
|
2022-10-05 19:43:33 -04:00
|
|
|
|
_check_dfu
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2022-11-13 09:28:10 -05:00
|
|
|
|
if [ "$1" = '--tweaks' ] && [ ! -e ".tweaksinstalled" ] && [ ! -e ".disclaimeragree" ] && [[ ! "$@" == *"--semi-tethered"* ]]; then
|
2022-10-03 17:55:40 +02:00
|
|
|
|
echo "!!! WARNING WARNING WARNING !!!"
|
|
|
|
|
|
echo "This flag will add tweak support BUT WILL BE TETHERED."
|
|
|
|
|
|
echo "THIS ALSO MEANS THAT YOU'LL NEED A PC EVERY TIME TO BOOT."
|
2022-11-13 09:28:10 -05:00
|
|
|
|
echo "THIS ONLY WORKS ON 15.0-15.7.1"
|
2022-10-03 16:16:06 -04:00
|
|
|
|
echo "DO NOT GET ANGRY AT US IF UR DEVICE IS BORKED, IT'S YOUR OWN FAULT AND WE WARNED YOU"
|
2022-10-05 19:43:33 -04:00
|
|
|
|
echo "DO YOU UNDERSTAND? TYPE 'Yes, do as I say' TO CONTINUE"
|
2022-10-03 17:55:40 +02:00
|
|
|
|
read -r answer
|
2022-10-05 19:43:33 -04:00
|
|
|
|
if [ "$answer" = 'Yes, do as I say' ]; then
|
2022-10-05 19:48:37 -04:00
|
|
|
|
echo "Are you REALLY sure? WE WARNED YOU!"
|
|
|
|
|
|
echo "Type 'Yes, I am sure' to continue"
|
2022-10-03 17:55:40 +02:00
|
|
|
|
read -r answer
|
2022-10-05 19:48:37 -04:00
|
|
|
|
if [ "$answer" = 'Yes, I am sure' ]; then
|
2022-10-03 16:16:06 -04:00
|
|
|
|
echo "[*] Enabling tweaks"
|
2022-10-03 17:55:40 +02:00
|
|
|
|
tweaks=1
|
2022-10-05 19:43:33 -04:00
|
|
|
|
touch .disclaimeragree
|
2022-10-03 17:55:40 +02:00
|
|
|
|
else
|
2022-11-12 15:28:38 -05:00
|
|
|
|
exit
|
2022-10-03 17:55:40 +02:00
|
|
|
|
fi
|
|
|
|
|
|
else
|
2022-11-12 15:28:38 -05:00
|
|
|
|
exit
|
2022-10-03 17:55:40 +02:00
|
|
|
|
fi
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
# Get device's iOS version from ideviceinfo if in normal mode
|
2022-10-03 17:55:40 +02:00
|
|
|
|
if [ "$1" = '--dfu' ] || [ "$1" = '--tweaks' ]; then
|
2022-09-24 15:08:17 -04:00
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
|
|
echo "[-] When using --dfu, please pass the version you're device is on"
|
|
|
|
|
|
exit
|
|
|
|
|
|
else
|
|
|
|
|
|
version=$2
|
|
|
|
|
|
fi
|
|
|
|
|
|
else
|
|
|
|
|
|
_wait normal
|
|
|
|
|
|
version=$(_info normal ProductVersion)
|
|
|
|
|
|
arch=$(_info normal CPUArchitecture)
|
|
|
|
|
|
if [ "$arch" = "arm64e" ]; then
|
|
|
|
|
|
echo "[-] palera1n doesn't, and never will, work on non-checkm8 devices"
|
|
|
|
|
|
exit
|
|
|
|
|
|
fi
|
|
|
|
|
|
echo "Hello, $(_info normal ProductType) on $version!"
|
|
|
|
|
|
|
|
|
|
|
|
echo "[*] Switching device into recovery mode..."
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/ideviceenterrecovery $(_info normal UniqueDeviceID)
|
2022-09-24 15:08:17 -04:00
|
|
|
|
_wait recovery
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Grab more info
|
|
|
|
|
|
echo "[*] Getting device info..."
|
|
|
|
|
|
cpid=$(_info recovery CPID)
|
|
|
|
|
|
model=$(_info recovery MODEL)
|
|
|
|
|
|
deviceid=$(_info recovery PRODUCT)
|
2022-09-30 21:44:29 -04:00
|
|
|
|
if [ ! "$ipsw" = "" ]; then
|
|
|
|
|
|
ipswurl=$ipsw
|
2022-09-24 15:08:17 -04:00
|
|
|
|
else
|
|
|
|
|
|
ipswurl=$(curl -sL "https://api.ipsw.me/v4/device/$deviceid?type=ipsw" | "$dir"/jq '.firmwares | .[] | select(.version=="'"$version"'") | .url' --raw-output)
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Have the user put the device into DFU
|
2022-10-03 17:55:40 +02:00
|
|
|
|
if [ ! "$1" = '--dfu' ] && [ ! "$1" = '--tweaks' ]; then
|
2022-09-24 15:08:17 -04:00
|
|
|
|
_dfuhelper
|
|
|
|
|
|
fi
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
|
|
|
|
# ============
|
|
|
|
|
|
# Ramdisk
|
|
|
|
|
|
# ============
|
|
|
|
|
|
|
|
|
|
|
|
# Dump blobs, and install pogo if needed
|
|
|
|
|
|
if [ ! -f blobs/"$deviceid"-"$version".shsh2 ]; then
|
|
|
|
|
|
mkdir -p blobs
|
|
|
|
|
|
|
2022-11-07 10:43:29 -05:00
|
|
|
|
cd ramdisk
|
2022-09-24 15:08:17 -04:00
|
|
|
|
chmod +x sshrd.sh
|
|
|
|
|
|
echo "[*] Creating ramdisk"
|
2022-11-11 18:19:52 -05:00
|
|
|
|
./sshrd.sh 15.6.1 `if [ ! "$1" = '--tweaks' ]; then echo "rootless"; fi`
|
2022-09-24 16:11:33 -04:00
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
echo "[*] Booting ramdisk"
|
2022-10-05 20:03:05 -04:00
|
|
|
|
./sshrd.sh boot
|
2022-09-24 15:08:17 -04:00
|
|
|
|
cd ..
|
2022-10-03 17:55:40 +02:00
|
|
|
|
# if known hosts file exists, remove it
|
|
|
|
|
|
if [ -f ~/.ssh/known_hosts ]; then
|
|
|
|
|
|
rm ~/.ssh/known_hosts
|
|
|
|
|
|
fi
|
2022-09-24 15:08:17 -04:00
|
|
|
|
|
|
|
|
|
|
# Execute the commands once the rd is booted
|
2022-09-29 13:18:36 -04:00
|
|
|
|
if [ "$os" = 'Linux' ]; then
|
2022-10-05 20:05:42 -04:00
|
|
|
|
sudo "$dir"/iproxy 2222 22 &
|
2022-09-29 13:16:59 -04:00
|
|
|
|
else
|
2022-10-05 20:05:42 -04:00
|
|
|
|
"$dir"/iproxy 2222 22 &
|
2022-09-29 13:16:59 -04:00
|
|
|
|
fi
|
|
|
|
|
|
|
2022-10-05 20:03:05 -04:00
|
|
|
|
if ! ("$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "echo connected" &> /dev/null); then
|
2022-09-24 15:08:17 -04:00
|
|
|
|
echo "[*] Waiting for the ramdisk to finish booting"
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2022-10-05 20:03:05 -04:00
|
|
|
|
while ! ("$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "echo connected" &> /dev/null); do
|
2022-09-24 15:08:17 -04:00
|
|
|
|
sleep 1
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
echo "[*] Dumping blobs and installing Pogo"
|
2022-09-19 08:09:14 -04:00
|
|
|
|
sleep 1
|
2022-11-11 18:36:07 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/bin/mount_filesystems"
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "cat /dev/rdisk1" | dd of=dump.raw bs=256 count=$((0x4000))
|
|
|
|
|
|
"$dir"/img4tool --convert -s blobs/"$deviceid"-"$version".shsh2 dump.raw
|
2022-09-24 15:08:17 -04:00
|
|
|
|
rm dump.raw
|
2022-10-05 19:17:57 -04:00
|
|
|
|
|
2022-11-11 18:37:24 -05:00
|
|
|
|
if [[ "$@" == *"--semi-tethered"* ]]; then
|
2022-11-13 15:39:21 -05:00
|
|
|
|
echo "[*] Creating fakefs, this may take a while (up to 10 minutes)"
|
|
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/sbin/newfs_apfs -A -D -o role=r -v System /dev/disk0s1"
|
|
|
|
|
|
sleep 2
|
2022-11-13 19:29:17 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/sbin/mount_apfs /dev/disk0s1s7 /mnt8"
|
2022-11-13 15:39:21 -05:00
|
|
|
|
sleep 1
|
|
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "cp -a /mnt1/. /mnt8/"
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
echo "[*] fakefs created, continuing..."
|
2022-11-11 18:37:24 -05:00
|
|
|
|
fi
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
if [[ ! "$@" == *"--no-install"* ]]; then
|
2022-09-24 17:05:10 -04:00
|
|
|
|
tipsdir=$("$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/bin/find /mnt2/containers/Bundle/Application/ -name 'Tips.app'" 2> /dev/null)
|
2022-10-05 19:17:57 -04:00
|
|
|
|
sleep 1
|
2022-10-07 16:11:37 -04:00
|
|
|
|
if [ "$tipsdir" = "" ]; then
|
2022-11-07 10:43:29 -05:00
|
|
|
|
echo "[!] Tips is not installed. Once your device reboots, install Tips from the App Store and retry"
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/sbin/reboot"
|
2022-10-05 19:17:57 -04:00
|
|
|
|
sleep 1
|
|
|
|
|
|
_kill_if_running iproxy
|
|
|
|
|
|
exit
|
|
|
|
|
|
fi
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/bin/cp -rf /usr/local/bin/loader.app/* $tipsdir"
|
2022-10-05 19:17:57 -04:00
|
|
|
|
sleep 1
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/sbin/chown 33 $tipsdir/Tips"
|
2022-10-05 19:17:57 -04:00
|
|
|
|
sleep 1
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/bin/chmod 755 $tipsdir/Tips $tipsdir/PogoHelper"
|
2022-10-05 19:17:57 -04:00
|
|
|
|
sleep 1
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/sbin/chown 0 $tipsdir/PogoHelper"
|
2022-09-24 15:08:17 -04:00
|
|
|
|
fi
|
2022-10-05 19:17:57 -04:00
|
|
|
|
|
2022-10-03 17:55:40 +02:00
|
|
|
|
if [[ $1 == *"--tweaks"* ]]; then
|
2022-11-13 09:28:10 -05:00
|
|
|
|
#"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/sbin/nvram allow-root-hash-mismatch=1"
|
|
|
|
|
|
#"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/sbin/nvram root-live-fs=1"
|
|
|
|
|
|
if [[ "$@" == *"--semi-tethered"* ]]; then
|
|
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/sbin/nvram auto-boot=true"
|
|
|
|
|
|
else
|
2022-11-07 14:32:03 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/sbin/nvram auto-boot=false"
|
2022-11-07 10:43:29 -05:00
|
|
|
|
fi
|
2022-11-09 09:21:49 -05:00
|
|
|
|
|
|
|
|
|
|
has_active=$("$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "ls /mnt6/active" 2> /dev/null)
|
|
|
|
|
|
if [ ! "$has_active" = "/mnt6/active" ]; then
|
|
|
|
|
|
echo "[!] Active file does not exist! Please use SSH to create it"
|
|
|
|
|
|
echo " /mnt6/active should contain the name of the UUID in /mnt6"
|
|
|
|
|
|
echo " When done, type reboot in the SSH session, then rerun the script"
|
|
|
|
|
|
echo " ssh root@localhost -p 2222"
|
|
|
|
|
|
exit
|
|
|
|
|
|
fi
|
|
|
|
|
|
active=$("$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "cat /mnt6/active" 2> /dev/null)
|
|
|
|
|
|
|
2022-11-13 09:28:10 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' scp -o StrictHostKeyChecking=no -P2222 binaries/Kernel15Patcher.ios root@localhost:/mnt1/private/var/root/Kernel15Patcher.ios
|
|
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/sbin/chown 0 /mnt1/private/var/root/Kernel15Patcher.ios"
|
|
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/bin/chmod 755 /mnt1/private/var/root/Kernel15Patcher.ios"
|
2022-11-09 09:21:49 -05:00
|
|
|
|
|
2022-11-13 09:28:10 -05:00
|
|
|
|
# lets actually patch the kernel
|
|
|
|
|
|
echo "[*] Patching the kernel"
|
2022-11-13 09:55:10 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "rm -f /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.raw /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.patched /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.im4p /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcachd"
|
2022-11-13 09:28:10 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "cp /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcache /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcache.bak"
|
2022-11-13 13:46:47 -05:00
|
|
|
|
sleep 1
|
2022-11-13 16:22:23 +01:00
|
|
|
|
# download the kernel
|
|
|
|
|
|
echo "[*] Downloading BuildManifest"
|
|
|
|
|
|
"$dir"/pzb -g BuildManifest.plist "$ipswurl"
|
|
|
|
|
|
echo "[*] Downloading kernelcache"
|
|
|
|
|
|
"$dir"/pzb -g "$(awk "/""$cpid""/{x=1}x&&/kernelcache.release/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" "$ipswurl"
|
|
|
|
|
|
mv kernelcache.release.* work/kernelcache
|
2022-11-13 10:03:19 -05:00
|
|
|
|
if [[ "$deviceid" == "iPhone8"* ]] || [[ "$deviceid" == "iPad6"* ]]|| [[ "$deviceid" == *'iPad5'* ]]; then
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pyimg4 im4p extract -i work/kernelcache -o work/kcache.raw --extra work/kpp.bin
|
2022-11-13 10:03:19 -05:00
|
|
|
|
else
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pyimg4 im4p extract -i work/kernelcache -o work/kcache.raw
|
2022-11-13 10:03:19 -05:00
|
|
|
|
fi
|
2022-11-13 13:46:47 -05:00
|
|
|
|
sleep 1
|
2022-11-13 10:03:19 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' scp -o StrictHostKeyChecking=no -P2222 work/kcache.raw root@localhost:/mnt6/$active/System/Library/Caches/com.apple.kernelcaches/
|
2022-11-13 09:28:10 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/mnt1/private/var/root/Kernel15Patcher.ios /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.raw /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.patched"
|
|
|
|
|
|
"$dir"/sshpass -p 'alpine' scp -o StrictHostKeyChecking=no -P2222 root@localhost:/mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.patched work/
|
|
|
|
|
|
"$dir"/Kernel64Patcher work/kcache.patched work/kcache.patched2 -o -e -u
|
2022-11-13 13:46:47 -05:00
|
|
|
|
sleep 1
|
2022-11-13 16:22:23 +01:00
|
|
|
|
if [[ "$deviceid" == *'iPhone8'* ]] || [[ "$deviceid" == *'iPad6'* ]] || [[ "$deviceid" == *'iPad5'* ]]; then
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pyimg4 im4p create -i work/kcache.patched2 -o work/kcache.im4p -f krnl --extra work/kpp.bin --lzss
|
2022-11-13 10:56:37 -05:00
|
|
|
|
elif [[ $1 == *"--tweaks"* ]]; then
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pyimg4 im4p create -i work/kcache.patched2 -o work/kcache.im4p -f krnl --lzss
|
2022-11-13 10:03:19 -05:00
|
|
|
|
fi
|
2022-11-13 13:46:47 -05:00
|
|
|
|
sleep 1
|
2022-11-13 09:51:00 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' scp -o StrictHostKeyChecking=no -P2222 work/kcache.im4p root@localhost:/mnt6/$active/System/Library/Caches/com.apple.kernelcaches/
|
2022-11-13 10:03:19 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "img4 -i /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.im4p -o /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcachd -M /mnt6/$active/System/Library/Caches/apticket.der"
|
2022-11-13 09:55:10 -05:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "rm -f /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.raw /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.patched /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.im4p"
|
2022-11-09 09:21:49 -05:00
|
|
|
|
|
2022-11-13 13:46:47 -05:00
|
|
|
|
sleep 1
|
|
|
|
|
|
has_kernelcachd=$("$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "ls /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcachd" 2> /dev/null)
|
|
|
|
|
|
if [ "$has_kernelcachd" = "/mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcachd" ]; then
|
|
|
|
|
|
echo "[*] Custom kernelcache now exists!"
|
|
|
|
|
|
else
|
|
|
|
|
|
echo "[!] Custom kernelcache doesn't exist..? Please send a log and report this bug..."
|
|
|
|
|
|
fi
|
2022-11-13 14:52:03 -05:00
|
|
|
|
|
2022-11-09 09:21:49 -05:00
|
|
|
|
rm -rf work
|
|
|
|
|
|
mkdir work
|
|
|
|
|
|
else
|
|
|
|
|
|
cd work
|
|
|
|
|
|
echo "[*] Downloading BuildManifest"
|
|
|
|
|
|
"$dir"/pzb -g BuildManifest.plist "$ipswurl"
|
|
|
|
|
|
|
|
|
|
|
|
echo "[*] Getting apticket.der from device"
|
|
|
|
|
|
has_active=$("$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "ls /mnt6/active" 2> /dev/null)
|
|
|
|
|
|
if [ ! "$has_active" = "/mnt6/active" ]; then
|
|
|
|
|
|
echo "[!] Active file does not exist! Please use SSH to create it"
|
|
|
|
|
|
echo " /mnt6/active should contain the name of the UUID in /mnt6"
|
|
|
|
|
|
echo " When done, type reboot in the SSH session, then rerun the script"
|
|
|
|
|
|
echo " ssh root@localhost -p 2222"
|
|
|
|
|
|
exit
|
|
|
|
|
|
fi
|
|
|
|
|
|
active=$("$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "cat /mnt6/active" 2> /dev/null)
|
|
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "cat /mnt6/$active/System/Library/Caches/apticket.der" > apticket.der
|
|
|
|
|
|
|
|
|
|
|
|
echo "[*] Downloading kernelcache"
|
|
|
|
|
|
"$dir"/pzb -g "$(awk "/""$cpid""/{x=1}x&&/kernelcache.release/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" "$ipswurl"
|
|
|
|
|
|
|
|
|
|
|
|
echo "[*] Patching kernelcache"
|
|
|
|
|
|
cd ..
|
2022-11-13 10:03:19 -05:00
|
|
|
|
if [[ "$deviceid" == "iPhone8"* ]] || [[ "$deviceid" == "iPad6"* ]]|| [[ "$deviceid" == *'iPad5'* ]]; then
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pyimg4 im4p extract -i work/"$(awk "/""$model""/{x=1}x&&/kernelcache.release/{print;exit}" work/BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" -o work/kcache.raw --extra work/kpp.bin
|
2022-11-09 09:21:49 -05:00
|
|
|
|
else
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pyimg4 im4p extract -i work/"$(awk "/""$model""/{x=1}x&&/kernelcache.release/{print;exit}" work/BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" -o work/kcache.raw
|
2022-11-09 09:21:49 -05:00
|
|
|
|
fi
|
|
|
|
|
|
"$dir"/Kernel64Patcher work/kcache.raw work/kcache.patched -a -o
|
2022-11-09 16:38:10 -05:00
|
|
|
|
if [[ "$deviceid" == *'iPhone8'* ]] || [[ "$deviceid" == *'iPad6'* ]] || [[ "$deviceid" == *'iPad5'* ]] && [[ ! $1 == *"--tweaks"* ]]; then
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pyimg4 im4p create -i work/kcache.patched -o work/kcache.im4p -f krnl --extra work/kpp.bin --lzss
|
2022-11-09 09:21:49 -05:00
|
|
|
|
elif [[ ! $1 == *"--tweaks"* ]]; then
|
2022-11-13 15:52:38 -05:00
|
|
|
|
python3 -m pyimg4 im4p create -i work/kcache.patched -o work/kcache.im4p -f krnl --lzss
|
2022-11-09 09:21:49 -05:00
|
|
|
|
fi
|
2022-11-09 16:38:10 -05:00
|
|
|
|
"$dir"/img4 -i work/kcache.im4p -o work/kernelcache -M work/apticket.der `if [ "$os" = 'Linux' ]; then echo "-J"; fi`
|
2022-11-09 09:21:49 -05:00
|
|
|
|
|
|
|
|
|
|
echo "[*] Placing patched kernelcache"
|
|
|
|
|
|
cat work/kernelcache | "$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "cat > /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcachd"
|
|
|
|
|
|
|
|
|
|
|
|
rm -rf work
|
|
|
|
|
|
mkdir work
|
2022-10-03 17:55:40 +02:00
|
|
|
|
fi
|
2022-11-07 10:43:29 -05:00
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
sleep 2
|
2022-10-05 19:17:57 -04:00
|
|
|
|
echo "[*] Done! Rebooting your device"
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/sbin/reboot"
|
2022-09-24 15:08:17 -04:00
|
|
|
|
sleep 1
|
2022-09-29 13:16:59 -04:00
|
|
|
|
_kill_if_running iproxy
|
2022-09-24 15:08:17 -04:00
|
|
|
|
|
2022-10-05 19:17:57 -04:00
|
|
|
|
if [ "$1" = "--tweaks" ]; then
|
|
|
|
|
|
_wait recovery
|
|
|
|
|
|
else
|
2022-10-16 14:26:20 -04:00
|
|
|
|
sleep 5
|
2022-10-05 19:17:57 -04:00
|
|
|
|
_wait normal
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
|
2022-10-03 17:55:40 +02:00
|
|
|
|
echo "[*] Switching device into recovery mode..."
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/ideviceenterrecovery $(_info normal UniqueDeviceID)
|
2022-10-03 17:55:40 +02:00
|
|
|
|
_wait recovery
|
|
|
|
|
|
fi
|
|
|
|
|
|
sleep 10
|
2022-09-24 15:08:17 -04:00
|
|
|
|
_dfuhelper
|
|
|
|
|
|
sleep 2
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# ============
|
|
|
|
|
|
# Boot create
|
|
|
|
|
|
# ============
|
|
|
|
|
|
|
|
|
|
|
|
# Actually create the boot files
|
2022-11-07 11:00:24 -05:00
|
|
|
|
if [ ! -f boot-"$deviceid"/.fsboot ]; then
|
|
|
|
|
|
rm -rf boot-"$deviceid"
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
2022-11-09 16:38:10 -05:00
|
|
|
|
if [ ! -f boot-"$deviceid"/ibot.img4 ]; then
|
2022-09-17 08:34:50 -04:00
|
|
|
|
# Downloading files, and decrypting iBSS/iBEC
|
2022-11-07 11:00:24 -05:00
|
|
|
|
rm -rf boot-"$deviceid"
|
2022-09-18 17:18:19 -04:00
|
|
|
|
mkdir boot-"$deviceid"
|
2022-09-24 15:08:17 -04:00
|
|
|
|
|
|
|
|
|
|
echo "[*] Converting blob"
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/img4tool -e -s $(pwd)/blobs/"$deviceid"-"$version".shsh2 -m work/IM4M
|
2022-09-17 08:34:50 -04:00
|
|
|
|
cd work
|
|
|
|
|
|
|
2022-11-13 09:28:10 -05:00
|
|
|
|
echo "[*] Downloading BuildManifest"
|
|
|
|
|
|
"$dir"/pzb -g BuildManifest.plist "$ipswurl"
|
2022-10-08 15:12:11 -04:00
|
|
|
|
|
2022-11-13 09:28:10 -05:00
|
|
|
|
echo "[*] Downloading and decrypting iBSS"
|
|
|
|
|
|
"$dir"/pzb -g "$(awk "/""$cpid""/{x=1}x&&/iBSS[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" "$ipswurl"
|
|
|
|
|
|
"$dir"/gaster decrypt "$(awk "/""$cpid""/{x=1}x&&/iBSS[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1 | sed 's/Firmware[/]dfu[/]//')" iBSS.dec
|
2022-10-08 15:12:11 -04:00
|
|
|
|
|
2022-11-13 09:28:10 -05:00
|
|
|
|
echo "[*] Downloading and decrypting iBoot"
|
|
|
|
|
|
"$dir"/pzb -g "$(awk "/""$cpid""/{x=1}x&&/iBoot[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" "$ipswurl"
|
|
|
|
|
|
"$dir"/gaster decrypt "$(awk "/""$cpid""/{x=1}x&&/iBoot[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1 | sed 's/Firmware[/]all_flash[/]//')" ibot.dec
|
2022-10-03 18:19:55 -04:00
|
|
|
|
|
2022-11-09 16:38:10 -05:00
|
|
|
|
echo "[*] Patching and signing iBSS/iBoot"
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/iBoot64Patcher iBSS.dec iBSS.patched
|
2022-11-13 09:28:10 -05:00
|
|
|
|
if [[ "$@" == *"--semi-tethered"* ]]; then
|
2022-11-13 19:29:17 -05:00
|
|
|
|
"$dir"/iBoot64Patcherfsboot ibot.dec ibot.patched -b '-v keepsyms=1 debug=0x2014e rd=disk0s1s7'
|
2022-10-03 17:55:40 +02:00
|
|
|
|
else
|
2022-11-09 16:38:10 -05:00
|
|
|
|
"$dir"/iBoot64Patcherfsboot ibot.dec ibot.patched -b '-v keepsyms=1 debug=0x2014e'
|
2022-10-03 17:55:40 +02:00
|
|
|
|
fi
|
2022-11-07 10:54:39 -05:00
|
|
|
|
if [ "$os" = 'Linux' ]; then
|
2022-11-09 16:38:10 -05:00
|
|
|
|
sed -i 's/\/\kernelcache/\/\kernelcachd/g' ibot.patched
|
2022-11-07 10:54:39 -05:00
|
|
|
|
else
|
2022-11-09 16:38:10 -05:00
|
|
|
|
LC_ALL=C sed -i .bak -e 's/s\/\kernelcache/s\/\kernelcachd/g' ibot.patched
|
2022-11-07 10:54:39 -05:00
|
|
|
|
rm *.bak
|
|
|
|
|
|
fi
|
2022-09-17 08:34:50 -04:00
|
|
|
|
cd ..
|
2022-10-05 20:03:05 -04:00
|
|
|
|
"$dir"/img4 -i work/iBSS.patched -o boot-"$deviceid"/iBSS.img4 -M work/IM4M -A -T ibss
|
2022-11-13 19:29:17 -05:00
|
|
|
|
"$dir"/img4 -i work/ibot.patched -o boot-"$deviceid"/ibot.img4 -M work/IM4M -A -T `if [[ "$cpid" == *"0x80"* ]]; then echo "ibss"; else echo "ibec"; fi`
|
2022-11-07 11:00:24 -05:00
|
|
|
|
|
|
|
|
|
|
touch boot-"$deviceid"/.fsboot
|
2022-09-17 08:34:50 -04:00
|
|
|
|
fi
|
|
|
|
|
|
|
2022-09-24 15:08:17 -04:00
|
|
|
|
# ============
|
|
|
|
|
|
# Boot device
|
|
|
|
|
|
# ============
|
|
|
|
|
|
|
2022-09-18 14:13:02 -04:00
|
|
|
|
sleep 2
|
2022-09-24 15:08:17 -04:00
|
|
|
|
_pwn
|
2022-11-13 17:04:07 -05:00
|
|
|
|
_reset
|
2022-09-19 08:09:14 -04:00
|
|
|
|
echo "[*] Booting device"
|
2022-11-13 19:29:17 -05:00
|
|
|
|
if [[ "$cpid" == *"0x80"* ]]; then
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
"$dir"/irecovery -f boot-"$deviceid"/ibot.img4
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
"$dir"/irecovery -c fsboot
|
|
|
|
|
|
else
|
2022-11-13 17:10:55 -05:00
|
|
|
|
sleep 1
|
2022-10-23 09:43:51 -04:00
|
|
|
|
"$dir"/irecovery -f boot-"$deviceid"/iBSS.img4
|
|
|
|
|
|
sleep 1
|
2022-11-09 16:38:10 -05:00
|
|
|
|
"$dir"/irecovery -f boot-"$deviceid"/ibot.img4
|
2022-09-24 16:11:33 -04:00
|
|
|
|
sleep 1
|
2022-11-07 11:53:04 -05:00
|
|
|
|
"$dir"/irecovery -c fsboot
|
2022-11-13 19:29:17 -05:00
|
|
|
|
fi
|
2022-09-17 08:34:50 -04:00
|
|
|
|
|
2022-09-17 08:48:02 -04:00
|
|
|
|
if [ "$os" = 'Darwin' ]; then
|
2022-09-24 15:08:17 -04:00
|
|
|
|
if [ ! "$1" = '--dfu' ]; then
|
2022-09-17 11:04:13 -04:00
|
|
|
|
defaults write -g ignore-devices -bool false
|
|
|
|
|
|
defaults write com.apple.AMPDevicesAgent dontAutomaticallySyncIPods -bool false
|
|
|
|
|
|
killall Finder
|
|
|
|
|
|
fi
|
2022-09-17 08:48:02 -04:00
|
|
|
|
fi
|
2022-09-17 08:34:50 -04:00
|
|
|
|
|
2022-10-03 16:16:06 -04:00
|
|
|
|
cd logs
|
|
|
|
|
|
for file in *.log; do
|
|
|
|
|
|
mv "$file" SUCCESS_${file}
|
|
|
|
|
|
done
|
|
|
|
|
|
cd ..
|
2022-10-03 17:55:40 +02:00
|
|
|
|
|
2022-10-03 16:16:06 -04:00
|
|
|
|
rm -rf work rdwork
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
echo "Done!"
|
|
|
|
|
|
echo "The device should now boot to iOS"
|
2022-10-16 14:27:29 -04:00
|
|
|
|
echo "If this is your first time jailbreaking, open Tips app and then press Install"
|
2022-10-16 16:40:48 +02:00
|
|
|
|
echo "Otherwise, open Tips app and press Do All in the Tools section"
|
2022-10-16 14:27:29 -04:00
|
|
|
|
echo "If you have any issues, please join the Discord server and ask for help: https://dsc.gg/palera1n"
|
2022-10-16 16:40:48 +02:00
|
|
|
|
echo "Enjoy!"
|
2022-10-03 16:16:06 -04:00
|
|
|
|
|
|
|
|
|
|
} | tee logs/"$(date +%T)"-"$(date +%F)"-"$(uname)"-"$(uname -r)".log
|