Files
palera1n/palera1n.sh
T

1095 lines
35 KiB
Bash
Raw Normal View History

2022-09-19 08:09:14 -04:00
#!/usr/bin/env bash
2022-10-08 21:00:46 -04:00
2023-01-22 06:22:18 +02:00
pushd $(dirname "$0") &> /dev/null
2022-10-03 16:16:06 -04:00
mkdir -p logs
2022-12-14 14:54:34 -05:00
set -e
log="$(date +%T)"-"$(date +%F)"-"$(uname)"-"$(uname -r)".log
cd logs
touch "$log"
cd ..
2022-11-13 20:02:17 -05:00
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-17 08:34:50 -04:00
# Variables
# =========
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
2023-01-22 06:22:18 +02:00
network_timeout=-1 # seconds; -1 - unlimited
2022-12-18 15:49:03 -05:00
version="1.4.1"
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-11-18 03:00:43 +08:00
max_args=1
arg_count=0
2022-11-20 19:41:35 -05:00
disk=8
2022-12-12 16:34:36 -05:00
fs=disk0s1s$disk
2022-09-17 08:34:50 -04:00
# =========
2022-09-17 08:34:50 -04:00
# Functions
# =========
2022-11-20 03:35:53 +08:00
remote_cmd() {
2022-12-18 21:02:25 -05:00
"$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p6413 root@localhost "$@"
2022-11-20 03:35:53 +08:00
}
2022-12-11 18:37:02 -05:00
2022-11-20 03:35:53 +08:00
remote_cp() {
2022-12-18 21:02:25 -05:00
"$dir"/sshpass -p 'alpine' scp -o StrictHostKeyChecking=no -P6413 $@
2022-11-20 03:35:53 +08:00
}
2022-09-17 08:34:50 -04:00
step() {
2022-11-29 14:02:40 +01:00
for i in $(seq "$1" -1 0); do
if [ "$(get_device_mode)" = "dfu" ]; then
break
fi
printf '\r\e[K\e[1;36m%s (%d)' "$2" "$i"
2022-09-17 08:34:50 -04:00
sleep 1
done
2022-11-29 14:02:40 +01:00
printf '\e[0m\n'
2022-09-17 08:34:50 -04:00
}
2022-11-18 03:00:43 +08:00
print_help() {
cat << EOF
Usage: $0 [Options] [ subcommand | iOS version ]
2023-01-24 13:11:20 +01:00
iOS 15.0-16.3 jailbreak tool for checkm8 devices
2022-11-18 03:00:43 +08:00
Options:
--help Print this help
--tweaks Enable tweaks
--semi-tethered When used with --tweaks, make the jailbreak semi-tethered instead of tethered
--dfuhelper A helper to help get A11 devices into DFU mode from recovery mode
--skip-fakefs Don't create the fakefs even if --semi-tethered is specified
2022-11-19 21:42:09 +08:00
--no-baseband Indicate that the device does not have a baseband
2022-11-19 19:21:36 +08:00
--restorerootfs Remove the jailbreak (Actually more than restore rootfs)
2022-11-18 03:00:43 +08:00
--debug Debug the script
2023-02-01 00:00:12 +08:00
--china Enable Mainland China specific workarounds (启用对中国大陆网络环境的替代办法)
2022-12-12 16:34:36 -05:00
--serial Enable serial output on the device (only needed for testing with a serial cable)
2022-11-18 03:00:43 +08:00
Subcommands:
dfuhelper An alias for --dfuhelper
clean Deletes the created boot files
The iOS version argument should be the iOS version of your device.
It is required when starting from DFU mode.
EOF
}
parse_opt() {
case "$1" in
--)
no_more_opts=1
;;
--tweaks)
tweaks=1
;;
--semi-tethered)
semi_tethered=1
;;
--dfuhelper)
dfuhelper=1
;;
--skip-fakefs)
skip_fakefs=1
;;
--no-baseband)
2022-11-19 21:42:09 +08:00
no_baseband=1
2022-11-18 03:00:43 +08:00
;;
2022-12-12 16:34:36 -05:00
--serial)
serial=1
2022-11-18 03:00:43 +08:00
;;
--dfu)
2022-11-20 03:35:53 +08:00
echo "[!] DFU mode devices are now automatically detected and --dfu is deprecated"
2022-11-18 03:00:43 +08:00
;;
--restorerootfs)
restorerootfs=1
;;
2023-02-01 00:00:12 +08:00
--china)
china=1
;;
2022-11-18 03:00:43 +08:00
--debug)
debug=1
;;
--help)
print_help
exit 0
;;
*)
echo "[-] Unknown option $1. Use $0 --help for help."
exit 1;
esac
}
parse_arg() {
arg_count=$((arg_count + 1))
2022-11-18 03:00:43 +08:00
case "$1" in
dfuhelper)
dfuhelper=1
;;
clean)
clean=1
;;
*)
version="$1"
;;
esac
}
parse_cmdline() {
for arg in $@; do
if [[ "$arg" == --* ]] && [ -z "$no_more_opts" ]; then
parse_opt "$arg";
elif [ "$arg_count" -lt "$max_args" ]; then
parse_arg "$arg";
else
echo "[-] Too many arguments. Use $0 --help for help.";
exit 1;
fi
done
}
2022-11-20 03:35:53 +08:00
recovery_fix_auto_boot() {
if [ "$tweaks" = "1" ]; then
"$dir"/irecovery -c "setenv auto-boot false"
"$dir"/irecovery -c "saveenv"
2022-09-17 10:22:48 -04:00
else
2022-11-20 03:35:53 +08:00
"$dir"/irecovery -c "setenv auto-boot true"
"$dir"/irecovery -c "saveenv"
fi
if [ "$semi_tethered" = "1" ]; then
"$dir"/irecovery -c "setenv auto-boot true"
"$dir"/irecovery -c "saveenv"
2022-09-17 08:34:50 -04:00
fi
}
_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
sleep 2
2022-11-13 14:52:03 -05:00
#"$dir"/gaster reset
#sleep 1
fi
}
2022-11-13 17:04:07 -05:00
_reset() {
2022-12-12 16:34:36 -05:00
echo "[*] Resetting DFU state"
"$dir"/gaster reset
2022-11-13 17:04:07 -05:00
}
2022-11-20 03:35:53 +08:00
get_device_mode() {
if [ "$os" = "Darwin" ]; then
2022-11-29 14:01:15 -05:00
apples="$(system_profiler SPUSBDataType 2> /dev/null | grep -B1 'Vendor ID: 0x05ac' | grep 'Product ID:' | cut -dx -f2 | cut -d' ' -f1 | tail -r)"
2022-11-20 03:35:53 +08:00
elif [ "$os" = "Linux" ]; then
2022-12-12 16:34:36 -05:00
apples="$(lsusb | cut -d' ' -f6 | grep '05ac:' | cut -d: -f2)"
2022-11-20 03:35:53 +08:00
fi
local device_count=0
local usbserials=""
for apple in $apples; do
case "$apple" in
2022-12-01 05:11:29 +09:00
12a8|12aa|12ab)
2022-11-20 03:35:53 +08:00
device_mode=normal
device_count=$((device_count+1))
;;
1281)
device_mode=recovery
device_count=$((device_count+1))
;;
1227)
device_mode=dfu
device_count=$((device_count+1))
;;
1222)
device_mode=diag
device_count=$((device_count+1))
;;
1338)
device_mode=checkra1n_stage2
device_count=$((device_count+1))
;;
4141)
device_mode=pongo
device_count=$((device_count+1))
;;
esac
done
if [ "$device_count" = "0" ]; then
device_mode=none
elif [ "$device_count" -ge "2" ]; then
echo "[-] Please attach only one device" > /dev/tty
kill -30 0
exit 1;
fi
if [ "$os" = "Linux" ]; then
usbserials=$(cat /sys/bus/usb/devices/*/serial)
elif [ "$os" = "Darwin" ]; then
2022-12-12 16:34:36 -05:00
usbserials=$(system_profiler SPUSBDataType 2> /dev/null | grep 'Serial Number' | cut -d: -f2- | sed 's/ //')
2022-11-20 03:35:53 +08:00
fi
2022-11-25 19:33:03 +08:00
if grep -qE '(ramdisk tool|SSHRD_Script) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{1,2} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}' <<< "$usbserials"; then
2022-11-20 03:35:53 +08:00
device_mode=ramdisk
fi
echo "$device_mode"
}
_wait() {
if [ "$(get_device_mode)" != "$1" ]; then
echo "[*] Waiting for device in $1 mode"
fi
while [ "$(get_device_mode)" != "$1" ]; do
sleep 1
done
if [ "$1" = 'recovery' ]; then
recovery_fix_auto_boot;
fi
}
2023-01-22 06:22:18 +02:00
dfuhelper_first_try=true
_dfuhelper() {
2022-11-20 03:35:53 +08:00
local step_one;
2022-11-22 00:04:07 +08:00
deviceid=$( [ -z "$deviceid" ] && _info normal ProductType || echo $deviceid )
2022-11-20 13:43:12 -05:00
if [[ "$1" = 0x801* && "$deviceid" != *"iPad"* ]]; then
2022-11-20 03:35:53 +08:00
step_one="Hold volume down + side button"
else
step_one="Hold home + power button"
fi
2023-01-22 06:22:18 +02:00
if $dfuhelper_first_try; then
echo "[*] Press any key when ready for DFU mode"
read -n 1 -s
dfuhelper_first_try=false
fi
step 3 "Get ready"
2022-11-20 03:35:53 +08:00
step 4 "$step_one" &
sleep 3
2022-12-12 16:34:36 -05:00
"$dir"/irecovery -c "reset" &
2022-11-29 14:02:40 +01:00
wait
2022-11-20 13:43:12 -05:00
if [[ "$1" = 0x801* && "$deviceid" != *"iPad"* ]]; then
2023-01-22 13:40:03 -05:00
step 10 'Release side button, but keep holding volume down'
2022-11-20 13:43:12 -05:00
else
2023-01-22 13:40:03 -05:00
step 10 'Release power button, but keep holding home button'
2022-11-20 13:43:12 -05:00
fi
sleep 1
2022-11-20 03:35:53 +08:00
if [ "$(get_device_mode)" = "dfu" ]; then
echo "[*] Device entered DFU!"
2023-01-22 06:22:18 +02:00
dfuhelper_first_try=true
2022-11-20 03:35:53 +08:00
else
2023-01-22 06:22:18 +02:00
echo "[-] Device did not enter DFU mode"
2022-11-22 00:04:07 +08:00
return -1
2022-11-20 03:35:53 +08:00
fi
}
2023-01-22 06:22:18 +02:00
function _wait_for() {
timeout=$1
shift 1
until [ $timeout -eq 0 ] || ("$@" &> /dev/null); do
sleep 1
timeout=$(( timeout - 1 ))
done
if [ $timeout -eq 0 ]; then
return -1
fi
}
function _network() {
ping -q -c 1 -W 1 static.palera.in &>/dev/null
}
function _check_network_connection() {
if ! _network; then
echo "[*] Waiting for network"
if ! _wait_for $network_timeout _network; then
echo "[-] Network is unreachable. Check your connection and try again"
exit 1
fi
fi
}
2022-09-27 21:33:46 -04:00
_kill_if_running() {
if (pgrep -u root -x "$1" &> /dev/null > /dev/null); then
2022-09-27 21:33:46 -04:00
# yes, it's running as root. kill it
2023-01-22 06:22:18 +02:00
sudo killall $1 &> /dev/null
2022-09-27 21:33:46 -04:00
else
if (pgrep -x "$1" &> /dev/null > /dev/null); then
2023-01-22 06:22:18 +02:00
killall $1 &> /dev/null
2022-09-27 21:33:46 -04:00
fi
fi
}
_exit_handler() {
[ $? -eq 0 ] && exit
echo "[-] An error occurred"
2022-10-03 16:16:06 -04:00
if [ -d "logs" ]; then
cd logs
2022-12-14 14:54:34 -05:00
mv "$log" FAIL_${log}
cd ..
fi
2022-10-03 16:16:06 -04:00
2022-12-12 16:34:36 -05:00
echo "[*] A failure log has been made. If you're going ask for help, please attach the latest log."
}
trap _exit_handler EXIT
2022-09-27 15:22:11 -04:00
# ===========
# Fixes
# ===========
2023-01-22 06:22:18 +02:00
# ============
# Start
# ============
echo "palera1n | Version $version-$branch-$commit"
2023-01-21 23:24:17 -05:00
echo "Made with ❤ by Nebula, Mineek, Nathan, llsc12, Ploosh, and Nick Chan"
2023-01-22 06:22:18 +02:00
echo ""
version=""
parse_cmdline "$@"
if [ "$debug" = "1" ]; then
set -o xtrace
fi
# ============
# Dependencies
# ============
2022-11-25 19:33:03 +08:00
# Check for required commands
if [ "$os" = 'Linux' ]; then
linux_cmds='lsusb'
fi
for cmd in curl unzip python3 git ssh scp killall sudo grep pgrep ${linux_cmds}; do
if ! command -v "${cmd}" > /dev/null; then
echo "[-] Command '${cmd}' not installed, please install it!";
cmd_not_found=1
fi
done
if [ "$cmd_not_found" = "1" ]; then
exit 1
fi
# 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
if [ ! -e "$dir"/gaster ]; then
2023-01-22 06:22:18 +02:00
echo '[-] gaster not installed. Press any key to install it, or press ctrl + c to cancel'
read -n 1 -s
_check_network_connection
2022-12-22 20:25:01 -05:00
curl -sLO https://static.palera.in/deps/gaster-"$os".zip
2022-10-05 20:03:05 -04:00
unzip gaster-"$os".zip
mv gaster "$dir"/
rm -rf gaster gaster-"$os".zip
fi
# Check for pyimg4
2022-11-15 19:09:23 -05:00
if ! python3 -c 'import pkgutil; exit(not pkgutil.find_loader("pyimg4"))'; then
echo '[-] pyimg4 not installed. Press any key to install it, or press ctrl + c to cancel'
read -n 1 -s
2023-01-22 06:22:18 +02:00
_check_network_connection
2022-11-15 19:09:23 -05:00
python3 -m pip install pyimg4
fi
# ============
# Prep
# ============
# Update submodules
2023-02-01 00:00:12 +08:00
if [ "$china" != "1" ]; then
git submodule update --init --recursive
elif ! [ -f ramdisk/sshrd.sh ]; then
curl -LO https://static.palera.in/deps/ramdisk.tgz
tar xf ramdisk.tgz
fi
# 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
2022-11-18 03:00:43 +08:00
if [ "$clean" = "1" ]; then
rm -rf boot* work .tweaksinstalled
echo "[*] Removed the created boot files"
exit
fi
2022-11-18 03:00:43 +08:00
if [ -z "$tweaks" ] && [ "$semi_tethered" = "1" ]; then
echo "[!] --semi-tethered may not be used with rootless"
echo " Rootless is already semi-tethered"
2022-11-25 19:33:03 +08:00
>&2 echo "Hint: to use tweaks on semi-tethered, specify the --tweaks option"
2022-11-18 03:00:43 +08:00
exit 1;
fi
2022-11-19 19:21:36 +08:00
if [ "$tweaks" = 1 ] && [ ! -e ".tweaksinstalled" ] && [ ! -e ".disclaimeragree" ] && [ -z "$semi_tethered" ] && [ -z "$restorerootfs" ]; 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."
2023-01-24 13:12:53 +01:00
echo "THIS WORKS ON 15.0-16.3"
2022-12-12 16:34:36 -05:00
echo "DO NOT GET ANGRY AT US IF YOUR 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-12-12 16:34:36 -05:00
echo "[-] Please type it exactly if you'd like to proceed. Otherwise, remove --tweaks, or add --semi-tethered"
exit
2022-10-03 17:55:40 +02:00
fi
else
2022-12-12 16:34:36 -05:00
echo "[-] Please type it exactly if you'd like to proceed. Otherwise, remove --tweaks, or add --semi-tethered"
exit
2022-10-03 17:55:40 +02:00
fi
fi
2023-01-22 06:22:18 +02:00
function _wait_for_device() {
# Get device's iOS version from ideviceinfo if in normal mode
echo "[*] Waiting for devices"
while [ "$(get_device_mode)" = "none" ]; do
sleep 1;
done
echo $(echo "[*] Detected $(get_device_mode) mode device" | sed 's/dfu/DFU/')
2022-11-20 03:35:53 +08:00
2023-01-22 06:22:18 +02:00
if grep -E 'pongo|checkra1n_stage2|diag' <<< "$(get_device_mode)"; then
echo "[-] Detected device in unsupported mode '$(get_device_mode)'"
exit 1;
fi
2022-11-20 03:35:53 +08:00
2023-01-22 06:22:18 +02:00
if [ "$(get_device_mode)" != "normal" ] && [ -z "$version" ] && [ "$dfuhelper" != "1" ]; then
echo "[-] You must pass the version your device is on when not starting from normal mode"
exit
fi
if [ "$(get_device_mode)" = "ramdisk" ]; then
# If a device is in ramdisk mode, perhaps iproxy is still running?
_kill_if_running iproxy
echo "[*] Rebooting device in SSH Ramdisk"
if [ "$os" = 'Linux' ]; then
sudo "$dir"/iproxy 6413 22 &
else
"$dir"/iproxy 6413 22 &
fi
sleep 2
remote_cmd "/usr/sbin/nvram auto-boot=false"
remote_cmd "/sbin/reboot"
_kill_if_running iproxy
_wait recovery
fi
if [ "$(get_device_mode)" = "normal" ]; then
version=${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..."
"$dir"/ideviceenterrecovery $(_info normal UniqueDeviceID)
_wait recovery
fi
# Grab more info
echo "[*] Getting device info..."
cpid=$(_info recovery CPID)
model=$(_info recovery MODEL)
deviceid=$(_info recovery PRODUCT)
if (( 0x8020 <= cpid )) && (( cpid < 0x8720 )); then
echo "[-] palera1n doesn't, and never will, work on non-checkm8 devices"
exit
fi
2023-01-22 06:22:18 +02:00
if [ "$dfuhelper" = "1" ]; then
echo "[*] Running DFU helper"
_dfuhelper "$cpid" || {
echo "[-] Failed to enter DFU mode, trying again"
sleep 3
_wait_for_device
}
exit
fi
2023-01-22 06:22:18 +02:00
if [ ! "$ipsw" = "" ]; then
ipswurl=$ipsw
2022-11-18 14:07:26 -05:00
else
2023-01-22 06:22:18 +02:00
#buildid=$(curl -sL https://api.ipsw.me/v4/ipsw/$version | "$dir"/jq '.[0] | .buildid' --raw-output)
if [[ "$deviceid" == *"iPad"* ]]; then
device_os=iPadOS
device=iPad
elif [[ "$deviceid" == *"iPod"* ]]; then
device_os=iOS
device=iPod
else
device_os=iOS
device=iPhone
fi
_check_network_connection
buildid=$(curl -sL https://api.ipsw.me/v4/ipsw/$version | "$dir"/jq '[.[] | select(.identifier | startswith("'$device'")) | .buildid][0]' --raw-output)
if [ "$buildid" == "19B75" ]; then
buildid=19B74
fi
ipswurl=$(curl -sL https://api.appledb.dev/ios/$device_os\;$buildid.json | "$dir"/jq -r .devices\[\"$deviceid\"\].ipsw)
2022-11-18 14:07:26 -05:00
fi
2022-11-18 22:10:17 -05:00
2023-01-22 06:22:18 +02:00
if [ "$restorerootfs" = "1" ]; then
rm -rf "blobs/"$deviceid"-"$version".der" "boot-$deviceid" work .tweaksinstalled ".fs-$deviceid"
2022-11-18 22:16:36 -05:00
fi
2023-01-22 06:22:18 +02:00
# Have the user put the device into DFU
if [ "$(get_device_mode)" != "dfu" ]; then
recovery_fix_auto_boot;
_dfuhelper "$cpid" || {
echo "[-] Failed to enter DFU mode, trying again"
sleep 3
_wait_for_device
}
fi
sleep 2
}
_wait_for_device
# ============
# Ramdisk
# ============
2022-11-18 03:00:43 +08:00
# Dump blobs, and install pogo if needed
2022-12-12 16:34:36 -05:00
if [ -f blobs/"$deviceid"-"$version".der ]; then
if [ -f .rd_in_progress ]; then
rm blobs/"$deviceid"-"$version".der
fi
fi
if [ ! -f blobs/"$deviceid"-"$version".der ]; then
mkdir -p blobs
2022-12-12 16:34:36 -05:00
_kill_if_running iproxy
2022-11-07 10:43:29 -05:00
cd ramdisk
chmod +x sshrd.sh
echo "[*] Creating ramdisk"
2022-12-12 16:34:36 -05:00
./sshrd.sh `if [[ "$version" == *"16"* ]]; then echo "16.0.3"; else echo "15.6"; fi` `if [ -z "$tweaks" ]; then echo "rootless"; fi`
2022-09-24 16:11:33 -04:00
echo "[*] Booting ramdisk"
2022-10-05 20:03:05 -04:00
./sshrd.sh boot
cd ..
2022-11-22 00:04:07 +08:00
# remove special lines from known_hosts
2022-10-03 17:55:40 +02:00
if [ -f ~/.ssh/known_hosts ]; then
2022-11-22 00:04:07 +08:00
if [ "$os" = "Darwin" ]; then
sed -i.bak '/localhost/d' ~/.ssh/known_hosts
sed -i.bak '/127\.0\.0\.1/d' ~/.ssh/known_hosts
elif [ "$os" = "Linux" ]; then
sed -i '/localhost/d' ~/.ssh/known_hosts
sed -i '/127\.0\.0\.1/d' ~/.ssh/known_hosts
fi
2022-10-03 17:55:40 +02:00
fi
# Execute the commands once the rd is booted
2022-09-29 13:18:36 -04:00
if [ "$os" = 'Linux' ]; then
2022-12-18 21:02:25 -05:00
sudo "$dir"/iproxy 6413 22 &
2022-09-29 13:16:59 -04:00
else
2022-12-18 21:02:25 -05:00
"$dir"/iproxy 6413 22 &
2022-09-29 13:16:59 -04:00
fi
2022-11-20 12:35:58 +01:00
while ! (remote_cmd "echo connected" &> /dev/null); do
sleep 1
done
2022-11-25 19:33:03 +08:00
2022-12-12 16:34:36 -05:00
touch .rd_in_progress
if [ "$tweaks" = "1" ]; then
echo "[*] Testing for baseband presence"
2022-12-17 18:00:29 -05:00
if [ "$(remote_cmd "/usr/bin/mgask HasBaseband | grep -E 'true|false'")" = "true" ] && [[ "${cpid}" == *"0x700"* ]]; then
2022-11-20 19:41:35 -05:00
disk=7
2022-12-12 16:34:36 -05:00
elif [ "$(remote_cmd "/usr/bin/mgask HasBaseband | grep -E 'true|false'")" = "false" ]; then
2022-12-17 18:00:29 -05:00
if [[ "${cpid}" == *"0x700"* ]]; then
2022-12-12 16:34:36 -05:00
disk=6
else
disk=7
fi
fi
if [ -z "$semi_tethered" ]; then
disk=1
fi
if [[ "$version" == *"16"* ]]; then
fs=disk1s$disk
else
fs=disk0s1s$disk
2022-11-20 19:41:35 -05:00
fi
2022-12-12 20:06:00 -05:00
echo "$disk" > .fs-"$deviceid"
2022-11-19 18:15:49 +08:00
fi
2022-12-12 16:34:36 -05:00
# mount filesystems, no user data partition
remote_cmd "/usr/bin/mount_filesystems_nouser"
2022-11-19 19:21:36 +08:00
2022-11-20 03:35:53 +08:00
has_active=$(remote_cmd "ls /mnt6/active" 2> /dev/null)
2022-11-19 19:21:36 +08:00
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"
2022-12-18 21:02:25 -05:00
echo " ssh root@localhost -p 6413"
2022-11-19 19:21:36 +08:00
exit
fi
2022-11-20 03:35:53 +08:00
active=$(remote_cmd "cat /mnt6/active" 2> /dev/null)
2022-11-19 19:21:36 +08:00
if [ "$restorerootfs" = "1" ]; then
echo "[*] Removing Jailbreak"
2022-12-13 18:03:26 -05:00
if [ ! "$fs" = "disk1s1" ] || [ ! "$fs" = "disk0s1s1" ]; then
remote_cmd "/sbin/apfs_deletefs $fs > /dev/null || true"
fi
2022-11-20 03:35:53 +08:00
remote_cmd "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-12-12 16:34:36 -05:00
remote_cmd "mv /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcache.bak /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcache || true"
2022-11-20 03:35:53 +08:00
remote_cmd "/bin/sync"
remote_cmd "/usr/sbin/nvram auto-boot=true"
2022-11-19 19:21:36 +08:00
rm -f BuildManifest.plist
echo "[*] Done! Rebooting your device (if it doesn't reboot, you may force reboot)"
2022-11-20 03:35:53 +08:00
remote_cmd "/sbin/reboot"
2022-11-19 19:21:36 +08:00
exit;
fi
2022-12-12 16:34:36 -05:00
echo "[*] Dumping apticket"
2022-09-19 08:09:14 -04:00
sleep 1
2022-12-12 16:34:36 -05:00
remote_cp root@localhost:/mnt6/$active/System/Library/Caches/apticket.der blobs/"$deviceid"-"$version".der
#remote_cmd "cat /dev/rdisk1" | dd of=dump.raw bs=256 count=$((0x4000))
#"$dir"/img4tool --convert -s blobs/"$deviceid"-"$version".shsh2 dump.raw
#rm dump.raw
2022-10-05 19:17:57 -04:00
2022-11-18 03:00:43 +08:00
if [ "$semi_tethered" = "1" ]; then
if [ -z "$skip_fakefs" ]; then
2022-11-15 12:52:20 -05:00
echo "[*] Creating fakefs, this may take a while (up to 10 minutes)"
remote_cmd "/sbin/newfs_apfs -A -D -o role=r -v Xystem /dev/disk0s1" && {
2022-12-13 18:03:26 -05:00
sleep 2
remote_cmd "/sbin/mount_apfs /dev/$fs /mnt8"
sleep 1
remote_cmd "cp -a /mnt1/. /mnt8/"
sleep 1
echo "[*] fakefs created, continuing..."
2022-11-22 00:04:07 +08:00
} || echo "[*] Using the old fakefs, run restorerootfs if you need to clean it"
2022-11-14 20:17:32 -05:00
fi
2022-11-11 18:37:24 -05:00
fi
2022-11-20 03:35:53 +08:00
#remote_cmd "/usr/sbin/nvram allow-root-hash-mismatch=1"
#remote_cmd "/usr/sbin/nvram root-live-fs=1"
2022-12-12 16:34:36 -05:00
if [ "$tweaks" = "1" ]; then
if [ "$semi_tethered" = "1" ]; then
remote_cmd "/usr/sbin/nvram auto-boot=true"
else
remote_cmd "/usr/sbin/nvram auto-boot=false"
fi
2022-11-09 09:21:49 -05:00
else
2022-12-12 16:34:36 -05:00
remote_cmd "/usr/sbin/nvram auto-boot=true"
2022-10-03 17:55:40 +02:00
fi
2022-11-07 10:43:29 -05:00
2022-11-14 10:02:25 +08:00
# lets actually patch the kernel
echo "[*] Patching the kernel"
2022-12-12 16:34:36 -05:00
remote_cmd "rm -f /mnt6/$active/kpf"
if [[ "$version" == *"16"* ]]; then
remote_cp binaries/Kernel16Patcher.ios root@localhost:/mnt6/$active/kpf
2022-11-19 15:41:28 -05:00
else
2022-12-12 16:34:36 -05:00
remote_cp binaries/Kernel15Patcher.ios root@localhost:/mnt6/$active/kpf
fi
remote_cmd "/usr/sbin/chown 0 /mnt6/$active/kpf"
remote_cmd "/bin/chmod 755 /mnt6/$active/kpf"
remote_cmd "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"
if [ "$tweaks" = "1" ]; then
if [ "$semi_tethered" = "1" ]; then
remote_cmd "cp /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcache /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcache.bak"
else
remote_cmd "mv /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcache /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcache.bak || true"
2022-12-12 16:34:36 -05:00
fi
2022-11-19 15:41:28 -05:00
fi
2022-11-14 10:02:25 +08:00
sleep 1
2022-11-19 15:41:28 -05:00
2023-01-22 06:22:18 +02:00
# Checking network connection before downloads
_check_network_connection
2022-11-14 10:02:25 +08:00
# download the kernel
echo "[*] Downloading BuildManifest"
"$dir"/pzb -g BuildManifest.plist "$ipswurl"
2022-11-19 15:41:28 -05:00
2022-11-14 10:02:25 +08:00
echo "[*] Downloading kernelcache"
2022-11-15 16:45:09 -06:00
"$dir"/pzb -g "$(awk "/""$model""/{x=1}x&&/kernelcache.release/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" "$ipswurl"
2022-11-19 15:41:28 -05:00
2022-12-12 16:34:36 -05:00
echo "[*] Patching kernelcache"
2022-11-14 10:02:25 +08:00
mv kernelcache.release.* work/kernelcache
2022-11-20 13:43:12 -05:00
if [[ "$deviceid" == "iPhone8"* ]] || [[ "$deviceid" == "iPad6"* ]] || [[ "$deviceid" == *'iPad5'* ]]; then
2022-11-15 19:09:23 -05:00
python3 -m pyimg4 im4p extract -i work/kernelcache -o work/kcache.raw --extra work/kpp.bin
2022-11-14 10:02:25 +08:00
else
2022-11-15 19:09:23 -05:00
python3 -m pyimg4 im4p extract -i work/kernelcache -o work/kcache.raw
2022-11-14 10:02:25 +08:00
fi
sleep 1
2022-11-20 03:35:53 +08:00
remote_cp work/kcache.raw root@localhost:/mnt6/$active/System/Library/Caches/com.apple.kernelcaches/
2022-12-12 16:34:36 -05:00
remote_cmd "/mnt6/$active/kpf /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.raw /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.patched"
2022-11-20 03:35:53 +08:00
remote_cp root@localhost:/mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kcache.patched work/
2022-12-12 16:34:36 -05:00
if [ "$tweaks" = "1" ]; then
if [[ "$version" == *"16"* ]]; then
2022-12-15 18:31:27 -05:00
"$dir"/Kernel64Patcher work/kcache.patched work/kcache.patched2 -e -o -u -l -t -h -d
2022-12-12 16:34:36 -05:00
else
"$dir"/Kernel64Patcher work/kcache.patched work/kcache.patched2 -e -l
2022-12-12 16:34:36 -05:00
fi
else
"$dir"/Kernel64Patcher work/kcache.patched work/kcache.patched2 -a
fi
2022-11-14 10:02:25 +08:00
sleep 1
if [[ "$deviceid" == *'iPhone8'* ]] || [[ "$deviceid" == *'iPad6'* ]] || [[ "$deviceid" == *'iPad5'* ]]; then
2022-11-15 19:09:23 -05:00
python3 -m pyimg4 im4p create -i work/kcache.patched2 -o work/kcache.im4p -f krnl --extra work/kpp.bin --lzss
else
2022-11-15 19:09:23 -05:00
python3 -m pyimg4 im4p create -i work/kcache.patched2 -o work/kcache.im4p -f krnl --lzss
2022-11-14 10:02:25 +08:00
fi
sleep 1
2022-11-20 03:35:53 +08:00
remote_cp work/kcache.im4p root@localhost:/mnt6/$active/System/Library/Caches/com.apple.kernelcaches/
remote_cmd "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"
remote_cmd "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-14 10:02:25 +08:00
sleep 1
2022-11-20 03:35:53 +08:00
has_kernelcachd=$(remote_cmd "ls /mnt6/$active/System/Library/Caches/com.apple.kernelcaches/kernelcachd" 2> /dev/null)
2022-11-14 10:02:25 +08:00
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-12-12 16:34:36 -05:00
if [ "$tweaks" = "1" ]; then
sleep 1
if [ "$semi_tethered" = "1" ]; then
remote_cmd "/sbin/mount_apfs /dev/$fs /mnt8 || true"
di=8
else
disk=1
di=1
fi
if [[ "$version" == *"16"* ]]; then
remote_cmd "rm -rf /mnt$di/System/Library/Caches/com.apple.dyld"
2022-12-12 16:34:36 -05:00
remote_cmd "ln -s /System/Cryptexes/OS/System/Library/Caches/com.apple.dyld /mnt$di/System/Library/Caches/"
fi
# iOS 16 stuff
# if [[ "$version" == *"16"* ]]; then
# if [ -z "$semi_tethered" ]; then
# echo "[*] Performing iOS 16 fixes"
# sleep 1
# os_disk=$(remote_cmd "/usr/sbin/hdik /mnt6/cryptex1/current/os.dmg | head -3 | tail -1 | sed 's/ .*//'")
# sleep 1
# app_disk=$(remote_cmd "/usr/sbin/hdik /mnt6/cryptex1/current/app.dmg | head -3 | tail -1 | sed 's/ .*//'")
# sleep 1
# remote_cmd "/sbin/mount_apfs -o ro $os_disk /mnt2"
# sleep 1
# remote_cmd "/sbin/mount_apfs -o ro $app_disk /mnt9"
# sleep 1
# remote_cmd "rm -rf /mnt1/System/Cryptexes/App /mnt1/System/Cryptexes/OS"
# sleep 1
# remote_cmd "mkdir /mnt1/System/Cryptexes/App /mnt1/System/Cryptexes/OS"
# sleep 1
# remote_cmd "cp -a /mnt9/. /mnt1/System/Cryptexes/App"
# sleep 1
# remote_cmd "cp -a /mnt2/. /mnt1/System/Cryptexes/OS"
# sleep 1
# remote_cmd "rm -rf /mnt1/System/Cryptexes/OS/System/Library/Caches/com.apple.dyld"
# sleep 1
# remote_cmd "cp -a /mnt2/System/Library/Caches/com.apple.dyld /mnt1/System/Library/Caches/"
# fi
# fi
echo "[*] Copying files to rootfs"
remote_cmd "rm -rf /mnt$di/jbin /mnt$di/.installed_palera1n"
sleep 1
remote_cmd "mkdir -p /mnt$di/jbin/binpack /mnt$di/jbin/loader.app"
sleep 1
2023-01-22 06:22:18 +02:00
# Checking network connection before downloads
_check_network_connection
2022-12-12 16:34:36 -05:00
# download loader
cd other/rootfs/jbin
rm -rf loader.app
2023-01-22 06:22:18 +02:00
echo "[*] Downloading loader"
2022-12-22 20:25:01 -05:00
curl -LO https://static.palera.in/deps/loader.zip
2022-12-22 20:36:29 -05:00
unzip loader.zip -d .
2022-12-12 16:34:36 -05:00
unzip palera1n.ipa -d .
mv Payload/palera1nLoader.app loader.app
rm -rf palera1n.zip loader.zip palera1n.ipa Payload
# download jbinit files
rm -f jb.dylib jbinit jbloader launchd
2023-01-22 06:22:18 +02:00
echo "[*] Downloading jbinit files"
2022-12-22 20:25:01 -05:00
curl -L https://static.palera.in/deps/rootfs.zip -o rfs.zip
2022-12-12 16:34:36 -05:00
unzip rfs.zip -d .
unzip rootfs.zip -d .
rm rfs.zip rootfs.zip
cd ../../..
2022-12-18 15:05:31 -05:00
# download binpack
mkdir -p other/rootfs/jbin/binpack
2023-01-22 06:22:18 +02:00
echo "[*] Downloading binpack"
2022-12-18 15:05:31 -05:00
curl -L https://static.palera.in/binpack.tar -o other/rootfs/jbin/binpack/binpack.tar
2022-12-12 16:34:36 -05:00
sleep 1
remote_cp -r other/rootfs/* root@localhost:/mnt$di
{
echo "{"
echo " \"version\": \"${version} (${commit}_${branch})\","
echo " \"args\": \"$@\","
echo " \"pc\": \"$(uname) $(uname -r)\""
echo "}"
} > work/.installed_palera1n
sleep 1
remote_cp work/.installed_palera1n root@localhost:/mnt$di
remote_cmd "ldid -s /mnt$di/jbin/launchd /mnt$di/jbin/jbloader /mnt$di/jbin/jb.dylib"
remote_cmd "chmod +rwx /mnt$di/jbin/launchd /mnt$di/jbin/jbloader /mnt$di/jbin/post.sh"
remote_cmd "tar -xvf /mnt$di/jbin/binpack/binpack.tar -C /mnt$di/jbin/binpack/"
sleep 1
remote_cmd "rm /mnt$di/jbin/binpack/binpack.tar"
fi
rm -rf work BuildManifest.plist
2022-11-14 10:02:25 +08:00
mkdir work
2022-12-12 16:34:36 -05:00
rm .rd_in_progress
2022-11-14 10:02:25 +08:00
sleep 2
2022-12-12 16:34:36 -05:00
echo "[*] Phase 1 done! Rebooting your device (if it doesn't reboot, you may force reboot)"
2022-11-20 03:35:53 +08:00
remote_cmd "/sbin/reboot"
sleep 1
2022-09-29 13:16:59 -04:00
_kill_if_running iproxy
2022-11-18 03:00:43 +08:00
if [ "$semi_tethered" = "1" ]; then
2022-11-14 09:52:57 -05:00
_wait normal
2022-11-14 10:51:39 -05:00
sleep 5
2022-11-14 09:52:57 -05:00
echo "[*] Switching device into recovery mode..."
"$dir"/ideviceenterrecovery $(_info normal UniqueDeviceID)
2022-11-18 03:00:43 +08:00
elif [ -z "$tweaks" ]; then
2022-10-05 19:17:57 -04:00
_wait normal
2022-11-14 10:51:39 -05:00
sleep 5
2022-10-05 19:17:57 -04:00
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
fi
2022-11-14 09:52:57 -05:00
_wait recovery
2023-01-22 06:22:18 +02:00
_dfuhelper "$cpid" || {
echo "[-] Failed to enter DFU mode, trying again"
sleep 3
_wait_for_device
}
sleep 2
fi
# ============
# Boot create
# ============
# Actually create the boot files
2022-12-12 16:34:36 -05:00
disk=$(cat .fs-"$deviceid")
if [[ "$version" == *"16"* ]]; then
fs=disk1s$disk
else
fs=disk0s1s$disk
fi
boot_args=""
if [ "$serial" = "1" ]; then
boot_args="serial=3"
else
boot_args="-v"
fi
2022-12-18 15:49:03 -05:00
if [[ "$deviceid" == iPhone9,[1-4] ]] || [[ "$deviceid" == "iPhone10,"* ]]; then
2022-12-12 16:34:36 -05:00
if [ ! -f boot-"$deviceid"/.payload ]; then
rm -rf boot-"$deviceid"
fi
else
if [ ! -f boot-"$deviceid"/.local ]; then
rm -rf boot-"$deviceid"
fi
2022-11-07 11:00:24 -05:00
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"
mkdir boot-"$deviceid"
2022-12-12 16:34:36 -05:00
#echo "[*] Converting blob"
#"$dir"/img4tool -e -s $(pwd)/blobs/"$deviceid"-"$version".shsh2 -m work/IM4M
2022-09-17 08:34:50 -04:00
cd work
2023-01-22 06:22:18 +02:00
# Checking network connection before downloads
_check_network_connection
2022-12-18 15:49:03 -05:00
# Do payload if on iPhone 7-X
if [[ "$deviceid" == iPhone9,[1-4] ]] || [[ "$deviceid" == "iPhone10,"* ]]; then
2022-12-12 16:34:36 -05:00
if [[ "$version" == "16.0"* ]] || [[ "$version" == "15"* ]]; then
newipswurl="$ipswurl"
2022-11-14 20:17:32 -05:00
else
2022-12-12 16:34:36 -05:00
buildid=$(curl -sL https://api.ipsw.me/v4/ipsw/16.0.3 | "$dir"/jq '[.[] | select(.identifier | startswith("'iPhone'")) | .buildid][0]' --raw-output)
newipswurl=$(curl -sL https://api.appledb.dev/ios/iOS\;$buildid.json | "$dir"/jq -r .devices\[\"$deviceid\"\].ipsw)
2022-11-14 20:17:32 -05:00
fi
2022-11-07 11:00:24 -05:00
2022-12-12 16:34:36 -05:00
echo "[*] Downloading BuildManifest"
"$dir"/pzb -g BuildManifest.plist "$newipswurl"
echo "[*] Downloading and decrypting iBoot"
"$dir"/pzb -g "$(awk "/""$model""/{x=1}x&&/iBoot[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" "$newipswurl"
"$dir"/gaster decrypt "$(awk "/""$model""/{x=1}x&&/iBoot[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1 | sed 's/Firmware[/]all_flash[/]//')" ibot.dec
echo "[*] Patching and signing iBoot"
"$dir"/iBoot64Patcher ibot.dec ibot.patched
if [[ "$deviceid" == iPhone9,[1-4] ]]; then
"$dir"/iBootpatch2 --t8010 ibot.patched ibot.patched2
else
"$dir"/iBootpatch2 --t8015 ibot.patched ibot.patched2
fi
if [ "$os" = 'Linux' ]; then
sed -i 's/\/\kernelcache/\/\kernelcachd/g' ibot.patched2
else
LC_ALL=C sed -i.bak -e 's/s\/\kernelcache/s\/\kernelcachd/g' ibot.patched2
rm *.bak
fi
cd ..
"$dir"/img4 -i work/ibot.patched2 -o boot-"$deviceid"/ibot.img4 -M blobs/"$deviceid"-"$version".der -A -T ibss
touch boot-"$deviceid"/.payload
else
echo "[*] Downloading BuildManifest"
"$dir"/pzb -g BuildManifest.plist "$ipswurl"
echo "[*] Downloading and decrypting iBSS"
"$dir"/pzb -g "$(awk "/""$model""/{x=1}x&&/iBSS[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" "$ipswurl"
"$dir"/gaster decrypt "$(awk "/""$model""/{x=1}x&&/iBSS[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1 | sed 's/Firmware[/]dfu[/]//')" iBSS.dec
echo "[*] Downloading and decrypting iBoot"
"$dir"/pzb -g "$(awk "/""$model""/{x=1}x&&/iBoot[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1)" "$ipswurl"
"$dir"/gaster decrypt "$(awk "/""$model""/{x=1}x&&/iBoot[.]/{print;exit}" BuildManifest.plist | grep '<string>' | cut -d\> -f2 | cut -d\< -f1 | sed 's/Firmware[/]all_flash[/]//')" ibot.dec
echo "[*] Patching and signing iBSS/iBoot"
"$dir"/iBoot64Patcher iBSS.dec iBSS.patched
if [ "$semi_tethered" = "1" ]; then
if [ "$serial" = "1" ]; then
"$dir"/iBoot64Patcher ibot.dec ibot.patched -b "serial=3 rd=$fs" -l
else
"$dir"/iBoot64Patcher ibot.dec ibot.patched -b "-v rd=$fs" -l
fi
else
if [ "$serial" = "1" ]; then
"$dir"/iBoot64Patcher ibot.dec ibot.patched -b "serial=3" -f
else
"$dir"/iBoot64Patcher ibot.dec ibot.patched -b "-v" -f
fi
fi
if [ "$os" = 'Linux' ]; then
sed -i 's/\/\kernelcache/\/\kernelcachd/g' ibot.patched
else
LC_ALL=C sed -i.bak -e 's/s\/\kernelcache/s\/\kernelcachd/g' ibot.patched
rm *.bak
fi
cd ..
"$dir"/img4 -i work/iBSS.patched -o boot-"$deviceid"/iBSS.img4 -M blobs/"$deviceid"-"$version".der -A -T ibss
"$dir"/img4 -i work/ibot.patched -o boot-"$deviceid"/ibot.img4 -M blobs/"$deviceid"-"$version".der -A -T `if [[ "$cpid" == *"0x801"* ]]; then echo "ibss"; else echo "ibec"; fi`
touch boot-"$deviceid"/.local
fi
2022-09-17 08:34:50 -04:00
fi
# ============
# Boot device
# ============
2022-09-18 14:13:02 -04:00
sleep 2
_pwn
2022-11-13 17:04:07 -05:00
_reset
2022-09-19 08:09:14 -04:00
echo "[*] Booting device"
2022-12-18 15:49:03 -05:00
if [[ "$deviceid" == iPhone9,[1-4] ]] || [[ "$deviceid" == "iPhone10,"* ]]; then
2022-11-13 20:02:17 -05:00
sleep 1
"$dir"/irecovery -f boot-"$deviceid"/ibot.img4
2022-12-12 16:34:36 -05:00
sleep 3
"$dir"/irecovery -c "dorwx"
sleep 2
if [[ "$deviceid" == iPhone9,[1-4] ]]; then
"$dir"/irecovery -f other/payload/payload_t8010.bin
else
"$dir"/irecovery -f other/payload/payload_t8015.bin
fi
sleep 3
"$dir"/irecovery -c "go"
2022-11-13 20:02:17 -05:00
sleep 1
2022-12-12 16:34:36 -05:00
"$dir"/irecovery -c "go xargs $boot_args"
sleep 1
"$dir"/irecovery -c "go xfb"
sleep 1
"$dir"/irecovery -c "go boot $fs"
2022-11-13 19:29:17 -05:00
else
2022-12-12 16:34:36 -05:00
if [[ "$cpid" == *"0x801"* ]]; then
sleep 1
"$dir"/irecovery -f boot-"$deviceid"/ibot.img4
else
sleep 1
"$dir"/irecovery -f boot-"$deviceid"/iBSS.img4
sleep 4
"$dir"/irecovery -f boot-"$deviceid"/ibot.img4
fi
2022-09-17 08:34:50 -04:00
2022-12-14 18:36:43 -05:00
if [ -z "$semi_tethered" ]; then
sleep 2
"$dir"/irecovery -c fsboot
fi
2022-11-28 21:50:30 -05:00
fi
if [ -d "logs" ]; then
cd logs
2022-12-14 14:54:34 -05:00
mv "$log" SUCCESS_${log}
cd ..
fi
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-12-12 17:13:36 -05:00
echo "When you unlock the device, it will respring about 30 seconds after"
echo "If this is your first time jailbreaking, open the new palera1n app, then press Install"
echo "Otherwise, press Do All in the settings section of the app"
echo "If you have any issues, please first check the common-issues.md document for common issues"
2023-02-01 00:00:12 +08:00
if [ "$china" != "1" ]; then
echo "If that list doesn't solve your issue, join the Discord server and ask for help: https://dsc.gg/palera1n"
fi
2022-10-16 16:40:48 +02:00
echo "Enjoy!"
2022-10-03 16:16:06 -04:00
2022-12-18 03:20:44 +01:00
} 2>&1 | tee logs/${log}
2023-01-22 06:22:18 +02:00
popd &> /dev/null