Last active
June 18, 2023 09:23
-
-
Save Liam0205/e8850f0a66237b264c1a4da85587ca43 to your computer and use it in GitHub Desktop.
XinaminePatcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ! type dpkg-deb >/dev/null 2>&1; then | |
echo "Please install 'dpkg-deb'." | |
fi | |
if ! type file >/dev/null 2>&1; then | |
echo "Please install 'file' from Bingner or Procursus." | |
fi | |
if ! type otool >/dev/null 2>&1; then | |
echo "Please install 'odcctools'." | |
fi | |
if ! ldid 2>&1 | grep -q 'sha1\|sha2'; then | |
echo "Please install 'ldid' (must have -H option)." | |
fi | |
LDID="ldid -Hsha256" | |
OLD="$(mktemp -qd)" | |
NEW="$(mktemp -qd)" | |
if [ ! -d "$OLD" ] || [ ! -d "$NEW" ]; then | |
echo "Creating temporary directories failed." | |
exit 1; | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dpkg-deb -R "$1" "$OLD" | |
if [ -d "$OLD/var/jb" ]; then | |
echo "Deb already rootless. Skipping and exiting cleanly." | |
rm -rf "$OLD" "$NEW" | |
exit 0; | |
fi | |
mkdir -p "$NEW"/var/jb | |
cp -a "$OLD"/DEBIAN "$NEW" | |
sed 's|iphoneos-arm|iphoneos-arm64|' < "$OLD"/DEBIAN/control > "$NEW"/DEBIAN/control | |
chmod -R 755 "$NEW"/DEBIAN >/dev/null 2>&1 | |
chmod 644 "$NEW"/DEBIAN/control >/dev/null 2>&1 | |
rm -rf "$OLD"/DEBIAN | |
mv -f "$OLD"/.* "$OLD"/* "$NEW"/var/jb >/dev/null 2>&1 || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find "$NEW" -type f | while read -r file; do | |
if file -ib "$file" | grep -q "x-mach-binary; charset=binary"; then | |
INSTALL_NAME=$(otool -D "$file" | grep -v -e ":$" -e "^Archive :" | head -n1) | |
otool -L "$file" | tail -n +2 | grep -e /System | grep /Library/'[^/]'\*.dylib | cut -d' ' -f1 | tr -d "[:blank:]" > "$OLD"/._lib_cache | |
if [ -n "$INSTALL_NAME" ]; then | |
install_name_tool -id @rpath/"$(basename "$INSTALL_NAME")" "$file" >/dev/null 2>&1 | |
fi | |
if otool -L "$file" | grep -q CydiaSubstrate; then | |
install_name_tool -change /Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate @rpath/libsubstrate.dylib "$file" >/dev/null 2>&1 | |
fi | |
if [ -f "$OLD"/._lib_cache ]; then | |
cat "$OLD"/._lib_cache | while read line; do | |
install_name_tool -change "$line" @rpath/"$(basename "$line")" "$file" >/dev/null 2>&1 | |
done | |
fi | |
install_name_tool -add_rpath "/var/jb/Library/Frameworks" "$file" >/dev/null 2>&1 | |
install_name_tool -add_rpath "/var/jb/usr/lib" "$file" >/dev/null 2>&1 | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find "$NEW" -type f | while read -r file; do | |
if file -ib "$file" | grep -q "x-mach-binary; charset=binary"; then | |
sed -i 's#\x00/Library/MobileSub#\x00/var/LIY/MobileSub#g' "$file" | |
sed -i 's#\x00/Library/Sn#\x00/var/LIY/Sn#g' "$file" | |
sed -i 's#\x00/Library/Th#\x00/var/LIY/Th#g' "$file" | |
sed -i 's#\x00/Library/Application#\x00/var/LIY/Application#g' "$file" | |
sed -i 's#\x00/Library/LaunchD#\x00/var/LIY/LaunchD#g' "$file" | |
sed -i 's#\x00/Library/PreferenceB#\x00/var/LIY/PreferenceB#g' "$file" | |
sed -i 's#\x00/Library/PreferenceL#\x00/var/LIY/PreferenceL#g' "$file" | |
sed -i 's#\x00/Library/Frameworks#\x00/var/LIY/Frameworks#g' "$file" | |
sed -i 's#\x00/bin/sh#\x00/var/sh#g' "$file" | |
sed -i 's#\x00/usr/lib#\x00/var/lib#g' "$file" | |
sed -i 's#\x00/usr/bin#\x00/var/bin#g' "$file" | |
sed -i 's#\x00/var/mobile/Library/Preferences#\x00/var/jb/vmo/Library/Preferences#g' "$file" | |
sed -i 's#\x00/var/mobile/Library/Application#\x00/var/jb/vmo/Library/Application#g' "$file" | |
sed -i 's#view/Library/Application#view/var/LIY/Application#g' "$file" | |
sed -i 's#\x00/Applications#\x00/var/jb/Xapps#g' "$file" | |
sed -i 's#\x00/User/Library#\x00/var/jb/UsrLb#g' "$file" | |
#Revert Exceptions | |
sed -i 's#\x00/var/lib/libobjc.A.dylib#\x00/usr/lib/libobjc.A.dylib#g' "$file" | |
sed -i 's#\x00/var/lib/libc++.1.dylib#\x00/usr/lib/libc++.1.dylib#g' "$file" | |
sed -i 's#\x00/var/lib/libSystem.B.dylib#\x00/usr/lib/libSystem.B.dylib#g' "$file" | |
sed -i 's#\x00/var/lib/libstdc++.6.dylib#\x00/usr/lib/libstdc++.6.dylib#g' "$file" | |
sed -i 's#\x00/var/lib/libMobileGestalt.dylib#\x00/usr/lib/libMobileGestalt.dylib#g' "$file" | |
sed -i 's#\x00/var/lib/system/#\x00/usr/lib/system/#g' "$file" | |
sed -i 's#\x00/var/lib/dyld#\x00/usr/lib/dyld#g' "$file" | |
ldid -S "$file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment