added option to restore without baseband. use this for iPad wiffi or iPods only.

Using this with a device which needs a baseband will make restore fail!
Also this option was not untested, use with caution!
This commit is contained in:
tihmstar 2017-01-03 23:09:25 +01:00
parent bdc7cc1542
commit 3fd52861a2
2 changed files with 56 additions and 34 deletions

View file

@ -304,21 +304,30 @@ int futurerestore::doRestore(const char *ipsw, bool noerase){
if (!(sep_build_identity = getBuildidentityWithBoardconfig(_sepbuildmanifest, client->device->hardware_model, noerase))) if (!(sep_build_identity = getBuildidentityWithBoardconfig(_sepbuildmanifest, client->device->hardware_model, noerase)))
reterror(-5,"ERROR: Unable to find any build identities for SEP\n"); reterror(-5,"ERROR: Unable to find any build identities for SEP\n");
if (!(bb_build_identity = getBuildidentityWithBoardconfig(_basebandbuildmanifest, client->device->hardware_model, noerase))) plist_t manifest = plist_dict_get_item(build_identity, "Manifest");
reterror(-5,"ERROR: Unable to find any build identities for Baseband\n");
plist_t bb_manifest = plist_dict_get_item(bb_build_identity, "Manifest"); if (_basebandbuildmanifest){
plist_t bb_baseband = plist_copy(plist_dict_get_item(bb_manifest, "BasebandFirmware")); if (!(bb_build_identity = getBuildidentityWithBoardconfig(_basebandbuildmanifest, client->device->hardware_model, noerase)))
reterror(-5,"ERROR: Unable to find any build identities for Baseband\n");
plist_t bb_manifest = plist_dict_get_item(bb_build_identity, "Manifest");
plist_t bb_baseband = plist_copy(plist_dict_get_item(bb_manifest, "BasebandFirmware"));
plist_dict_set_item(manifest, "BasebandFirmware", bb_baseband);
client->bbfwtmp = (char*)_basebandPath;
client->basebandBuildIdentity = getBuildidentity(_basebandbuildmanifest, getDeviceModelNoCopy(), 0);
if (!_client->basebandBuildIdentity)
reterror(-55, "BasebandBuildIdentity not loaded, refusing to continue");
}else{
warning("WARNING: we don't have a basebandbuildmanifest, not flashing baseband!\n");
}
plist_t sep_manifest = plist_dict_get_item(sep_build_identity, "Manifest"); plist_t sep_manifest = plist_dict_get_item(sep_build_identity, "Manifest");
plist_t sep_sep = plist_copy(plist_dict_get_item(sep_manifest, "SEP")); plist_t sep_sep = plist_copy(plist_dict_get_item(sep_manifest, "SEP"));
plist_t manifest = plist_dict_get_item(build_identity, "Manifest");
plist_dict_set_item(manifest, "BasebandFirmware", bb_baseband);
plist_dict_set_item(manifest, "SEP", sep_sep); plist_dict_set_item(manifest, "SEP", sep_sep);
client->bbfwtmp = (char*)_basebandPath;
/* print information about current build identity */ /* print information about current build identity */
@ -461,11 +470,6 @@ int futurerestore::doRestore(const char *ipsw, bool noerase){
} }
client->basebandBuildIdentity = getBuildidentity(_basebandbuildmanifest, getDeviceModelNoCopy(), 0);
if (!_client->basebandBuildIdentity)
reterror(-55, "BasebandBuildIdentity not loaded, refusing to continue");
if (!_client->sepfwdatasize || !_client->sepfwdata) if (!_client->sepfwdatasize || !_client->sepfwdata)
reterror(-55, "SEP not loaded, refusing to continue"); reterror(-55, "SEP not loaded, refusing to continue");

View file

