From 61831ded8b7775244ddd32683181aebf60ab6807 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:06:44 +0200 Subject: Allow getting the ecid for any device model --- src/idevicerestore.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/idevicerestore.c') diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 00c35c1..93623bc 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -432,11 +432,6 @@ int get_cpid(struct idevicerestore_client_t* client, uint32_t* cpid) { } int get_ecid(struct idevicerestore_client_t* client, uint64_t* ecid) { - if(client->device->index <= DEVICE_IPOD2G) { - *ecid = 0; - return 0; - } - switch (client->mode->index) { case MODE_NORMAL: if (normal_get_ecid(client->uuid, ecid) < 0) { -- cgit v1.1-32-gdbae From 38b8439c0b9b4b64aae1c812da322146d0843446 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:13:01 +0200 Subject: Add and improve some comments for restore process --- src/idevicerestore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/idevicerestore.c') diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 93623bc..50e2783 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -166,7 +166,7 @@ int main(int argc, char* argv[]) { error("ERROR: Unable to find device ECID\n"); return -1; } - debug("Found ECID %llu\n", client->ecid); + info("Found ECID %llu\n", client->ecid); } // choose whether this is an upgrade or a restore (default to upgrade) -- cgit v1.1-32-gdbae From 50c1616ff66ccb4e674405659cb2e6f8207bc915 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:13:37 +0200 Subject: Refactor tss request requirements to work with iPhone 3G and iOS 4 This gets rid of the device model checking code and allows devices like the iPhone 3G to get shsh blobs as required by iOS 4. The requirement if the components need to be signed is determined by which kind of manifest filename is within the IPSW. --- src/idevicerestore.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/idevicerestore.c') diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 50e2783..32dd736 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) { int optindex = 0; char* ipsw = NULL; char* uuid = NULL; - uint64_t ecid = 0; + int tss_enabled = 0; // create an instance of our context struct idevicerestore_client_t* client = (struct idevicerestore_client_t*) malloc(sizeof(struct idevicerestore_client_t)); @@ -149,7 +149,7 @@ int main(int argc, char* argv[]) { // extract buildmanifest plist_t buildmanifest = NULL; info("Extracting BuildManifest from IPSW\n"); - if (ipsw_extract_build_manifest(ipsw, &buildmanifest) < 0) { + if (ipsw_extract_build_manifest(ipsw, &buildmanifest, &tss_enabled) < 0) { error("ERROR: Unable to extract BuildManifest from %s\n", ipsw); return -1; } @@ -157,9 +157,15 @@ int main(int argc, char* argv[]) { /* print iOS information from the manifest */ build_manifest_print_information(buildmanifest); + if (client->flags & FLAG_CUSTOM) { + /* prevent signing custom firmware */ + tss_enabled = 0; + info("Custom firmware requested. Disabled TSS request.\n"); + } + // devices are listed in order from oldest to newest // so we'll need their ECID - if (client->device->index > DEVICE_IPOD2G) { + if (tss_enabled) { debug("Getting device's ECID for TSS request\n"); // fetch the device's ECID for the TSS request if (get_ecid(client, &client->ecid) < 0) { @@ -194,22 +200,20 @@ int main(int argc, char* argv[]) { /* print information about current build identity */ build_identity_print_information(build_identity); - if (client->flags & FLAG_CUSTOM > 0) { - if (client->device->index > DEVICE_IPOD2G) { - if (get_shsh_blobs(client, ecid, build_identity, &client->tss) < 0) { - error("ERROR: Unable to get SHSH blobs for this device\n"); - return -1; - } - } - - /* verify if we have tss records if required */ - if ((client->device->index > DEVICE_IPOD2G) && (client->tss == NULL)) { - error("ERROR: Unable to proceed without a tss record.\n"); - plist_free(buildmanifest); + if (tss_enabled) { + if (get_shsh_blobs(client, client->ecid, build_identity, &client->tss) < 0) { + error("ERROR: Unable to get SHSH blobs for this device\n"); return -1; } } + /* verify if we have tss records if required */ + if ((tss_enabled) && (client->tss == NULL)) { + error("ERROR: Unable to proceed without a tss record.\n"); + plist_free(buildmanifest); + return -1; + } + // Extract filesystem from IPSW and return its name char* filesystem = NULL; if (ipsw_extract_filesystem(client->ipsw, build_identity, &filesystem) < 0) { -- cgit v1.1-32-gdbae From 18e9411aac155ff4aa35ac1c50e752102b1ed531 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:50:29 +0200 Subject: Move ecid retrieval code right before shsh blob retrieval --- src/idevicerestore.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/idevicerestore.c') diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 32dd736..90fe4bc 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -163,18 +163,6 @@ int main(int argc, char* argv[]) { info("Custom firmware requested. Disabled TSS request.\n"); } - // devices are listed in order from oldest to newest - // so we'll need their ECID - if (tss_enabled) { - debug("Getting device's ECID for TSS request\n"); - // fetch the device's ECID for the TSS request - if (get_ecid(client, &client->ecid) < 0) { - error("ERROR: Unable to find device ECID\n"); - return -1; - } - info("Found ECID %llu\n", client->ecid); - } - // choose whether this is an upgrade or a restore (default to upgrade) client->tss = NULL; plist_t build_identity = NULL; @@ -200,7 +188,16 @@ int main(int argc, char* argv[]) { /* print information about current build identity */ build_identity_print_information(build_identity); + /* retrieve shsh blobs if required */ if (tss_enabled) { + debug("Getting device's ECID for TSS request\n"); + /* fetch the device's ECID for the TSS request */ + if (get_ecid(client, &client->ecid) < 0) { + error("ERROR: Unable to find device ECID\n"); + return -1; + } + info("Found ECID %llu\n", client->ecid); + if (get_shsh_blobs(client, client->ecid, build_identity, &client->tss) < 0) { error("ERROR: Unable to get SHSH blobs for this device\n"); return -1; -- cgit v1.1-32-gdbae From db6dc7b5310138eb6eb3eb099f22ccde65e3e765 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Wed, 14 Jul 2010 04:52:15 +0200 Subject: Further improve some output to better guide the user --- src/idevicerestore.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/idevicerestore.c') diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 90fe4bc..f3fdbdc 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -206,7 +206,7 @@ int main(int argc, char* argv[]) { /* verify if we have tss records if required */ if ((tss_enabled) && (client->tss == NULL)) { - error("ERROR: Unable to proceed without a tss record.\n"); + error("ERROR: Unable to proceed without a TSS record.\n"); plist_free(buildmanifest); return -1; } @@ -490,13 +490,16 @@ int get_shsh_blobs(struct idevicerestore_client_t* client, uint64_t ecid, plist_ return -1; } - info("Sending TSS request\n"); + info("Sending TSS request... "); response = tss_send_request(request); if (response == NULL) { + info("ERROR: Unable to send TSS request\n"); plist_free(request); return -1; } + info("received SHSH blobs\n"); + plist_free(request); *tss = response; return 0; @@ -552,7 +555,6 @@ int ipsw_get_component_by_path(const char* ipsw, plist_t tss, const char* path, } if (tss) { - info("Signing img3...\n"); img3 = img3_parse_file(component_data, component_size); if (img3 == NULL) { error("ERROR: Unable to parse IMG3: %s\n", component_name); @@ -568,6 +570,7 @@ int ipsw_get_component_by_path(const char* ipsw, plist_t tss, const char* path, return -1; } + info("Signing %s\n", component_name); if (img3_replace_signature(img3, component_blob) < 0) { error("ERROR: Unable to replace IMG3 signature\n"); free(component_blob); -- cgit v1.1-32-gdbae