From 5e6a75585366e1d0a375f83a3e215b8d0e948cde Mon Sep 17 00:00:00 2001 From: Nebula Date: Wed, 9 Nov 2022 09:21:49 -0500 Subject: [PATCH] add kernelcache back --- palera1n.sh | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/palera1n.sh b/palera1n.sh index 949aaa6..1b79483 100755 --- a/palera1n.sh +++ b/palera1n.sh @@ -417,6 +417,78 @@ if [ ! -f blobs/"$deviceid"-"$version".shsh2 ]; then if [[ ! "$@" == *"--semi-tethered"* ]]; then "$dir"/sshpass -p 'alpine' ssh -o StrictHostKeyChecking=no -p2222 root@localhost "/usr/sbin/nvram auto-boot=false" fi + + cd work + echo "[*] Downloading BuildManifest" + ipswurl=$(_beta_url) + "$dir"/pzb -g AssetData/boot/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 AssetData/boot/"$(awk "/""$cpid""/{x=1}x&&/kernelcache.release/{print;exit}" BuildManifest.plist | grep '' | cut -d\> -f2 | cut -d\< -f1 | sed 's/release/development/')" "$ipswurl" + + echo "[*] Patching kernelcache" + cd .. + modelwithoutap=$(echo "$model" | sed 's/ap//') + bpatchfile=$(find ../patches -name "$modelwithoutap".bpatch) + "$dir"/img4 -i work/kernelcache.development.* -o work/kernelcache -M work/apticket.der -T rkrn -P "$bpatchfile" `if [ "$os" = 'Linux' ]; then echo "-J"; fi` + + 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 + 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 '' | cut -d\> -f2 | cut -d\< -f1)" "$ipswurl" + + echo "[*] Patching kernelcache" + cd .. + if [[ "$deviceid" == "iPhone8"* ]] || [[ "$deviceid" == "iPad6"* ]] then + python3 -m pyimg4 im4p extract -i work/"$(awk "/""$model""/{x=1}x&&/kernelcache.release/{print;exit}" work/BuildManifest.plist | grep '' | cut -d\> -f2 | cut -d\< -f1)" -o work/kcache.raw --extra work/kpp.bin + else + python3 -m pyimg4 im4p extract -i work/"$(awk "/""$model""/{x=1}x&&/kernelcache.release/{print;exit}" work/BuildManifest.plist | grep '' | cut -d\> -f2 | cut -d\< -f1)" -o work/kcache.raw + fi + "$dir"/Kernel64Patcher work/kcache.raw work/kcache.patched -a -o + if [[ "$deviceid" == *'iPhone8'* ]] || [[ "$deviceid" == *'iPad6'* ]] && [[ ! $1 == *"--tweaks"* ]]; then + python3 -m pyimg4 im4p create -i work/kcache.patched -o work/kcache.im4p --extra work/kpp.bin -f rkrn --lzss + elif [[ ! $1 == *"--tweaks"* ]]; then + python3 -m pyimg4 im4p create -i work/kcache.patched -o work/kcache.im4p -f rkrn --lzss + fi + "$dir"/img4 -i work/kcache.im4p -o work/kernelcache -M work/apticket.der -T rkrn `if [ "$os" = 'Linux' ]; then echo "-J"; fi` + + 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 fi sleep 2