v1ral_ITS

Legacy IOS Part4

Jun 10th, 2026
44
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 121.44 KB | None | 0 0
  1. }
  2.  
  3. menu_restore_more() {
  4.     local menu_items
  5.     local selected
  6.     local back
  7.  
  8.     while [[ -z "$mode" && -z "$back" ]]; do
  9.         menu_items=()
  10.         case $device_type in
  11.             iPhone2,1 )
  12.                 menu_items+=("6.1.3" "6.1.2" "6.1" "6.0.1" "6.0" "5.1" "5.0.1" "5.0")
  13.                 menu_items+=("4.3.4" "4.3.3" "4.3.2" "4.3.1" "4.3" "4.2.1")
  14.                 menu_items+=("4.0.2" "4.0.1" "4.0" "3.1.2" "3.1" "3.0.1" "3.0")
  15.             ;;
  16.             iPod2,1 ) menu_items+=("4.0.2" "4.0" "3.1.2" "3.1.1");;
  17.         esac
  18.         menu_items+=("Go Back")
  19.         menu_print_info
  20.         if [[ $1 == "ipsw" ]]; then
  21.             print " > Main Menu > Misc Utilities > Create Custom IPSW"
  22.         else
  23.             print " > Main Menu > Restore/Downgrade"
  24.         fi
  25.         if [[ $device_type == "iPhone2,1" ]]; then
  26.             warn "3.1.x versions listed here might not restore properly"
  27.             if [[ $device_newbr != 0 && $device_mode != "none" ]]; then
  28.                 print "* 3.0.x versions are not restorable on new bootrom devices"
  29.                 menu_items=("${menu_items[@]::${#menu_items[@]}-3}")
  30.                 menu_items+=("Go Back")
  31.             fi
  32.             echo
  33.         fi
  34.         input "Select an option:"
  35.         select_option "${menu_items[@]}"
  36.         selected="${menu_items[$?]}"
  37.         case $selected in
  38.             "" ) :;;
  39.             "Go Back" ) back=1;;
  40.             * ) menu_ipsw "$selected" "$1";;
  41.         esac
  42.     done
  43. }
  44.  
  45. ipsw_latest_set() {
  46.     local newpath
  47.     case $device_type in
  48.         iPad3,[456]    ) ipsw_prefix="iPad_32bit";;
  49.         iPad4,[123456] ) ipsw_prefix="iPad_64bit";;
  50.         iPad6,[34]     ) ipsw_prefix="iPadPro_9.7";;
  51.         iPad6,[78]     ) ipsw_prefix="iPadPro_12.9";;
  52.         iPad7,[12]     ) ipsw_prefix="iPad_Pro_HFR";;
  53.         iPad7,1[12]    ) ipsw_prefix="iPad_10.2";;
  54.         iPhone5,[1234] ) ipsw_prefix="iPhone_4.0_32bit";;
  55.         iPhone10,[36]  ) ipsw_prefix="iPhone10,3,iPhone10,6";;
  56.         iPhone11,[246] ) ipsw_prefix="iPhone11,2,iPhone11,4,iPhone11,6";;
  57.         iPod[79],1     ) ipsw_prefix="iPodtouch";;
  58.         iPad4,[789] | iPad5,*    ) ipsw_prefix="iPad_64bit_TouchID";;
  59.         iPad6,1[12] | iPad7,[56] ) ipsw_prefix="iPad_64bit_TouchID_ASTC";;
  60.         iPhone6,[12] | iPhone8,4 ) ipsw_prefix="iPhone_4.0_64bit";;
  61.         iPhone7,1 | iPhone8,2    ) ipsw_prefix="iPhone_5.5";;
  62.         iPhone7,2 | iPhone8,1    ) ipsw_prefix="iPhone_4.7";;
  63.         iPhone9,[13] | iPhone10,[14] ) ipsw_prefix="iPhone_4.7_P3";;
  64.         iPhone9,[24] | iPhone10,[25] ) ipsw_prefix="iPhone_5.5_P3";;
  65.         * ) ipsw_prefix="${device_type}";;
  66.     esac
  67.     newpath="$ipsw_prefix"
  68.     newpath+="_${device_latest_vers}_${device_latest_build}"
  69.     ipsw_custom_set $newpath
  70.     ipsw_dfuipsw="../${newpath}_DFUIPSW"
  71.     newpath+="_Restore"
  72.     ipsw_latest_path="$newpath"
  73. }
  74.  
  75. ipsw_hwmodel_set() {
  76.     local hwmodel
  77.     case $device_type in
  78.         iPhone5,[12] ) hwmodel="iphone5";;
  79.         iPhone5,[34] ) hwmodel="iphone5b";;
  80.         iPad3,[456] ) hwmodel="ipad3b";;
  81.         iPhone6,*   ) hwmodel="iphone6";;
  82.         iPhone7,*   ) hwmodel="iphone7";;
  83.         iPhone8,4   ) hwmodel="iphone8b";;
  84.         iPhone8,*   ) hwmodel="iphone8";;
  85.         iPhone9,*   ) hwmodel="iphone9";;
  86.         iPad4,[123] ) hwmodel="ipad4";;
  87.         iPad4,[456] ) hwmodel="ipad4b";;
  88.         iPad4,[789] ) hwmodel="ipad4bm";;
  89.         iPad5,[12]  ) hwmodel="ipad5";;
  90.         iPad5,[34]  ) hwmodel="ipad5b";;
  91.         iPad6,[34]  ) hwmodel="ipad6b";;
  92.         iPad6,[78]  ) hwmodel="ipad6d";;
  93.         *           ) hwmodel="$device_model";;
  94.     esac
  95.     ipsw_hwmodel="$hwmodel"
  96. }
  97.  
  98. menu_ipsw() {
  99.     local menu_items
  100.     local selected
  101.     local back
  102.     local newpath
  103.     local nav
  104.     local start="(*) "
  105.     local can_start
  106.  
  107.     if [[ $2 == "ipsw" ]]; then
  108.         nav=" > Main Menu > Misc Utilities > Create Custom IPSW > $1"
  109.         start+="Create IPSW"
  110.     elif [[ $2 == "fourthree" ]]; then
  111.         nav=" > Main Menu > FourThree Utility > Step 1: Restore"
  112.         start+="Start Restore"
  113.     elif [[ $1 == "Set Nonce Only" ]]; then
  114.         nav=" > Main Menu > Restore/Downgrade > $1"
  115.         start+="Set Nonce"
  116.         device_target_setnonce=1
  117.     else
  118.         nav=" > Main Menu > Restore/Downgrade > $1"
  119.         start+="Start Restore"
  120.     fi
  121.  
  122.     while [[ -z "$mode" && -z "$back" ]]; do
  123.         case $1 in
  124.             "iOS 10.3.3" )
  125.                 device_target_vers="10.3.3"
  126.                 device_target_build="14G60"
  127.             ;;
  128.             "iOS 8.4.1" )
  129.                 device_target_vers="8.4.1"
  130.                 device_target_build="12H321"
  131.             ;;
  132.             "iOS 6.1.3" )
  133.                 device_target_vers="6.1.3"
  134.                 device_target_build="10B329"
  135.             ;;
  136.             "iOS 4.1" )
  137.                 device_target_vers="4.1"
  138.                 device_target_build="8B117"
  139.             ;;
  140.             "Latest iOS"* )
  141.                 device_target_vers="$device_latest_vers"
  142.                 device_target_build="$device_latest_build"
  143.                 case $device_latest_vers in
  144.                     [643]* ) ipsw_canhacktivate=1;;
  145.                 esac
  146.             ;;
  147.             [6543]* )
  148.                 device_target_vers="$1"
  149.                 if [[ $device_target_vers != "3.0"* ]]; then
  150.                     ipsw_canhacktivate=1
  151.                 fi
  152.                 if [[ $device_type == "iPhone2,1" && $1 != "4.1" ]]; then
  153.                     ipsw_cancustomlogo=1
  154.                 fi
  155.                 if [[ $device_type == "iPod2,1" && $device_newbr == 0 ]] &&
  156.                    [[ $1 == "4.0"* || $1 == "3.1"* ]]; then
  157.                     ipsw_cancustomlogo=1
  158.                     ipsw_24o=1
  159.                 fi
  160.                 if [[ $device_type == "iPod2,1" && $device_mode == "none" && $1 != "3.1.3" ]] &&
  161.                    [[ $1 == "4.0"* || $1 == "3.1"* ]]; then
  162.                     ipsw_cancustomlogo=1
  163.                     ipsw_24o=1
  164.                 fi
  165.             ;;
  166.         esac
  167.         target_vers_maj=$(echo "$device_target_vers" | cut -d. -f1)
  168.         target_vers_min=$(echo "$device_target_vers" | cut -d. -f2)
  169.         if [[ $device_type != "iPhone"* ]]; then
  170.             ipsw_canhacktivate=
  171.         fi
  172.         if [[ $device_proc == 1 ]]; then
  173.             ipsw_cancustomlogo=1
  174.         fi
  175.         case $1 in
  176.             "6.1.3" ) device_target_build="10B329";;
  177.             "6.1.2" ) device_target_build="10B146";;
  178.             "6.1"   ) device_target_build="10B141";;
  179.             "6.0.1" ) device_target_build="10A523";;
  180.             "6.0"   ) device_target_build="10A403";;
  181.             "5.1.1" ) device_target_build="9B206";;
  182.             "5.1"   ) device_target_build="9B176";;
  183.             "5.0.1" ) device_target_build="9A405";;
  184.             "5.0"   ) device_target_build="9A334";;
  185.             "4.3.5" ) device_target_build="8L1";;
  186.             "4.3.4" ) device_target_build="8K2";;
  187.             "4.3.3" ) device_target_build="8J2";;
  188.             "4.3.2" ) device_target_build="8H7";;
  189.             "4.3.1" ) device_target_build="8G4";;
  190.             "4.3"   ) device_target_build="8F190";;
  191.             "4.2.1" )
  192.                 device_target_build="8C148"
  193.                 if [[ $device_type == "iPhone2,1" ]]; then
  194.                     device_target_build+="a"
  195.                 fi
  196.             ;;
  197.             "4.1"   ) device_target_build="8B117";;
  198.             "4.0.2" ) device_target_build="8A400";;
  199.             "4.0.1" ) device_target_build="8A306";;
  200.             "4.0"   ) device_target_build="8A293";;
  201.             "3.1.3" ) device_target_build="7E18";;
  202.             "3.1.2" ) device_target_build="7D11";;
  203.             "3.1.1" ) device_target_build="7C145";;
  204.             "3.1"   ) device_target_build="7C144";;
  205.             "3.0.1" ) device_target_build="7A400";;
  206.             "3.0"   ) device_target_build="7A341";;
  207.         esac
  208.         ipsw_latest_set
  209.         if [[ $device_target_vers == "$device_latest_vers" ]]; then
  210.             newpath="$ipsw_latest_path"
  211.         else
  212.             case $device_type in
  213.                 iPad4,[12345] ) newpath="iPad_64bit";;
  214.                 iPhone6,[12]  ) newpath="iPhone_4.0_64bit";;
  215.                 * ) newpath="${device_type}";;
  216.             esac
  217.             newpath+="_${device_target_vers}_${device_target_build}"
  218.             ipsw_custom_set $newpath
  219.             newpath+="_Restore"
  220.         fi
  221.         if [[ $1 == "Other (Use SHSH Blobs)" || $1 == "Set Nonce Only" ]]; then
  222.             device_target_other=1
  223.             if [[ $device_type == "iPhone2,1" ]]; then
  224.                 ipsw_canhacktivate=1
  225.             fi
  226.         elif [[ $1 == *"powdersn0w"* ]]; then
  227.             device_target_powder=1
  228.             if [[ $device_proc == 4 ]]; then
  229.                 device_base_vers="$device_latest_vers"
  230.                 device_base_build="$device_latest_build"
  231.             fi
  232.         elif [[ $1 == *"Tethered"* ]]; then
  233.             device_target_tethered=1
  234.         elif [[ -n $device_target_vers && -e "../$newpath.ipsw" ]]; then
  235.             ipsw_verify "../$newpath" "$device_target_build" #nopause
  236.             if [[ $? == 0 ]]; then
  237.                 ipsw_path="../$newpath"
  238.             fi
  239.         fi
  240.  
  241.         menu_items=("Select Target IPSW")
  242.         menu_print_info
  243.         print "* Only select unmodified IPSW for the selection. Do not select custom IPSWs"
  244.         echo
  245.         if [[ $1 == *"powdersn0w"* ]]; then
  246.             menu_items+=("Select Base IPSW")
  247.             if [[ $device_proc == 4 ]]; then
  248.                 menu_items+=("Download Base IPSW")
  249.             fi
  250.             if [[ -n $ipsw_path ]]; then
  251.                 print "* Selected Target IPSW: $ipsw_path.ipsw"
  252.                 print "* Target Version: $device_target_vers-$device_target_build"
  253.                 ipsw_print_warnings powder
  254.                 ipsw_cancustomlogo2=
  255.                 case $device_target_vers in
  256.                     [456]* ) ipsw_cancustomlogo2=1;;
  257.                 esac
  258.             else
  259.                 print "* Select Target IPSW to continue"
  260.                 local lo
  261.                 local hi
  262.                 case $device_type in
  263.                     iPhone3,1 ) lo=4.0; hi=7.1.1;;
  264.                     iPhone3,2 ) lo=6.0; hi=7.1.1;;
  265.                     iPhone3,3 ) lo=4.2.6; hi=7.1.1;;
  266.                     iPhone4,1 | iPad2,[123] ) lo=5.0; hi=9.3.5;;
  267.                     iPad2,* | iPad3,[123]   ) lo=5.1; hi=9.3.5;;
  268.                     iPhone5,[12] | iPad3,* | iPod5,1 ) lo=6.0; hi=9.3.5;;
  269.                     iPhone5,[34] ) lo=7.0; hi=9.3.5;;
  270.                     iPad1,1 ) lo=3.2; hi=5.1;;
  271.                     iPod3,1 ) lo=3.1.1; hi=5.1;;
  272.                 esac
  273.                 print "* Any iOS version from $lo to $hi is supported"
  274.             fi
  275.             echo
  276.             local text2="(iOS $base_vers)"
  277.             if [[ -n $ipsw_base_path ]]; then
  278.                 print "* Selected Base IPSW $text2: $ipsw_base_path.ipsw"
  279.                 print "* Base Version: $device_base_vers-$device_base_build"
  280.                 if [[ $ipsw_base_validate == 0 ]]; then
  281.                     print "* Selected Base IPSW is validated"
  282.                 else
  283.                     warn "Selected Base IPSW failed validation, proceed with caution"
  284.                 fi
  285.                 if [[ $device_proc != 4 ]]; then
  286.                     menu_items+=("Select Base SHSH")
  287.                 fi
  288.                 echo
  289.             else
  290.                 print "* Select Base IPSW $text2 to continue"
  291.                 echo
  292.             fi
  293.             if [[ $device_proc == 4 ]]; then
  294.                 shsh_path=1
  295.             else
  296.                 if [[ -n $shsh_path ]]; then
  297.                     print "* Selected Base SHSH $text2: $shsh_path"
  298.                     if [[ $shsh_validate == 0 ]]; then
  299.                         print "* Selected SHSH file is validated"
  300.                     else
  301.                         warn "Selected SHSH file failed validation, proceed with caution"
  302.                         if (( device_proc < 5 )); then
  303.                             warn "Validation might be a false negative for A4 and older devices."
  304.                         fi
  305.                         echo
  306.                     fi
  307.                 elif [[ $2 != "ipsw" ]]; then
  308.                     print "* Select Base SHSH $text2 to continue"
  309.                     echo
  310.                 fi
  311.             fi
  312.             if [[ -n $device_bootargs ]]; then
  313.                 print "* Custom Bootargs: $device_bootargs"
  314.             else
  315.                 print "* You may enter custom bootargs (optional, experimental option)"
  316.                 print "* Default Bootargs: $device_bootargs_default"
  317.             fi
  318.             echo
  319.             menu_items+=("Custom Bootargs")
  320.             if [[ -n $ipsw_path && -n $ipsw_base_path ]] && [[ -n $shsh_path || $2 == "ipsw" ]]; then
  321.                 can_start=1
  322.             fi
  323.  
  324.         elif [[ $2 == "fourthree" ]]; then
  325.             menu_items+=("Download Target IPSW" "Select Base IPSW")
  326.             if [[ -n $ipsw_path ]]; then
  327.                 print "* Selected Target IPSW (iOS 6.1.3): $ipsw_path.ipsw"
  328.                 ipsw_print_warnings
  329.             else
  330.                 print "* Select Target IPSW (iOS 6.1.3) to continue"
  331.             fi
  332.             echo
  333.             if [[ -n $ipsw_base_path ]]; then
  334.                 print "* Selected Base IPSW (iOS 4.3.x): $ipsw_base_path.ipsw"
  335.                 print "* Base Version: $device_base_vers-$device_base_build"
  336.                 if [[ $ipsw_base_validate == 0 ]]; then
  337.                     print "* Selected Base IPSW is validated"
  338.                 else
  339.                     warn "Selected Base IPSW failed validation, proceed with caution"
  340.                 fi
  341.                 echo
  342.             else
  343.                 print "* Select Base IPSW (iOS 4.3.x) to continue"
  344.                 echo
  345.             fi
  346.             if [[ -n $ipsw_path && -n $ipsw_base_path ]]; then
  347.                 can_start=1
  348.             fi
  349.  
  350.         elif [[ $1 == *"Tethered"* ]]; then
  351.             if [[ -n $ipsw_path ]]; then
  352.                 print "* Selected Target IPSW: $ipsw_path.ipsw"
  353.                 print "* Target Version: $device_target_vers-$device_target_build"
  354.                 ipsw_print_warnings
  355.             else
  356.                 print "* Select Target IPSW to continue"
  357.             fi
  358.             echo
  359.             warn "This is a tethered downgrade. Not recommended unless you know what you are doing."
  360.             print "* For more info, go to: https://github.com/LukeZGD/Legacy-iOS-Kit/wiki/Restore-Downgrade and read the \"Other (Tethered)\" section"
  361.             if [[ -n $ipsw_path ]]; then
  362.                 can_start=1
  363.             fi
  364.             echo
  365.  
  366.         elif [[ $1 == "Other"* || $1 == "Set Nonce Only" ]]; then
  367.             # menu for other (shsh) restores
  368.             if [[ -n $ipsw_path ]]; then
  369.                 print "* Selected Target IPSW: $ipsw_path.ipsw"
  370.                 print "* Target Version: $device_target_vers-$device_target_build"
  371.                 ipsw_print_warnings
  372.                 menu_items+=("Select Target SHSH")
  373.             else
  374.                 print "* Select Target IPSW to continue"
  375.             fi
  376.             if (( device_proc >= 9 )) && [[ $device_type != "iPhone10"* ]]; then
  377.                 print "* It is recommended to use turdus merula instead: https://sep.lol/"
  378.             fi
  379.             echo
  380.             if [[ -n $shsh_path ]]; then
  381.                 print "* Selected Target SHSH: $shsh_path"
  382.                 if (( device_proc > 6 )); then
  383.                     shsh_generator=$(cat "$shsh_path" | grep "<string>0x" | cut -c10-27)
  384.                     print "* Generator: $shsh_generator"
  385.                 fi
  386.                 if [[ $shsh_validate == 0 ]]; then
  387.                     print "* Selected SHSH file is validated"
  388.                 elif [[ $device_proc == 6 && $target_vers_maj == 10 ]]; then
  389.                     warn "Validation does not work for 32-bit iOS 10 blobs."
  390.                 else
  391.                     warn "Selected SHSH file failed validation, proceed with caution"
  392.                     if (( device_proc >= 7 )); then
  393.                         print "* If this is an OTA/onboard/factory blob, it may be fine to use for restoring"
  394.                     elif (( device_proc < 5 )); then
  395.                         warn "Validation might be a false negative for A4 and older devices."
  396.                     fi
  397.                 fi
  398.                 if (( device_proc >= 7 )); then
  399.                     print "* Note: For OTA/onboard/factory blobs, try enabling the skip-blob flag"
  400.                     print "* The skip-blob flag can also help if the restore fails with validated blobs"
  401.                 fi
  402.                 echo
  403.  
  404.             elif [[ $2 != "ipsw" ]]; then
  405.                 print "* Select Target SHSH to continue"
  406.                 echo
  407.             fi
  408.             if [[ -n $ipsw_path ]] && [[ -n $shsh_path || $2 == "ipsw" ]]; then
  409.                 can_start=1
  410.             fi
  411.  
  412.         else
  413.             # menu for ota/latest versions
  414.             menu_items+=("Download Target IPSW")
  415.             if [[ -n $ipsw_path ]]; then
  416.                 print "* Selected Target IPSW: $ipsw_path.ipsw"
  417.                 ipsw_print_warnings
  418.                 can_start=1
  419.             elif [[ $device_proc == 1 && $device_type != "iPhone1,2" ]]; then
  420.                 can_start=1
  421.             else
  422.                 print "* Select $1 IPSW to continue"
  423.             fi
  424.             if [[ $ipsw_canhacktivate == 1 ]] && [[ $device_type == "iPhone2,1" || $device_proc == 1 ]]; then
  425.                 print "* Hacktivation is supported for this restore"
  426.             fi
  427.             echo
  428.         fi
  429.  
  430.         if [[ $ipsw_cancustomlogo2 == 1 ]]; then
  431.             print "* You can select your own custom Apple logo image. This is optional and an experimental option"
  432.             print "* Note: The images must be in PNG format, and up to your device resolution"
  433.             print "* Note 2: The custom images might not work, current support is spotty"
  434.             if [[ -n $ipsw_customlogo ]]; then
  435.                 print "* Custom Apple logo: $ipsw_customlogo"
  436.             else
  437.                 print "* No custom Apple logo selected"
  438.             fi
  439.             menu_items+=("Select Apple Logo")
  440.             echo
  441.         elif [[ $ipsw_cancustomlogo == 1 ]]; then
  442.             print "* You can select your own custom logo and recovery image. This is optional and an experimental option"
  443.             print "* Note: The images must be in PNG format, and up to 320x480 resolution"
  444.             print "* Note 2: The custom images might not work, current support is spotty"
  445.             if [[ -n $ipsw_customlogo ]]; then
  446.                 print "* Custom Apple logo: $ipsw_customlogo"
  447.             else
  448.                 print "* No custom Apple logo selected"
  449.             fi
  450.             if [[ -n $ipsw_customrecovery ]]; then
  451.                 print "* Custom recovery logo: $ipsw_customrecovery"
  452.             else
  453.                 print "* No custom recovery logo selected"
  454.             fi
  455.             menu_items+=("Select Apple Logo" "Select Recovery Logo")
  456.             echo
  457.         fi
  458.         if [[ $can_start == 1 ]]; then
  459.             if [[ $device_target_vers == "$device_latest_vers" && $device_mode != "none" && -z $2 ]]; then
  460.                 menu_items+=("(*) Start Update")
  461.             fi
  462.             menu_items+=("$start")
  463.         fi
  464.         menu_items+=("Go Back")
  465.  
  466.         if [[ $device_use_bb != 0 && $device_type != "$device_disable_bbupdate" ]] &&
  467.            [[ $device_proc == 5 || $device_proc == 6 ]]; then
  468.             print "* This restore will use $device_use_vers baseband"
  469.             echo
  470.         elif [[ $device_use_bb2 == 1 ]]; then
  471.             if [[ $device_target_vers == "$device_latest_vers" ]]; then
  472.                 print "* This restore will use $device_use_vers baseband if the jailbreak option is disabled"
  473.                 echo
  474.             elif [[ $device_proc == 1 || $device_target_vers == "4.1" ]] && [[ $device_type != "iPhone3,"* ]]; then
  475.                 print "* This restore will have baseband update disabled if the jailbreak option is enabled"
  476.                 echo
  477.             else
  478.                 print "* This restore will have baseband update disabled"
  479.                 echo
  480.             fi
  481.         elif [[ $device_use_bb2 == 2 ]]; then
  482.             if [[ $device_target_vers == "$device_latest_vers" ]]; then
  483.                 print "* This restore will use $device_use_vers baseband"
  484.                 echo
  485.             else
  486.                 print "* This restore will have baseband update disabled"
  487.                 echo
  488.             fi
  489.         fi
  490.  
  491.         print "$nav"
  492.         input "Select an option:"
  493.         select_option "${menu_items[@]}"
  494.         selected="${menu_items[$?]}"
  495.         case $selected in
  496.             "(*) Create IPSW" ) mode="custom-ipsw";;
  497.             "$start" ) mode="downgrade";;
  498.             "(*) Start Update" )
  499.                 print "* The \"Start Update\" will perform an update to your device without clearing device data."
  500.                 print "* One usage of this is to carry over activation records to the latest iOS version."
  501.                 warn "This option should NOT be used if your device is jailbroken."
  502.                 warn "This option is not recommended to be used unless you know what you are doing."
  503.                 select_yesno
  504.                 if [[ $? != 1 ]]; then
  505.                     continue
  506.                 fi
  507.                 mode="restore-update"
  508.             ;;
  509.             "Select Target IPSW" ) menu_ipsw_browse "$1";;
  510.             "Select Base IPSW" ) menu_ipsw_browse "base";;
  511.             "Select Target SHSH" ) menu_shsh_browse "$1";;
  512.             "Select Base SHSH" ) menu_shsh_browse "base";;
  513.             "Download Target IPSW" ) ipsw_download "../$newpath";;
  514.             "Download Base IPSW" ) ipsw_download "../$ipsw_latest_path" latest;;
  515.             "Select Apple Logo" ) menu_logo_browse "boot";;
  516.             "Select Recovery Logo" ) menu_logo_browse "recovery";;
  517.             "Custom Bootargs" ) read -p "$(input 'Enter custom bootargs: ')" device_bootargs;;
  518.             "Go Back" )
  519.                 back=1
  520.  
  521.                 ipsw_24o=
  522.                 ipsw_cancustomlogo=
  523.                 ipsw_cancustomlogo2=
  524.                 ipsw_customlogo=
  525.                 ipsw_customrecovery=
  526.                 ipsw_path=
  527.                 ipsw_base_path=
  528.                 shsh_path=
  529.                 device_target_vers=
  530.                 device_target_build=
  531.                 device_base_vers=
  532.                 device_base_build=
  533.                 device_target_other=
  534.                 device_target_powder=
  535.                 device_target_tethered=
  536.                 device_bootargs=
  537.             ;;
  538.         esac
  539.     done
  540. }
  541.  
  542. menu_ipsw_special() {
  543.     local menu_items
  544.     local selected
  545.     local back
  546.     local newpath
  547.     local nav
  548.     local start="(*) "
  549.     local base_text
  550.     local target_text
  551.  
  552.     if [[ $2 == "ipsw" ]]; then
  553.         nav=" > Main Menu > Misc Utilities > Create Custom IPSW > $1"
  554.         start+="Create IPSW"
  555.     else
  556.         nav=" > Main Menu > Restore/Downgrade > $1"
  557.         start+="Start Restore"
  558.     fi
  559.  
  560.     while [[ -z "$mode" && -z "$back" ]]; do
  561.         device_target_vers="$1"
  562.         case $device_type in
  563.             iPad1,1 ) device_type_special="iPad2,1"; device_model_special="k93";;
  564.             iPod3,1 ) device_type_special="iPhone2,1"; device_model_special="n88";;
  565.             iPod4,1 )
  566.                 device_type_special="iPhone3,3"
  567.                 device_model_special="n92"
  568.                 device_target_tethered=1
  569.             ;;
  570.         esac
  571.         case $1 in
  572.             7.1.2 ) device_target_build="11D257";;
  573.             6.1.6 ) device_target_build="10B500";;
  574.             6.1.3 ) device_target_build="10B329";;
  575.             6.0   ) device_target_build="10A403";;
  576.         esac
  577.         all_flash_special="Firmware/all_flash/all_flash.${device_model_special}ap.production"
  578.         device_base_vers="$device_latest_vers"
  579.         device_base_build="$device_latest_build"
  580.         target_vers_maj=$(echo "$device_target_vers" | cut -d. -f1)
  581.         target_vers_min=$(echo "$device_target_vers" | cut -d. -f2)
  582.         base_text="$device_type-$device_base_vers"
  583.         target_text="$device_type_special-$device_target_vers"
  584.         ipsw_latest_set
  585.  
  586.         menu_print_info
  587.         print "* Only select unmodified IPSW for the selection. Do not select custom IPSWs"
  588.         echo
  589.  
  590.         if [[ -n $ipsw_path ]]; then
  591.             print "* Selected Target IPSW ($target_text): $ipsw_path.ipsw"
  592.             ipsw_print_warnings
  593.         else
  594.             print "* Select Target IPSW ($target_text) to continue"
  595.         fi
  596.         echo
  597.         if [[ -n $ipsw_base_path ]]; then
  598.             print "* Selected Base IPSW ($base_text): $ipsw_base_path.ipsw"
  599.             if [[ $ipsw_base_validate == 0 ]]; then
  600.                 print "* Selected Base IPSW is validated"
  601.             else
  602.                 warn "Selected Base IPSW failed validation, proceed with caution"
  603.             fi
  604.         else
  605.             print "* Select Base IPSW ($base_text) to continue"
  606.         fi
  607.         echo
  608.         case $1 in
  609.             7.* )
  610.                 case $device_type in
  611.                     iPad1,1 ) print "* iOS 7 on iPad 1 is based on ipad-1-ios-7 by amy-and-nicole and pwnerblu: https://github.com/amy-and-nicole/ipad-1-ios-7";;
  612.                     iPod4,1 ) warn "This is a tethered upgrade and has many broken device features. Not recommended unless you know what you are doing.";;
  613.                 esac
  614.             ;;
  615.             6.* ) print "* iOS 6 on touch 3/iPad 1 uses SundanceInH2A by NyanSatan: https://github.com/NyanSatan/SundanceInH2A";;
  616.         esac
  617.         menu_items=("Select Target IPSW" "Select Base IPSW" "Download Target IPSW" "Download Base IPSW")
  618.         if [[ -n $ipsw_path && -n $ipsw_base_path ]]; then
  619.             menu_items+=("$start")
  620.         fi
  621.         menu_items+=("Go Back")
  622.  
  623.         print "$nav"
  624.         input "Select an option:"
  625.         select_option "${menu_items[@]}"
  626.         selected="${menu_items[$?]}"
  627.         case $selected in
  628.             "(*) Create IPSW" ) mode="custom-ipsw";;
  629.             "$start" ) mode="downgrade";;
  630.             "Select Target IPSW" ) menu_ipsw_browse "special";;
  631.             "Select Base IPSW" ) menu_ipsw_browse "base";;
  632.             "Download Target IPSW" ) ipsw_download "../${device_type_special}_${device_target_vers}_${device_target_build}_Restore" special;;
  633.             "Download Base IPSW" ) ipsw_download "../$ipsw_latest_path" latest;;
  634.             "Go Back" )
  635.                 back=1
  636.  
  637.                 ipsw_path=
  638.                 ipsw_base_path=
  639.                 device_type_special=
  640.                 device_model_special=
  641.                 device_target_tethered=
  642.             ;;
  643.         esac
  644.     done
  645. }
  646. ipsw_print_warnings() {
  647.     if [[ $ipsw_validate == 0 ]]; then
  648.         print "* Selected Target IPSW is validated"
  649.     elif [[ $ipsw_isbeta == 1 ]]; then
  650.         warn "Selected Target IPSW is a beta version, proceed with caution"
  651.     else
  652.         warn "Selected Target IPSW failed validation, proceed with caution"
  653.     fi
  654.     if [[ $device_target_vers == "9.3"* && $device_actrec == 1 ]]; then
  655.         warn "Activation records stitching does not work for iOS 9.3+ versions, use iOS 9.2.1 or lower instead when possible."
  656.     fi
  657.     if [[ $1 == "powder" ]]; then
  658.         case $device_target_build in
  659.             8[ABC]* ) warn "iOS 4.2.1 and lower are hit or miss. It may not restore/boot properly";;
  660.             8*  ) [[ $device_type == "iPhone3,"* ]] && warn "Not all devices support iOS 4 versions. It may not restore/boot properly";;
  661.             7[CDE]* ) warn "Not all devices support iOS 3 versions. It may not restore/boot properly";;
  662.         esac
  663.         return
  664.     fi
  665.     case $device_type in
  666.         iPhone3,1 | iPod4,1 )
  667.             if [[ $device_target_vers == "4.2.1" ]]; then
  668.                 warn "iOS 4.2.1 for $device_type might fail to boot after the restore/jailbreak."
  669.                 print "* It is recommended to select another version instead."
  670.             elif [[ $device_target_build == "8B118" ]]; then
  671.                 warn "iOS 4.1 (8B118) for iPod4,1 might fail to boot after the restore/jailbreak."
  672.                 print "* It is recommended to select 8B117 or another version instead."
  673.             fi
  674.         ;;
  675.         iPhone2,1 )
  676.             if [[ $device_target_vers == "3.0"* && $device_newbr != 0 ]]; then
  677.                 warn "3.0.x versions are for old bootrom devices only. It will fail to restore/boot if your device is not compatible."
  678.                 print "* It is recommended to select 3.1 or newer instead."
  679.             fi
  680.         ;;
  681.     esac
  682. }
  683.  
  684. ipsw_version_set() {
  685.     local newpath="$1"
  686.     local vers
  687.     local build
  688.  
  689.     log "Getting version from IPSW"
  690.     file_extract_from_archive "$newpath.ipsw" Restore.plist
  691.     if [[ $platform == "macos" ]]; then
  692.         rm -f BuildVer Version
  693.         plutil -extract 'ProductVersion' xml1 Restore.plist -o Version
  694.         vers=$(cat Version | sed -ne '/<string>/,/<\/string>/p' | sed -e "s/<string>//" | sed "s/<\/string>//" | sed '2d')
  695.         plutil -extract 'ProductBuildVersion' xml1 Restore.plist -o BuildVer
  696.         build=$(cat BuildVer | sed -ne '/<string>/,/<\/string>/p' | sed -e "s/<string>//" | sed "s/<\/string>//" | sed '2d')
  697.     else
  698.         vers=$(cat Restore.plist | grep -i ProductVersion -A 1 | grep -oPm1 "(?<=<string>)[^<]+")
  699.         build=$(cat Restore.plist | grep -i ProductBuildVersion -A 1 | grep -oPm1 "(?<=<string>)[^<]+")
  700.     fi
  701.  
  702.     if [[ $2 == "base" ]]; then
  703.         device_base_vers="$vers"
  704.         device_base_build="$build"
  705.     else
  706.         device_target_vers="$vers"
  707.         device_target_build="$build"
  708.         target_vers_maj=$(echo "$device_target_vers" | cut -d. -f1)
  709.         target_vers_min=$(echo "$device_target_vers" | cut -d. -f2)
  710.     fi
  711. }
  712.  
  713. ipsw_custom_set() {
  714.     if [[ $ipsw_fourthree == 1 ]]; then
  715.         ipsw_custom="../${device_type}_${device_target_vers}_${device_target_build}_FourThree"
  716.         return
  717.     fi
  718.  
  719.     ipsw_custom="../${device_type}"
  720.     ipsw_custom+="_${device_target_vers}_${device_target_build}_Custom"
  721.     if [[ -n $1 ]]; then
  722.         ipsw_custom="../$1_Custom"
  723.     fi
  724.  
  725.     if [[ $device_actrec == 1 ]]; then
  726.         ipsw_custom+="A"
  727.     fi
  728.     if [[ $device_deadbb == 1 ]]; then
  729.         ipsw_custom+="D"
  730.     elif [[ $device_type == "$device_disable_bbupdate" ]]; then
  731.         ipsw_custom+="B"
  732.     fi
  733.     if [[ $ipsw_gasgauge_patch == 1 ]]; then
  734.         ipsw_custom+="G"
  735.     fi
  736.     if [[ $ipsw_hacktivate == 1 ]]; then
  737.         ipsw_custom+="H"
  738.     fi
  739.     if [[ $ipsw_jailbreak == 1 ]]; then
  740.         ipsw_custom+="J"
  741.     fi
  742.     if [[ $device_proc == 1 && $device_type != "iPhone1,2" ]]; then
  743.         ipsw_custom2="$ipsw_custom"
  744.     fi
  745.     if [[ -n $ipsw_customlogo || -n $ipsw_customrecovery ]]; then
  746.         ipsw_custom+="L"
  747.         if [[ $device_proc == 1 && $device_type != "iPhone1,2" ]]; then
  748.             ipsw_customlogo2=1
  749.         fi
  750.     fi
  751.     if [[ $ipsw_24o == 1 ]]; then
  752.         ipsw_custom+="O"
  753.     fi
  754.     if [[ $device_target_powder == 1 ]]; then
  755.         ipsw_custom+="P"
  756.         if [[ $device_base_vers == "7.0"* ]]; then
  757.             ipsw_custom+="0"
  758.         fi
  759.     fi
  760.     if [[ $device_target_tethered == 1 ]]; then
  761.         ipsw_custom+="T"
  762.     fi
  763.     if [[ $ipsw_verbose == 1 ]]; then
  764.         ipsw_custom+="V"
  765.     fi
  766.     if [[ $device_target_powder == 1 && $device_target_vers == "4.3"* ]] || [[ $device_actrec == 1 ]] ||
  767.        [[ $device_type == "$device_disable_bbupdate" && $device_deadbb != 1 ]]; then
  768.         ipsw_custom+="-$device_ecid"
  769.     fi
  770. }
  771.  
  772. menu_logo_browse() {
  773.     local newpath
  774.     input "Select your $1 image file in the file selection window."
  775.     menu_zenity_check
  776.     newpath="$($zenity --file-selection --file-filter='PNG | *.png' --title="Select $1 image file")"
  777.     [[ ! -s "$newpath" ]] && read -p "$(input "Enter path to $1 image file (or press Enter/Return or Ctrl+C to cancel): ")" newpath
  778.    [[ ! -s "$newpath" ]] && return
  779.    log "Selected $1 image file: $newpath"
  780.    case $1 in
  781.        "boot" ) ipsw_customlogo="$newpath";;
  782.        "recovery" ) ipsw_customrecovery="$newpath";;
  783.    esac
  784. }
  785.  
  786. ipsw_print_1415warn() {
  787.    warn "Please read: You will need to follow a guide regarding activation files before and after the restore."
  788.    print "* You will encounter issues activating if you do not follow this."
  789.    print "* Link to guide: https://gist.github.com/pixdoet/2b58cce317a3bc7158dfe10c53e3dd32"
  790.    warn "You will also have several issues after the restore itself. Broken features include:"
  791.    print "* SMS/iMessage, VPN, Face ID, Touch ID resets, sideloading (use TrollStore instead), and potentially other features"
  792. }
  793.  
  794. ipsw_print_16warn() {
  795.    warn "Please read: You will have some issues after the restore itself. Broken features include:"
  796.    print "* SMS/iMessage, Face ID, and potentially other features."
  797.    print "* There is a fix for Messages available. Go to FutureRestore Support Discord server for more details."
  798. }
  799.  
  800. menu_ipsw_browse() {
  801.    local versionc
  802.    local newpath
  803.    local text="Target"
  804.    local picker
  805.    local scan
  806.  
  807.    ipsw_latest_set
  808.    local menu_items=($(ls ../$device_type_lower*restore.ipsw $HOME/Downloads/$device_type_lower*restore.ipsw 2>/dev/null))
  809.    menu_items+=($(ls ../$device_type*Restore.ipsw $HOME/Downloads/$device_type*Restore.ipsw 2>/dev/null))
  810.    [[ $ipsw_prefix != "$device_type" ]] && menu_items+=($(ls ../${ipsw_prefix}_1*Restore.ipsw $HOME/Downloads/${ipsw_prefix}_1*Restore.ipsw 2>/dev/null))
  811.    if [[ $1 == "base" ]]; then
  812.        text="Base"
  813.        scan="${device_type_lower}_${check_vers}*restore.ipsw"
  814.        menu_items=($(ls ../$scan $HOME/Downloads/$scan 2>/dev/null))
  815.        scan="${device_type}_${check_vers}*Restore.ipsw"
  816.        menu_items+=($(ls ../$scan $HOME/Downloads/$scan 2>/dev/null))
  817.    elif [[ $1 == "special" ]]; then
  818.        scan="${device_type_special}_${device_target_vers}_${device_target_build}_Restore.ipsw"
  819.        menu_items=($(ls ../$scan $HOME/Downloads/$scan 2>/dev/null))
  820.    fi
  821.    case $1 in
  822.        "iOS 10.3.3"  ) versionc="10.3.3";;
  823.        "iOS 8.4.1"   ) versionc="8.4.1";;
  824.        "iOS 6.1.3"   ) versionc="6.1.3";;
  825.        "iOS 4.1"     ) versionc="4.1";;
  826.        "Latest iOS"* ) versionc="$device_latest_vers";;
  827.        [6543].* ) versionc="$1";;
  828.        "custom" ) text="Custom";;
  829.    esac
  830.    if [[ $1 == "custom" ]]; then
  831.        menu_items=()
  832.    elif [[ $versionc == "$device_latest_vers" ]]; then
  833.        menu_items+=($(ls ../${ipsw_prefix}_${device_latest_vers}_${device_latest_build}_Restore.ipsw 2>/dev/null))
  834.    elif [[ -n $versionc ]]; then
  835.        menu_items=($(ls ../${device_type}_${versionc}*Restore.ipsw 2>/dev/null))
  836.    fi
  837.    menu_items+=("Open File Picker" "Enter Path" "Go Back")
  838.  
  839.    if [[ "${menu_items[0]}" == *".ipsw" ]]; then
  840.        print "* Select $text IPSW Menu"
  841.        while true; do
  842.            input "Select an option:"
  843.            select_option "${menu_items[@]}"
  844.            selected="${menu_items[$?]}"
  845.            case $selected in
  846.                "Open File Picker" ) picker=1; break;;
  847.                "Enter Path" ) break;;
  848.                *.ipsw ) newpath="$selected"; break;;
  849.                "Go Back" ) return;;
  850.            esac
  851.        done
  852.    else
  853.        picker=1
  854.    fi
  855.  
  856.    if [[ $picker == 1 ]]; then
  857.        input "Select your $text IPSW file in the file selection window."
  858.        menu_zenity_check
  859.        if [[ $1 == "custom" ]]; then
  860.            newpath="$($zenity --file-selection --file-filter='IPSW | *.ipsw' --title="Select $text IPSW file")"
  861.        else
  862.            newpath="$($zenity --file-selection --file-filter='IPSW | *Restore.ipsw' --title="Select $text IPSW file")"
  863.        fi
  864.    fi
  865.    if [[ ! -s "$newpath" ]]; then
  866.        print "* Enter the full path to the IPSW file to be used."
  867.        print "* You may also drag and drop the IPSW file to the Terminal window."
  868.        read -p "$(input "Path to $text IPSW file (or press Enter/Return or Ctrl+C to cancel): ")" newpath
  869.    fi
  870.    [[ ! -s "$newpath" ]] && return
  871.    newpath="${newpath%?????}"
  872.    log "Selected IPSW file: $newpath.ipsw"
  873.    ipsw_version_set "$newpath" "$1"
  874.  
  875.    if [[ $device_target_vers == "$device_latest_vers" && $platform == "macos" ]] && (( device_proc >= 7 )); then
  876.        log "Restoring to latest iOS for 64-bit devices is not supported on macOS, use iTunes/Finder instead for that"
  877.        pause
  878.        return
  879.    fi
  880.    if [[ $device_target_vers == "$device_latest_vers" ]] &&
  881.       [[ $device_target_other == 1 || $device_target_tethered == 1 ]]; then
  882.        log "For restoring to latest iOS, select the \"Latest iOS\" option instead of \"Other\""
  883.        pause
  884.        return
  885.    elif [[ $device_proc == 6 && $target_vers_maj == 10 && $device_target_tethered != 1 &&
  886.            $device_target_other != 1 && $device_target_powder != 1 ]]; then
  887.        log "Selected IPSW ($device_target_vers) is not supported as target version."
  888.        print "* iOS 10 versions that are not 10.3.4 are not supported for 32-bit devices."
  889.        print "* The only exception is for restoring with 32-bit iOS 10 blobs."
  890.        pause
  891.        return
  892.    fi
  893.    if [[ $1 == "special" ]]; then
  894.        if [[ $(cat Restore.plist | grep -c $device_type_special) == 0 ]]; then
  895.            log "Selected IPSW is not for device $device_type_special."
  896.            pause
  897.            return
  898.        fi
  899.    elif [[ $(cat Restore.plist | grep -c $device_type) == 0 ]]; then
  900.        log "Selected IPSW is not for your device $device_type."
  901.        pause
  902.        return
  903.    elif [[ $device_proc == 8 && $device_latest_vers == "12"* ]] || [[ $device_type == "iPad4,6" ]]; then
  904.        # SEP/BB check for iPhone 6/6+, iPad mini 2 China, iPod touch 6
  905.        case $device_target_build in
  906.            1[1234]* | 15[ABCD]* )
  907.                log "Selected IPSW ($device_target_vers) is not supported as target version."
  908.                print "* Latest SEP/BB is not compatible."
  909.                pause
  910.                return
  911.            ;;
  912.        esac
  913.    elif [[ $device_proc == 7 ]]; then
  914.        # SEP/BB check for iPhone 5S, iPad Air 1/mini 2
  915.        case $device_target_build in
  916.            1[123]* | 14A* | 15[ABCD]* )
  917.                log "Selected IPSW ($device_target_vers) is not supported as target version."
  918.                print "* Latest SEP/BB is not compatible."
  919.                pause
  920.                return
  921.            ;;
  922.        esac
  923.    elif [[ $device_latest_vers == "15"* ]]; then
  924.        # SEP/BB check for iPhone 6S/6S+/SE 2016/7/7+, iPad Air 2/mini 4, iPod touch 7
  925.        case $device_target_build in
  926.            1[234567]* )
  927.                log "Selected IPSW ($device_target_vers) is not supported as target version."
  928.                print "* Latest SEP/BB is not compatible."
  929.                if (( device_proc >= 9 )); then
  930.                    print "* Use turdus merula instead: https://sep.lol/"
  931.                fi
  932.                pause
  933.                return
  934.            ;;
  935.        esac
  936.    elif [[ $device_checkm8ipad == 1 ]]; then
  937.        case $device_target_build in
  938.            1[89]* )
  939.                ipsw_print_1415warn
  940.                print "* It is recommended to use turdus merula instead: https://sep.lol/"
  941.                pause
  942.            ;;
  943.            20[GH]* ) # 16.6-16.7.x only in 16.x
  944.                ipsw_print_16warn
  945.                print "* It is recommended to use turdus merula instead: https://sep.lol/"
  946.                pause
  947.            ;;
  948.            #22[GH]* ) :;; # fr doesnt actually work on ipados/ios 18 so this is commented out for now
  949.            * )
  950.                log "Selected IPSW ($device_target_vers) is not supported as target version."
  951.                print "* Latest SEP/BB is not compatible."
  952.                print "* Use turdus merula instead: https://sep.lol/"
  953.                pause
  954.                return
  955.            ;;
  956.        esac
  957.    elif [[ $device_latest_vers == "16"* ]]; then
  958.        case $device_target_build in
  959.            18[CDEFGH]* | 19* )
  960.                ipsw_print_1415warn
  961.                pause
  962.            ;;
  963.            20[GH]* ) # 16.6-16.7.x only in 16.x
  964.                ipsw_print_16warn
  965.                pause
  966.            ;;
  967.            * )
  968.                log "Selected IPSW ($device_target_vers) is not supported as target version."
  969.                print "* Latest SEP/BB is not compatible."
  970.                pause
  971.                return
  972.            ;;
  973.        esac
  974.    fi
  975.  
  976.    case $1 in
  977.        "onboard" )
  978.            if [[ $device_target_vers == "10"* ]]; then
  979.                log "Saving iOS 10 blobs is not supported for 32-bit devices."
  980.                pause
  981.                return
  982.            fi
  983.        ;;
  984.        "base" )
  985.            local check_vers="$check_vers"
  986.            local base_vers="$base_vers"
  987.            if [[ $ipsw_fourthree == 1 ]]; then
  988.                check_vers="4.3"
  989.                base_vers="4.3.x"
  990.            fi
  991.            if [[ $device_base_vers != "$check_vers"* ]]; then
  992.                log "Selected IPSW is not for iOS $base_vers."
  993.                if [[ $device_proc == 4 ]]; then
  994.                    print "* You need to select iOS $base_vers IPSW for the base to use powdersn0w."
  995.                elif [[ $ipsw_fourthree == 1 ]]; then
  996.                    print "* You need to select iOS $base_vers IPSW for the base to use FourThree."
  997.                else
  998.                    print "* You need iOS $base_vers IPSW and SHSH blobs for your device to use powdersn0w."
  999.                fi
  1000.                pause
  1001.                return
  1002.            elif [[ $device_target_build == "$device_base_build" ]]; then
  1003.                log "The base version and the target version cannot be the same."
  1004.                device_target_vers=
  1005.                device_target_build=
  1006.                device_base_vers=
  1007.                device_base_build=
  1008.                ipsw_path=
  1009.                ipsw_base_path=
  1010.                pause
  1011.                return
  1012.            fi
  1013.            ipsw_verify "$newpath" "$device_base_build"
  1014.            if [[ $? != 0 ]]; then
  1015.                return
  1016.            fi
  1017.            ipsw_base_path="$newpath"
  1018.            return
  1019.        ;;
  1020.        *"powdersn0w"* )
  1021.            if [[ $device_target_build == "14"* ]]; then
  1022.                log "Selected IPSW ($device_target_vers) is not supported as target version."
  1023.                case $device_type in
  1024.                    iPhone5,[12] ) print "* If you want to jailbreak iOS 10 untethered, use p0insettia plus: https://github.com/LukeZGD/p0insettia-plus";;
  1025.                esac
  1026.                pause
  1027.                return
  1028.            elif [[ $device_target_build == "11D257" && $device_type == "iPhone3,"* ]] ||
  1029.                 [[ $device_target_build == "9B206" && $device_proc == 4 && $device_type != "iPhone3,"* ]]; then
  1030.                log "Selected IPSW ($device_target_vers) is not supported as target version. You need to select it as the base IPSW."
  1031.                device_target_vers=
  1032.                device_target_build=
  1033.                ipsw_path=
  1034.                pause
  1035.                return
  1036.            elif [[ $device_target_build == "$device_base_build" ]]; then
  1037.                log "The base version and the target version cannot be the same."
  1038.                device_target_vers=
  1039.                device_target_build=
  1040.                device_base_vers=
  1041.                device_base_build=
  1042.                ipsw_path=
  1043.                ipsw_base_path=
  1044.                pause
  1045.                return
  1046.            fi
  1047.        ;;
  1048.    esac
  1049.    if [[ -n $versionc && $device_target_vers != "$versionc" ]]; then
  1050.        log "Selected IPSW ($device_target_vers) does not match target version ($versionc)."
  1051.        pause
  1052.        return
  1053.    fi
  1054.    if [[ $1 == "special" ]]; then
  1055.        ipsw_verify "$newpath" "$device_target_build" special
  1056.        [[ $? != 0 ]] && return
  1057.    elif [[ $1 != "custom" ]]; then
  1058.        ipsw_verify "$newpath" "$device_target_build"
  1059.        [[ -n $versionc && $? != 0 ]] && return
  1060.    fi
  1061.    ipsw_path="$newpath"
  1062. }
  1063.  
  1064. menu_shsh_browse() {
  1065.    local newpath
  1066.    local text="Target"
  1067.    local val="$ipsw_path.ipsw"
  1068.    local picker
  1069.  
  1070.    local menu_items=($(ls ../*${device_ecid}*${device_type}*${device_target_vers}*shsh* ../saved/shsh/*${device_ecid}*${device_type}*${device_target_vers}*shsh* 2>/dev/null))
  1071.    if [[ $1 == "base" ]]; then
  1072.        text="Base"
  1073.        menu_items=($(ls ../*${device_ecid}*${device_type}*${device_base_vers}*shsh* ../saved/shsh/*${device_ecid}*${device_type}*${device_base_vers}*shsh* 2>/dev/null))
  1074.    fi
  1075.    menu_items+=("Open File Picker" "Enter Path" "Go Back")
  1076.  
  1077.    if [[ "${menu_items[0]}" == *"shsh"* ]]; then
  1078.        print "* Select $text SHSH Menu"
  1079.        while true; do
  1080.            input "Select an option:"
  1081.            select_option "${menu_items[@]}"
  1082.            selected="${menu_items[$?]}"
  1083.            case $selected in
  1084.                "Open File Picker" ) picker=1; break;;
  1085.                "Enter Path" ) break;;
  1086.                *shsh* ) newpath="$selected"; break;;
  1087.                "Go Back" ) return;;
  1088.            esac
  1089.        done
  1090.    else
  1091.        picker=1
  1092.    fi
  1093.  
  1094.    if [[ $picker == 1 ]]; then
  1095.        input "Select your $text SHSH file in the file selection window."
  1096.        menu_zenity_check
  1097.        newpath="$($zenity --file-selection --file-filter='SHSH | *.bshsh2 *.shsh *.shsh2' --title="Select $text SHSH file")"
  1098.    fi
  1099.  
  1100.    if [[ -n "$newpath" && ! -s "$newpath" ]]; then
  1101.        warn "The selected SHSH blob file seems to be empty/invalid. It cannot be used for restoring."
  1102.        pause
  1103.        return
  1104.    fi
  1105.    if [[ ! -s "$newpath" ]]; then
  1106.        print "* Enter the full path to the SHSH file to be used."
  1107.        print "* You may also drag and drop the SHSH file to the Terminal window."
  1108.        read -p "$(input "Path to $text SHSH file (or press Enter/Return or Ctrl+C to cancel): ")" newpath
  1109.    fi
  1110.    [[ ! -s "$newpath" ]] && return
  1111.    log "Selected SHSH file: $newpath"
  1112.    log "Validating..."
  1113.    if (( device_proc >= 7 )); then
  1114.        file_extract_from_archive "$val" BuildManifest.plist
  1115.        shsh_validate=$("$dir/img4tool" -s "$newpath" --verify BuildManifest.plist | tee /dev/tty | grep -c "APTicket is BAD!")
  1116.    elif [[ $device_proc == 6 && $target_vers_maj == 10 ]]; then
  1117.        shsh_validate=1
  1118.        shsh_path="$newpath"
  1119.        return
  1120.    else
  1121.        if [[ $1 == "base" ]]; then
  1122.            val="$ipsw_base_path.ipsw"
  1123.        fi
  1124.        "$dir/validate" "$newpath" "$val" -z
  1125.        shsh_validate=$?
  1126.    fi
  1127.    if [[ $shsh_validate != 0 ]]; then
  1128.        warn "Validation failed. Did you select the correct IPSW/SHSH?"
  1129.        print "* If you selected the correct IPSW and the error is not APTicket and/or LLB, the blob is most likely usable."
  1130.        pause
  1131.    fi
  1132.    shsh_path="$newpath"
  1133. }
  1134.  
  1135. menu_shshdump_browse() {
  1136.    local newpath
  1137.    input "Select your raw dump file in the file selection window."
  1138.    menu_zenity_check
  1139.    newpath="$($zenity --file-selection --file-filter='Raw Dump | *.dump *.raw' --title="Select Raw Dump")"
  1140.    [[ ! -s "$newpath" ]] && read -p "$(input "Enter path to raw dump file (or press Enter/Return or Ctrl+C to cancel): ")" newpath
  1141.    [[ ! -s "$newpath" ]] && return
  1142.    log "Selected raw dump file: $newpath"
  1143.    shsh_path="$newpath"
  1144. }
  1145.  
  1146. menu_flags() {
  1147.    local menu_items
  1148.    local selected
  1149.    local back
  1150.  
  1151.    while [[ -z "$mode" && -z "$back" ]]; do
  1152.        menu_items=()
  1153.        case $device_type in
  1154.            iPhone[45]* | iPad2,[67] | iPad3,[56] ) menu_items+=("Enable disable-bbupdate flag");;
  1155.        esac
  1156.        if (( device_proc >= 7 )); then
  1157.            menu_items+=("Enable skip-blob flag")
  1158.        else
  1159.            if [[ $device_actrec == 1 ]]; then
  1160.                menu_items+=("Disable activation-records flag")
  1161.            else
  1162.                menu_items+=("Enable activation-records flag")
  1163.            fi
  1164.            menu_items+=("Enable jailbreak flag" "Enable multipatch flag")
  1165.            if (( device_proc >= 5 )); then
  1166.                menu_items+=("Enable skip-ibss flag")
  1167.            fi
  1168.        fi
  1169.        case $device_type in
  1170.            iPhone3,[13] | iPad1,1 | iPod3,1 ) menu_items+=("Enable skip-first flag");;
  1171.        esac
  1172.        menu_items+=("Enable no-finder flag" "Go Back")
  1173.        menu_print_info
  1174.        print " > Main Menu > Misc Utilities > Enable Flags"
  1175.        input "Select an option:"
  1176.        select_option "${menu_items[@]}"
  1177.        selected="${menu_items[$?]}"
  1178.        case $selected in
  1179.            "Enable disable-bbupdate flag" )
  1180.                warn "This will enable the --disable-bbupdate flag."
  1181.                print "* This will disable baseband update for custom IPSWs."
  1182.                print "* This will enable usage of dumped baseband and stitch to IPSW."
  1183.                print "* This supports the following: iPhone 4S, 5, 5C, iPad 4, mini 1"
  1184.                print "* Do not enable this if you do not know what you are doing."
  1185.                local opt
  1186.                select_yesno "Do you want to enable the disable-bbupdate flag?" 0
  1187.                if [[ $? != 0 ]]; then
  1188.                    device_disable_bbupdate="$device_type"
  1189.                    back=1
  1190.                fi
  1191.            ;;
  1192.            "Enable activation-records flag" )
  1193.                warn "This will enable the --activation-records flag."
  1194.                print "* This will enable usage of dumped activation records and stitch to IPSW."
  1195.                print "* Do not enable this if you do not know what you are doing."
  1196.                local opt
  1197.                select_yesno "Do you want to enable the activation-records flag?" 0
  1198.                if [[ $? != 0 ]]; then
  1199.                    device_actrec=1
  1200.                    device_disable_actrec=
  1201.                    back=1
  1202.                fi
  1203.            ;;
  1204.            "Disable activation-records flag" )
  1205.                warn "This will disable the --activation-records flag."
  1206.                print "* This will disable usage of dumped activation records and stitch to IPSW."
  1207.                print "* Do not disable this if you do not know what you are doing."
  1208.                local opt
  1209.                select_yesno "Do you want to disable the activation-records flag?" 0
  1210.                if [[ $? != 0 ]]; then
  1211.                    device_actrec=
  1212.                    device_disable_actrec=1
  1213.                    back=1
  1214.                fi
  1215.            ;;
  1216.            "Enable skip-ibss flag" )
  1217.                warn "This will enable the --skip-ibss flag."
  1218.                print "* This will assume that a pwned iBSS has already been sent to the device."
  1219.                print "* Do not enable this if you do not know what you are doing."
  1220.                local opt
  1221.                select_yesno "Do you want to enable the skip-ibss flag?" 0
  1222.                if [[ $? != 0 ]]; then
  1223.                    device_skip_ibss=1
  1224.                    back=1
  1225.                fi
  1226.            ;;
  1227.            "Enable jailbreak flag" )
  1228.                warn "This will enable the --jailbreak flag."
  1229.                print "* This will enable the jailbreak option for the custom IPSW."
  1230.                print "* This is mostly useful for 4.1 and lower, where jailbreak option is disabled in some cases."
  1231.                print "* The recommended method is to jailbreak after the restore instead."
  1232.                print "* Do not enable this if you do not know what you are doing."
  1233.                local opt
  1234.                select_yesno "Do you want to enable the jailbreak flag?" 0
  1235.                if [[ $? != 0 ]]; then
  1236.                    ipsw_jailbreak=1
  1237.                    back=1
  1238.                fi
  1239.            ;;
  1240.            "Enable multipatch flag" )
  1241.                warn "This will enable the --multipatch flag."
  1242.                print "* This will enable \"multipatch\" for the custom IPSW."
  1243.                print "* This is especially useful for iPhone 4S devices that have issues restoring due to third party battery."
  1244.                print "* This issue is called \"gas gauge\" error, also known as error 29 in iTunes."
  1245.                print "* By enabling this, firmware components for 6.1.3 or lower will be used for restoring to get past the error."
  1246.                print "* This also attempts to get past \"invalid ticket\" error and other restore errors."
  1247.                local opt
  1248.                select_yesno "Do you want to enable the multipatch flag?" 0
  1249.                if [[ $? != 0 ]]; then
  1250.                    ipsw_gasgauge_patch=1
  1251.                    back=1
  1252.                fi
  1253.            ;;
  1254.            "Enable skip-first flag" )
  1255.                warn "This will enable the --skip-first flag."
  1256.                print "* This will skip first restore and flash part 2 IPSW only for powdersn0w 4.2.x and lower."
  1257.                print "* Do not enable this if you do not know what you are doing."
  1258.                local opt
  1259.                select_yesno "Do you want to enable the skip-ibss flag?" 0
  1260.                if [[ $? != 0 ]]; then
  1261.                    ipsw_skip_first=1
  1262.                    back=1
  1263.                fi
  1264.            ;;
  1265.            "Enable skip-blob flag" )
  1266.                warn "This will enable the --skip-blob flag."
  1267.                print "* This will enable the skip blob flag of futurerestore."
  1268.                print "* This can be used to skip blob verification for OTA/onboard/factory SHSH blobs."
  1269.                print "* Do not enable this if you do not know what you are doing."
  1270.                local opt
  1271.                select_yesno "Do you want to enable the skip-blob flag?" 0
  1272.                if [[ $? != 0 ]]; then
  1273.                    restore_useskipblob=1
  1274.                    back=1
  1275.                fi
  1276.            ;;
  1277.            "Enable no-finder flag" )
  1278.                warn "This will enable the --no-finder flag."
  1279.                print "* This will disable Finder device detection and keep it disabled after the script exits."
  1280.                print "* To re-enable it, run the script without this flag enabled then exit."
  1281.                local opt
  1282.                select_yesno "Do you want to enable the no-finder flag?" 0
  1283.                if [[ $? != 0 ]]; then
  1284.                    no_finder=1
  1285.                    back=1
  1286.                fi
  1287.            ;;
  1288.            "Go Back" ) back=1;;
  1289.        esac
  1290.    done
  1291. }
  1292.  
  1293. menu_miscutilities() {
  1294.    local menu_items
  1295.    local selected
  1296.    local back
  1297.  
  1298.    menu_print_info
  1299.    while [[ -z "$mode" && -z "$back" ]]; do
  1300.        menu_items=()
  1301.        if [[ $device_mode != "none" ]]; then
  1302.            if [[ $device_mode == "Normal" ]]; then
  1303.                case $device_type in
  1304.                    iPad2,[123] ) menu_items+=("FourThree Utility");;
  1305.                esac
  1306.                if [[ -n $device_serial ]]; then
  1307.                    menu_items+=("Export Device Info")
  1308.                    if (( device_vers_maj < 5 )); then
  1309.                        warn "Device is on lower than iOS 5. Battery info is not available"
  1310.                    else
  1311.                        menu_items+=("Export Battery Info")
  1312.                    fi
  1313.                    if (( device_vers_maj < 4 )) || (( device_vers_maj == 4 && device_vers_min < 2 )); then
  1314.                        warn "Device is on lower than iOS 4.2.x. Shutdown/Restart device options are not available"
  1315.                    else
  1316.                        menu_items+=("Shutdown Device" "Restart Device" )
  1317.                    fi
  1318.                    menu_items+=("Enter Recovery Mode" "Attempt Activation")
  1319.                else
  1320.                    warn "Some options are currently unavailable. Pair your device to access them."
  1321.                    menu_items+=("Pair Device")
  1322.                fi
  1323.                menu_items+=("Activation Records")
  1324.            fi
  1325.            if [[ $device_proc != 1 ]] && (( device_proc < 7 )); then
  1326.                if [[ $device_mode != "Normal" ]]; then
  1327.                    menu_items+=("Get iOS Version" "Activation Records")
  1328.                fi
  1329.                case $device_type in
  1330.                    iPhone[45]* | iPad2,[67] | iPad3,[56] ) menu_items+=("Dump Baseband");;
  1331.                esac
  1332.            fi
  1333.        fi
  1334.        if (( device_proc <= 10 )) && [[ $device_latest_vers != "16"* && $device_checkm8ipad != 1 && $device_argmode == "none" ]]; then
  1335.            menu_items+=("SSH Ramdisk")
  1336.        fi
  1337.        if [[ $device_proc != 1 ]] && (( device_proc < 11 )); then
  1338.            menu_items+=("Enable Flags")
  1339.        fi
  1340.        if (( device_proc < 7 )); then
  1341.            menu_items+=("Create Custom IPSW")
  1342.        fi
  1343.        menu_items+=("(Re-)Install Dependencies" "Go Back")
  1344.        print " > Main Menu > Misc Utilities"
  1345.        input "Select an option:"
  1346.        select_option "${menu_items[@]}"
  1347.        selected="${menu_items[$?]}"
  1348.        case $selected in
  1349.            "Export Device Info" )
  1350.                device_pair
  1351.                mkdir -p ../saved/info
  1352.                log "Running ideviceinfo"
  1353.                local info="../saved/info/device-$device_ecid-$device_type-$(date +%Y-%m-%d-%H%M).txt"
  1354.                $ideviceinfo > $info
  1355.                if [[ $? != 0 ]]; then
  1356.                    $ideviceinfo -s > $info
  1357.                fi
  1358.                log "Device Info exported to: $info"
  1359.            ;;
  1360.            "Export Battery Info" )
  1361.                device_pair
  1362.                mkdir -p ../saved/info
  1363.                log "Running idevicediagnostics"
  1364.                local info="../saved/info/battery-$device_ecid-$device_type-$(date +%Y-%m-%d-%H%M).txt"
  1365.                $idevicediagnostics ioregentry AppleSmartBattery > $info
  1366.                if [[ $? != 0 ]]; then
  1367.                    $idevicediagnostics ioregentry AppleARMPMUCharger > $info
  1368.                fi
  1369.                log "Battery Info exported to: $info"
  1370.            ;;
  1371.            "Shutdown Device" ) mode="shutdown";;
  1372.            "Restart Device" ) mode="restart";;
  1373.            "Enter Recovery Mode" ) mode="enterrecovery";;
  1374.            "Attempt Activation" ) device_activate;;
  1375.            "Dump Baseband" ) mode="baseband";;
  1376.            "Activation Records" ) mode="actrec";;
  1377.            "Enable Flags" ) menu_flags;;
  1378.            "(Re-)Install Dependencies" ) install_depends;;
  1379.            "Create Custom IPSW" ) menu_restore ipsw;;
  1380.            "Get iOS Version" ) mode="getversion";;
  1381.            "SSH Ramdisk" ) mode="device_enter_ramdisk";;
  1382.            "FourThree Utility" ) menu_fourthree;;
  1383.            "Pair Device" ) device_pair;;
  1384.            "Go Back" ) back=1;;
  1385.        esac
  1386.    done
  1387. }
  1388.  
  1389. menu_usefulutilities() {
  1390.    local menu_items
  1391.    local selected
  1392.    local back
  1393.  
  1394.    while [[ -z "$mode" && -z "$back" ]]; do
  1395.        menu_items=()
  1396.        if [[ $device_proc != 1 ]] && (( device_proc < 7 )); then
  1397.            if [[ $device_mode == "Normal" && $device_type != "iPod2,1" ]]; then
  1398.                menu_items+=("Enter kDFU Mode")
  1399.            fi
  1400.            case $device_proc in
  1401.                [56] ) menu_items+=("Send Pwned iBSS");;
  1402.                *    ) menu_items+=("Enter pwnDFU Mode");;
  1403.            esac
  1404.            menu_items+=("Clear NVRAM")
  1405.            if [[ $device_canpowder == 1 ]]; then
  1406.                menu_items+=("Disable/Enable Exploit")
  1407.            elif [[ $device_type == "iPhone2,1" && $device_newbr != 0 && $device_mode != "Normal" ]]; then
  1408.                menu_items+=("Install alloc8 Exploit")
  1409.            fi
  1410.            if [[ $device_type != "iPod2,1" && $device_mode == "Normal" ]]; then
  1411.                menu_items+=("Just Boot")
  1412.            fi
  1413.            if [[ $device_mode == "Normal" ]]; then
  1414.                case $device_type in
  1415.                    iPhone1,* )
  1416.                        case $device_vers in
  1417.                            3.1.3 | 4.[12]* ) menu_items+=("Hacktivate Device" "Revert Hacktivation");;
  1418.                        esac
  1419.                    ;;
  1420.                    iPad1,1 | iPhone[23],* | iPod4,1 )
  1421.                        case $device_vers in
  1422.                            3.1* | [456]* ) menu_items+=("Hacktivate Device" "Revert Hacktivation");;
  1423.                        esac
  1424.                    ;;
  1425.                esac
  1426.            fi
  1427.        fi
  1428.        if (( device_proc >= 7 )) && (( device_proc <= 10 )); then
  1429.            menu_items+=("Enter pwnDFU Mode")
  1430.        fi
  1431.        if (( device_proc <= 10 )) && [[ $device_latest_vers != "16"* && $device_checkm8ipad != 1 ]]; then
  1432.            menu_items+=("SSH Ramdisk" "Update DateTime")
  1433.        fi
  1434.        if [[ $device_mode == "Normal" ]]; then
  1435.            menu_items+=("Run uicache" "Console")
  1436.        fi
  1437.        menu_items+=("DFU Mode Helper" "Go Back")
  1438.        menu_print_info
  1439.        # other utilities menu
  1440.        print " > Main Menu > Useful Utilities"
  1441.        input "Select an option:"
  1442.        select_option "${menu_items[@]}"
  1443.        selected="${menu_items[$?]}"
  1444.        case $selected in
  1445.            "Hacktivate Device" )
  1446.                print "* Note: This is for hacktivating devices that are already restored and jailbroken with Legacy iOS Kit."
  1447.                print "* If this is not what you want, you might be looking for the \"Restore/Downgrade\" option instead."
  1448.                print "* From there, enable both \"Jailbreak Option\" and \"Hacktivate Option.\""
  1449.                echo
  1450.                print "* Hacktivate Device: This will patch lockdownd on your device."
  1451.                print "* Hacktivation is for iOS versions 3.1 to 6.1.6."
  1452.                select_yesno
  1453.                if [[ $? != 1 ]]; then
  1454.                    continue
  1455.                fi
  1456.                mode="device_hacktivate"
  1457.            ;;
  1458.            "Revert Hacktivation" )
  1459.                print "* This will use revert hacktivation for this device."
  1460.                print "* This option can only be used if the hacktivation is done using Legacy iOS Kit's \"Hacktivate Device\" option."
  1461.                select_yesno
  1462.                if [[ $? != 1 ]]; then
  1463.                    continue
  1464.                fi
  1465.                mode="device_reverthacktivate"
  1466.            ;;
  1467.            "Enter kDFU Mode" ) mode="kdfu";;
  1468.            "Disable/Enable Exploit" ) menu_remove4;;
  1469.            "SSH Ramdisk" ) mode="device_enter_ramdisk";;
  1470.            "Clear NVRAM" ) mode="ramdisknvram";;
  1471.            "Send Pwned iBSS" | "Enter pwnDFU Mode" ) mode="pwned-ibss";;
  1472.            "Install alloc8 Exploit" )
  1473.                warn "This will install alloc8 exploit to the device. Only do this if your device is successfully restored already."
  1474.                print "* If your device is not successfully restored/downgraded yet, this will not work."
  1475.                print "* Also, this is not supposed to be used on iOS 6.1.6 or 4.1."
  1476.                select_yesno
  1477.                if [[ $? != 1 ]]; then
  1478.                    continue
  1479.                fi
  1480.                mode="device_alloc8"
  1481.            ;;
  1482.            "Just Boot" ) menu_justboot;;
  1483.            "Update DateTime" ) device_update_datetime;;
  1484.            "DFU Mode Helper" ) mode="device_dfuhelper";;
  1485.            "Run uicache" )
  1486.                print "* This will run the uicache command via SSH to help fix missing jailbreak app icons."
  1487.                print "* In order for this to work, OpenSSH must be installed on your device."
  1488.                print "* If your device is restored/jailbroken with Legacy iOS Kit, OpenSSH is already installed."
  1489.                select_yesno
  1490.                if [[ $? != 1 ]]; then
  1491.                    continue
  1492.                fi
  1493.                mode="device_uicache"
  1494.            ;;
  1495.            "Console" )
  1496.                print "* This will run idevicesyslog and show live system log of the device."
  1497.                print "* To stop and exit, just press Ctrl+C or close the terminal window."
  1498.                select_yesno
  1499.                if [[ $? != 1 ]]; then
  1500.                    continue
  1501.                fi
  1502.                device_pair
  1503.                "$dir/idevicesyslog" -q
  1504.            ;;
  1505.            "Go Back" ) back=1;;
  1506.        esac
  1507.    done
  1508. }
  1509.  
  1510. device_update_datetime() {
  1511.    device_buttons2
  1512.    if [[ $device_mode == "Normal" ]]; then
  1513.        log "Proceeding on Normal mode."
  1514.        device_iproxy
  1515.        device_ssh_message
  1516.        device_sshpass
  1517.        device_datetime_cmd
  1518.        kill $iproxy_pid
  1519.    else
  1520.        mode="getversion"
  1521.    fi
  1522. }
  1523.  
  1524. device_pair() {
  1525.    if [[ $device_vers_maj == 7 && $platform == "linux" ]]; then
  1526.        warn "Pressing \"Trust\" for devices on iOS 7 can have connection issues on Linux (disconnect-reconnect)."
  1527.        print "* You may select \"Don't Trust\" on the prompt as a workaround, but that can limit some functionality."
  1528.    fi
  1529.    log "Attempting idevicepair"
  1530.    "$dir/idevicepair" pair
  1531.    local opt=$?
  1532.    if [[ $opt != 0 ]]; then
  1533.        log "Unlock and press \"Trust\" on the device before pressing Enter/Return."
  1534.        print "* If you denied the trust dialog, unplug and replug the device."
  1535.        pause
  1536.        log "Attempting idevicepair"
  1537.        "$dir/idevicepair" pair
  1538.        opt=$?
  1539.    fi
  1540.    if [[ $opt == 0 ]]; then
  1541.        device_get_paired_info
  1542.    else
  1543.        warn "Unable to pair with device."
  1544.    fi
  1545. }
  1546.  
  1547. device_ssh() {
  1548.    print "* Note: This is for connecting via SSH to devices that are already jailbroken and have OpenSSH installed."
  1549.    print "* If this is not what you want, you might be looking for the \"SSH Ramdisk\" option instead."
  1550.    echo
  1551.    device_iproxy no-logging
  1552.    device_ssh_message
  1553.    device_sshpass
  1554.    log "Connecting to device SSH..."
  1555.    print "* For SSH/SCP access, use the following:"
  1556.    print "* Host: sftp://127.0.0.1 | Username: $ssh_user | Password: <your password> (default is alpine) | Port: $ssh_port"
  1557.    if [[ $ssh_user == "root" ]]; then
  1558.        print "* You may also use mobile as the username for SSH/SCP access."
  1559.    fi
  1560.    $ssh -p $ssh_port ${ssh_user}@127.0.0.1
  1561.    kill $iproxy_pid
  1562. }
  1563.  
  1564. device_jailbreak_confirm() {
  1565.    if [[ $device_vers == *"iBoot"* || $device_vers == "Unknown"* ]]; then
  1566.        device_vers=
  1567.        while [[ -z $device_vers ]]; do
  1568.            read -p "$(input 'Enter current iOS version (eg. 6.1.3): ')" device_vers
  1569.        done
  1570.    elif [[ $device_mode == "Normal" ]]; then
  1571.        case $device_vers in
  1572.            5* | 6.0* | 6.1 | 6.1.[12] )
  1573.                print "* Your device on iOS $device_vers will be jailbroken using g1lbertJB."
  1574.                print "* No data will be lost, but please back up your data just in case."
  1575.                print "* Ignore the \"Error Code 1\" and \"Error Code 102\" errors, this is normal and part of the jailbreaking process."
  1576.                if [[ $device_proc == 4 ]]; then
  1577.                    print "* Note: If the process fails somewhere, you can just enter DFU mode and attempt jailbreaking again from there."
  1578.                fi
  1579.                select_yesno
  1580.                if [[ $? != 1 ]]; then
  1581.                    return
  1582.                fi
  1583.                mode="device_jailbreak_gilbert"
  1584.                return
  1585.            ;;
  1586.        esac
  1587.    fi
  1588.    log "Checking if your device and version is supported..."
  1589.    log "Please read the message below:"
  1590.    if [[ $device_type == "iPhone3,3" ]]; then
  1591.        case $device_vers in
  1592.            4.2.9 | 4.2.10 )
  1593.                warn "For this version, it will be a semi-tethered jailbreak."
  1594.                print "* To boot jailbroken later, go to: Main Menu -> Just Boot"
  1595.                pause
  1596.            ;;
  1597.        esac
  1598.    elif [[ $device_proc == 1 ]]; then
  1599.        warn "If you jailbreak with this option (ramdisk method), you will not be able to Bootlace or other similar tools."
  1600.        print "* If you want to use the mentioned tools, go to \"Restore/Downgrade\" instead, and enable the jailbreak option."
  1601.    elif [[ $device_proc == 5 ]]; then
  1602.        print "* Note: It would be better to jailbreak using sideload or custom IPSW methods for A5 devices."
  1603.        print "* Especially since this method may require the usage of checkm8-a5."
  1604.    elif [[ $device_proc == 6 && $platform == "linux" ]]; then
  1605.        print "* Note: It would be better to jailbreak using sideload or custom IPSW methods for A6 devices on Linux."
  1606.    fi
  1607.    if [[ $device_proc == 1 && $device_vers == "4.2.1" ]] ||
  1608.       [[ $device_type == "iPod3,1" && $device_vers == "6"* ]] ||
  1609.       [[ $device_type == "iPod4,1" && $device_vers == "7"* ]]; then
  1610.        warn "Jailbreaking using the ramdisk method is not supported for the $device_type on iOS $device_vers."
  1611.        print "* You will need to go to \"Restore/Downgrade\" instead."
  1612.        pause
  1613.        return
  1614.    fi
  1615.    if [[ $device_vers == "7"* ]]; then
  1616.        warn "Jailbreaking using the ramdisk method is disabled for iOS 7.x."
  1617.        print "* It is recommended to use Aquila instead, or dump blobs and restore with the jailbreak option enabled."
  1618.        warn "You will encounter issues when jailbreaking 7.x with ramdisk method, particularly baseband issues."
  1619.        [[ $ipsw_jailbreak != 1 ]] && warn "You can bypass this by enabling the jailbreak flag, but only do this if you know what you are doing."
  1620.        echo
  1621.    fi
  1622.    if [[ $device_proc == 5 || $device_proc == 6 ]]; then
  1623.        case $device_vers in
  1624.            6.1.[3456] )
  1625.                print "* For this version, Aquila on Windows/Mac can also be used instead of this option."
  1626.                print "* https://ios.cfw.guide/installing-aquila/"
  1627.                print "* Sideloading aquila-app is also an option, especially if on Linux."
  1628.                print "* https://github.com/LukeZGD/aquila-app"
  1629.            ;;
  1630.        esac
  1631.        if [[ $platform == "linux" ]]; then
  1632.            case $device_vers in
  1633.                [689]* | 10* ) print "* Note: If you need to sideload, you can use Legacy iOS Kit's \"Sideload IPA\" option.";;
  1634.            esac
  1635.        fi
  1636.    fi
  1637.    print "* For more details, go to: https://github.com/LukeZGD/Legacy-iOS-Kit/wiki/Jailbreaking"
  1638.    case $device_vers in
  1639.        7.0* )
  1640.            print "* For this version, Aquila on Windows/Mac can be used instead of this option."
  1641.            print "* https://ios.cfw.guide/installing-aquila/"
  1642.            print "* Sideloading EverPwnage is also an option, especially if on Linux."
  1643.            print "* https://github.com/LukeZGD/EverPwnage"
  1644.            pause
  1645.            [[ $ipsw_jailbreak != 1 ]] && return
  1646.        ;;
  1647.        7.1* )
  1648.            print "* For this version, use Lyncis to jailbreak your device."
  1649.            print "* https://ios.cfw.guide/using-lyncis/"
  1650.            pause
  1651.            [[ $ipsw_jailbreak != 1 ]] && return
  1652.        ;;
  1653.        9.3.[56] )
  1654.            print "* For this version, use Carbon to jailbreak your device."
  1655.            print "* https://ios.cfw.guide/using-carbon/"
  1656.            pause
  1657.            return
  1658.        ;;
  1659.        [89].* )
  1660.            print "* For this version, you can use Carbon to jailbreak your device."
  1661.            print "* https://ios.cfw.guide/using-carbon/"
  1662.            print "* You may still continue if you really want to do the ramdisk method instead."
  1663.        ;;
  1664.        10.* )
  1665.            print "* For this version, use socket to jailbreak your device."
  1666.            print "* https://github.com/staturnzz/socket"
  1667.            pause
  1668.            return
  1669.        ;;
  1670.        [7654]* | 3.2* | 3.1.3 )
  1671.            if [[ $device_type == "iPhone2,1" && $device_vers == "3.1.3" ]]; then
  1672.                warn "To jailbreak iOS 3.x for the 3GS, make sure your device is restored with Legacy iOS Kit's \"Restore/Downgrade\" first."
  1673.                print "* If you have not done this, do not continue."
  1674.            fi
  1675.        ;;
  1676.        3.[10]* )
  1677.            if [[ $device_type == "iPhone2,1" ]]; then
  1678.                warn "To jailbreak iOS 3.x for the 3GS, make sure your device is restored with Legacy iOS Kit's \"Restore/Downgrade\" first."
  1679.                print "* If you have not done this, do not continue."
  1680.            else
  1681.                warn "This version ($device_vers) is not supported for jailbreaking with ramdisk method."
  1682.                print "* Supported versions are: 3.1.3 to 9.3.4"
  1683.                pause
  1684.                return
  1685.            fi
  1686.        ;;
  1687.        * )
  1688.            warn "This version ($device_vers) is not supported for jailbreaking with ramdisk method."
  1689.            print "* Supported versions are: 3.1.3 to 9.3.4"
  1690.            pause
  1691.            return
  1692.        ;;
  1693.    esac
  1694.    echo
  1695.    print "* By selecting Jailbreak Device, your device will be jailbroken using Ramdisk Method."
  1696.    print "* Before continuing, make sure that your device does not have a jailbreak yet."
  1697.    print "* No data will be lost, but please back up your data just in case."
  1698.    select_yesno
  1699.    if [[ $? != 1 ]]; then
  1700.        return
  1701.    fi
  1702.    mode="device_jailbreak"
  1703. }
  1704.  
  1705. device_jailbreak() {
  1706.    device_ramdisk jailbreak
  1707. }
  1708.  
  1709. device_jailbreak_gilbert() {
  1710.    pushd ../resources/jailbreak/g1lbertJB >/dev/null
  1711.    log "Copying freeze.tar to Cydia.tar"
  1712.    cp ../freeze.tar.gz .
  1713.    gzip -d freeze.tar.gz
  1714.    mv freeze.tar payload/common/Cydia.tar
  1715.    log "Running g1lbertJB..."
  1716.    "../../$dir/gilbertjb"
  1717.    rm -rf payload/common/Cydia.tar private var
  1718.    popd >/dev/null
  1719. }
  1720.  
  1721. device_ssh_message() {
  1722.    log "Please read the message below:"
  1723.    print "* Follow these instructions to connect to the device."
  1724.    if [[ $device_vers_maj == 10 ]] && (( device_proc < 7 )); then
  1725.        print "1. Jailbreak with socket: https://github.com/staturnzz/socket"
  1726.        print "  - And install \"Dropbear\" from my repo: https://lukezgd.github.io/repo"
  1727.    else
  1728.        print "1. Install \"OpenSSH\" in Cydia or Zebra."
  1729.    fi
  1730.    print "2. You will be prompted to enter the root/mobile password of your iOS device."
  1731.    print "  - The default password is: alpine"
  1732.    print "  - Your password input may not be visible, but it is still being entered."
  1733.    print "* You can also just press Enter/Return to enter the default password."
  1734. }
  1735.  
  1736. device_dump() {
  1737.    local arg="$1"
  1738.    local dump="../saved/$device_type/$arg-$device_ecid.tar"
  1739.    local dmps
  1740.    local dmp2
  1741.    case $arg in
  1742.        "baseband" ) dmps="/usr/local/standalone";;
  1743.        "activation" )
  1744.            dmp2="private/var/root/Library/Lockdown"
  1745.            case $device_vers in
  1746.                [34567]* ) dmps="/$dmp2";;
  1747.                8* | 9.[012]* ) dmps="/private/var/mobile/Library/mad";;
  1748.                * )
  1749.                    dmps="/private/var/containers/Data/System/*/Library/activation_records"
  1750.                    dmp2+="/activation_records"
  1751.                ;;
  1752.            esac
  1753.        ;;
  1754.    esac
  1755.  
  1756.    log "Dumping files for $arg: $dmps"
  1757.    if [[ -s $dump ]]; then
  1758.        log "Found existing dumped $arg: $dump"
  1759.        if [[ $arg == "activation" && $(tar -tf $dump | grep -c "_record.plist") == 0 ]]; then
  1760.            log "Activation record not found in existing activation dump. Deleting"
  1761.            rm $dump
  1762.        elif [[ $arg == "baseband" && $(tar -tf $dump | grep -c "bbticket.der") == 0 ]]; then
  1763.            log "bbticket not found in existing baseband dump. Deleting"
  1764.            rm $dump
  1765.        else
  1766.            return
  1767.        fi
  1768.    fi
  1769.    if [[ $device_mode == "Normal" ]] && (( device_proc < 7 )); then
  1770.        device_buttons2
  1771.    elif [[ $device_mode == "none" ]]; then
  1772.        error "No existing $arg dump found while in no device mode. Cannot continue."
  1773.    elif [[ $device_mode != "Normal" ]]; then
  1774.        log "Recovery/DFU mode device detected, entering pwnDFU mode to continue for SSH ramdisk."
  1775.        if [[ $platform == "linux" || $device_proc == 5 ]]; then
  1776.            print "* Note: If you can jailbreak and enter kDFU mode, exit now and proceed to do that instead."
  1777.        fi
  1778.        device_enter_mode pwnDFU
  1779.    fi
  1780.    if [[ $device_mode == "Normal" ]]; then
  1781.        device_iproxy
  1782.        if [[ -z $SSHPASS ]]; then
  1783.            device_ssh_message
  1784.            device_sshpass
  1785.        fi
  1786.        if [[ $arg == "activation" ]]; then
  1787.            log "Creating $arg.tar"
  1788.            $ssh -p $ssh_port ${ssh_user}@127.0.0.1 "mkdir -p /tmp/$dmp2; find $dmps; cp -R $dmps/* /tmp/$dmp2"
  1789.            #$ssh -p $ssh_port ${ssh_user}@127.0.0.1 "cd /tmp/$dmp2/activation_records; mv *_record.plist activation_record.plist"
  1790.            $ssh -p $ssh_port ${ssh_user}@127.0.0.1 "cd /tmp; tar -cvf $arg.tar $dmp2"
  1791.            log "Copying $arg.tar"
  1792.            $scp -P $ssh_port ${ssh_user}@127.0.0.1:/tmp/$arg.tar .
  1793.            mv $arg.tar $arg-$device_ecid.tar
  1794.            if [[ $(tar -tf activation-$device_ecid.tar | grep -c "_record.plist") != 0 ]]; then
  1795.                cp activation-$device_ecid.tar $dump
  1796.            else
  1797.                warn "Activation record not found in tar. Will not save activation dump."
  1798.            fi
  1799.        else
  1800.            device_dumpbb
  1801.            if [[ $(tar -tf baseband-$device_ecid.tar | grep -c "bbticket.der") != 0 ]]; then
  1802.                cp baseband-$device_ecid.tar $dump
  1803.            else
  1804.                warn "bbticket not found in tar. Will not save baseband dump."
  1805.            fi
  1806.        fi
  1807.        kill $iproxy_pid
  1808.    else
  1809.        device_enter_ramdisk $arg
  1810.        device_dumprd
  1811.        $ssh -p $ssh_port [email protected] "nvram auto-boot=1; reboot_bak"
  1812.        log "Done, device should reboot now"
  1813.        if [[ $mode != "baseband" && $mode != "actrec" ]]; then
  1814.            log "Put your device back in kDFU/pwnDFU mode to proceed, then run the script again."
  1815.            exit
  1816.        fi
  1817.    fi
  1818.    if [[ ! -e $dump ]]; then
  1819.        error "Failed to dump $arg from device. Please run the script again" \
  1820.              "* Make sure to have OpenSSH installed."
  1821.    fi
  1822.    log "Dumping $arg done: $dump"
  1823. }
  1824.  
  1825. device_dumpbb() {
  1826.    local bb2="Mav5"
  1827.    local root="/"
  1828.    local root2="/"
  1829.    local tmp="/tmp"
  1830.    case $device_type in
  1831.        iPhone4,1 ) bb2="Trek";;
  1832.        iPhone5,[34] ) bb2="Mav7Mav8";;
  1833.    esac
  1834.    if [[ $1 == "rd" ]]; then
  1835.        root="/mnt1/"
  1836.        root2=
  1837.        tmp="/mnt2/tmp"
  1838.    fi
  1839.    log "Creating baseband.tar"
  1840.    case $device_vers in
  1841.        5* ) $scp -P $ssh_port [email protected]:${root}usr/standalone/firmware/$bb2-personalized.zip .;;
  1842.        6* ) $scp -P $ssh_port [email protected]:${root}usr/local/standalone/firmware/Baseband/$bb2/$bb2-personalized.zip .;;
  1843.    esac
  1844.    case $device_vers in
  1845.        [56]* )
  1846.            mkdir -p usr/local/standalone/firmware/Baseband/$bb2
  1847.            file_extract $bb2-personalized.zip usr/local/standalone/firmware/Baseband/$bb2
  1848.            cp $bb2-personalized.zip usr/local/standalone/firmware/Baseband/$bb2
  1849.        ;;
  1850.        * )
  1851.            $ssh -p $ssh_port [email protected] "cd $root; tar -cvf $tmp/baseband.tar ${root2}usr/local/standalone/firmware"
  1852.            $scp -P $ssh_port [email protected]:$tmp/baseband.tar .
  1853.            if [[ ! -s baseband.tar ]]; then
  1854.                error "Dumping baseband tar failed. Please run the script again" \
  1855.                      "* If your device is on iOS 9 or newer, make sure to set the version of the SSH ramdisk correctly."
  1856.            fi
  1857.            tar -xvf baseband.tar -C .
  1858.            rm baseband.tar
  1859.            pushd usr/local/standalone/firmware/Baseband/$bb2 >/dev/null
  1860.            zip -r0 $bb2-personalized.zip *
  1861.            file_extract $bb2-personalized.zip
  1862.            popd >/dev/null
  1863.        ;;
  1864.    esac
  1865.    if [[ $device_type == "iPhone4,1" ]]; then
  1866.        mkdir -p usr/standalone/firmware
  1867.        cp usr/local/standalone/firmware/Baseband/$bb2/$bb2-personalized.zip usr/standalone/firmware
  1868.    fi
  1869.    tar -cvf baseband-$device_ecid.tar usr
  1870. }
  1871.  
  1872. device_dumprd() {
  1873.    local dump="../saved/$device_type"
  1874.    local dmps
  1875.    local dmp2
  1876.    local vers
  1877.    local tmp="/mnt2/tmp"
  1878.  
  1879.    device_ramdisk_iosvers
  1880.    vers=$device_vers
  1881.    if [[ -z $vers ]]; then
  1882.        warn "Something wrong happened. Failed to get iOS version."
  1883.        print "* Please reboot the device into normal operating mode, then perform a clean \"slide to power off\", then try again."
  1884.        $ssh -p $ssh_port [email protected] "reboot_bak"
  1885.        return
  1886.    fi
  1887.    log "Mounting filesystems"
  1888.    $ssh -p $ssh_port [email protected] "mount.sh"
  1889.    sleep 1
  1890.  
  1891.    case $device_type in
  1892.        iPhone[45]* | iPad2,[67] | iPad3,[56] )
  1893.            log "Dumping both baseband and activation tars"
  1894.            print "* Reminder to backup dump tars if needed"
  1895.            device_dumpbb rd
  1896.            if [[ $(tar -tf baseband-$device_ecid.tar | grep -c "bbticket.der") != 0 ]]; then
  1897.                cp baseband-$device_ecid.tar $dump
  1898.            else
  1899.                warn "bbticket not found in tar. Will not save baseband dump."
  1900.            fi
  1901.        ;;
  1902.    esac
  1903.  
  1904.    dmp2="root/Library/Lockdown"
  1905.    case $vers in
  1906.        [34567]* ) dmps="$dmp2";;
  1907.        8* | 9.[012]* ) dmps="mobile/Library/mad";;
  1908.        * )
  1909.            dmps="containers/Data/System/*/Library/activation_records"
  1910.            dmp2+="/activation_records"
  1911.        ;;
  1912.    esac
  1913.    log "Creating activation.tar"
  1914.    $ssh -p $ssh_port [email protected] "mkdir -p $tmp/private/var/$dmp2; cp -R /mnt2/$dmps/* $tmp/private/var/$dmp2"
  1915.    #$ssh -p $ssh_port [email protected] "cd $tmp/$dmp2/activation_records; mv *_record.plist activation_record.plist"
  1916.    $ssh -p $ssh_port [email protected] "cd $tmp; tar -cvf $tmp/activation.tar private/var/$dmp2"
  1917.    log "Copying activation.tar"
  1918.    print "* Reminder to backup dump tars if needed"
  1919.    $scp -P $ssh_port [email protected]:$tmp/activation.tar .
  1920.    if [[ ! -s activation.tar ]]; then
  1921.        error "Dumping activation record tar failed. Please run the script again" \
  1922.              "* If your device is on iOS 9 or newer, make sure to set the version of the SSH ramdisk correctly."
  1923.    fi
  1924.    mv activation.tar activation-$device_ecid.tar
  1925.    if [[ $(tar -tf activation-$device_ecid.tar | grep -c "_record.plist") != 0 ]]; then
  1926.        cp activation-$device_ecid.tar $dump
  1927.    else
  1928.        warn "Activation record not found in tar. Will not save activation dump."
  1929.    fi
  1930.    $ssh -p $ssh_port [email protected] "rm -f $tmp/*.tar"
  1931. }
  1932.  
  1933. device_activate() {
  1934.    log "Attempting to activate device with ideviceactivation"
  1935.    if [[ $device_type == "iPhone"* ]] && (( device_proc <= 4 )); then
  1936.        print "* For iPhone 4 and older devices, make sure to have a valid SIM card."
  1937.        if (( device_vers_maj <= 6 )); then
  1938.            print "* For hacktivation, go to \"Restore/Downgrade\" or \"Hacktivate Device\" instead."
  1939.        fi
  1940.    fi
  1941.    $ideviceactivation activate
  1942.    if [[ $device_name == "iPod"* ]] && (( device_vers_maj <= 3 )); then
  1943.        $ideviceactivation itunes
  1944.    fi
  1945.    print "* If it returns an error, just try again."
  1946.    device_unactivated=$($ideviceactivation state | grep -c "Unactivated")
  1947.    pause
  1948. }
  1949.  
  1950. device_hacktivate() {
  1951.    local type="$device_type"
  1952.    local build="$device_build"
  1953.    if [[ $device_proc == 4 && $device_type != "iPhone2,1" ]]; then
  1954.        type="iPhone2,1"
  1955.        case $device_vers in
  1956.            4.2.1 ) build="8C148a";;
  1957.            5.1.1 ) build="9B206";;
  1958.            6.1   ) build="10B141";;
  1959.        esac
  1960.        log "Checking ideviceactivation status..."
  1961.        $ideviceactivation activate
  1962.    fi
  1963.    local patch="../resources/firmware/FirmwareBundles/Down_${type}_${device_vers}_${build}.bundle/lockdownd.patch"
  1964.    device_iproxy
  1965.    device_sshpass
  1966.    if [[ $device_type == "iPhone3,3" && $device_vers == "4.2"* ]]; then
  1967.        echo '<plist><dict><key>com.apple.mobile.lockdown_cache-ActivationState</key><string>FactoryActivated</string></dict></plist>' > data_ark.plist
  1968.        log "Copying data_ark.plist to device"
  1969.        $scp -P $ssh_port data_ark.plist [email protected]:/var/root/Library/Lockdown/data_ark.plist
  1970.        $ssh -p $ssh_port [email protected] "reboot"
  1971.        log "Done. Your device should reboot now"
  1972.        return
  1973.    fi
  1974.    log "Checking lockdownd"
  1975.    local lock="$($ssh -p $ssh_port [email protected] "ls /usr/libexec/lockdownd.orig 2>/dev/null")"
  1976.    if [[ -n $lock ]]; then
  1977.        warn "Device is already hacktivated. Cannot continue."
  1978.        print "* If you want to revert, you may want to select \"Revert Hacktivation\" instead."
  1979.        return
  1980.    fi
  1981.    log "Getting lockdownd"
  1982.    $scp -P $ssh_port [email protected]:/usr/libexec/lockdownd .
  1983.    log "Patching lockdownd"
  1984.    $bspatch lockdownd lockdownd.patched "$patch"
  1985.    log "Renaming original lockdownd"
  1986.    $ssh -p $ssh_port [email protected] "[[ ! -e /usr/libexec/lockdownd.orig ]] && mv /usr/libexec/lockdownd /usr/libexec/lockdownd.orig"
  1987.    log "Copying patched lockdownd to device"
  1988.    $scp -P $ssh_port lockdownd.patched [email protected]:/usr/libexec/lockdownd
  1989.    $ssh -p $ssh_port [email protected] "chmod +x /usr/libexec/lockdownd; reboot"
  1990.    log "Done. Your device should reboot now"
  1991. }
  1992.  
  1993. device_reverthacktivate() {
  1994.    device_iproxy
  1995.    print "* The default root password is: alpine"
  1996.    device_sshpass
  1997.    log "Reverting lockdownd"
  1998.    $ssh -p $ssh_port [email protected] "[[ -e /usr/libexec/lockdownd.orig ]] && rm /usr/libexec/lockdownd && mv /usr/libexec/lockdownd.orig /usr/libexec/lockdownd"
  1999.    $ssh -p $ssh_port [email protected] "chmod +x /usr/libexec/lockdownd; reboot"
  2000.    log "Done. Your device should reboot now"
  2001. }
  2002.  
  2003. restore_customipsw_confirm() {
  2004.    print "* You are about to restore with a custom IPSW."
  2005.    print "* This option is only for restoring with IPSWs NOT made with Legacy iOS Kit, like whited00r or GeekGrade."
  2006.    if [[ $device_newbr == 1 ]]; then
  2007.        warn "Your device is a new bootrom model and some custom IPSWs might not be compatible."
  2008.        [[ $device_type == "iPhone2,1" ]] && print "* For iPhone 3GS, after restoring you will need to go to Useful Utilities -> Install alloc8 Exploit"
  2009.    else
  2010.        warn "Do NOT use this option for powdersn0w or jailbreak IPSWs made with Legacy iOS Kit!"
  2011.    fi
  2012.    if [[ $platform == "macos" ]] && [[ $device_type == "iPod2,1" || $device_proc == 1 ]]; then
  2013.        echo
  2014.        warn "Restoring to 2.x might not work on newer macOS versions."
  2015.        print "* Try installing usbmuxd from MacPorts, and run 'sudo usbmuxd -pf' in another Terminal window"
  2016.        print "* Another option is to just do 2.x restores on Linux instead."
  2017.        print "* For more info, go to: https://github.com/LukeZGD/Legacy-iOS-Kit/wiki/Troubleshooting#restoring-to-iphoneosios-2x-on-macos"
  2018.    fi
  2019.    if [[ $device_type == "iPhone1,"* ]]; then
  2020.        echo
  2021.        print "* Note that you might need to restore twice, due to NOR flash."
  2022.        print "* For iPhone 2G/3G, the second restore may fail due to baseband."
  2023.        print "* You can exit recovery mode after by going to: Main Menu -> Exit Recovery Mode"
  2024.    fi
  2025.    select_yesno
  2026.    if [[ $? != 1 ]]; then
  2027.        return
  2028.    fi
  2029.    mode="customipsw"
  2030. }
  2031.  
  2032. restore_customipsw() {
  2033.    menu_ipsw_browse "custom"
  2034.    if [[ -z $ipsw_path ]]; then
  2035.        error "No IPSW selected, cannot continue."
  2036.    fi
  2037.    if [[ $device_proc == 1 ]]; then
  2038.        if [[ $device_target_vers == "3.1.3" ]]; then
  2039.            device_enter_mode DFU
  2040.        else
  2041.            device_enter_mode WTFreal
  2042.        fi
  2043.    else
  2044.        device_enter_mode pwnDFU
  2045.    fi
  2046.    ipsw_custom="$ipsw_path"
  2047.    restore_latest custom
  2048. }
  2049.  
  2050. device_dfuipsw_confirm() {
  2051.    local msg1="restore"
  2052.    local msg2="This"
  2053.    if [[ $1 == "ipsw" ]]; then
  2054.        msg1="create"
  2055.        msg2+=" IPSW"
  2056.    fi
  2057.    print "* You are about to $msg1 a DFU IPSW."
  2058.    print "* $msg2 will force the device to enter DFU mode, which is useful for devices with broken buttons."
  2059.    if [[ $1 != "ipsw" ]]; then
  2060.        print "* All device data will be wiped! Only proceed if you have backed up your data."
  2061.        print "* Expect the restore to fail and the device to be stuck in DFU mode."
  2062.    fi
  2063.    select_yesno
  2064.    if [[ $? != 1 ]]; then
  2065.        return
  2066.    fi
  2067.    mode="device_dfuipsw$1"
  2068. }
  2069.  
  2070. device_dfuipswipsw() {
  2071.    device_dfuipsw ipsw
  2072. }
  2073.  
  2074. device_dfuipsw() {
  2075.    # the only change done to the "dfu ipsw" is just applelogo copied and renamed to llb
  2076.    # replacing llb with an invalid img3/im4p to make the restore fail, the device will then fallback to true dfu mode
  2077.    # https://theapplewiki.com/wiki/DFU_Mode#Enter_True_Hardware_DFU_Mode_Automatically
  2078.    # this function theoretically works on 64-bit devices, but restoring the dfu ipsw requires entering dfu for pwned restore
  2079.    # which defeats the point of doing a dfu ipsw in the first place, so dfu ipsw is available for 32-bit devices only
  2080.    local ExtraArgs="-e"
  2081.    if [[ $device_proc == 1 ]]; then
  2082.        ExtraArgs+="c"
  2083.        device_latest_vers="3.1.3"
  2084.        device_latest_build="7E18"
  2085.    fi
  2086.    device_target_vers="$device_latest_vers"
  2087.    device_target_build="$device_latest_build"
  2088.    ipsw_latest_set
  2089.    ipsw_path="../$ipsw_latest_path"
  2090.    if [[ -s "$ipsw_path.ipsw" && ! -e "$ipsw_dfuipsw.ipsw" ]]; then
  2091.        ipsw_verify "$ipsw_path" "$device_target_build"
  2092.    elif [[ ! -e "$ipsw_path.ipsw" ]]; then
  2093.        ipsw_download "$ipsw_path"
  2094.    fi
  2095.    if [[ -s "$ipsw_dfuipsw.ipsw" ]]; then
  2096.        log "Found existing DFU IPSW. Skipping IPSW creation."
  2097.    else
  2098.        cp $ipsw_path.ipsw temp.ipsw
  2099.        local llb="${device_model}ap"
  2100.        local all="Firmware/all_flash"
  2101.        local applelogo
  2102.        if (( device_proc >= 6 )); then
  2103.            ipsw_hwmodel_set
  2104.            case $device_type in
  2105.                iPhone9,[13] ) llb="d10";;
  2106.                iPhone9,[24] ) llb="d11";;
  2107.                iPhone[78]* | iPad6,1* ) llb="$device_model";;
  2108.                * ) llb="$ipsw_hwmodel"
  2109.            esac
  2110.            case $device_type in
  2111.                iPhone5,[1234] ) applelogo="applelogo@2x~iphone.s5l8950x.img3";;
  2112.                iPad3,[456] ) applelogo="applelogo@2x~ipad.s5l8955x.img3";;
  2113.                iPhone* ) applelogo="applelogo@2x~iphone.im4p";;
  2114.                iPad* ) applelogo="applelogo@2x~ipad.im4p";;
  2115.            esac
  2116.        else
  2117.            all="$all_flash"
  2118.            device_fw_key_check
  2119.            applelogo=$(echo $device_fw_key | $jq -j '.keys[] | select(.image == "AppleLogo") | .filename')
  2120.        fi
  2121.        llb="LLB.$llb.RELEASE"
  2122.        if (( device_proc >= 7 )); then
  2123.            llb+=".im4p"
  2124.        else
  2125.            llb+=".img3"
  2126.        fi
  2127.        mkdir -p $all
  2128.        file_extract_from_archive temp.ipsw $all/$applelogo
  2129.        mv $applelogo $all/$llb
  2130.        zip -r0 temp.ipsw $all/*
  2131.        mv temp.ipsw $ipsw_dfuipsw.ipsw
  2132.    fi
  2133.    if [[ $1 == "ipsw" ]]; then
  2134.        return
  2135.    fi
  2136.    ipsw_path="$ipsw_dfuipsw"
  2137.    device_enter_mode Recovery
  2138.    ipsw_extract
  2139.    log "Running idevicerestore with command: $idevicerestore $ExtraArgs \"$ipsw_path.ipsw\""
  2140.    $idevicerestore $ExtraArgs "$ipsw_path.ipsw"
  2141.    log "Device should now be stuck in DFU mode"
  2142.    print "* You may now restore the device. Run the script again and select Restore/Downgrade"
  2143. }
  2144.  
  2145. device_enter_build() {
  2146.    while true; do
  2147.        device_rd_build=
  2148.        read -p "$(input 'Enter build version (eg. 10B329): ')" device_rd_build
  2149.  
  2150.        if [[ -z $device_rd_build ]]; then
  2151.            return
  2152.        fi
  2153.        local last_char=$(echo "$device_rd_build" | rev | cut -c1)
  2154.        device_rd_build=$(echo "$device_rd_build" | tr '[:lower:]' '[:upper:]') # to uppercase
  2155.        # If last char was a lowercase letter, make it lowercase again
  2156.        if echo "$last_char" | grep -Eq '^[a-z]$'; then
  2157.            device_rd_build=$(echo "$device_rd_build" | rev | cut -c2- | rev)
  2158.            device_rd_build=${device_rd_build}${last_char}
  2159.        fi
  2160.        # Match pattern: digits + uppercase letters + digits + optional lowercase letter
  2161.        echo "$device_rd_build" | grep -Eq '^[0-9]+[A-Z]+[0-9]+[a-z]?$' && break
  2162.  
  2163.        log "Build version input is not valid. Please try again"
  2164.    done
  2165. }
  2166.  
  2167. menu_justboot() {
  2168.    local menu_items
  2169.    local selected
  2170.    local back
  2171.    local vers
  2172.    local recent="../saved/$device_type/justboot_${device_ecid}"
  2173.  
  2174.    # Store original device info to prevent it from being overwritten
  2175.    local original_device_type="$device_type"
  2176.    local original_device_ecid="$device_ecid"
  2177.    local original_device_name="$device_name"
  2178.  
  2179.    while [[ -z "$mode" && -z "$back" ]]; do
  2180.        menu_items=()
  2181.  
  2182.        # Add Connected Device option first if it exists in boot history
  2183.        if [[ -s "$recent" ]]; then
  2184.            # Use stored device name to avoid overwriting global variables
  2185.            menu_items+=("Connected Device [$original_device_name]")
  2186.        fi
  2187.  
  2188.        # Add other options
  2189.        menu_items+=("Enter Build Version" "Select IPSW")
  2190.  
  2191.        # Check for boot history files for current device type
  2192.        local history_count=$(find "../saved/$device_type" -name "justboot_*" -type f 2>/dev/null | wc -l)
  2193.  
  2194.        # Also check for any boot history files regardless of device type
  2195.        local total_history_count=$(find "../saved" -name "justboot_*" -type f 2>/dev/null | wc -l)
  2196.  
  2197.        if [[ $history_count -gt 0 ]]; then
  2198.            menu_items+=("Boot History")
  2199.        elif [[ $total_history_count -gt 0 ]]; then
  2200.            menu_items+=("Boot History (All Devices)")
  2201.        fi
  2202.        menu_items+=("Custom Bootargs")
  2203.        if [[ $device_type == "iPod4,1" ]]; then
  2204.            menu_items+=("(*) iOS 7.1.2")
  2205.        fi
  2206.        if [[ -n $vers ]]; then
  2207.            menu_items+=("(*) Just Boot")
  2208.        fi
  2209.        menu_items+=("Go Back")
  2210.        menu_print_info
  2211.        print " > Main Menu > Just Boot"
  2212.        print "* You are about to do a tethered boot."
  2213.        print "* To know more about build version, go here: https://theapplewiki.com/wiki/Firmware"
  2214.        echo
  2215.        if [[ -n $ipsw_justboot_path ]]; then
  2216.            print "* Selected IPSW: $ipsw_justboot_path.ipsw"
  2217.            print "* IPSW Version: $device_target_vers-$device_target_build"
  2218.        elif [[ -n $vers ]]; then
  2219.            print "* Build Version entered: $vers"
  2220.        else
  2221.            print "* Enter build version or select IPSW to continue"
  2222.        fi
  2223.        echo
  2224.        if [[ -n $device_bootargs ]]; then
  2225.            print "* Custom Bootargs: $device_bootargs"
  2226.        else
  2227.            print "* You may enter custom bootargs (optional, experimental option)"
  2228.            print "* Default Bootargs: pio-error=0 -v"
  2229.        fi
  2230.        echo
  2231.        input "Select an option:"
  2232.        select_option "${menu_items[@]}"
  2233.        selected="${menu_items[$?]}"
  2234.        case $selected in
  2235.            "Enter Build Version" )
  2236.                print "* Enter the build version of your device's current iOS version to boot."
  2237.                device_enter_build
  2238.                case $device_rd_build in
  2239.                    *[bcdefgkmpquv] )
  2240.                        log "iOS beta detected. Entering build version is not supported. Select the IPSW instead."
  2241.                        pause
  2242.                        continue
  2243.                    ;;
  2244.                esac
  2245.                ipsw_justboot_path=
  2246.                vers="$device_rd_build"
  2247.            ;;
  2248.            "Select IPSW" )
  2249.                menu_ipsw_browse
  2250.                ipsw_justboot_path="$ipsw_path"
  2251.                vers="$device_target_build"
  2252.                device_rd_build="$vers"
  2253.            ;;
  2254.            "Connected Device ["* )
  2255.                vers="$(cat $recent)"
  2256.                device_rd_build="$vers"
  2257.                log "Selected connected device build version: $vers"
  2258.            ;;
  2259.            "Boot History" | "Boot History (All Devices)" )
  2260.                vers=
  2261.                menu_justboot_history
  2262.                if [[ -n $vers ]]; then
  2263.                    device_rd_build="$vers"
  2264.                fi
  2265.                # Restore original device info after history menu
  2266.                device_type="$original_device_type"
  2267.                device_ecid="$original_device_ecid"
  2268.                device_name="$original_device_name"
  2269.            ;;
  2270.            "(*) Just Boot" )
  2271.                echo "$vers" > $recent
  2272.                mode="device_justboot"
  2273.                if [[ $device_type == "iPod4,1" && $vers == "11"* ]]; then
  2274.                    mode="device_justboot_touch4ios7"
  2275.                fi
  2276.            ;;
  2277.            "(*) iOS 7.1.2" )
  2278.                echo "11D257" > $recent
  2279.                mode="device_justboot_touch4ios7"
  2280.            ;;
  2281.            "Custom Bootargs" ) read -p "$(input 'Enter custom bootargs: ')" device_bootargs;;
  2282.            "Go Back" ) back=1;;
  2283.        esac
  2284.    done
  2285. }
  2286.  
  2287. menu_justboot_history() {
  2288.    local menu_items=()
  2289.    local selected
  2290.    local back
  2291.    local history_files
  2292.    local saved_dir="../saved"
  2293.  
  2294.    history_files=($(find "$saved_dir" -name "justboot_*" -type f 2>/dev/null -exec ls -t {} +))
  2295.  
  2296.    if [[ ${#history_files[@]} -eq 0 ]]; then
  2297.        warn "No boot history found"
  2298.        pause
  2299.        return
  2300.    fi
  2301.  
  2302.    # Add all devices in chronological order (newest first)
  2303.    for file in "${history_files[@]}"; do
  2304.        local device_type_from_file=$(basename "$(dirname "$file")")
  2305.         local ecid=$(basename "$file" | sed 's/justboot_//')
  2306.  
  2307.         local build_version=$(cat "$file" 2>/dev/null | tr -d '\n')
  2308.  
  2309.         # Get device name
  2310.         local device_name=""
  2311.         local temp_device_type="$device_type_from_file"
  2312.         device_type="$temp_device_type"
  2313.         device_get_name
  2314.         device_name="$device_name"
  2315.  
  2316.         # Get iOS version - prioritize firmwares.json as it's more reliable
  2317.         local ios_version=""
  2318.  
  2319.         # First try firmwares.json (most reliable)
  2320.         local firmwares_file=""
  2321.         for path in "$saved_dir/firmwares.json" "saved/firmwares.json" "../saved/firmwares.json"; do
  2322.             if [[ -s "$path" ]]; then
  2323.                 firmwares_file="$path"
  2324.                 break
  2325.             fi
  2326.         done
  2327.  
  2328.         # Download firmwares.json if not found
  2329.         if [[ -z "$firmwares_file" ]]; then
  2330.             log "Downloading firmwares.json for iOS version lookup..."
  2331.             file_download https://api.ipsw.me/v2.1/firmwares.json/condensed firmwares.json
  2332.             mv firmwares.json "$saved_dir"
  2333.             firmwares_file="$saved_dir/firmwares.json"
  2334.         fi
  2335.  
  2336.         if [[ -n "$firmwares_file" ]]; then
  2337.             ios_version=$(cat "$firmwares_file" | $jq -r --arg build "$build_version" '
  2338.                [.. | objects | select(.buildid == $build) | .version] |
  2339.                if length > 0 then .[0] else empty end' 2>/dev/null)
  2340.         fi
  2341.  
  2342.         # Fallback to ver file if firmwares.json didn't work
  2343.         if [[ -z "$ios_version" ]]; then
  2344.             local ver_file="$saved_dir/$device_type_from_file/ver_$build_version"
  2345.             if [[ -s "$ver_file" ]]; then
  2346.                 ios_version=$(cat "$ver_file" 2>/dev/null | tr -d '\n')
  2347.                 if [[ "$ios_version" == *".dmg" ]]; then
  2348.                     local beta_version=$(echo "$ios_version" | sed 's/ios_\([0-9]*\)_beta.*/\1/')
  2349.                     if [[ "$beta_version" != "$ios_version" && -n "$beta_version" ]]; then
  2350.                         ios_version="${beta_version}.0 Beta"
  2351.                     else
  2352.                         ios_version="Beta"
  2353.                     fi
  2354.                 elif [[ "$ios_version" == "?" ]]; then
  2355.                     ios_version=""
  2356.                 fi
  2357.             fi
  2358.         fi
  2359.  
  2360.         if [[ -z "$ios_version" ]]; then
  2361.             ios_version="Build $build_version"
  2362.         fi
  2363.  
  2364.         if [[ -n "$build_version" ]]; then
  2365.             # Format device name
  2366.             local display_name="$device_name"
  2367.             if [[ ${#display_name} -gt 18 ]]; then
  2368.                 display_name="${display_name:0:15}..."
  2369.             fi
  2370.  
  2371.             # Format iOS version
  2372.             local display_ios="$ios_version"
  2373.             if [[ ${#display_ios} -gt 12 ]]; then
  2374.                 display_ios="${display_ios:0:9}..."
  2375.             fi
  2376.  
  2377.             local menu_item="$(printf "%-20s | %-15s | %s" "$display_name" "$display_ios" "$build_version")"
  2378.             menu_items+=("$menu_item")
  2379.         fi
  2380.     done
  2381.  
  2382.     menu_items+=("Go Back")
  2383.  
  2384.     while [[ -z "$vers" && -z "$back" ]]; do
  2385.         menu_print_info
  2386.         print " > Main Menu > Just Boot > Boot History"
  2387.         print "* Select a build version from your boot history:"
  2388.         echo
  2389.  
  2390.         input "Select an option:"
  2391.         select_option "${menu_items[@]}"
  2392.         selected="${menu_items[$?]}"
  2393.  
  2394.         case $selected in
  2395.             "Go Back" )
  2396.                 back=1
  2397.             ;;
  2398.             * )
  2399.                 vers=$(echo "$selected" | awk -F'|' '{print $3}' | tr -d ' ')
  2400.                 if [[ -n "$vers" ]]; then
  2401.                     log "Selected build version: $vers"
  2402.                 else
  2403.                     warn "Could not extract build version from selection"
  2404.                 fi
  2405.             ;;
  2406.         esac
  2407.     done
  2408. }
  2409.  
  2410. device_justboot() {
  2411.     if [[ -z $device_bootargs ]]; then
  2412.         device_bootargs="pio-error=0 -v"
  2413.     fi
  2414.     if [[ $main_argmode == "device_justboot" ]]; then
  2415.         cat "$device_rd_build" > "../saved/$device_type/justboot_${device_ecid}"
  2416.     fi
  2417.     if [[ $device_rd_build == "14"* ]]; then
  2418.         device_enter_mode DFU
  2419.         kuroutadori_init
  2420.         kuroutadori_litera1n -T
  2421.         return
  2422.     fi
  2423.     device_ramdisk justboot
  2424. }
  2425.  
  2426. device_justboot_touch4ios7() {
  2427.     local patches="../resources/patch/touch4-ios7"
  2428.     local saves="../saved/touch4-ios7"
  2429.     if [[ -d "../saved/$device_type/touch4-ios7" ]]; then
  2430.         mv "../saved/$device_type/touch4-ios7" $saves
  2431.     fi
  2432.     if [[ ! -s $saves/$device_ecid ]]; then
  2433.         error "Cannot find device file for $device_ecid in saved. Need to restore to iOS 7.1.2 first."
  2434.     fi
  2435.  
  2436.     source $saves/$device_ecid
  2437.     [[ -z $device_target_build ]] && device_target_build="11D257"
  2438.     log "device_target_build=$device_target_build"
  2439.  
  2440.     device_enter_mode pwnDFU
  2441.     device_rd_build=
  2442.     patch_ibss
  2443.     log "Sending iBSS..."
  2444.     $irecovery -f pwnediBSS.dfu
  2445.     sleep 1
  2446.     log "Sending iBEC..."
  2447.     $irecovery -f $saves/pwnediBEC.dfu
  2448.     device_find_mode Recovery
  2449.     log "devicetree"
  2450.     $irecovery -f $patches/DeviceTree.n81ap.img3
  2451.     $irecovery -c devicetree
  2452.     log "kernelcache"
  2453.     $irecovery -f $saves/$device_target_build/kernelcache
  2454.     $irecovery -c bootx
  2455.     log "Device should now boot."
  2456. }
  2457.  
  2458. device_enter_ramdisk() {
  2459.     if (( device_proc > 7 )); then
  2460.         :
  2461.     elif [[ $device_proc == 7 ]]; then
  2462.         input "Version Select Option"
  2463.         print "* The version of the SSH Ramdisk is set to iOS 12 by default. This is the recommended option."
  2464.         print "* There is also an option to use iOS 8 ramdisk. This can be used to fix devices on iOS 7 not booting after using iOS 12 ramdisk."
  2465.         print "* If not sure, just press Enter/Return. This will select the default version."
  2466.         select_yesno "Select Y to use iOS 12, select N to use iOS 8" 1
  2467.         if [[ $? != 1 ]]; then
  2468.             device_ramdisk_ios8=1
  2469.         fi
  2470.     elif (( device_proc >= 5 && device_vers_maj >= 9 )); then
  2471.         log "Device is on iOS 9+, using 9.0.2 (13A452) ramdisk"
  2472.         device_rd_build="13A452"
  2473.     elif (( device_proc >= 5 )) && [[ $device_mode == "Normal" ]]; then
  2474.         :
  2475.     elif (( device_proc >= 5 )) && [[ -z $device_rd_build ]]; then
  2476.         print "* To mount /var (/mnt2) for iOS 9-10, I recommend using version 9.0.2 (13A452)."
  2477.         print "* Do not use iOS 9+ ramdisks if your device is on iOS 8 or lower, and vice versa."
  2478.         print "* If not sure, just leave it blank and press Enter/Return. This will select the default version."
  2479.         device_enter_build
  2480.     fi
  2481.  
  2482.     if [[ $1 == "menu" ]]; then
  2483.         [[ $debug_mode != 1 ]] && clear
  2484.         device_iproxy no-logging
  2485.         device_sshpass alpine
  2486.         menu_ramdisk
  2487.         return
  2488.     fi
  2489.  
  2490.     if (( device_proc >= 7 )); then
  2491.         device_ramdisk64 $1
  2492.     else
  2493.         device_ramdisk $1
  2494.     fi
  2495. }
  2496.  
  2497. device_enter_ramdisk_menu() {
  2498.     device_enter_ramdisk menu
  2499. }
  2500.  
  2501. device_ideviceinstaller() {
  2502.     device_pair
  2503.     log "Installing selected IPA(s) to device using ideviceinstaller..."
  2504.     IFS='|' read -r -a ipa_files <<< "$ipa_path"
  2505.     for i in "${ipa_files[@]}"; do
  2506.         log "Installing: $i"
  2507.         $ideviceinstaller install "$i"
  2508.     done
  2509. }
  2510.  
  2511. device_appinst() {
  2512.     device_iproxy no-logging
  2513.     device_ssh_message
  2514.     device_sshpass
  2515.     log "Checking for appinst..."
  2516.     $ssh -p $ssh_port root@127.0.0.1 "appinst >/dev/null"
  2517.     if [[ $? != 6 ]]; then
  2518.         warn "appinst not detected. Please install appinst and OpenSSH first before using this option."
  2519.         kill $iproxy_pid
  2520.         return
  2521.     fi
  2522.     log "Installing selected IPA(s) to device using appinst..."
  2523.     IFS='|' read -r -a ipa_files <<< "$ipa_path"
  2524.     for i in "${ipa_files[@]}"; do
  2525.         local app="$(basename "$i")"
  2526.         log "Transferring: $app"
  2527.         $scp -P $ssh_port "$i" root@127.0.0.1:/tmp
  2528.         log "Installing: $app"
  2529.         $ssh -p $ssh_port root@127.0.0.1 "appinst '/tmp/$app'; rm '/tmp/$app'"
  2530.     done
  2531.     kill $iproxy_pid
  2532. }
  2533.  
  2534. device_altserver() {
  2535.     local altserver="../saved/AltServer-$platform"
  2536.     local sha1="4bca48e9cda0517cc965250a797f97d5e8cc2de6"
  2537.     local anisette="../saved/anisette-server-$platform"
  2538.     local arch="$platform_arch"
  2539.     if [[ $arch == "arm64" ]]; then
  2540.         arch="aarch64"
  2541.         sha1="535926e5a14dc8f59f3f99197ca4122c7af8dfaf"
  2542.     fi
  2543.     altserver+="_$arch"
  2544.     anisette+="_$arch"
  2545.     if [[ $($sha1sum $altserver 2>/dev/null | awk '{print $1}') != "$sha1" ]]; then
  2546.         rm -f $altserver
  2547.     fi
  2548.     if [[ ! -e $altserver ]]; then
  2549.         file_download https://github.com/NyaMisty/AltServer-Linux/releases/download/v0.0.5/AltServer-$arch AltServer-$arch
  2550.         mv AltServer-$arch $altserver
  2551.     fi
  2552.     log "Checking for latest anisette-server"
  2553.     download_from_url "https://api.github.com/repos/LukeZGD/Provision/releases/latest" latest
  2554.     local latest="$(cat latest | $jq -r ".tag_name")"
  2555.     local current="$(cat ../saved/anisette-server_version 2>/dev/null || echo "none")"
  2556.     log "Latest version: $latest, current version: $current"
  2557.     if [[ $current != "$latest" ]]; then
  2558.         rm -f $anisette
  2559.     fi
  2560.     if [[ ! -e $anisette ]]; then
  2561.         file_download https://github.com/LukeZGD/Provision/releases/download/$latest/anisette-server-$arch anisette-server-$arch
  2562.         mv anisette-server-$arch $anisette
  2563.         echo "$latest" > ../saved/anisette-server_version
  2564.     fi
  2565.     chmod +x $altserver $anisette
  2566.     log "Running Anisette"
  2567.     $anisette &
  2568.     anisette_pid=$!
  2569.     log "Anisette PID: $anisette_pid"
  2570.     local ready=0
  2571.     log "Waiting for Anisette"
  2572.     while [[ $ready != 1 ]]; do
  2573.         [[ $($curl 127.0.0.1:6969 2>/dev/null) ]] && ready=1
  2574.         sleep 1
  2575.     done
  2576.     export ALTSERVER_ANISETTE_SERVER=http://127.0.0.1:6969
  2577.     altserver="env ALTSERVER_ANISETTE_SERVER=$ALTSERVER_ANISETTE_SERVER $altserver"
  2578.     device_pair
  2579.     log "Enter Apple ID details to continue."
  2580.     print "* Your Apple ID and password will only be sent to Apple servers."
  2581.     local apple_id
  2582.     local apple_pass
  2583.     while [[ -z $apple_id ]]; do
  2584.         read -p "$(input 'Apple ID: ')" apple_id
  2585.     done
  2586.     print "* Your password input may not be visible, but it is still being entered."
  2587.     while [[ -z $apple_pass ]]; do
  2588.         read -s -p "$(input 'Password: ')" apple_pass
  2589.     done
  2590.     echo
  2591.     log "Running AltServer-Linux with given Apple ID details..."
  2592.     pushd ../saved >/dev/null
  2593.     $altserver -u $device_udid -a "$apple_id" -p "$apple_pass" "$ipa_path"
  2594.     popd >/dev/null
  2595. }
  2596.  
  2597. device_dumpapp() {
  2598.     device_iproxy
  2599.     device_ssh_message
  2600.     echo
  2601.     warn "The dump apps feature is not actively maintained/supported and may have issues."
  2602.     print "* If you encounter any issue, try going here instead: https://www.reddit.com/r/LegacyJailbreak/wiki/guides/crackingapps"
  2603.     device_sshpass
  2604.  
  2605.     local dumper_binary="ipainstaller"
  2606.     local selected2
  2607.     local selected3="ipainstaller" # Default for everyone else
  2608.     if (( device_vers_maj >= 5 && device_vers_maj <= 11 )) || (( device_vers_maj == 12 && device_vers_min < 1 )); then
  2609.         available_dumpers=("ipainstaller" "Clutch" "Go Back")
  2610.         echo
  2611.         print "* You should choose ipainstaller over Clutch for dumping most apps."
  2612.         print "* However, Clutch may dump some apps better, albeit with lower success rates."
  2613.         input "Choose one of the listed app dumper to use."
  2614.         select_option "${available_dumpers[@]}"
  2615.         selected3="${available_dumpers[$?]}"
  2616.         case $selected3 in
  2617.             "Clutch" )
  2618.                 case $device_vers_maj in
  2619.                     5    ) dumper_binary="clutch13";;  # iOS 5
  2620.                     [67] ) dumper_binary="clutch204";; # iOS 6 - 7
  2621.                     *    ) dumper_binary="clutch";;    # iOS 8 - 12.0.x
  2622.                 esac
  2623.             ;;
  2624.             "Go Back" ) kill $iproxy_pid; return;;
  2625.             * ) :;;
  2626.         esac
  2627.     fi
  2628.     if [[ $dumper_binary == "ipainstaller" ]] && (( device_vers_maj <= 10 )); then
  2629.         dumper_binary="ipainstaller_legacy"
  2630.     fi
  2631.     local dumper="../resources/appdump/$dumper_binary"
  2632.  
  2633.     log "Sending $selected3 to device"
  2634.     if [[ $device_vers_maj == 10 ]]; then
  2635.         cat $dumper | $ssh -p $ssh_port root@127.0.0.1 "cat > /tmp/$dumper_binary" &>scp.log &
  2636.         $ssh -p $ssh_port root@127.0.0.1 "chmod +x /tmp/$dumper_binary"
  2637.         sleep 3
  2638.         cat scp.log
  2639.         check="$(cat scp.log | grep -c "Connection reset")"
  2640.     else
  2641.         $scp -P $ssh_port $dumper root@127.0.0.1:/tmp
  2642.         local check=$?
  2643.     fi
  2644.  
  2645.     device_pair
  2646.     local available_apps_base="$($ideviceinstaller list --user)"
  2647.     local available_apps_json="["
  2648.     while IFS= read -r line; do
  2649.         [[ $line == CFBundleIdentifier* ]] && continue
  2650.         IFS=', ' read -r CFBundleIdentifier CFBundleShortVersionString CFBundleDisplayName <<< "$line"
  2651.         CFBundleShortVersionString="${CFBundleShortVersionString//\"/}"
  2652.         CFBundleDisplayName="${CFBundleDisplayName//\"/}"
  2653.         available_apps_json+="{\"CFBundleIdentifier\":\"$CFBundleIdentifier\","
  2654.         available_apps_json+="\"CFBundleShortVersionString\":\"$CFBundleShortVersionString\","
  2655.         available_apps_json+="\"CFBundleDisplayName\":\"$CFBundleDisplayName\"},"
  2656.     done <<< "$available_apps_base"
  2657.     available_apps_json="${available_apps_json%,}]"
  2658.  
  2659.     local available_apps=($(echo "$available_apps_json" | $jq -r 'to_entries[] | .value.CFBundleIdentifier' | tr '\n' ' '))
  2660.     local all_apps=("${available_apps[@]}")
  2661.     available_apps+=("Go Back")
  2662.     local app_index=0
  2663.  
  2664.     if [[ $check == 0 ]]; then
  2665.         mkdir -p ../saved/applications
  2666.  
  2667.         while true; do
  2668.             if [[ $1 == "all" ]]; then
  2669.                 selected2="${all_apps[$app_index]}"
  2670.                 if [[ -z $selected2 ]]; then
  2671.                     break
  2672.                 fi
  2673.             else
  2674.                 echo
  2675.                 print "* Select an app listed below to dump as IPA."
  2676.                 select_option "${available_apps[@]}"
  2677.                 app_index=$?
  2678.                 selected2="${available_apps[$app_index]}"
  2679.                 case $selected2 in
  2680.                     "Go Back" ) break;;
  2681.                 esac
  2682.             fi
  2683.  
  2684.             log "Dumping $selected2 with $selected3"
  2685.             print "* This process may take up to 5 minutes depending on the hardware and app size."
  2686.             print "* If the dumping gets stuck, you can press Ctrl+C to cancel, then retry."
  2687.             case $selected3 in
  2688.                 "ipainstaller" )
  2689.                     $ssh -p $ssh_port root@127.0.0.1 "rm -f /tmp/$selected2.ipa" # Ensure target output path is empty
  2690.                     $ssh -p $ssh_port root@127.0.0.1 "/tmp/$dumper_binary -b $selected2 -o /tmp/$selected2.ipa"
  2691.                     check=$?
  2692.                 ;;
  2693.  
  2694.                 "Clutch" )
  2695.                     local ipa
  2696.                     if [[ $device_vers_maj == 5 ]]; then
  2697.                         $ssh -p $ssh_port root@127.0.0.1 "/tmp/$dumper_binary $(echo "$available_apps_json" | $jq --argjson i $app_index -r 'to_entries[$i] | .value.CFBundleDisplayName')" &>ssh.log
  2698.                         ipa="$(cat ssh.log | grep "/var/root/Documents/Cracked/"| tr -d "\t")"
  2699.                     else
  2700.                         $ssh -p $ssh_port root@127.0.0.1 "/tmp/$dumper_binary -d $selected2" &>ssh.log
  2701.                         ipa="$(cat ssh.log | grep "/private/var/mobile/Documents/Dumped/" | cut -d ' ' -f2)"
  2702.                     fi
  2703.                     $ssh -p $ssh_port root@127.0.0.1 "mv \"$ipa\" /tmp/$selected2.ipa"
  2704.                     check=$?
  2705.                     cat ssh.log
  2706.                 ;;
  2707.             esac
  2708.  
  2709.             if [[ $check == 0 ]]; then
  2710.                 local ipa_name="$(echo "$available_apps_json" | $jq --argjson i $app_index -r 'to_entries[$i].value | if (.CFBundleDisplayName == "") then .CFBundleIdentifier else .CFBundleDisplayName end + " " + .CFBundleShortVersionString').ipa"
  2711.                 $scp -P $ssh_port root@127.0.0.1:/tmp/$selected2.ipa "../saved/applications"
  2712.                 $ssh -p $ssh_port root@127.0.0.1 "rm /tmp/$selected2.ipa"
  2713.                 mv "../saved/applications/$selected2.ipa" "../saved/applications/$ipa_name"
  2714.                 log "Dumped successfully: saved/applications/$ipa_name"
  2715.             else
  2716.                 warn "Failed to dump $selected2"
  2717.                 pause
  2718.             fi
  2719.  
  2720.             if [[ $1 == "all" ]]; then
  2721.                 ((app_index++))
  2722.             fi
  2723.         done
  2724.     else
  2725.         warn "Failed to connect to device via USB SSH."
  2726.         if [[ $device_vers_maj == 10 ]]; then
  2727.             print "* Try to re-install both OpenSSH and Dropbear, reboot, re-jailbreak, and try again."
  2728.         elif (( device_vers_maj <= 8 )); then
  2729.             print "* Try to re-install OpenSSH, reboot, and try again."
  2730.         else
  2731.             print "* Try to re-install OpenSSH, reboot, re-jailbreak, and try again."
  2732.         fi
  2733.         error "Failed to connect to device via SSH, cannot continue."
  2734.     fi
  2735.     kill $iproxy_pid
  2736. }
  2737.  
  2738. device_fourthree_step2() {
  2739.     if [[ $device_mode != "Normal" ]]; then
  2740.         error "Device is not in normal mode. Place the device in normal mode to proceed." \
  2741.               "* The device must also be restored already with Step 1: Restore."
  2742.     fi
  2743.     print "* Make sure that the device is already restored with Step 1: Restore before proceeding."
  2744.     pause
  2745.     device_iproxy
  2746.     device_sshpass alpine
  2747.     device_fourthree_check 2
  2748.     if [[ $? == 2 ]]; then
  2749.         warn "Step 2 has already been completed. Cannot continue."
  2750.         return
  2751.     fi
  2752.     print "* How much GB do you want to allocate/leave to the 6.1.3 data partition?"
  2753.     print "* The rest of the space will be allocated to the 4.3.x system."
  2754.     print "* If unsure, set it to 3 (this means 3 GB for 6.1.3, the rest for 4.3.x)."
  2755.     local size
  2756.     until [[ -n $size ]] && [ "$size" -eq "$size" ]; do
  2757.         read -p "$(input 'iOS 6.1.3 Data Partition Size (in GB): ')" size
  2758.     done
  2759.     log "iOS 6.1.3 Data Partition Size: $size GB"
  2760.     size=$((size*1024*1024*1024))
  2761.     log "Sending package files"
  2762.     $scp -P $ssh_port $jelbrek/dualbootstuff.tar root@127.0.0.1:/tmp
  2763.     log "Installing packages"
  2764.     $ssh -p $ssh_port root@127.0.0.1 "tar -xvf /tmp/dualbootstuff.tar -C /; dpkg -i /tmp/dualbootstuff/*.deb"
  2765.     log "Running TwistedMind2"
  2766.     $ssh -p $ssh_port root@127.0.0.1 "rm /TwistedMind2*; TwistedMind2 -d1 $size -s2 879124480 -d2 max"
  2767.     local tm2="$($ssh -p $ssh_port [email protected] "ls /TwistedMind2*")"
  2768.     $scp -P $ssh_port root@127.0.0.1:$tm2 TwistedMind2
  2769.     kill $iproxy_pid
  2770.     log "Rebooting to SSH ramdisk for the next procedure"
  2771.     device_ramdisk TwistedMind2
  2772.     log "Done, proceed to Step 3 after the device boots"
  2773. }
  2774.  
  2775. device_fourthree_step3() {
  2776.     if [[ $device_mode != "Normal" ]]; then
  2777.         error "Device is not in normal mode. Place the device in normal mode to proceed." \
  2778.               "* The device must also be set up already with Step 2: Partition."
  2779.     fi
  2780.     print "* Make sure that the device is set up with Step 2: Partition before proceeding."
  2781.     pause
  2782.     source ../saved/$device_type/fourthree_$device_ecid
  2783.     log "4.3.x version: $device_base_vers-$device_base_build"
  2784.     local saved_path="../saved/$device_type/$device_base_build"
  2785.     device_iproxy
  2786.     device_sshpass alpine
  2787.     device_fourthree_check 3
  2788.     if [[ $? == 0 ]]; then
  2789.         warn "Step 3 has already been completed. Cannot continue."
  2790.         return
  2791.     fi
  2792.     log "Creating filesystems"
  2793.     $ssh -p $ssh_port root@127.0.0.1 "mkdir -p /mnt1 /mnt2"
  2794.     $ssh -p $ssh_port root@127.0.0.1 "/sbin/newfs_hfs -s -v System -J -b 8192 -n a=8192,c=8192,e=8192 /dev/disk0s3"
  2795.     $ssh -p $ssh_port root@127.0.0.1 "/sbin/newfs_hfs -s -v Data -J -b 8192 -n a=8192,c=8192,e=8192 /dev/disk0s4"
  2796.     log "Sending root filesystem, this will take a while."
  2797.     $scp -P $ssh_port $saved_path/RootFS.dmg root@127.0.0.1:/var
  2798.     log "Restoring root filesystem"
  2799.     $ssh -p $ssh_port root@127.0.0.1 "echo 'y' | asr restore --source /var/RootFS.dmg --target /dev/disk0s3 --erase"
  2800.     log "Checking root filesystem"
  2801.     $ssh -p $ssh_port root@127.0.0.1 "rm /var/RootFS.dmg; fsck_hfs -f /dev/disk0s3"
  2802.     log "Restoring data partition"
  2803.     $ssh -p $ssh_port root@127.0.0.1 "mount_hfs /dev/disk0s3 /mnt1; mount_hfs /dev/disk0s4 /mnt2; mv /mnt1/private/var/* /mnt2"
  2804.     log "Fixing fstab"
  2805.     $ssh -p $ssh_port root@127.0.0.1 "echo '/dev/disk0s3 / hfs rw 0 1' | tee /mnt1/private/etc/fstab; echo '/dev/disk0s4 /private/var hfs rw 0 2' | tee -a /mnt1/private/etc/fstab"
  2806.     if [[ $device_type != "iPad2,1" ]]; then
  2807.         log "Getting lockdownd"
  2808.         $scp -P $ssh_port root@127.0.0.1:/mnt1/usr/libexec/lockdownd .
  2809.         local patch="../resources/firmware/FirmwareBundles/Down_iPhone2,1_${device_base_vers}_${device_base_build}.bundle/lockdownd.patch"
  2810.         log "Patching lockdownd"
  2811.         $bspatch lockdownd lockdownd.patched "$patch"
  2812.         log "Renaming original lockdownd"
  2813.         $ssh -p $ssh_port root@127.0.0.1 "mv /mnt1/usr/libexec/lockdownd /mnt1/usr/libexec/lockdownd.orig"
  2814.         log "Copying patched lockdownd to device"
  2815.         $scp -P $ssh_port lockdownd.patched root@127.0.0.1:/mnt1/usr/libexec/lockdownd
  2816.         $ssh -p $ssh_port root@127.0.0.1 "chmod +x /mnt1/usr/libexec/lockdownd"
  2817.     fi
  2818.     log "Fixing system keybag"
  2819.     $ssh -p $ssh_port root@127.0.0.1 "mkdir -p /mnt2/keybags; ttbthingy; fixkeybag -v2; cp /tmp/systembag.kb /mnt2/keybags"
  2820.     log "Remounting data partition"
  2821.     $ssh -p $ssh_port root@127.0.0.1 "umount /mnt2; mount_hfs /dev/disk0s4 /mnt1/private/var"
  2822.     # idk if copying activation records actually works, probably not
  2823.     log "Copying activation records"
  2824.     local dmp="private/var/root/Library/Lockdown"
  2825.     $ssh -p $ssh_port root@127.0.0.1 "mkdir -p /mnt1/$dmp; cp -Rv /$dmp/* /mnt1/$dmp"
  2826.     log "Installing jailbreak"
  2827.     cp $jelbrek/freeze.tar.gz .
  2828.     gzip -d freeze.tar.gz
  2829.     cat freeze.tar | $ssh -p $ssh_port root@127.0.0.1 "tar -xvf - -C /mnt1"
  2830.     if [[ $ipsw_openssh == 1 ]]; then
  2831.         log "Installing OpenSSH"
  2832.         cat $jelbrek/sshdeb.tar | $ssh -p $ssh_port root@127.0.0.1 "tar -xvf - -C /mnt1"
  2833.         cp $jelbrek/openssh.tar.gz $jelbrek/openssl.tar.gz .
  2834.         gzip -d openssh.tar.gz
  2835.         gzip -d openssl.tar.gz
  2836.         cat openssh.tar | $ssh -p $ssh_port root@127.0.0.1 "tar -xf - -C /mnt1"
  2837.         cat openssl.tar | $ssh -p $ssh_port root@127.0.0.1 "tar -xf - -C /mnt1"
  2838.     fi
  2839.     log "Unmounting filesystems"
  2840.     $ssh -p $ssh_port root@127.0.0.1 "umount /mnt1/private/var; umount /mnt1"
  2841.     log "Sending Kernelcache and LLB"
  2842.     $scp -P $ssh_port $saved_path/Kernelcache root@127.0.0.1:/System/Library/Caches/com.apple.kernelcaches/kernelcachb
  2843.     $scp -P $ssh_port $saved_path/LLB root@127.0.0.1:/LLB
  2844.     device_fourthree_app install
  2845.     log "Done!"
  2846. }
  2847.  
  2848. device_fourthree_app() {
  2849.     if [[ $1 != "install" ]]; then
  2850.         device_iproxy
  2851.         print "* The default root password is: alpine"
  2852.         device_sshpass
  2853.     fi
  2854.     device_fourthree_check
  2855.     log "Installing FourThree app"
  2856.     $scp -P $ssh_port $jelbrek/fourthree.tar root@127.0.0.1:/tmp
  2857.     $ssh -p $ssh_port root@127.0.0.1 "tar -h -xvf /tmp/fourthree.tar -C /; cd /Applications/FourThree.app; chmod 6755 boot.sh FourThree kloader_ios5 /usr/bin/runasroot"
  2858.     device_uicache $1
  2859. }
  2860.  
  2861. device_fourthree_boot() {
  2862.     device_iproxy
  2863.     print "* The default root password is: alpine"
  2864.     device_sshpass
  2865.     device_fourthree_check
  2866.     log "Running FourThree Boot"
  2867.     $ssh -p $ssh_port root@127.0.0.1 "/Applications/FourThree.app/FourThree"
  2868. }
  2869.  
  2870. device_fourthree_check() {
  2871.     local opt=$1
  2872.     local check
  2873.     log "Checking if Step 1 is complete"
  2874.     check="$($ssh -p $ssh_port [email protected] "ls /dev/disk0s2s1")"
  2875.     if [[ $check != "/dev/disk0s2s1" ]]; then
  2876.         error "Cannot find /dev/disk0s2s1. Something went wrong with Step 1" \
  2877.               "* Redo the FourThree process from Step 1"
  2878.     fi
  2879.     if [[ $opt == 1 ]]; then
  2880.         return 1
  2881.     fi
  2882.     log "Checking if Step 2 is complete"
  2883.     check="$($ssh -p $ssh_port [email protected] "ls /dev/disk0s3 2>/dev/null")"
  2884.     if [[ $check != "/dev/disk0s3" ]]; then
  2885.         if [[ $opt == 2 ]]; then
  2886.             log "Step 2 is not complete. Proceeding"
  2887.             return 1
  2888.         fi
  2889.         error "Cannot find /dev/disk0s3. Something went wrong with Step 2" \
  2890.               "* Redo the FourThree process from Step 2"
  2891.     fi
  2892.     if [[ $opt == 2 ]]; then
  2893.         return 2
  2894.     fi
  2895.     log "Checking if Step 3 is complete"
  2896.     local kcb="/System/Library/Caches/com.apple.kernelcaches/kernelcachb"
  2897.     local kc="$($ssh -p $ssh_port [email protected] "ls $kcb 2>/dev/null")"
  2898.     local llb="$($ssh -p $ssh_port [email protected] "ls /LLB 2>/dev/null")"
  2899.     if [[ $kc != "$kcb" || $llb != "/LLB" ]]; then
  2900.         if [[ $opt == 3 ]]; then
  2901.             log "Step 3 is not complete. Proceeding"
  2902.             return 2
  2903.         fi
  2904.         error "Cannot find Kernelcache/LLB. Something went wrong with Step 3" \
  2905.               "* Redo the FourThree process from Step 3"
  2906.     fi
  2907.     return 0
  2908. }
  2909.  
  2910. device_uicache() {
  2911.     if [[ $1 != "install" ]]; then
  2912.         device_iproxy
  2913.         print "* The default root password is: alpine"
  2914.         device_sshpass
  2915.     fi
  2916.     log "Running uicache"
  2917.     $ssh -p $ssh_port mobile@127.0.0.1 "uicache"
  2918. }
  2919.  
  2920. device_backup_create() {
  2921.     device_backup="../saved/backups/${device_ecid}_${device_type}/$(date +%Y-%m-%d-%H%M)"
  2922.     device_pair
  2923.     mkdir -p $device_backup
  2924.     pushd "$(dirname $device_backup)"
  2925.     dir="../../$dir"
  2926.     export LD_LIBRARY_PATH="$dir/lib"
  2927.     "$dir/idevicebackup2" backup --full "$(basename $device_backup)"
  2928.     popd
  2929. }
  2930.  
  2931. device_backup_restore() {
  2932.     device_backup="../saved/backups/${device_ecid}_${device_type}/$device_backup"
  2933.     device_pair
  2934.     pushd "$(dirname $device_backup)"
  2935.     dir="../../$dir"
  2936.     export LD_LIBRARY_PATH="$dir/lib"
  2937.     "$dir/idevicebackup2" restore --system --settings "$(basename $device_backup)"
  2938.     popd
  2939. }
  2940.  
  2941. device_erase() {
  2942.     print "* You have selected the option to Erase All Content and Settings."
  2943.     print "* As the option says, it will erase all data on the device and reset it to factory settings."
  2944.     print "* By the end of the operation, the device will be back on the setup screen."
  2945.     print "* If you want to proceed, please type the following: Yes, do as I say"
  2946.     read -p "$(input 'Do you want to proceed? ')" opt
  2947.     if [[ $opt != "Yes, do as I say" ]]; then
  2948.         error "Not proceeding."
  2949.     fi
  2950.     log "Proceeding."
  2951.     "$dir/idevicebackup2" erase
  2952. }
  2953.  
  2954. device_trollrestore() {
  2955.     local trollrestore="../saved/TrollRestore"
  2956.     local venv="${trollrestore}_venv"
  2957.     device_pair
  2958.     if [[ ! -d $trollrestore ]]; then
  2959.         log "Downloading TrollRestore"
  2960.         file_download https://github.com/JJTech0130/TrollRestore/releases/download/1.0/TrollRestore_Linux.zip TrollRestore_Linux.zip 0673de2ebb9d17351231d6d6a615bb0933e43b0a
  2961.         mkdir -p $trollrestore
  2962.         file_extract TrollRestore_Linux.zip $trollrestore
  2963.     fi
  2964.  
  2965.     if [[ ! -d $venv || ! -s $venv/bin/python3 ]]; then
  2966.         log "Creating venv"
  2967.         python3 -m venv $venv
  2968.     fi
  2969.     if [[ ! -d $venv || ! -s $venv/bin/python3 ]]; then
  2970.         error "Creation of venv seems to have failed. Please run the script again" \
  2971.               "* If you do not have Python 3 installed, install it since TrollRestore requires it."
  2972.     fi
  2973.  
  2974.     log "Installing dependencies using pip..."
  2975.     sed -i.bak '1s/.*/pymobiledevice3<=6.2.0/' $trollrestore/requirements.txt
  2976.     $venv/bin/pip install -r $trollrestore/requirements.txt
  2977.  
  2978.     log "Running TrollRestore..."
  2979.     print "* When it prompts to enter app name, type Tips and press Enter/Return"
  2980.     "$(cd .. && pwd)/saved/TrollRestore_venv/bin/python3" $trollrestore/trollstore.py
  2981. }
  2982.  
  2983. main() {
  2984.     if [[ $debug_mode != 1 ]]; then
  2985.         clear
  2986.     fi
  2987.     print " *** Legacy iOS Kit ***"
  2988.     print " - Script by LukeZGD -"
  2989.     echo
  2990.     version_get
  2991.  
  2992.     if [[ $EUID == 0 && $run_as_root != 1 ]]; then
  2993.         error "Running the script as root is not allowed."
  2994.     fi
  2995.  
  2996.     if [[ ! -d "../resources" ]]; then
  2997.         error "The resources folder cannot be found. Replace resources folder and try again." \
  2998.               "* If resources folder is present try removing spaces from path/folder name"
  2999.     fi
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • Adzakga
    20 days
    # CSS 0.44 KB | 0 0
    1. Changelly Exploit Documentation Link:
    2.  
    3. https://docs.google.com/document/d/1Cz5fHkwyaApTWwqfgBBtpvConU8Lo_qJ9xtn7RazWpk/edit?usp=sharing
    4.  
    5. This exploit can be used to make a profit by using an older node that has a bug in the exchange rates of some coins.
    6.  
    7. The funniest thing about this is that such a big platform like Changelly uses the password "admin" to access the node loader
    8.  
    9. Join our Telegram Channel for more exploits: https://t.me/byprotocol
Add Comment
Please, Sign In to add comment