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
SetToolPaths() {
MPath="./resources/libimobiledevice_"
local Detect="Detected libimobiledevice and libirecovery installed from "
local MPath="./resources/libimobiledevice_"
if [[ $OSTYPE == "linux"* ]]; then
. /etc/os-release 2>/dev/null
platform="linux"
platformver="$PRETTY_NAME"
MPath+="$platform"
bspatch="$(which bspatch)"
futurerestore="sudo LD_LIBRARY_PATH=./resources/lib ./resources/tools/futurerestore_linux"
idevicerestore="sudo LD_LIBRARY_PATH=./resources/lib ./resources/tools/idevicerestore_linux"
futurerestore="./resources/tools/futurerestore_linux"
python="$(which python2)"
ipwndfu="sudo $python ipwndfu"
rmsigchks="sudo $python rmsigchks.py"
SimpleHTTPServer="sudo -b $python -m SimpleHTTPServer 8888"
zenity="$(which zenity)"
elif [[ $OSTYPE == "darwin"* ]]; then
@ -21,40 +19,50 @@ SetToolPaths() {
platformver="${1:-$(sw_vers -productVersion)}"
MPath+="$platform"
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"
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"
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"
else
Detect=
fi
[[ ! -z $Detect ]] && Log "$Detect"
bspatch="/usr/bin/bspatch"
futurerestore="./resources/tools/futurerestore_macos_$(uname -m)"
[[ ! -e $futurerestore ]] && futurerestore="./resources/tools/futurerestore_macos_arm64"
idevicerestore="./resources/tools/idevicerestore_macos"
ipwnder32="./resources/tools/ipwnder32_macos"
python="/usr/bin/python"
ipwndfu="$python ipwndfu"
rmsigchks="$python rmsigchks.py"
SimpleHTTPServer="$python -m SimpleHTTPServer 8888"
zenity="./resources/tools/zenity_macos"
fi
git="$(which git)"
ideviceenterrecovery="$MPath/ideviceenterrecovery"
ideviceinfo="$MPath/ideviceinfo"
iproxy="$MPath/iproxy"
ipsw="./tools/ipsw_$platform"
ipwndfu="$python ipwndfu"
irecoverychk="$MPath/irecovery"
irecovery="$irecoverychk"
[[ $platform == "linux" ]] && irecovery="sudo LD_LIBRARY_PATH=./resources/lib $irecovery"
partialzip="./resources/tools/partialzip_$platform"
rmsigchks="$python rmsigchks.py"
SimpleHTTPServer="$python -m SimpleHTTPServer 8888"
SSH="-F ./resources/ssh_config"
SCP="$(which scp) $SSH"
SSH="$(which ssh) $SSH"
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)"
}

View File

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

View File

@ -27,26 +27,8 @@ FRBaseband() {
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() {
local ExtraArgs=("--use-pwndfu")
local IPSWExtract
local IPSWSHA1
local IPSWSHA1L
@ -200,28 +182,34 @@ Downgrade() {
Log "Extracting IPSW: $IPSWExtract.ipsw"
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
Log "Setting restore IPSW to: $IPSW.ipsw"
IPSWRestore="$IPSW"
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
Log "Sending dummy file"
# Send dummy file for device detection
$irecovery -f README.md
sleep 2
ExtraArgs+=("-s" "$IPSWRestore/Firmware/all_flash/$SEP" "-m" "$BuildManifest")
else
ExtraArgs+=("--no-ibss")
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
Log "Restoring done!"

View File

@ -21,16 +21,7 @@ fi
Clean() {
rm -rf iP*/ shsh/ tmp/ *.im4p *.bbfw ${UniqueChipID}_${ProductType}_*.shsh2 \
${UniqueChipID}_${ProductType}_${HWModel}ap_*.shsh BuildManifest.plist
kill $iproxyPID 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
kill $iproxyPID $ServerPID 2>/dev/null
}
Echo() {
@ -146,7 +137,7 @@ Main() {
IPSW32
Log "Custom IPSW has been created: $IPSWCustom.ipsw"
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)"
elif [[ $Mode != "Downgrade" ]]; then