diff --git a/.gitignore b/.gitignore index 41a75f2..6b4d18f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ *.shsh2 iP*/ tmp/ -tools/ BuildManifest.plist +tools/futurerestore* +tools/tsschecker* diff --git a/README.md b/README.md index e7d6433..d4c7288 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,33 @@ # 841-OTA-Downgrader - Downgrade almost any 32-bit device to iOS 8.4.1 + Script that can be used to downgrade almost any 32-bit device to iOS 8.4.1 + +### Tools used by this script: +- cURL +- partialZipBrowser +- tsschecker +- bsdiff (bspatch) +- kloader +- futurerestore + +### Tested on: +- iPad3,3 + +### Supported devices: +- iPad2,1 +- iPad2,2 +- iPad2,3 +- iPad2,4 +- iPad2,5 +- iPad2,6 +- iPad2,7 +- iPad3,1 +- iPad3,2 +- iPad3,3 +- iPad3,4 +- iPad3,5 +- iPad3,6 +- iPod5,1 +- iPhone4,1 +- iPhone5,1 +- iPhone5,2 -### WIP diff --git a/restore.sh b/restore.sh index 33e1858..9887a85 100755 --- a/restore.sh +++ b/restore.sh @@ -53,10 +53,7 @@ key_n41=baf05fe0282f78c18c2e3842be4f9021919d586b55594281f5b5abd0f6e61495 iv_n42=fdad2b7a35384fa2ffc7221213ca1082 key_n42=74cd68729b800a20b1f8e8a3cb5517024a09f074eaa05b099db530fb5783275e -rm -rf iP*/ -rm -rf tmp/ -rm -rf $(ls *.shsh2) -rm -rf BuildManifest.plist +rm -rf iP*/ tmp/ $(ls *.shsh2) BuildManifest.plist clear echo "******* 841-OTA-Downgrader *******" @@ -93,35 +90,72 @@ then exit fi -echo "Downloading tsschecker..." mkdir tmp -curl -L -# "https://github.com/tihmstar/tsschecker/releases/download/v212/tsschecker_v212_mac_win_linux.zip" > "tmp/tsschecker.zip" -echo "Extracting tsschecker..." -unzip -j tmp/tsschecker.zip tsschecker_$platform -d tools/ -chmod +x tools/tsschecker_$platform -echo -echo "Downloading futurerestore..." -curl -L -# "http://api.tihmstar.net/builds/futurerestore/futurerestore-latest.zip" > "tmp/futurerestore.zip" -echo "Extracting futurerestore..." -unzip -j tmp/futurerestore.zip futurerestore_$platform -d tools/ -chmod +x tools/futurerestore_$platform -echo +if [ ! -e tools/tsschecker_$platform ] +then + echo "Downloading tsschecker..." + curl -L -# "https://github.com/tihmstar/tsschecker/releases/download/v212/tsschecker_v212_mac_win_linux.zip" -o "tmp/tsschecker.zip" + echo "Extracting tsschecker..." + unzip -j tmp/tsschecker.zip tsschecker_$platform -d tools/ + chmod +x tools/tsschecker_$platform + echo +fi +if [ ! -e tools/tsschecker_$platform ] +then + echo "Download/extract tsschecker failed. Please run the script again" + exit +fi + +if [ ! -e tools/futurerestore_$platform ] +then + echo "Downloading futurerestore..." + curl -L -# "http://api.tihmstar.net/builds/futurerestore/futurerestore-latest.zip" -o "tmp/futurerestore.zip" + echo "Extracting futurerestore..." + unzip -j tmp/futurerestore.zip futurerestore_$platform -d tools/ + chmod +x tools/futurerestore_$platform + echo +fi +if [ ! -e tools/futurerestore_$platform ] +then + echo "Download/extract futurerestore failed. Please run the script again" + exit +fi echo "Downloading ota.json..." -curl -L -# "https://api.ipsw.me/v2.1/ota.json/condensed" > "tmp/ota.json" -echo "Copying ota.json to /tmp..." -cp tmp/ota.json /tmp +curl -L -# "https://api.ipsw.me/v2.1/ota.json/condensed" -o "tmp/ota.json" +echo 'Copying ota.json to /tmp or $TMPDIR...' +if [ $platform == macos ] +then + cp tmp/ota.json $TMPDIR +else + cp tmp/ota.json /tmp +fi echo +if [ ! -e tmp/ota.json ] +then + echo "Download ota.json failed. Please run the script again" + exit +fi echo "Downloading BuildManifest.plist..." OTAFirmware=$(curl "https://api.ipsw.me/v4/ota/download/$ProductType/12H321?prerequisite=12H143" -s -L -I -o /dev/null -w '%{url_effective}') pzb -g AssetData/boot/BuildManifest.plist $OTAFirmware echo +if [ ! -e BuildManifest.plist ] +then + echo "Download BuildManifest.plist failed. Please run the script again" + exit +fi echo "Saving 8.4.1 blobs with tsschecker..." env "LD_PRELOAD=libcurl.so.3" tools/tsschecker_$platform -d $ProductType -i 8.4.1 -o -s -e $UniqueChipID -m BuildManifest.plist echo +if [ ! -e $(ls *.shsh2) ] +then + echo "Saving 8.4.1 blobs failed. Please run the script again" + exit +fi echo "Extracting 8.4.1 IPSW..." unzip -q ${IPSW}.ipsw -d $IPSW/ @@ -133,16 +167,17 @@ key=key_$HardwareModelLower echo "IV = ${!iv}" echo "Key = ${!key}" tools/xpwntool_$platform $IPSW/Firmware/dfu/$iBSS.dfu tmp/iBSS.dec -k ${!key} -iv ${!iv} -decrypt +dd bs=64 skip=1 if=tmp/iBSS.dec of=tmp/iBSS.dec2 echo echo "Patching iBSS..." -bspatch tmp/iBSS.dec tmp/pwnediBSS patches/$iBSS.patch +bspatch tmp/iBSS.dec2 tmp/pwnediBSS patches/$iBSS.patch echo -if [ $(echo $version | cut -c 1) == 1 ] +if [[ $(echo $ProductVersion | cut -c 1) == 1 ]] then kloader="kloader_hgsp" -elif [ $(echo $version | cut -c 1) == 5 ] +elif [[ $(echo $ProductVersion | cut -c 1) == 5 ]] then kloader="kloader5" else diff --git a/tools/kloader b/tools/kloader new file mode 100755 index 0000000..56398b6 Binary files /dev/null and b/tools/kloader differ diff --git a/tools/kloader5 b/tools/kloader5 new file mode 100755 index 0000000..ec6b2c8 Binary files /dev/null and b/tools/kloader5 differ diff --git a/tools/kloader_hgsp b/tools/kloader_hgsp new file mode 100755 index 0000000..99e7cc4 Binary files /dev/null and b/tools/kloader_hgsp differ diff --git a/tools/xpwntool_linux b/tools/xpwntool_linux new file mode 100755 index 0000000..f00e75b Binary files /dev/null and b/tools/xpwntool_linux differ diff --git a/tools/xpwntool_macos b/tools/xpwntool_macos new file mode 100755 index 0000000..555bfec Binary files /dev/null and b/tools/xpwntool_macos differ