Skip to content

Commit

Permalink
Support the newest Autumn 2021 Devices, and some improvements.
Browse files Browse the repository at this point in the history
New:
* Adds full support for the iPad (2021) (9th generation) and Apple Watch Series 7.
* Adds partial support for the iPhone 13 model series and iPad mini 6, (see note below).

Fixes:
* Fix iOS 15 blob saving for newer devices - fixes errors 94 and 126.

Changes:
* Now downloads the BuildManifest.plist directly (if available).
* Merge branch 'tihmstar:master' - get up to date upstream.

Note: tsschecker can't get baseband blobs for devices that use the SDX60M yet as the bbgcid is unknown,
support will be added as soon as i can get the bbgcid.

Co-authored-by: tihmstar, 1Conan, Cryptiiic and nyuszika7h.
  • Loading branch information
DanTheMann15 authored Sep 23, 2021
1 parent d7f6161 commit e3c6a49
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ missing
*/all.h*
*/tsschecker*
stamp-h1
xcuserdata
xcuserdata
configure~
1 change: 1 addition & 0 deletions tsschecker/download.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ int downloadFile(const char *url, const char *dstPath){
curl_easy_setopt(mcurl, CURLOPT_TIMEOUT, 20L); //20 sec
curl_easy_setopt(mcurl, CURLOPT_WRITEFUNCTION, my_fwrite);
curl_easy_setopt(mcurl, CURLOPT_WRITEDATA, dfile);
curl_easy_setopt(mcurl, CURLOPT_FAILONERROR, 1);

CURLcode res = curl_easy_perform(mcurl);
curl_easy_cleanup(mcurl);
Expand Down
18 changes: 9 additions & 9 deletions tsschecker/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ static struct option longopts[] = {
};

void cmd_help(){
printf("Checks (real) TSS signing status of device/firmware\n\n");
printf("Checks (real) TSS signing status for device/firmware\n\n");
printf("Usage: tsschecker [OPTIONS]\n\n");
printf(" -h, --help\t\t\tprints usage information\n");
printf(" -d, --device MODEL\t\tspecify device by its model (eg. iPhone8,1)\n");
printf(" -i, --ios VERSION\t\tspecify firmware version (eg. 13.4.1)\n");
printf(" -Z --buildid BUILD\t\tspecific buildid instead of firmware version (eg. 17E255)\n");
printf(" -B, --boardconfig BOARD \tspecific boardconfig instead of device model (eg. n71ap)\n");
printf(" -d, --device MODEL\t\tspecify device by its model (eg. iPhone10,3)\n");
printf(" -i, --ios VERSION\t\tspecify firmware version (eg. 14.7.1)\n");
printf(" -Z --buildid BUILD\t\tspecify buildid instead of firmware version (eg. 18G82)\n");
printf(" -B, --boardconfig BOARD \tspecify boardconfig instead of device model (eg. d22ap)\n");
printf(" -o, --ota\t\t\tcheck OTA signing status, instead of normal restore\n");
printf(" -b, --no-baseband\t\tdon't check baseband signing status. Request tickets without baseband\n");
printf(" -m, --build-manifest\t\tmanually specify a BuildManifest (can be used with -d)\n");
Expand All @@ -78,10 +78,10 @@ void cmd_help(){
printf(" -l, --latest\t\t\tuse the latest public firmware version instead of manually specifying one\n");
printf(" \t\tespecially useful with -s and -e for saving shsh blobs\n");
printf(" -e, --ecid ECID\t\tmanually specify ECID to be used for fetching blobs, instead of using random ones\n");
printf(" \t\tECID must be either DEC or HEX eg. 5482657301265 or ab46efcbf71\n");
printf(" -g, --generator GEN\t\tmanually specify generator in format 0x%%16llx\n\n");
printf(" \t\tECID must be either DEC or HEX eg. 5482657301265 or 0xab46efcbf71\n");
printf(" -g, --generator GEN\t\tmanually specify generator in HEX format 16 in length (eg. 0x1111111111111111)\n\n");
printf(" --apnonce NONCE\t\tmanually specify ApNonce instead of using random ones\n\t\t\t\t(required for saving blobs for A12/S4 and newer devices with generator)\n\n");
printf(" --sepnonce NONCE\t\tmanually specify SepNonce instead of using random ones (not required for saving blobs)\n");
printf(" --sepnonce NONCE\t\tmanually specify SEP Nonce instead of using random ones (not required for saving blobs)\n");
printf(" --bbsnum SNUM\t\tmanually specify BbSNUM in HEX to save valid BBTickets (not required for saving blobs)\n\n");
printf(" --save-path PATH\t\tspecify output path for saving shsh blobs\n");
printf(" --beta\t\t\trequest tickets for a beta instead of normal release (use with -o)\n");
Expand Down Expand Up @@ -149,7 +149,7 @@ char *parseNonce(const char *nonce, size_t *parsedLen){
int main(int argc, const char * argv[]) {
int err = 0;
int isSigned = 0;
printf("tsschecker version: "TSSCHECKER_VERSION_COUNT".0-"TSSCHECKER_VERSION_SHA"\n");
printf("tsschecker version: 0."TSSCHECKER_VERSION_COUNT".0-"TSSCHECKER_VERSION_SHA"\n");
printf("%s\n",fragmentzip_version());

dbglog = 1;
Expand Down
12 changes: 8 additions & 4 deletions tsschecker/tss.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#else
#include <sys/stat.h>
#define __mkdir(path, mode) mkdir(path, mode)
#define FMT_qu "%qu"
#define FMT_qu "%llu"
#endif

#ifdef HAVE_CONFIG_H
Expand All @@ -48,7 +48,11 @@
#include "tss.h"
#include "endianness.h"

#define TSS_CLIENT_VERSION_STRING "libauthinstall-776.40.16"
#ifdef WIN32
#define TSS_CLIENT_VERSION_STRING "libauthinstall_Win-850.0.2"
#else
#define TSS_CLIENT_VERSION_STRING "libauthinstall-850.0.2"
#endif
#define ECID_STRSIZE 0x20
#define GET_RAND(min, max) ((rand() % (max - min)) + min)

Expand Down Expand Up @@ -766,8 +770,8 @@ int tss_request_add_ap_tags(plist_t request, plist_t parameters, plist_t overrid
debug("DEBUG: %s: Skipping '%s' as it is not trusted", __func__, key);
continue;
}
if (!_plist_dict_get_bool(info_dict, "IsFirmwarePayload") && !_plist_dict_get_bool(info_dict, "IsSecondaryFirmwarePayload") && !_plist_dict_get_bool(info_dict, "IsFUDFirmware")) {
debug("DEBUG: %s: Skipping '%s' as it is neither firmware nor secondary nor FUD firmware payload\n", __func__, key);
if (!_plist_dict_get_bool(manifest_entry, "Trusted") && !_plist_dict_get_bool(info_dict, "IsFirmwarePayload") && !_plist_dict_get_bool(info_dict, "IsSecondaryFirmwarePayload") && !_plist_dict_get_bool(info_dict, "IsFUDFirmware")) {
debug("DEBUG: %s: Skipping '%s' as it is neither firmware nor secondary firmware payload\n", __func__, key);
continue;
}
}
Expand Down
69 changes: 65 additions & 4 deletions tsschecker/tsschecker.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ static struct bbdevice bbdevices[] = {
{"iPhone13,2", 3095201109, 4}, // iPhone 12
{"iPhone13,3", 3095201109, 4}, // iPhone 12 Pro
{"iPhone13,4", 3095201109, 4}, // iPhone 12 Pro Max
{"iPhone14,2", 0, 0}, // iPhone 13 Pro Max
{"iPhone14,3", 0, 0}, // iPhone 13 Pro
{"iPhone14,4", 0, 0}, // iPhone 13 mini
{"iPhone14,5", 0, 0}, // iPhone 13

// iPads
{"iPad1,1", 0, 0}, // iPad (1st gen)
Expand All @@ -201,6 +205,8 @@ static struct bbdevice bbdevices[] = {
{"iPad7,12", 165673526, 12}, // iPad (7th gen, 2019, Cellular)
{"iPad11,6", 0, 0}, // iPad (8th gen, 2020, Wi-Fi)
{"iPad11,7", 165673526, 12}, // iPad (8th gen, 2020, Cellular)
{"iPad12,1", 0, 0}, // iPad (9th gen, 2021, Wi-Fi)
{"iPad12,2", 165673526, 12}, // iPad (9th gen, 2021, Cellular)

// iPad minis
{"iPad2,5", 0, 0}, // iPad mini (1st gen, Wi-Fi)
Expand All @@ -216,6 +222,8 @@ static struct bbdevice bbdevices[] = {
{"iPad5,2", 3840149528, 4}, // iPad mini 4 (Cellular)
{"iPad11,1", 0, 0}, // iPad mini (5th gen, Wi-Fi)
{"iPad11,2", 165673526, 12}, // iPad mini (5th gen, Cellular)
{"iPad14,1", 0, 0}, // iPad mini (6th gen, Wi-Fi)
{"iPad14,2", 0, 0}, // iPad mini (6th gen, Cellular)

// iPad Airs
{"iPad4,1", 0, 0}, // iPad Air (Wi-Fi)
Expand Down Expand Up @@ -285,6 +293,10 @@ static struct bbdevice bbdevices[] = {
{"Watch6,2", 0, 0}, // Apple Watch Series 6 (44mm GPS)
{"Watch6,3", 744114402, 12}, // Apple Watch Series 6 (40mm GPS + Cellular)
{"Watch6,4", 744114402, 12}, // Apple Watch Series 6 (44mm GPS + Cellular)
{"Watch6,6", 0, 0}, // Apple Watch Series 7 (41mm GPS)
{"Watch6,7", 0, 0}, // Apple Watch Series 7 (45mm GPS)
{"Watch6,8", 744114402, 12}, // Apple Watch Series 7 (41mm GPS + Cellular)
{"Watch6,9", 744114402, 12}, // Apple Watch Series 7 (45mm GPS + Cellular)

// HomePods
{"AudioAccessory1,1", 0, 0}, // HomePod 1st gen
Expand Down Expand Up @@ -531,7 +543,20 @@ t_versionURL *getFirmwareUrls(const char *deviceModel, t_iosVersion *versVals, j
return (t_versionURL*)rets_base;
}

#ifdef WIN32
static void fragmentzip_callback(){}
#else
static void printline(int percent){
info("%03d [",percent);for (int i=0; i<100; i++) putchar((percent >0) ? ((--percent > 0) ? '=' : '>') : ' ');
info("]");
}

static void fragmentzip_callback(unsigned int progress){
info("\x1b[A\033[J"); //clear 2 lines
printline((int)progress);
info("\n");
}
#endif

int downloadPartialzip(const char *url, const char *file, const char *dst){
log("[LFZP] downloading %s from %s\n",file,url);
Expand Down Expand Up @@ -586,10 +611,34 @@ char *getBuildManifest(char *url, const char *device, const char *version, const

if (!f || nocache){
//download if it isn't there
if (downloadPartialzip(url, (isOta) ? "AssetData/boot/BuildManifest.plist" : "BuildManifest.plist", fileDir)){
free(fileDir);
return NULL;
int got_buildmanifest = 0;

if (!isOta) {
int index = 0;
for (int i = 0; i < strlen(url); i++) {
if (url[i] == '/') {
index = i;
}
}

char *buildmanifest_url = malloc(strlen(url));
buildmanifest_url = strncpy(buildmanifest_url, url, index);
buildmanifest_url[index] = '\0';
buildmanifest_url = strcat(buildmanifest_url, "/BuildManifest.plist");

if (downloadFile(buildmanifest_url, fileDir) == 0) {
free(buildmanifest_url);
got_buildmanifest = 1;
}
}

if (!got_buildmanifest) {
if (downloadPartialzip(url, (isOta) ? "AssetData/boot/BuildManifest.plist" : "BuildManifest.plist", fileDir)){
free(fileDir);
return NULL;
}
}

f = fopen(fileDir, "rb");
}
fseek(f, 0, SEEK_END);
Expand Down Expand Up @@ -875,6 +924,14 @@ int tssrequest(plist_t *tssreqret, char *buildManifest, t_devicevals *devVals, t
reterror("[TSSR] ERROR: Unable to add img3 tags to TSS request\n");
}
}
if (plist_dict_get_item(tssreq, "Savage,BE-Dev-Patch"))
plist_dict_remove_item(tssreq, "Savage,BE-Dev-Patch");
if(plist_dict_get_item(tssreq, "Savage,BE-Prod-Patch"))
plist_dict_remove_item(tssreq, "Savage,BE-Prod-Patch");
if(plist_dict_get_item(tssreq, "Savage,BF-Dev-Patch"))
plist_dict_remove_item(tssreq, "Savage,BF-Dev-Patch");
if(plist_dict_get_item(tssreq, "Savage,BF-Prod-Patch"))
plist_dict_remove_item(tssreq, "Savage,BF-Prod-Patch");
if (basebandMode == kBasebandModeOnlyBaseband) {
if (plist_dict_get_item(tssreq, "@ApImg4Ticket"))
plist_dict_set_item(tssreq, "@ApImg4Ticket", plist_new_bool(0));
Expand Down Expand Up @@ -1176,7 +1233,11 @@ int printListOfDevices(jssytok_t *tokens){
size_t currLen = 0;
int rspn = 0;
putchar('\n');
jssytok_t *ctok = jssy_dictGetValueForKey(tokens, "devices");
jssytok_t *ctok = NULL;
if (!(ctok = jssy_dictGetValueForKey(tokens, "devices"))){
warning("Failed to get value for key 'devices', trying with tokens instead!\n\n");
ctok = tokens;
}

jssytok_t *tmp = ctok->subval;
for (size_t i=0; i<ctok->size; tmp = tmp->next,i++) {
Expand Down

0 comments on commit e3c6a49

Please sign in to comment.