Skip to content

Commit 4b691e9

Browse files
authored
Refuse to save baseband blobs without bbsnum, fix bbsnum (#47)
* Maybe use long opts correctly * Refuse to save baseband blobs without bbsnum, fix bbsnum
1 parent 8808a88 commit 4b691e9

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

tsschecker/main.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <errno.h>
2222

2323
#include <libfragmentzip/libfragmentzip.h>
24+
2425
#include "download.h"
2526
#include "debug.h"
2627
#include "tsschecker.h"
@@ -34,6 +35,7 @@
3435
#define FLAG_SAVE_CRYPTEX_NONCE (1 << 5)
3536

3637
extern int idevicerestore_debug;
38+
extern unsigned char *base64decode(const char *buf, size_t *size);
3739
#define reterror(code,a ...) {error(a); err = code; goto error;}
3840

3941
static struct option longopts[] = {
@@ -439,20 +441,27 @@ int main(int argc, const char * argv[]) {
439441
if (bbinfo->bbsnumSize == 0) {
440442
reterror(-8, "[TSSC] this device has no baseband, so it does not make sense to provide BbSNUM.\n");
441443
}
442-
443-
if ((devVals.bbsnum = (uint8_t *)parseNonce(bbsnum, &devVals.bbsnumSize))) {
444-
info("[TSSC] manually specified BbSNUM to use, parsed \"%s\" to hex:", bbsnum);
445-
unsigned char *tmp = devVals.bbsnum;
446-
for (int i=0; i< devVals.bbsnumSize; i++) info("%02x", *tmp++);
447-
info("\n");
448-
449-
if (bbinfo->bbsnumSize != devVals.bbsnumSize) {
450-
reterror(-8, "[TSSC] BbSNUM length for this device should be %d, but you gave one of length %d\n", (int)bbinfo->bbsnumSize,
451-
(int)devVals.bbsnumSize);
452-
}
453-
} else {
444+
445+
devVals.bbsnumSize = 100;
446+
if(!(devVals.bbsnum = (unsigned char *)base64decode(bbsnum, &devVals.bbsnumSize)) || (devVals.bbsnumSize > bbinfo->bbsnumSize) || !devVals.bbsnumSize || devVals.bbsnumSize == 100) {
447+
if (!(devVals.bbsnum = (uint8_t *)parseNonce(bbsnum, &devVals.bbsnumSize))) {
454448
reterror(-7, "[TSSC] manually specified BbSNUM=%s, but parsing failed\n", bbsnum);
449+
}
455450
}
451+
452+
info("[TSSC] manually specified BbSNUM to use, parsed \"%s\" to hex:", bbsnum);
453+
unsigned char *tmp = devVals.bbsnum;
454+
for (int i=0; i< devVals.bbsnumSize; i++) info("%02x", *tmp++);
455+
info("\n");
456+
457+
if (bbinfo->bbsnumSize != devVals.bbsnumSize) {
458+
reterror(-8, "[TSSC] BbSNUM length for this device should be %d, but you gave one of length %d\n", (int)bbinfo->bbsnumSize,
459+
(int)devVals.bbsnumSize);
460+
}
461+
} else {
462+
if(versVals.basebandMode == kBasebandModeOnlyBaseband || versVals.basebandMode == kBasebandModeWithBaseband) {
463+
reterror(-7, "[TSSC] No Baseband Serial Number was specified, refusing to save baseband blobs\n\nPlease run ideviceinfo -k \"BasebandSerialNumber\" to get Baseband Serial Number\n");
464+
}
456465
}
457466

458467
if (!buildmanifest) { //no need to get firmwares/ota json if specifying buildmanifest manually

0 commit comments

Comments
 (0)