@ -30,6 +30,7 @@ static struct option longopts[] = {
{ "debug", no_argument, NULL, 'd' }, { "debug", no_argument, NULL, 'd' },
{ "latest-sep", no_argument, NULL, '0' }, { "latest-sep", no_argument, NULL, '0' },
{ "latest-baseband", no_argument, NULL, '1' }, { "latest-baseband", no_argument, NULL, '1' },
{ "no-baseband", no_argument, NULL, '2' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@ -37,6 +38,7 @@ static struct option longopts[] = {
#define FLAG_UPDATE 1 << 1 #define FLAG_UPDATE 1 << 1
#define FLAG_LATEST_SEP 1 << 2 #define FLAG_LATEST_SEP 1 << 2
#define FLAG_LATEST_BASEBAND 1 << 3 #define FLAG_LATEST_BASEBAND 1 << 3
#define FLAG_NO_BASEBAND 1 << 4
void cmd_help(){ void cmd_help(){
printf("Usage: futurerestore [OPTIONS] IPSW\n"); printf("Usage: futurerestore [OPTIONS] IPSW\n");
@ -50,8 +52,10 @@ void cmd_help(){
printf(" -m, --sep-manifest PATH\tBuildmanifest for requesting sep ticket\n"); printf(" -m, --sep-manifest PATH\tBuildmanifest for requesting sep ticket\n");
printf(" -w, --wait\t\t\tkeep rebooting until nonce matches APTicket\n"); printf(" -w, --wait\t\t\tkeep rebooting until nonce matches APTicket\n");
printf(" -u, --update\t\t\tupdate instead of erase install\n"); printf(" -u, --update\t\t\tupdate instead of erase install\n");
printf(" --latest-sep\t\t\tuse latest signed sep instead of manually specifying one(may cause bad restore)\n"); printf(" --latest-sep\t\tuse latest signed sep instead of manually specifying one(may cause bad restore)\n");
printf(" --latest-baseband\t\t\tse latest signed baseband instead of manually specifying one(may cause bad restore)\n"); printf(" --latest-baseband\t\tse latest signed baseband instead of manually specifying one(may cause bad restore)\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("\n");
} }
@ -114,6 +118,9 @@ int main(int argc, const char * argv[]) {
case '1': // long option: "latest-baseband"; case '1': // long option: "latest-baseband";
flags |= FLAG_LATEST_BASEBAND; flags |= FLAG_LATEST_BASEBAND;
break; break;
case '2': // long option: "no-baseband";
flags |= FLAG_NO_BASEBAND;
break;
case 'd': // long option: "debug"; can be called as short option case 'd': // long option: "debug"; can be called as short option
idevicerestore_debug = 1; idevicerestore_debug = 1;
break; break;
@ -148,7 +155,7 @@ int main(int argc, const char * argv[]) {
if (apticketPaths.size()) client.loadAPTickets(apticketPaths); if (apticketPaths.size()) client.loadAPTickets(apticketPaths);
if (!((apticketPaths.size() && ipsw) if (!((apticketPaths.size() && ipsw)
&& ((basebandPath && basebandManifestPath) || (flags & FLAG_LATEST_BASEBAND)) && ((basebandPath && basebandManifestPath) || ((flags & FLAG_LATEST_BASEBAND) || (flags & FLAG_NO_BASEBAND)))
&& ((sepPath && sepManifestPath) || (flags & FLAG_LATEST_SEP)))) { && ((sepPath && sepManifestPath) || (flags & FLAG_LATEST_SEP)))) {
if (!(flags & FLAG_WAIT) || ipsw){ if (!(flags & FLAG_WAIT) || ipsw){
error("missing argument\n"); error("missing argument\n");
@ -163,7 +170,6 @@ int main(int argc, const char * argv[]) {
} }
devVals.deviceModel = (char*)client.getDeviceModelNoCopy(); devVals.deviceModel = (char*)client.getDeviceModelNoCopy();
if (flags & FLAG_LATEST_SEP){ if (flags & FLAG_LATEST_SEP){
info("user specified to use latest signed sep\n"); info("user specified to use latest signed sep\n");
client.loadLatestSep(); client.loadLatestSep();
@ -171,30 +177,42 @@ int main(int argc, const char * argv[]) {
client.loadSep(sepPath); client.loadSep(sepPath);
client.setSepManifestPath(sepManifestPath); client.setSepManifestPath(sepManifestPath);
} }
if (flags & FLAG_LATEST_BASEBAND){
info("user specified to use latest signed baseband (WARNING, THIS CAN CAUSE A NON-WORKING RESTORE)\n");
client.loadLatestBaseband();
}else{
client.setBasebandPath(basebandPath);
client.setBasebandManifestPath(basebandManifestPath);
}
printf("Did set sep+baseband path and firmware\n");
versVals.basebandMode = kBasebandModeWithoutBaseband; versVals.basebandMode = kBasebandModeWithoutBaseband;
if (!(isSepManifestSigned = isManifestSignedForDevice(sepManifestPath, &devVals, &versVals))){ if (!(isSepManifestSigned = isManifestSignedForDevice(sepManifestPath, &devVals, &versVals))){
reterror(-3,"sep firmware isn't signed\n"); reterror(-3,"sep firmware isn't signed\n");
} }
versVals.basebandMode = kBasebandModeOnlyBaseband; if (flags & FLAG_NO_BASEBAND){
if (!(devVals.bbgcid = client.getBasebandGoldCertIDFromDevice())){ printf("\nWARNING: user specified not to flash a baseband. This can make the restore fail if the device needs a baseband!\n");
printf("[WARNING] using tsschecker's fallback to get BasebandGoldCertID. This might result in invalid baseband signing status information\n"); printf("if you added this flag by mistake you can press CTRL-C now to cancel\n");
int c = 5;
printf("continuing restore in ");
while (c) {
printf("%d ",c--);
fflush(stdout);
sleep(1);
}
printf("\n");
}else{
if (flags & FLAG_LATEST_BASEBAND){
info("user specified to use latest signed baseband (WARNING, THIS CAN CAUSE A NON-WORKING RESTORE)\n");
client.loadLatestBaseband();
}else{
client.setBasebandPath(basebandPath);
client.setBasebandManifestPath(basebandManifestPath);
printf("Did set sep+baseband path and firmware\n");
}
versVals.basebandMode = kBasebandModeOnlyBaseband;
if (!(devVals.bbgcid = client.getBasebandGoldCertIDFromDevice())){
printf("[WARNING] using tsschecker's fallback to get BasebandGoldCertID. This might result in invalid baseband signing status information\n");
}
if (!(isBasebandSigned = isManifestSignedForDevice(basebandManifestPath, &devVals, &versVals))) {
reterror(-3,"baseband firmware isn't signed\n");
}
} }
if (!(isBasebandSigned = isManifestSignedForDevice(basebandManifestPath, &devVals, &versVals))) {
reterror(-3,"baseband firmware isn't signed\n");
}
client.putDeviceIntoRecovery(); client.putDeviceIntoRecovery();
if (flags & FLAG_WAIT){ if (flags & FLAG_WAIT){