Skip to content

Commit 9391a14

Browse files
authored
Add erase-install parameter and a few updates (#18)
* add erase-install parameter and a few updates * Update README.md * Update tsschecker versioning * Update tss auth client version * Fix a few misaligned whitespaces * Nonce Entanglement documentation update. * remove unneeded bitmasks from -u and -E
1 parent 5252a78 commit 9391a14

File tree

6 files changed

+100
-70
lines changed

6 files changed

+100
-70
lines changed

README.md

Lines changed: 49 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,35 @@ tsschecker is a powerful tool to check TSS signing status on combinations of var
1212
tsschecker is not only meant to be used to check firmware signing status, but also to explore Apple's TSS servers.<br/>
1313
By using all of its customization possibilities, you might discover a combination of devices and firmware versions that is getting signed but wasn't getting signed before.
1414

15-
# About nonces:
16-
## recommended generators for saving tickets:
17-
* `0xbd34a880be0b53f3` // default on the Electra, Chimera and Odyssey jailbreak apps.
18-
* `0x1111111111111111` // default on the unc0ver jailbreak app.
15+
# About Nonces:
16+
A [Nonce](https://wikipedia.org/wiki/Cryptographic_nonce) ("Number-used-ONCE") is a randomly generated value that is used to randomize apple's signed hash blobs.
1917

20-
## Nonce Entangling (Apple A12/S4 and newer)
21-
Newer devices, such as the iPhone XR or the Apple Watch Series 4 (and any device newer) have nonce-entangling.
18+
it is created by the device with a nonce seed (generator) and then hashes that seed to create the nonce.<br/>On arm64e devices, nonce generation works a bit differently, see "Nonce Entangling" for more details.
2219

23-
this means any boot nonce generated by your device is now also UID derived, and consequently device-specific.<br/>to save usable tickets for a newer device, you need to get the boot nonce that your device actually generates from your generator.
20+
## Recommended nonce-seeds (Generators) for saving tickets:
21+
* `0xbd34a880be0b53f3` // default on the [Electra](https://coolstar.org/electra/), [Chimera](https://chimera.coolstar.org/) and [Odyssey](https://theodyssey.dev/) jailbreak apps.
22+
* `0x1111111111111111` // default on the [unc0ver](https://unc0ver.dev) jailbreak app.
2423

25-
for information on how to get your actual boot nonce, [see this post on r/jailbreak](https://www.reddit.com/r/jailbreak/comments/cssh8f/tutorial_easiest_way_to_save_blobs_on_a12/).
24+
## Nonce Entangling (arm64e devices)
25+
arm64e devices such as the iPhone XR, Apple Watch Series 4 and all newer devices have nonce-entangling.
26+
27+
Nonce Entangling further randomizes the boot nonce by encrypting a constant value with the [UID key](https://www.theiphonewiki.com/wiki/UID_key) (using AES-256-CBC)<br/>It is then used to encrypt the "generator" value (using AES-128-CBC) before hashing it to become the boot nonce.
28+
29+
In short, nonce entangling makes the boot nonce unique to that device only.
30+
31+
To save reusable tickets for any arm64e device, you must get the boot nonce that the device creates from your generator,<br/>
32+
the simpliest way to get a nonce/generator pair is to use airsquared's [blobsaver](https://github.com/airsquared/blobsaver) tool and read them from the device.
33+
34+
For more information, visit The iPhone Wiki:<br/>
35+
[The iPhone Wiki](https://www.theiphonewiki.com/) ([AES Keys](https://theiphonewiki.com/wiki/AES_Keys), [Nonce](https://theiphonewiki.com/wiki/Nonce))
2636

2737
## Nonce Collisions:
2838

2939
the Nonce Collision method only works on a few firmwares and devices, and is not reliable and not recommended.<br/>it's a lot better to save a ticket with a generator and use the [checkm8](https://github.com/axi0mx/ipwndfu) bootrom exploit or a nonce setter.
3040

3141
Recovery Nonce Collisions only occur on a few iOS versions, like iOS 9.3.3 and iOS 10.1-10.2 on the iPhone 5s<br/>and is not reliable as once you update, your device will almost-certainly not collide nonces anymore.
3242

33-
DFU Nonce Collisions on the other hand, very commonly occur on any device using A7 and A8 chipsets regardless of iOS version and is MUCH more reliable than using recovery collisions.
43+
DFU Nonce Collisions on the other hand, very commonly occur on any device using A7 and A8 chipsets regardless of iOS version,<br/> and is MUCH more reliable than using recovery collisions.
3444

3545
# Build
3646
Install or Compile dependencies
@@ -74,32 +84,33 @@ sudo make install
7484
# Help
7585
Usage: `tsschecker [OPTIONS]`
7686

77-
Example: `tsschecker -d iPhone10,1 -B D20AP -e [ECID] -i 13.4.1 --generator 0x1111111111111111 -s`
78-
79-
| option (short) | option (long) | description |
80-
|----------------|-----------------------------|-----------------------------------------------------------------------------------|
81-
| `-h` | `--help` | prints usage information |
82-
| `-d` | `--device MODEL` | specify device by its model (eg. `iPhone8,1`) |
83-
| `-i` | `--ios VERSION` | specify firmware version (eg. `13.4.1`) |
84-
| `-Z` | `--buildid BUILD ` | specific buildid instead of firmware version (eg. `17E255`) |
85-
| `-B` | `--boardconfig BOARD ` | specific boardconfig instead of device model (eg. `n71ap`) |
86-
| `-o` | `--ota` | check OTA signing status, instead of normal restore |
87-
| `-b` | `--no-baseband` | don't check baseband signing status. Request tickets without baseband |
88-
| `-m` | `--build-manifest` | manually specify a BuildManifest (can be used with `-d`) |
89-
| `-s` | `--save` | save fetched shsh blobs (mostly makes sense with -e) |
90-
| `-u` | `--update-install ` | request update tickets instead of erase |
91-
| `-l` | `--latest` | use the latest public firmware version instead of manually specifying one<br/>especially useful with `-s` and `-e` for saving signing tickets |
92-
| `-e` | `--ecid ECID` | manually specify ECID to be used for fetching blobs, instead of using random ones.<br/>ECID must be either DEC or HEX eg. `5482657301265` or `ab46efcbf71` |
93-
| `-g` | `--generator GEN` | manually specify generator in format 0x%%16llx |
94-
| `-8` | `--apnonce NONCE` | manually specify ApNonce instead of using random ones<br/>(required for saving blobs for A12/S4 and newer devices with generator) |
95-
| `-9` | `--sepnonce NONCE` | manually specify SepNonce instead of using random ones (not required for saving signing tickets) |
96-
| `-c` | `--bbsnum SNUM` | manually specify BbSNUM in HEX to save valid BBTickets (not required for saving blobs) |
97-
| `-3` | `--save-path PATH` | specify path for saving shsh blobs |
98-
| `-6` | `--beta` | request ticket for a beta instead of normal release (use with `-o`) |
99-
| `-1` | `--list-devices` | list all known devices |
100-
| `-2` | `--list-ios` | list all known firmware versions |
101-
| `-7` | `--nocache` | ignore caches and re-download required files |
102-
| `-4` | `--print-tss-request` | print the TSS request that will be sent to Apple |
103-
| `-5` | `--print-tss-response` | print the TSS response that comes from Apple |
104-
| `-r` | `--raw` | send raw file to Apple's TSS server (useful for debugging) |
105-
| `-0` | `--debug` | print extra tss info(useful for debugging) |
87+
Example: `tsschecker -d iPhone10,1 -B D20AP -e 5482657301265 -i 14.7.1 --generator 0x1111111111111111 -s`
88+
89+
| option<br/>(short) | option<br/>(long) | description |
90+
|-------|-------------------------|--------------------|
91+
| `-h` | `--help` | prints usage information |
92+
| `-d` | `--device MODEL` | specify device by its model (eg. `iPhone10,3`) |
93+
| `-i` | `--ios VERSION` | specify firmware version (eg. `14.7.1`) |
94+
| `-Z` | `--buildid BUILD` | specific buildid instead of firmware version (eg. `18G82`) |
95+
| `-B` | `--boardconfig BOARD` | specific boardconfig instead of device model (eg. `d22ap`) |
96+
| `-o` | `--ota` | check OTA signing status, instead of normal restore |
97+
| `-b` | `--no-baseband` | don't check baseband signing status. Request tickets without baseband |
98+
| `-m` | `--build-manifest` | manually specify a BuildManifest (can be used with `-d`) |
99+
| `-s` | `--save` | save fetched shsh blobs (mostly makes sense with -e) |
100+
| `-u` | `--update-install` | only request tickets for InstallType=Update |
101+
| `-E` | `--erase-install` | only request tickets for InstallType=Erase |
102+
| `-l` | `--latest` | use the latest public firmware version instead of manually specifying one<br/>especially useful with `-s` and `-e` for saving signing tickets |
103+
| `-e` | `--ecid ECID` | manually specify ECID to be used for fetching blobs, instead of using random ones.<br/>ECID must be either DEC or HEX eg. `5482657301265` or `ab46efcbf71` |
104+
| `-g` | `--generator GEN` | manually specify generator in format 0x%%16llx |
105+
| `-8` | `--apnonce NONCE` | manually specify ApNonce instead of using random ones<br/>(required when saving blobs for arm64e devices with a matching generator) |
106+
| `-9` | `--sepnonce NONCE` | manually specify SepNonce instead of using random ones (not required for saving signing tickets) |
107+
| `-c` | `--bbsnum SNUM` | manually specify BbSNUM in HEX to save valid BBTickets (not required for saving blobs) |
108+
| `-3` | `--save-path PATH` | specify path for saving shsh blobs |
109+
| `-6` | `--beta` | request ticket for a beta instead of normal release (use with `-o`) |
110+
| `-1` | `--list-devices` | list all known devices |
111+
| `-2` | `--list-ios` | list all known firmware versions |
112+
| `-7` | `--nocache` | ignore caches and re-download required files |
113+
| `-4` | `--print-tss-request` | print the TSS request that will be sent to Apple |
114+
| `-5` | `--print-tss-response` | print the TSS response that comes from Apple |
115+
| `-r` | `--raw` | send raw file to Apple's TSS server (useful for debugging) |
116+
| `-0` | `--debug` | print extra tss info(useful for debugging) |

tsschecker/all.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
#ifndef all_h
1010
#define all_h
1111

12+
#define TSSCHECKER_VERSION_MAJOR "0"
13+
#define TSSCHECKER_VERSION_PATCH "0"
14+
1215
#ifdef DEBUG // this is for developing with Xcode
13-
#define TSSCHECKER_VERSION_COUNT "Debug"
14-
#define TSSCHECKER_VERSION_SHA "Build: " __DATE__ " " __TIME__
16+
#define TSSCHECKER_BUILD_TYPE "DEBUG"
17+
#define TSSCHECKER_VERSION_SHA "Build: " __DATE__ " " __TIME__ ""
1518
#else
19+
#define TSSCHECKER_BUILD_TYPE "RELEASE"
1620
#endif
1721

1822
#endif /* all_h */

tsschecker/main.c

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,24 @@ static struct option longopts[] = {
4343
{ "ota", no_argument, NULL, 'o' },
4444
{ "save", no_argument, NULL, 's' },
4545
{ "latest", no_argument, NULL, 'l' },
46-
{ "update-install", optional_argument, NULL, 'u' },
46+
{ "update-install", no_argument, NULL, 'u' },
47+
{ "erase-install", no_argument, NULL, 'E' },
4748
{ "boardconfig", required_argument, NULL, 'B' },
4849
{ "buildid", required_argument, NULL, 'Z' },
49-
{ "debug", no_argument, NULL, '0' },
50-
{ "list-devices", no_argument, NULL, '1' },
51-
{ "list-ios", no_argument, NULL, '2' },
52-
{ "save-path", required_argument, NULL, '3' },
53-
{ "print-tss-request", no_argument, NULL, '4' },
54-
{ "print-tss-response", no_argument, NULL, '5' },
55-
{ "beta", no_argument, NULL, '6' },
56-
{ "nocache", no_argument, NULL, '7' },
57-
{ "apnonce", required_argument, NULL, '8' },
58-
{ "sepnonce", required_argument, NULL, '9' },
59-
{ "raw", required_argument, NULL, 'r' },
60-
{ "bbsnum", required_argument, NULL, 'c' },
61-
{ "server-url", required_argument, NULL, 'S' },
62-
{ "bplist", no_argument, NULL, 'p' },
50+
{ "debug", no_argument, NULL, '0' },
51+
{ "list-devices", no_argument, NULL, '1' },
52+
{ "list-ios", no_argument, NULL, '2' },
53+
{ "save-path", required_argument, NULL, '3' },
54+
{ "print-tss-request", no_argument, NULL, '4' },
55+
{ "print-tss-response", no_argument, NULL, '5' },
56+
{ "beta", no_argument, NULL, '6' },
57+
{ "nocache", no_argument, NULL, '7' },
58+
{ "apnonce", required_argument, NULL, '8' },
59+
{ "sepnonce", required_argument, NULL, '9' },
60+
{ "raw", required_argument, NULL, 'r' },
61+
{ "bbsnum", required_argument, NULL, 'c' },
62+
{ "server-url", required_argument, NULL, 'S' },
63+
{ "bplist", no_argument, NULL, 'p' },
6364
{ "generator", required_argument, NULL, 'g' },
6465
{ NULL, 0, NULL, 0 }
6566
};
@@ -76,13 +77,14 @@ void cmd_help(){
7677
printf(" -b, --no-baseband\t\tdon't check baseband signing status. Request tickets without baseband\n");
7778
printf(" -m, --build-manifest\t\tmanually specify a BuildManifest (can be used with -d)\n");
7879
printf(" -s, --save\t\t\tsave fetched shsh blobs (mostly makes sense with -e)\n");
79-
printf(" -u, --update-install\t\trequest update tickets instead of erase\n");
80+
printf(" -u, --update-install\t\tonly request tickets for InstallType=Update\n");
81+
printf(" -E, --erase-install\t\tonly request tickets for InstallType=Erase\n");
8082
printf(" -l, --latest\t\t\tuse the latest public firmware version instead of manually specifying one\n");
8183
printf(" \t\tespecially useful with -s and -e for saving shsh blobs\n");
8284
printf(" -e, --ecid ECID\t\tmanually specify ECID to be used for fetching blobs, instead of using random ones\n");
8385
printf(" \t\tECID must be either DEC or HEX eg. 5482657301265 or 0xab46efcbf71\n");
8486
printf(" -g, --generator GEN\t\tmanually specify generator in HEX format 16 in length (eg. 0x1111111111111111)\n\n");
85-
printf(" -8 --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");
87+
printf(" -8 --apnonce NONCE\t\tmanually specify ApNonce instead of using random ones\n\t\t\t\t(required when saving blobs for arm64e devices with a matching generator)\n\n");
8688
printf(" -9 --sepnonce NONCE\t\tmanually specify SEP Nonce instead of using random ones (not required for saving blobs)\n");
8789
printf(" -c --bbsnum SNUM\t\tmanually specify BbSNUM in HEX to save valid BBTickets (not required for saving blobs)\n\n");
8890
printf(" -3 --save-path PATH\t\tspecify output path for saving shsh blobs\n");
@@ -154,7 +156,7 @@ char *parseNonce(const char *nonce, size_t *parsedLen){
154156
int main(int argc, const char * argv[]) {
155157
int err = 0;
156158
int isSigned = 0;
157-
printf("tsschecker version: 0."TSSCHECKER_VERSION_COUNT"-"TSSCHECKER_VERSION_SHA"\n");
159+
printf("tsschecker version: "TSSCHECKER_VERSION_MAJOR"."TSSCHECKER_VERSION_COUNT"."TSSCHECKER_VERSION_PATCH"-"TSSCHECKER_VERSION_SHA"-"TSSCHECKER_BUILD_TYPE"\n");
158160
printf("%s\n",fragmentzip_version());
159161

160162
dbglog = 1;
@@ -184,7 +186,7 @@ int main(int argc, const char * argv[]) {
184186
return -1;
185187
}
186188

187-
while ((opt = getopt_long(argc, (char* const *)argv, "hd:i:Z:B:e:g:b:u:m:3:8:9:r:c:S:lso0124567p", longopts, &optindex)) > 0) {
189+
while ((opt = getopt_long(argc, (char* const *)argv, "hd:i:Z:B:e:g:b:m:3:8:9:r:c:S:uElso0124567p", longopts, &optindex)) > 0) {
188190
switch (opt) {
189191
case 'h': // long option: "help"; can be called as short option
190192
cmd_help();
@@ -225,15 +227,17 @@ int main(int argc, const char * argv[]) {
225227
if (optarg) versVals.basebandMode = atoi(optarg);
226228
else versVals.basebandMode = kBasebandModeWithoutBaseband;
227229
break;
228-
case 'u': // long option: "update"; can be called as short option
229-
if (optarg) {
230-
if ((devVals.installType = atoi(optarg)) > 2 || devVals.installType < 0){
231-
warning("unknown installType %d. Setting installType to default (%d)\n",devVals.installType,devVals.installType = kInstallTypeDefault);
232-
}
233-
}else
234-
devVals.installType = kInstallTypeUpdate;
230+
case 'u': // long option: "update-install"; can be called as short option
231+
devVals.installType = kInstallTypeUpdate;
232+
update_install = 1;
235233
if (devVals.installType)
236-
printf("[TSSC] manually setting install type = %s\n",devVals.installType == kInstallTypeUpdate ? "Update" : "Erase");
234+
printf("[TSSC] Manually setting install type = Update\n");
235+
break;
236+
case 'E': // long option: "erase-install"; can be called as short option
237+
devVals.installType = kInstallTypeErase;
238+
erase_install = 1;
239+
if (devVals.installType)
240+
printf("[TSSC] Manually setting install type = Erase\n");
237241
break;
238242
case 'l': // long option: "latest"; can be called as short option
239243
flags |= FLAG_LATEST_IOS;

tsschecker/tss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <unistd.h>
2828
#include <curl/curl.h>
2929
#include <plist/plist.h>
30-
#define AUTH_VERSION "850.0.2"
30+
#define AUTH_VERSION "914.40.5"
3131
#ifdef WIN32
3232
#define TSS_CLIENT_VERSION_STRING "libauthinstall_Win-"AUTH_VERSION""
3333
#else

tsschecker/tsschecker.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ int print_tss_request = 0;
121121
int print_tss_response = 0;
122122
int nocache = 0;
123123
int save_shshblobs = 0;
124+
int update_install = 0;
125+
int erase_install = 0;
124126
int save_bplist = 0;
125127
const char *shshSavePath = "."DIRECTORY_DELIMITER_STR;
126128

@@ -1206,7 +1208,7 @@ int isManifestBufSignedForDevice(char *buildManifestBuffer, t_devicevals *devVal
12061208
if (isSigned && save_shshblobs){
12071209
if (!devVals->installType){
12081210
plist_t tssreq2 = NULL;
1209-
info("also requesting APTicket for installType=Update\n");
1211+
info("[TSSC] Also requesting APTicket for installType=Update\n");
12101212
devVals->installType = kInstallTypeUpdate;
12111213
if (tssrequest(&tssreq2, buildManifestBuffer, devVals, basebandMode)){
12121214
warning("[TSSR] failed to build tssrequest for alternative installType\n");
@@ -1217,7 +1219,14 @@ int isManifestBufSignedForDevice(char *buildManifestBuffer, t_devicevals *devVal
12171219
if (tssreq2) plist_free(tssreq2);
12181220
devVals->installType = kInstallTypeDefault;
12191221
}
1220-
{
1222+
if (update_install) {
1223+
plist_t tssreq2 = NULL;
1224+
}
1225+
else if (erase_install) {
1226+
plist_t tssreq2 = NULL;
1227+
}
1228+
else {
1229+
info("[TSSC] Also requesting APTicket without a nonce\n");
12211230
plist_t tssreq2 = NULL;
12221231
char *apnonce = devVals->apnonce;
12231232
size_t apnonceLen = devVals->parsedApnonceLen;

tsschecker/tsschecker.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ extern int dbglog;
2424
extern int print_tss_response;
2525
extern int nocache;
2626
extern int save_shshblobs;
27+
extern int update_install;
28+
extern int erase_install;
2729
extern int save_bplist;
2830
extern const char *shshSavePath;
2931

0 commit comments

Comments
 (0)