From 8a90bf4723b30df89b18058df8cd2b2464aa3310 Mon Sep 17 00:00:00 2001
From: LukeZGD <26163116+LukeZGD@users.noreply.github.com>
Date: Tue, 20 Sep 2022 20:29:49 +0800
Subject: [PATCH] Support for iPhone3,3 on iPhone4Down
- not very tested
- also add restore to 7.1.2 support for all iphone 4 models
---
.gitignore | 1 +
README.md | 5 +++--
resources/depends.sh | 4 ++++
resources/device.sh | 2 +-
resources/ipsw.sh | 48 ++++++++++++++++++++++++++++++++++++++++++++
restore.sh | 9 ++++++++-
6 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/.gitignore b/.gitignore
index 965b1d0..208381d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,7 @@ resources/jailbreak/bin.tar
resources/jailbreak/cydia.tar
resources/jailbreak/untether.tar
resources/libimobiledevice*/
+resources/powdersn0w/
resources/ramdisk/
saved/
sshdeb.tar
diff --git a/README.md b/README.md
index 31390ed..64c83a1 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@
- **iPhone 5C and iPad mini 3 devices are NOT supported!**
- iPhone 5C can still be restored to versions that you have SHSH blobs for
- iPhone 4 devices also support restoring with SHSH blobs
-- **iPhone4Down supports the iPhone 4 GSM (iPhone3,1) only**
+- **iPhone4Down supports iPhone 4 GSM and CDMA (iPhone3,1 and iPhone3,3)**
@@ -48,10 +48,11 @@
iPad mini 1 |
iPod touch 5 |
- iOS 6.1.3 |
+ iOS 6.1.3 |
iPhone 4S |
iPad 2 (except iPad2,4) |
+ iPhone 4 GSM, CDMA |
iOS 7.1.2 |
iPhone 4 (all models) |
diff --git a/resources/depends.sh b/resources/depends.sh
index b36f93e..ac90fb9 100755
--- a/resources/depends.sh
+++ b/resources/depends.sh
@@ -118,6 +118,10 @@ SaveExternal() {
Link=https://web.archive.org/web/20210529174714if_/https://codeload.github.com/dora2-iOS/ch3rryflower/zip/316d2cdc5351c918e9db9650247b91632af3f11f
Name=ch3rryflower
SHA1=790d56db354151b9740c929e52c097ba57f2929d
+ elif [[ $1 == "powdersn0w" ]]; then
+ Link=https://dora2ios.github.io/download/konayuki/powdersn0w_v2.0b3.zip
+ Name=powdersn0w
+ SHA1=c733aac4a0833558ef9f5517f2a11ca547110b6e
fi
if [[ -d ./resources/$Name ]]; then
return
diff --git a/resources/device.sh b/resources/device.sh
index 115daff..29b4394 100755
--- a/resources/device.sh
+++ b/resources/device.sh
@@ -158,7 +158,7 @@ GetDeviceValues() {
if [[ $ProductType == "iPhone3"* ]]; then
DeviceProc=4
- if [[ $ProductType == "iPhone3,1" ]]; then
+ if [[ $ProductType != "iPhone3,2" ]]; then
Log "$ProductType detected. iPhone4Down functions enabled."
Echo "* This script uses powdersn0w by dora2ios"
else
diff --git a/resources/ipsw.sh b/resources/ipsw.sh
index 941baf4..b0d503a 100755
--- a/resources/ipsw.sh
+++ b/resources/ipsw.sh
@@ -42,6 +42,11 @@ JailbreakSet() {
}
JailbreakOption() {
+ if [[ $ProductType == "iPhone3,3" && $OSVer != "7.1.2" ]]; then
+ IPSWCustom="${ProductType}_${OSVer}_${BuildVer}_Custom"
+ return
+ fi
+
Input "Jailbreak Option"
Echo "* When this option is enabled, your device will be jailbroken on restore."
if [[ $OSVer == "6.1.3" ]]; then
@@ -257,6 +262,9 @@ IPSW4() {
if [[ $OSVer == "4.3"* ]]; then
IPSW4Cherry
return
+ elif [[ $ProductType == "iPhone3,3" && $OSVer != "7.1.2" ]]; then
+ IPSW4Powder
+ return
else
local JBURL2="https://github.com/LukeZGD/powdersn0w_pub/raw/main/xpwn/src/target/n90/11D257/exploit"
JailbreakFiles $JBURL2 exploit bedd10a96ba0f305a0af74a15e1eee88946070a1
@@ -416,6 +424,46 @@ IPSW4Cherry() {
cd ../../..
}
+IPSW4Powder() {
+ Log "powdersn0w v2.0b3 will be used instead of powdersn0w_pub for iPhone3,3" # powdersn0w_pub doesn't have n92 exploit
+ SaveExternal powdersn0w # downloads powdersn0w from https://dora2ios.github.io/download/konayuki/powdersn0w_v2.0b3.zip
+
+ powderdir="../resources/powdersn0w/macosx_x86_64"
+ cd tmp
+ cp -rf $powderdir/FirmwareBundles $powderdir/src .
+ powdersn0w="$powderdir/ipsw"
+
+ if [[ $platform != "macos" ]]; then
+ echo "QlNESUZGNDA2AAAAAAAAAEkAAAAAAAAA4HscAAAAAABCWmg5MUFZJlNZcLcTFwAAB+DBQKAABAAIQCBCACAAIjEaNCDJiDaAhcW9PF3JFOFCQcLcTFxCWmg5MUFZJlNZidWPbQAOTMKswAAAAJAAEAAACKAAAAigAFCDJiBNUpoPU+qqe5IkMxAqd8VISW223BKUbv4u5IpwoSETqx7aQlpoORdyRThQkAAAAAA=" | base64 -d | tee ipsw.patch >/dev/null
+ $bspatch $powderdir/ipsw $powderdir/ipsw_patched ipsw.patch
+ powdersn0w="darling $(pwd)/$powderdir/ipsw_patched"
+ if [[ ! $(which darling) ]]; then
+ Error "Cannot find darling. darling is required to create custom IPSW."
+ fi
+ fi
+# above patch changes temp path from /tmp to ././ (current dir)
+# only modifies xpwn part, hopefully doesn't violate nbsk license. here is the equivalent diff (based on gpl code released):
+: '
+main.c:
+187c188
+< strcpy(tmpFileBuffer, "/tmp/rootXXXXXX");
+---
+> strcpy(tmpFileBuffer, "././/rootXXXXXX");
+outputstate.c:
+292c292
+< strcpy(tmpFileBuffer, "/tmp/pwnXXXXXX");
+---
+> strcpy(tmpFileBuffer, "././/pwnXXXXXX");
+'
+ Log "Preparing custom IPSW with powdersn0w..."
+ $powdersn0w ../$IPSW.ipsw ../$IPSWCustom.ipsw -useDRA ../$IPSW7.ipsw
+ cd ..
+
+ if [[ ! -e $IPSWCustom.ipsw ]]; then
+ Error "Failed to find custom IPSW. Please run the script again"
+ fi
+}
+
IPSW64() {
if [[ -e $IPSWCustom.ipsw ]]; then
Log "Found existing Custom IPSW. Skipping IPSW creation."
diff --git a/restore.sh b/restore.sh
index a755427..f398b5d 100755
--- a/restore.sh
+++ b/restore.sh
@@ -321,9 +321,10 @@ SelectVersion() {
if [[ $ProductType == "iPhone3"* ]]; then
[[ $Mode == "IPSW32" ]] && Selection+=("7.1.2")
+ [[ $ProductType != "iPhone3,2" ]] && Selection+=("6.1.3")
if [[ $ProductType == "iPhone3,1" ]]; then
- Selection+=("6.1.3 ""5.1.1 (9B208)" "5.1.1 (9B206)")
+ Selection+=("5.1.1 (9B208)" "5.1.1 (9B206)")
Selection2=("6.1.2" "6.1" "6.0.1" "6.0" "5.1" "5.0.1" "5.0")
if [[ $platform != "linux" ]]; then
Echo "* iOS 4.3.x downgrades are supported on Linux only"
@@ -334,6 +335,12 @@ SelectVersion() {
Selection2+=("4.3.3" "4.3")
fi
Selection+=("More versions")
+
+ elif [[ $ProductType == "iPhone3,3" && $platform != "macos" && $Mode != "Restore712" ]]; then
+ Echo "* For creating 6.1.3 custom IPSW, make sure to have darling installed: https://github.com/darlinghq/darling"
+ Echo "* For Ubuntu/Debian, you may install the .deb from releases."
+ Echo "* For Arch, you may install darling-bin from AUR."
+ Echo "* For other distros, you might need to build darling yourself."
fi
if [[ $Mode == "Restore712" ]]; then