Add option "--exit-recovery"

Co-Authored-By: Luke S. <luke@street.dev>
pull/303/head
s0uthwest 2019-12-25 11:01:47 -08:00
parent 13a14f7e96
commit c02e9d5876
5 changed files with 29 additions and 25 deletions

1
.gitignore vendored
View File

@ -19,7 +19,6 @@ libtool
ltmain.sh
m4
missing
*/config.h*
*/futurerestore*
stamp-h1
xcuserdata

View File

@ -8,6 +8,7 @@ AM_INIT_AUTOMAKE([subdir-objects])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIRS([m4])
# Versioning.
AC_DEFINE([VERSION_COMMIT_COUNT], "m4_esyscmd([git rev-list --count HEAD | tr -d '\n'])", [Git commit count])
AC_DEFINE([VERSION_COMMIT_SHA], "m4_esyscmd([git rev-parse HEAD | tr -d '\n'])", [Git commit sha])
AC_SUBST([VERSION_COMMIT_COUNT], ["m4_esyscmd([git rev-list --count HEAD | tr -d '\n'])"])
@ -17,8 +18,7 @@ AC_SUBST([VERSION_COMMIT_SHA], ["m4_esyscmd([git rev-parse HEAD | tr -d '\n'])"]
AC_PROG_CXX
AC_PROG_CC
# Check for operating system
# Check for operating system.
AC_MSG_CHECKING([whether we need platform-specific build settings])
case $host_os in
darwin* )
@ -26,13 +26,11 @@ case $host_os in
;;
esac
# Checks the flags.
CFLAGS="-DIDEVICERESTORE_NOMAIN=1 -DTSSCHECKER_NOMAIN=1"
CXXFLAGS+=" -std=c++11"
CFLAGS+=" -std=c11"
AC_DEFUN([AX_UNPRECIOUS], [
m4_define([_AC_PRECIOUS_VARS], m4_bpatsubst(_AC_PRECIOUS_VARS, [$1], []))
])
@ -42,8 +40,7 @@ export CFLAGS
AC_CONFIG_SUBDIRS(external/idevicerestore external/tsschecker)
AC_CONFIG_SRCDIR([futurerestore])
# Checks the libraries.
LIBIPATCHER_REQUIRES_STR="libipatcher >= 61"
LIBPLIST_REQUIRES_STR="libplist >= 2.0.0"
LIBZIP_REQUIRES_STR="libzip >= 0.10"
@ -61,7 +58,6 @@ PKG_CHECK_MODULES(libirecovery, $LIBIRECOVERY_REQUIRES_STR)
PKG_CHECK_MODULES(libimg4tool, $IMG4TOOL_REQUIRES_STR)
PKG_CHECK_MODULES(libgeneral, $LIBGENERAL_REQUIRES_STR)
# Optional module libipatcher
AC_ARG_WITH([libipatcher],
[AS_HELP_STRING([--without-libipatcher],
@ -87,7 +83,6 @@ AM_CONDITIONAL([HAVE_LIBIPATCHER],[test "x$do_libipatcher" = "xyes"])
AC_DEFINE(CUSTOM_LOGGING, 1, [required for futurerestore])
LT_INIT
AC_OUTPUT([
@ -95,7 +90,6 @@ Makefile
futurerestore/Makefile
])
echo "
Configuration for $PACKAGE $VERSION:
-------------------------------------------

View File

@ -178,6 +178,12 @@ void futurerestore::setAutoboot(bool val){
retassure(!recovery_set_autoboot(_client, val),"Setting auto-boot failed?!\n");
}
void futurerestore::exitRecovery() {
setAutoboot(true);
recovery_send_reset(_client);
recovery_client_free(_client);
}
plist_t futurerestore::nonceMatchesApTickets(){
retassure(_didInit, "did not init\n");
@ -188,7 +194,6 @@ plist_t futurerestore::nonceMatchesApTickets(){
_rerestoreiOS9 = (info("Detected iOS 9 re-restore, proceeding in DFU mode\n"),true);
}
unsigned char* realnonce;
int realNonceSize = 0;
if (_rerestoreiOS9) {

View File

@ -63,7 +63,6 @@ class futurerestore {
//methods
void enterPwnRecovery(plist_t build_identity, std::string bootargs = "");
public:
futurerestore(bool isUpdateInstall = false, bool isPwnDfu = false);
bool init();
@ -71,6 +70,7 @@ public:
uint64_t getDeviceEcid();
void putDeviceIntoRecovery();
void setAutoboot(bool val);
void exitRecovery();
void waitForNonce();
void waitForNonce(vector<const char *>nonces, size_t nonceSize);
void loadAPTickets(const vector<const char *> &apticketPaths);
@ -93,14 +93,12 @@ public:
void setBasebandPath(const char *basebandPath);
bool isUpdateInstall(){return _isUpdateInstall;};
plist_t sepManifest(){return _sepbuildmanifest;};
plist_t basebandManifest(){return _basebandbuildmanifest;};
const char *sepManifestPath(){return _sepbuildmanifestPath;};
const char *basebandManifestPath(){return _basebandbuildmanifestPath;};
bool is32bit(){return !is_image4_supported(_client);};
uint64_t getBasebandGoldCertIDFromDevice();
void doRestore(const char *ipsw);
@ -117,7 +115,4 @@ public:
static std::string getGeneratorFromSHSH2(const plist_t shsh2);
};
#endif /* futurerestore_hpp */

View File

@ -1,4 +1,4 @@
//
// main.cpp
// futurerestore
//
@ -6,7 +6,6 @@
// Copyright © 2016 tihmstar. All rights reserved.
//
#include <iostream>
#include <getopt.h>
#include <string.h>
@ -42,6 +41,7 @@ static struct option longopts[] = {
{ "use-pwndfu", no_argument, NULL, '3' },
{ "just-boot", optional_argument, NULL, '4' },
#endif
{ "exit-recovery", no_argument, NULL, '5' },
{ NULL, 0, NULL, 0 }
};
@ -70,9 +70,9 @@ void cmd_help(){
printf(" --use-pwndfu\t\tuse this for restoring devices with odysseus method. Device needs to be in kDFU mode already\n");
printf(" --just-boot=\"-v\"\t\tuse this to tethered boot the device from kDFU mode. You can optionally set bootargs\n");
#endif
printf(" --exit-recovery\t\tExit recovery mode and quit\n");
printf(" --no-baseband\t\tskip checks and don't flash baseband.\n");
printf(" \t\tWARNING: only use this for device without baseband (eg iPod or some wifi only iPads)\n");
printf("\n");
printf(" \t\tWARNING: only use this for device without baseband (eg iPod or some wifi only iPads)\n\n");
}
using namespace std;
@ -91,6 +91,7 @@ int main_r(int argc, const char * argv[]) {
int optindex = 0;
int opt = 0;
long flags = 0;
bool exitRecovery = false;
int isSepManifestSigned = 0;
int isBasebandSigned = 0;
@ -112,8 +113,7 @@ int main_r(int argc, const char * argv[]) {
return -1;
}
while ((opt = getopt_long(argc, (char* const *)argv, "ht:b:p:s:m:wud01", longopts, &optindex)) > 0) {
while ((opt = getopt_long(argc, (char* const *)argv, "ht:b:p:s:m:wud0123", longopts, &optindex)) > 0) {
switch (opt) {
case 't': // long option: "apticket"; can be called as short option
apticketPaths.push_back(optarg);
@ -146,7 +146,7 @@ int main_r(int argc, const char * argv[]) {
flags |= FLAG_NO_BASEBAND;
break;
#ifdef HAVE_LIBIPATCHER
case '3': // long option: "no-baseband";
case '3': // long option: "use-pwndfu";
flags |= FLAG_IS_PWN_DFU;
break;
case '4': // long option: "just-boot";
@ -154,6 +154,9 @@ int main_r(int argc, const char * argv[]) {
break;
break;
#endif
case '5': // long option: "exit-recovery";
exitRecovery = true;
break;
case 'd': // long option: "debug"; can be called as short option
idevicerestore_debug = 1;
break;
@ -169,6 +172,8 @@ int main_r(int argc, const char * argv[]) {
ipsw = argv[0];
}else if (argc == optind && flags & FLAG_WAIT) {
info("User requested to only wait for APNonce to match, but not actually restoring\n");
}else if (exitRecovery){
info("Exiting recovery mode\n");
}else{
error("argument parsing failed! agrc=%d optind=%d\n",argc,optind);
if (idevicerestore_debug){
@ -185,6 +190,12 @@ int main_r(int argc, const char * argv[]) {
printf("futurerestore init done\n");
retassure(!bootargs || (flags & FLAG_IS_PWN_DFU),"--just-boot requires --use-pwndfu\n");
if (exitRecovery) {
client.exitRecovery();
info("Done\n");
return 0;
}
try {
if (apticketPaths.size()) client.loadAPTickets(apticketPaths);