mirror of
https://github.com/tihmstar/futurerestore.git
synced 2025-01-02 19:25:31 +00:00
changed the way baseband tickets are handled (i really hope this doesn't fuck up the entire restore)
This commit is contained in:
parent
da40807d6f
commit
961dbc808a
|
@ -254,8 +254,6 @@ int futurerestore::doRestore(const char *ipsw, bool noerase){
|
||||||
int delete_fs = 0;
|
int delete_fs = 0;
|
||||||
char* filesystem = NULL;
|
char* filesystem = NULL;
|
||||||
plist_t buildmanifest = NULL;
|
plist_t buildmanifest = NULL;
|
||||||
plist_t sepbuildmanifest = NULL;
|
|
||||||
plist_t basebandbuildmanifest = NULL;
|
|
||||||
plist_t build_identity = NULL;
|
plist_t build_identity = NULL;
|
||||||
plist_t sep_build_identity = NULL;
|
plist_t sep_build_identity = NULL;
|
||||||
plist_t bb_build_identity = NULL;
|
plist_t bb_build_identity = NULL;
|
||||||
|
@ -312,16 +310,14 @@ int futurerestore::doRestore(const char *ipsw, bool noerase){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sepbuildmanifest = loadPlistFromFile(_sepManifestPath);
|
sep_build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(_sepbuildmanifest, client->device->hardware_model, "Erase");
|
||||||
sep_build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(sepbuildmanifest, client->device->hardware_model, "Erase");
|
if (!sep_build_identity) sep_build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(_sepbuildmanifest, client->device->hardware_model, "Update");
|
||||||
if (!sep_build_identity) sep_build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(sepbuildmanifest, client->device->hardware_model, "Update");
|
|
||||||
if (sep_build_identity == NULL) {
|
if (sep_build_identity == NULL) {
|
||||||
reterror(-5,"ERROR: Unable to find any build identities for sep\n");
|
reterror(-5,"ERROR: Unable to find any build identities for sep\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
basebandbuildmanifest = loadPlistFromFile(_basebandManifestPath);
|
bb_build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(_basebandbuildmanifest, client->device->hardware_model, "Erase");
|
||||||
bb_build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(basebandbuildmanifest, client->device->hardware_model, "Erase");
|
if (!bb_build_identity) bb_build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(_basebandbuildmanifest, client->device->hardware_model, "Update");
|
||||||
if (!bb_build_identity) bb_build_identity = build_manifest_get_build_identity_for_model_with_restore_behavior(basebandbuildmanifest, client->device->hardware_model, "Update");
|
|
||||||
if (bb_build_identity == NULL) {
|
if (bb_build_identity == NULL) {
|
||||||
reterror(-5,"ERROR: Unable to find any build identities for baseband\n");
|
reterror(-5,"ERROR: Unable to find any build identities for baseband\n");
|
||||||
}
|
}
|
||||||
|
@ -472,13 +468,16 @@ int futurerestore::doRestore(const char *ipsw, bool noerase){
|
||||||
reterror(-11,"ERROR: Unable to get SHSH blobs for SEP\n");
|
reterror(-11,"ERROR: Unable to get SHSH blobs for SEP\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *fsep = fopen(_sepPath, "r");
|
|
||||||
fseek(fsep, 0, SEEK_END);
|
client->basebandBuildIdentity = getBuildidentity(_basebandbuildmanifest, getDeviceModelNoCopy(), noerase);
|
||||||
client->sepfwdatasize = ftell(fsep);
|
|
||||||
fseek(fsep, 0, SEEK_SET);
|
if (!_client->basebandBuildIdentity)
|
||||||
client->sepfwdata = (char*)malloc(client->sepfwdatasize);
|
reterror(-55, "BasebandBuildIdentity not loaded, refusing to continue");
|
||||||
fread(client->sepfwdata, 1, client->sepfwdatasize, fsep);
|
|
||||||
fclose(fsep);
|
|
||||||
|
if (!_client->sepfwdatasize || !_client->sepfwdata)
|
||||||
|
reterror(-55, "SEP not loaded, refusing to continue");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (client->mode->index == MODE_RESTORE) {
|
if (client->mode->index == MODE_RESTORE) {
|
||||||
|
@ -495,8 +494,6 @@ int futurerestore::doRestore(const char *ipsw, bool noerase){
|
||||||
error:
|
error:
|
||||||
safeFree(client->sepfwdata);
|
safeFree(client->sepfwdata);
|
||||||
safePlistFree(buildmanifest);
|
safePlistFree(buildmanifest);
|
||||||
safePlistFree(sepbuildmanifest);
|
|
||||||
safePlistFree(basebandbuildmanifest);
|
|
||||||
safePlistFree(build_identity);
|
safePlistFree(build_identity);
|
||||||
safePlistFree(sep_build_identity);
|
safePlistFree(sep_build_identity);
|
||||||
safePlistFree(bb_build_identity);
|
safePlistFree(bb_build_identity);
|
||||||
|
@ -520,6 +517,8 @@ futurerestore::~futurerestore(){
|
||||||
for (auto plist : _aptickets){
|
for (auto plist : _aptickets){
|
||||||
safePlistFree(plist);
|
safePlistFree(plist);
|
||||||
}
|
}
|
||||||
|
safePlistFree(_sepbuildmanifest);
|
||||||
|
safePlistFree(_basebandbuildmanifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
void futurerestore::loadFirmwareTokens(){
|
void futurerestore::loadFirmwareTokens(){
|
||||||
|
@ -590,16 +589,56 @@ void futurerestore::loadLatestBaseband(){
|
||||||
info("downloading Baseband\n\n");
|
info("downloading Baseband\n\n");
|
||||||
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
|
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _basebandPath = BASEBAND_TMP_PATH))
|
||||||
reterror(-32, "could not download baseband\n");
|
reterror(-32, "could not download baseband\n");
|
||||||
saveStringToFile(manifeststr, _basebandManifestPath = BASEBAND_MANIFEST_TMP_PATH);
|
saveStringToFile(manifeststr, BASEBAND_MANIFEST_TMP_PATH);
|
||||||
|
setBasebandManifestPath(BASEBAND_TMP_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
void futurerestore::loadLatestSep(){
|
void futurerestore::loadLatestSep(){
|
||||||
char * manifeststr = getLatestManifest();
|
char * manifeststr = getLatestManifest();
|
||||||
char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getDeviceModelNoCopy(), 0);
|
char *pathStr = getPathOfElementInManifest("SEP", manifeststr, getDeviceModelNoCopy(), 0);
|
||||||
info("downloading SEP\n\n");
|
info("downloading SEP\n\n");
|
||||||
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, _sepPath = SEP_TMP_PATH))
|
if (downloadPartialzip(getLatestFirmwareUrl(), pathStr, SEP_TMP_PATH))
|
||||||
reterror(-33, "could not download SEP\n");
|
reterror(-33, "could not download SEP\n");
|
||||||
saveStringToFile(manifeststr, _sepManifestPath = SEP_MANIFEST_TMP_PATH);
|
loadSep(SEP_TMP_PATH);
|
||||||
|
saveStringToFile(manifeststr, SEP_MANIFEST_TMP_PATH);
|
||||||
|
setSepManifestPath(SEP_MANIFEST_TMP_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
void futurerestore::setSepManifestPath(const char *sepManifestPath){
|
||||||
|
if (!(_sepbuildmanifest = loadPlistFromFile(sepManifestPath)))
|
||||||
|
reterror(-14, "failed to load SEPManifest");
|
||||||
|
}
|
||||||
|
|
||||||
|
void futurerestore::setBasebandManifestPath(const char *basebandManifestPath){
|
||||||
|
if (!(_basebandbuildmanifest = loadPlistFromFile(basebandManifestPath)))
|
||||||
|
reterror(-14, "failed to load BasebandManifest");
|
||||||
|
};
|
||||||
|
|
||||||
|
void futurerestore::loadSep(const char *sepPath){
|
||||||
|
FILE *fsep = fopen(sepPath, "r");
|
||||||
|
if (!fsep)
|
||||||
|
reterror(-15, "failed to read SEP\n");
|
||||||
|
|
||||||
|
fseek(fsep, 0, SEEK_END);
|
||||||
|
_client->sepfwdatasize = ftell(fsep);
|
||||||
|
fseek(fsep, 0, SEEK_SET);
|
||||||
|
|
||||||
|
if (!(_client->sepfwdata = (char*)malloc(_client->sepfwdatasize)))
|
||||||
|
reterror(-15, "failed to malloc memory for SEP\n");
|
||||||
|
|
||||||
|
if (fread(_client->sepfwdata, 1, _client->sepfwdatasize, fsep) != _client->sepfwdatasize)
|
||||||
|
reterror(-15, "failed to load SEP\n");
|
||||||
|
|
||||||
|
fclose(fsep);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void futurerestore::setBasebandPath(const char *basebandPath){
|
||||||
|
FILE *fbb = fopen(basebandPath, "r");
|
||||||
|
if (!fbb)
|
||||||
|
reterror(-15, "failed to read Baseband");
|
||||||
|
_basebandPath = basebandPath;
|
||||||
|
fclose(fbb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -692,7 +731,7 @@ plist_t futurerestore::loadPlistFromFile(const char *path){
|
||||||
char *buf = (char*)malloc(bufSize);
|
char *buf = (char*)malloc(bufSize);
|
||||||
if (!buf){
|
if (!buf){
|
||||||
error("failed to alloc memory\n");
|
error("failed to alloc memory\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fread(buf, 1, bufSize, f);
|
fread(buf, 1, bufSize, f);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "idevicerestore.h"
|
#include "idevicerestore.h"
|
||||||
#include "jsmn.h"
|
#include "jsmn.h"
|
||||||
|
#include <plist/plist.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -43,11 +44,10 @@ class futurerestore {
|
||||||
char *__latestManifest = NULL;
|
char *__latestManifest = NULL;
|
||||||
char *__latestFirmwareUrl = NULL;
|
char *__latestFirmwareUrl = NULL;
|
||||||
|
|
||||||
const char *_sepManifestPath = NULL;
|
plist_t _sepbuildmanifest = NULL;
|
||||||
const char *_basebandManifestPath = NULL;
|
plist_t _basebandbuildmanifest = NULL;
|
||||||
const char *_sepPath = NULL;
|
|
||||||
const char *_basebandPath = NULL;
|
|
||||||
|
|
||||||
|
const char *_basebandPath;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
futurerestore();
|
futurerestore();
|
||||||
|
@ -69,16 +69,15 @@ public:
|
||||||
void loadLatestBaseband();
|
void loadLatestBaseband();
|
||||||
void loadLatestSep();
|
void loadLatestSep();
|
||||||
|
|
||||||
void setSepManifestPath(const char *sepManifestPath){_sepManifestPath = sepManifestPath;};
|
void setSepManifestPath(const char *sepManifestPath);
|
||||||
void setBasebandManifestPath(const char *basebandManifestPath){_basebandManifestPath = basebandManifestPath;};
|
void setBasebandManifestPath(const char *basebandManifestPath);
|
||||||
void setSepPath(const char *sepPath){_sepPath = sepPath;};
|
void loadSep(const char *sepPath);
|
||||||
void setBasebandPath(const char *basebandPath){_basebandPath = basebandPath;};
|
void setBasebandPath(const char *basebandPath);
|
||||||
|
|
||||||
|
|
||||||
const char *sepManifestPath(){return _sepManifestPath;};
|
plist_t sepManifest(){return _sepbuildmanifest;};
|
||||||
const char *basebandManifestPath(){return _basebandManifestPath;};
|
plist_t basebandManifest(){return _basebandbuildmanifest;};
|
||||||
const char *sepPath(){return _sepPath;};
|
|
||||||
const char *basebandPath(){return _basebandPath;};
|
|
||||||
|
|
||||||
uint64_t getBasebandGoldCertIDFromDevice();
|
uint64_t getBasebandGoldCertIDFromDevice();
|
||||||
|
|
||||||
|
|
|
@ -132,6 +132,14 @@ int main(int argc, const char * argv[]) {
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
|
||||||
ipsw = argv[0];
|
ipsw = argv[0];
|
||||||
|
}else{
|
||||||
|
error("argument parsing failed! agrc=%d optind=%d\n",argc,optind);
|
||||||
|
if (idevicerestore_debug){
|
||||||
|
for (int i=0; i<argc; i++) {
|
||||||
|
printf("argv[%d]=%s\n",i,argv[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -5;
|
||||||
}
|
}
|
||||||
|
|
||||||
futurerestore client;
|
futurerestore client;
|
||||||
|
@ -163,7 +171,7 @@ int main(int argc, const char * argv[]) {
|
||||||
info("user specified to use latest signed sep\n");
|
info("user specified to use latest signed sep\n");
|
||||||
client.loadLatestSep();
|
client.loadLatestSep();
|
||||||
}else{
|
}else{
|
||||||
client.setSepPath(sepPath);
|
client.loadSep(sepPath);
|
||||||
client.setSepManifestPath(sepManifestPath);
|
client.setSepManifestPath(sepManifestPath);
|
||||||
}
|
}
|
||||||
if (flags & FLAG_LATEST_BASEBAND){
|
if (flags & FLAG_LATEST_BASEBAND){
|
||||||
|
@ -178,7 +186,7 @@ int main(int argc, const char * argv[]) {
|
||||||
|
|
||||||
|
|
||||||
versVals.basebandMode = kBasebandModeWithoutBaseband;
|
versVals.basebandMode = kBasebandModeWithoutBaseband;
|
||||||
if (!(isSepManifestSigned = isManifestSignedForDevice(client.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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +196,7 @@ int main(int argc, const char * argv[]) {
|
||||||
printf("[WARNING] using tsschecker's fallback to get BasebandGoldCertID. This might result in invalid baseband signing status information\n");
|
printf("[WARNING] using tsschecker's fallback to get BasebandGoldCertID. This might result in invalid baseband signing status information\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(isBasebandSigned = isManifestSignedForDevice(client.basebandManifestPath(), &devVals, &versVals))) {
|
if (!(isBasebandSigned = isManifestSignedForDevice(basebandManifestPath, &devVals, &versVals))) {
|
||||||
reterror(-3,"baseband firmware isn't signed\n");
|
reterror(-3,"baseband firmware isn't signed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue