Some script updates

- Print device version
- Do not run SimpleHTTPServer as root
- Other cleanup stuff
This commit is contained in:
LukeZGD 2021-11-06 22:10:04 +08:00
parent 3d9f12b146
commit 26a3236d61
4 changed files with 51 additions and 66 deletions

View File

@ -1,19 +1,17 @@
#!/bin/bash #!/bin/bash
SetToolPaths() { SetToolPaths() {
MPath="./resources/libimobiledevice_" local Detect="Detected libimobiledevice and libirecovery installed from "
local MPath="./resources/libimobiledevice_"
if [[ $OSTYPE == "linux"* ]]; then if [[ $OSTYPE == "linux"* ]]; then
. /etc/os-release 2>/dev/null . /etc/os-release 2>/dev/null
platform="linux" platform="linux"
platformver="$PRETTY_NAME" platformver="$PRETTY_NAME"
MPath+="$platform" MPath+="$platform"
bspatch="$(which bspatch)" bspatch="$(which bspatch)"
futurerestore="sudo LD_LIBRARY_PATH=./resources/lib ./resources/tools/futurerestore_linux" futurerestore="./resources/tools/futurerestore_linux"
idevicerestore="sudo LD_LIBRARY_PATH=./resources/lib ./resources/tools/idevicerestore_linux"
python="$(which python2)" python="$(which python2)"
ipwndfu="sudo $python ipwndfu"
rmsigchks="sudo $python rmsigchks.py"
SimpleHTTPServer="sudo -b $python -m SimpleHTTPServer 8888"
zenity="$(which zenity)" zenity="$(which zenity)"
elif [[ $OSTYPE == "darwin"* ]]; then elif [[ $OSTYPE == "darwin"* ]]; then
@ -21,40 +19,50 @@ SetToolPaths() {
platformver="${1:-$(sw_vers -productVersion)}" platformver="${1:-$(sw_vers -productVersion)}"
MPath+="$platform" MPath+="$platform"
if [[ -e /usr/local/bin/idevicedate && -e /usr/local/bin/irecovery ]]; then if [[ -e /usr/local/bin/idevicedate && -e /usr/local/bin/irecovery ]]; then
Log "Detected libimobiledevice and libirecovery installed from Homebrew (Intel Mac)" Detect+="Homebrew (Intel Mac)"
MPath="/usr/local/bin" MPath="/usr/local/bin"
elif [[ -e /opt/homebrew/bin/idevicedate && -e /opt/homebrew/bin/irecovery ]]; then elif [[ -e /opt/homebrew/bin/idevicedate && -e /opt/homebrew/bin/irecovery ]]; then
Log "Detected libimobiledevice and libirecovery installed from Homebrew (Apple Silicon)" Detect+="Homebrew (Apple Silicon)"
MPath="/opt/homebrew/bin" MPath="/opt/homebrew/bin"
elif [[ -e /opt/local/bin/idevicedate && -e /opt/local/bin/irecovery ]]; then elif [[ -e /opt/local/bin/idevicedate && -e /opt/local/bin/irecovery ]]; then
Log "Detected libimobiledevice and libirecovery installed from MacPorts" Detect+="MacPorts"
MPath="/opt/local/bin" MPath="/opt/local/bin"
else
Detect=
fi fi
[[ ! -z $Detect ]] && Log "$Detect"
bspatch="/usr/bin/bspatch" bspatch="/usr/bin/bspatch"
futurerestore="./resources/tools/futurerestore_macos_$(uname -m)" futurerestore="./resources/tools/futurerestore_macos_$(uname -m)"
[[ ! -e $futurerestore ]] && futurerestore="./resources/tools/futurerestore_macos_arm64" [[ ! -e $futurerestore ]] && futurerestore="./resources/tools/futurerestore_macos_arm64"
idevicerestore="./resources/tools/idevicerestore_macos"
ipwnder32="./resources/tools/ipwnder32_macos" ipwnder32="./resources/tools/ipwnder32_macos"
python="/usr/bin/python" python="/usr/bin/python"
ipwndfu="$python ipwndfu"
rmsigchks="$python rmsigchks.py"
SimpleHTTPServer="$python -m SimpleHTTPServer 8888"
zenity="./resources/tools/zenity_macos" zenity="./resources/tools/zenity_macos"
fi fi
git="$(which git)" git="$(which git)"
ideviceenterrecovery="$MPath/ideviceenterrecovery" ideviceenterrecovery="$MPath/ideviceenterrecovery"
ideviceinfo="$MPath/ideviceinfo" ideviceinfo="$MPath/ideviceinfo"
iproxy="$MPath/iproxy" iproxy="$MPath/iproxy"
ipsw="./tools/ipsw_$platform" ipsw="./tools/ipsw_$platform"
ipwndfu="$python ipwndfu"
irecoverychk="$MPath/irecovery" irecoverychk="$MPath/irecovery"
irecovery="$irecoverychk" irecovery="$irecoverychk"
[[ $platform == "linux" ]] && irecovery="sudo LD_LIBRARY_PATH=./resources/lib $irecovery"
partialzip="./resources/tools/partialzip_$platform" partialzip="./resources/tools/partialzip_$platform"
rmsigchks="$python rmsigchks.py"
SimpleHTTPServer="$python -m SimpleHTTPServer 8888"
SSH="-F ./resources/ssh_config" SSH="-F ./resources/ssh_config"
SCP="$(which scp) $SSH" SCP="$(which scp) $SSH"
SSH="$(which ssh) $SSH" SSH="$(which ssh) $SSH"
tsschecker="./resources/tools/tsschecker_$platform" tsschecker="./resources/tools/tsschecker_$platform"
if [[ $platform == "linux" ]]; then
# these need to run as root for device detection
futurerestore="sudo $futurerestore"
ipwndfu="sudo $ipwndfu"
irecovery="sudo LD_LIBRARY_PATH=./resources/lib $irecovery"
rmsigchks="sudo $rmsigchks"
fi
Log "Running on platform: $platform ($platformver)" Log "Running on platform: $platform ($platformver)"
} }

View File

@ -32,15 +32,14 @@ FindDevice() {
GetDeviceValues() { GetDeviceValues() {
local ideviceinfo2 local ideviceinfo2
local version
Log "Finding device in Normal mode..." Log "Finding device in Normal mode..."
DeviceState= DeviceState=
ideviceinfo2=$($ideviceinfo -s) ideviceinfo2=$($ideviceinfo -s)
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
Log "Finding device in DFU/recovery mode..." Log "Finding device in DFU/recovery mode..."
if [[ $platform == "linux" ]]; then [[ $platform == "linux" ]] && Echo "* Enter root password of your PC when prompted"
Echo "* Enter root password of your PC when prompted"
fi
DeviceState="$($irecovery -q 2>/dev/null | grep -w "MODE" | cut -c 7-)" DeviceState="$($irecovery -q 2>/dev/null | grep -w "MODE" | cut -c 7-)"
elif [[ ! -z $ideviceinfo2 ]]; then elif [[ ! -z $ideviceinfo2 ]]; then
DeviceState="Normal" DeviceState="Normal"
@ -66,6 +65,7 @@ GetDeviceValues() {
ProductVer=$(echo "$ideviceinfo2" | grep "ProductVer" | cut -c 17-) ProductVer=$(echo "$ideviceinfo2" | grep "ProductVer" | cut -c 17-)
UniqueChipID=$(echo "$ideviceinfo2" | grep "UniqueChipID" | cut -c 15-) UniqueChipID=$(echo "$ideviceinfo2" | grep "UniqueChipID" | cut -c 15-)
UniqueDeviceID=$(echo "$ideviceinfo2" | grep "UniqueDeviceID" | cut -c 17-) UniqueDeviceID=$(echo "$ideviceinfo2" | grep "UniqueDeviceID" | cut -c 17-)
version="(iOS $ProductVer) "
fi fi
if [[ ! $DeviceState ]]; then if [[ ! $DeviceState ]]; then
@ -115,7 +115,7 @@ GetDeviceValues() {
elif [[ $ProductType != "iPad2"* && $ProductType != "iPad3"* && $ProductType != "iPad4,1" && elif [[ $ProductType != "iPad2"* && $ProductType != "iPad3"* && $ProductType != "iPad4,1" &&
$ProductType != "iPad4,4" && $ProductType != "iPod5,1" && $ProductType != "iPhone5"* ]]; then $ProductType != "iPad4,4" && $ProductType != "iPod5,1" && $ProductType != "iPhone5"* ]]; then
Error "Your device $ProductType is not supported." Error "Your device $ProductType ${version}is not supported."
else else
BasebandURL=0 BasebandURL=0
fi fi
@ -153,14 +153,11 @@ GetDeviceValues() {
iBSSBuildVer="12H321" iBSSBuildVer="12H321"
fi fi
[[ ! $IPSWType ]] && IPSWType="$ProductType" [[ ! $IPSWType ]] && IPSWType="$ProductType"
iBEC="iBEC.$iBSS.RELEASE"
iBECb="iBEC.${iBSS}b.RELEASE"
iBSSb="iBSS.${iBSS}b.RELEASE"
iBSS="iBSS.$iBSS.RELEASE" iBSS="iBSS.$iBSS.RELEASE"
SEP="sep-firmware.$HWModel.RELEASE.im4p" SEP="sep-firmware.$HWModel.RELEASE.im4p"
Log "Found $ProductType in $DeviceState mode." Log "$ProductType ${version}connected in $DeviceState mode."
Log "Device ECID: $UniqueChipID" Log "ECID: $UniqueChipID"
} }
Baseband841() { Baseband841() {
@ -208,6 +205,7 @@ CheckM8() {
Log "Entering pwnDFU mode with $pwnDFUTool..." Log "Entering pwnDFU mode with $pwnDFUTool..."
if [[ $pwnDFUTool == "ipwndfu" ]]; then if [[ $pwnDFUTool == "ipwndfu" ]]; then
cd resources/ipwndfu cd resources/ipwndfu
[[ $platform == "linux" ]] && Echo "* Enter root password of your PC when prompted"
$ipwndfu -p $ipwndfu -p
if [[ $DeviceProc == 7 ]]; then if [[ $DeviceProc == 7 ]]; then
Log "Running rmsigchks.py..." Log "Running rmsigchks.py..."
@ -345,7 +343,7 @@ kDFU() {
Error "Cannot connect to device via SSH." \ Error "Cannot connect to device via SSH." \
"Please try the steps above to make sure that SSH is successful" "Please try the steps above to make sure that SSH is successful"
fi fi
$SSH root@$IPAddress "/tmp/$kloader /tmp/pwnediBSS" & $SSH root@$IPAddress "chmod +x /tmp/$kloader; /tmp/$kloader /tmp/pwnediBSS" &
fi fi
Log "Entering kDFU mode..." Log "Entering kDFU mode..."

View File

@ -27,26 +27,8 @@ FRBaseband() {
fi fi
} }
FutureRestore() {
local ExtraArgs=("--use-pwndfu")
if [[ $DeviceProc == 7 ]]; then
ExtraArgs+=("-s" "$IPSWRestore/Firmware/all_flash/$SEP" "-m" "$BuildManifest")
else
ExtraArgs+=("--no-ibss")
fi
Log "Proceeding to futurerestore..."
if [[ $Baseband == 0 ]]; then
Log "Device $ProductType has no baseband"
$futurerestore -t "$SHSH" --no-baseband "${ExtraArgs[@]}" "$IPSWRestore.ipsw"
else
FRBaseband
$futurerestore -t "$SHSH" -b saved/baseband/$Baseband -p $BuildManifest "${ExtraArgs[@]}" "$IPSWRestore.ipsw"
fi
}
Downgrade() { Downgrade() {
local ExtraArgs=("--use-pwndfu")
local IPSWExtract local IPSWExtract
local IPSWSHA1 local IPSWSHA1
local IPSWSHA1L local IPSWSHA1L
@ -200,28 +182,34 @@ Downgrade() {
Log "Extracting IPSW: $IPSWExtract.ipsw" Log "Extracting IPSW: $IPSWExtract.ipsw"
unzip -oq "$IPSWExtract.ipsw" -d "$IPSWExtract"/ unzip -oq "$IPSWExtract.ipsw" -d "$IPSWExtract"/
Log "Preparing for futurerestore... (Enter root password of your PC/Mac when prompted)"
cd resources
if [[ $platform == "linux" ]]; then
$SimpleHTTPServer
else
$SimpleHTTPServer &
fi
ServerRunning=1
cd ..
if [[ ! $IPSWRestore ]]; then if [[ ! $IPSWRestore ]]; then
Log "Setting restore IPSW to: $IPSW.ipsw" Log "Setting restore IPSW to: $IPSW.ipsw"
IPSWRestore="$IPSW" IPSWRestore="$IPSW"
fi fi
Log "Proceeding to futurerestore..."
[[ $platform == "linux" ]] && Echo "* Enter root password of your PC when prompted"
cd resources
$SimpleHTTPServer &
ServerPID=$!
cd ..
if [[ $DeviceProc == 7 ]]; then if [[ $DeviceProc == 7 ]]; then
Log "Sending dummy file" # Send dummy file for device detection
$irecovery -f README.md $irecovery -f README.md
sleep 2 sleep 2
ExtraArgs+=("-s" "$IPSWRestore/Firmware/all_flash/$SEP" "-m" "$BuildManifest")
else
ExtraArgs+=("--no-ibss")
fi fi
FutureRestore if [[ $Baseband == 0 ]]; then
Log "Device $ProductType has no baseband"
$futurerestore -t "$SHSH" --no-baseband "${ExtraArgs[@]}" "$IPSWRestore.ipsw"
else
FRBaseband
$futurerestore -t "$SHSH" -b saved/baseband/$Baseband -p $BuildManifest "${ExtraArgs[@]}" "$IPSWRestore.ipsw"
fi
echo echo
Log "Restoring done!" Log "Restoring done!"

View File

@ -21,16 +21,7 @@ fi
Clean() { Clean() {
rm -rf iP*/ shsh/ tmp/ *.im4p *.bbfw ${UniqueChipID}_${ProductType}_*.shsh2 \ rm -rf iP*/ shsh/ tmp/ *.im4p *.bbfw ${UniqueChipID}_${ProductType}_*.shsh2 \
${UniqueChipID}_${ProductType}_${HWModel}ap_*.shsh BuildManifest.plist ${UniqueChipID}_${ProductType}_${HWModel}ap_*.shsh BuildManifest.plist
kill $iproxyPID 2>/dev/null kill $iproxyPID $ServerPID 2>/dev/null
if [[ $ServerRunning == 1 ]]; then
Log "Stopping local server..."
if [[ $platform == "macos" ]]; then
ps aux | awk '/python/ {print "kill -9 "$2" 2>/dev/null"}' | bash
elif [[ $platform == "linux" ]]; then
Echo "* Enter root password of your PC when prompted"
ps aux | awk '/python/ {print "sudo kill -9 "$2" 2>/dev/null"}' | bash
fi
fi
} }
Echo() { Echo() {
@ -146,7 +137,7 @@ Main() {
IPSW32 IPSW32
Log "Custom IPSW has been created: $IPSWCustom.ipsw" Log "Custom IPSW has been created: $IPSWCustom.ipsw"
Echo "* This custom IPSW has a jailbreak built in." Echo "* This custom IPSW has a jailbreak built in."
Echo "* Run the script again and select Downgrade device to use the custom IPSW." Echo "* Run the script again and select Downgrade Device to use the custom IPSW."
Echo "* You may also use futurerestore manually (make sure to use the latest beta)" Echo "* You may also use futurerestore manually (make sure to use the latest beta)"
elif [[ $Mode != "Downgrade" ]]; then elif [[ $Mode != "Downgrade" ]]; then