@@ -447,21 +447,14 @@ void rebootUserspaceAction()
447447
448448int exploitStart (NSString * execDir)
449449{
450- NSFileManager * fm = NSFileManager .defaultManager ;
451-
452- // Patch basebin plists
453- NSURL *basebinDaemonsURL = [NSURL fileURLWithPath: jbroot (@" /basebin/LaunchDaemons" )];
454- for (NSURL *fileURL in [fm contentsOfDirectoryAtURL: basebinDaemonsURL includingPropertiesForKeys: nil options: 0 error: nil ]) {
455- NSString * plistContent = [NSString stringWithContentsOfFile: fileURL.path encoding: NSUTF8StringEncoding error: nil ];
456- if (plistContent) {
457- plistContent = [plistContent stringByReplacingOccurrencesOfString: @" @JBROOT@" withString: jbroot (@" /" )];
458- plistContent = [plistContent stringByReplacingOccurrencesOfString: @" @JBRAND@" withString: [NSString stringWithFormat: @" %016llX " ,jbrand ()]];
459- ASSERT ([plistContent writeToFile: fileURL.path atomically: YES encoding: NSUTF8StringEncoding error: nil ]);
460- }
450+ NSString * log=nil ;
451+ NSString * err=nil ;
452+ int status = spawn_root (jbroot (@" /basebin/TaskPortHaxx" ), @[execDir], &log, &err);
453+ if (status != 0 ) {
454+ STRAPLOG (" TaskPortHaxx: %@" , err); // only output stderr here
455+ return status;
461456 }
462457
463- ASSERT (spawn_root (jbroot (@" /basebin/TaskPortHaxx" ), @[execDir], nil , nil ) == 0 );
464-
465458 ASSERT (spawn_root (jbroot (@" /basebin/bsctl" ), @[@" usreboot" ], nil , nil ) == 0 );
466459
467460 return 0 ;
@@ -599,27 +592,37 @@ void bootstrapAction()
599592 [AppDelegate addLogText: Localized (@" exploit..." )];
600593
601594 NSString * execDir = [@" /var/db/com.apple.xpc.roleaccountd.staging/exec-" stringByAppendingString: [[NSUUID UUID ] UUIDString ]];
595+
596+ NSString * log=nil ;
597+ NSString * err=nil ;
598+ int status = spawn_root (jbroot (@" /basebin/TaskPortHaxx" ), @[@" prepare" , execDir], &log, &err);
599+ if (status != 0 ) {
600+ [AppDelegate showMesage: [NSString stringWithFormat: @" %@ \n\n %@ \n\n stderr:\n %@ " ,Localized (@" Please reboot device and try again!" ),log,err] title: [NSString stringWithFormat: @" code(%d )" ,status]];
601+ return ;
602+ }
602603
603604 @try {
604- ASSERT (spawn_root (jbroot (@" /basebin/TaskPortHaxx" ), @[@" prepare" , execDir], nil , nil ) == 0 );
605-
606605 int load_trust_cache (NSString *tcPath);
607606 ASSERT (load_trust_cache (jbroot (@" /tmp/TaskPortHaxx/UpdateBrainService/AssetData/.TrustCache" )) == 0 );
608607 }
609608 @catch (NSException *exception)
610609 {
611- [AppDelegate showMesage: [NSString stringWithFormat: @" ***exception: %@ " , exception] title: @" ERROR" ];
610+ [AppDelegate showMesage: [NSString stringWithFormat: @" ***exception: %@ \n\n %@ " , exception] title: @" ERROR" ];
612611 return ;
613612 }
614613
615614 const char * argv[] = {jbroot (" /basebin/bsctl" ), " resign" , NULL };
616- int status = spawn (argv[0 ], argv, environ, nil , ^(char * outstr, int length) {
615+ status = spawn (argv[0 ], argv, environ, nil , ^(char * outstr, int length) {
617616 NSString *str = [[NSString alloc ] initWithBytes: outstr length: length encoding: NSASCIIStringEncoding];
618617 [AppDelegate addLogText: str];
619618 }, ^(char * errstr, int length){
620619 NSString *str = [[NSString alloc ] initWithBytes: errstr length: length encoding: NSASCIIStringEncoding];
621620 [AppDelegate addLogText: [NSString stringWithFormat: @" ERR: %@ \n " ,str]];
622621 });
622+ if (status != 0 ) {
623+ [AppDelegate showMesage: @" " title: [NSString stringWithFormat: @" code(%d )" ,status]];
624+ return ;
625+ }
623626
624627 const char * argv2[] = {NSBundle .mainBundle .executablePath .fileSystemRepresentation , " exploit" , execDir.fileSystemRepresentation , NULL };
625628 status = spawn (argv2[0 ], argv2, environ, nil , ^(char * outstr, int length) {
@@ -630,7 +633,7 @@ void bootstrapAction()
630633 [AppDelegate addLogText: [NSString stringWithFormat: @" ERR: %@ \n " ,str]];
631634 });
632635 if (status!=0 ) {
633- [AppDelegate showMesage: [ NSString stringWithFormat: @" %@ \n\n stderr: \n %@ " ,log,err] title: [NSString stringWithFormat: @" code(%d )" ,status]];
636+ [AppDelegate showMesage: Localized ( @" Please reboot device and try again! " ) title: [NSString stringWithFormat: @" code(%d )" ,status]];
634637 return ;
635638 }
636639
@@ -643,7 +646,10 @@ void bootstrapAction()
643646
644647 [AppDelegate addLogText: Localized (@" respring now..." )]; sleep (1 );
645648 status = spawn_bootstrap_binary ((char *[]){" /usr/bin/sbreload" , NULL }, &log, &err);
646- if (status!=0 ) [AppDelegate showMesage: [NSString stringWithFormat: @" %@ \n\n stderr:\n %@ " ,log,err] title: [NSString stringWithFormat: @" code(%d )" ,status]];
649+ if (status!=0 ) {
650+ [AppDelegate showMesage: [NSString stringWithFormat: @" %@ \n\n stderr:\n %@ " ,log,err] title: [NSString stringWithFormat: @" code(%d )" ,status]];
651+ return ;
652+ }
647653
648654 });
649655}
0 commit comments