diff --git a/Bootstrap.xcodeproj/project.pbxproj b/Bootstrap.xcodeproj/project.pbxproj index 8d6071b8..9b91894d 100644 --- a/Bootstrap.xcodeproj/project.pbxproj +++ b/Bootstrap.xcodeproj/project.pbxproj @@ -436,7 +436,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 0.4.2; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -470,7 +470,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 1.0; + MARKETING_VERSION = 0.4.2; OTHER_LDFLAGS = ""; PRODUCT_BUNDLE_IDENTIFIER = com.roothide.Bootstrap; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate b/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate index acd42bfc..12cc42c9 100644 Binary files a/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate and b/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Bootstrap/AppViewController.m b/Bootstrap/AppViewController.m index db26bdb0..85d77843 100644 --- a/Bootstrap/AppViewController.m +++ b/Bootstrap/AppViewController.m @@ -160,6 +160,10 @@ - (void)updateData:(BOOL)sort { if([app.bundleURL.path.lastPathComponent isEqualToString:@"Bootstrap.app"]) continue; + + if([app.bundleIdentifier isEqualToString:NSBundle.mainBundle.bundleIdentifier] + || [app.bundleIdentifier isEqualToString:@"com.roothide.Bootstrap"]) + continue; [applications addObject:app]; } diff --git a/Bootstrap/Base.lproj/Main.storyboard b/Bootstrap/Base.lproj/Main.storyboard index 30131ce2..48b1f903 100644 --- a/Bootstrap/Base.lproj/Main.storyboard +++ b/Bootstrap/Base.lproj/Main.storyboard @@ -52,7 +52,7 @@ - + diff --git a/Bootstrap/ViewController.m b/Bootstrap/ViewController.m index 9ffdc27d..f6db7578 100644 --- a/Bootstrap/ViewController.m +++ b/Bootstrap/ViewController.m @@ -67,8 +67,13 @@ - (void)viewDidLoad { if(isSystemBootstrapped()) { - self.bootstraBtn.enabled = NO; - [self.bootstraBtn setTitle:Localized(@"Bootstrapped") forState:UIControlStateDisabled]; + if(checkBootstrapVersion()) { + self.bootstraBtn.enabled = NO; + [self.bootstraBtn setTitle:Localized(@"Bootstrapped") forState:UIControlStateDisabled]; + } else { + self.bootstraBtn.enabled = YES; + [self.bootstraBtn setTitle:Localized(@"Update") forState:UIControlStateNormal]; + } self.respringBtn.enabled = YES; self.appEnablerBtn.enabled = YES; @@ -134,7 +139,7 @@ - (void)viewDidLoad { uname(&systemInfo); [AppDelegate addLogText:[NSString stringWithFormat:@"device-model: %s",systemInfo.machine]]; - [AppDelegate addLogText:[NSString stringWithFormat:@"app-version: %@/%@",NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"],NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]]]; + [AppDelegate addLogText:[NSString stringWithFormat:@"app-version: %@",NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]]]; [AppDelegate addLogText:[NSString stringWithFormat:@"boot-session: %@",getBootSession()]]; @@ -162,20 +167,33 @@ - (void)viewDidLoad { if(isSystemBootstrapped()) { - [self checkServer]; + if([self checkServer]) { + [AppDelegate addLogText:Localized(@"bootstrap server check successful")]; + } [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkServer) name:UIApplicationWillEnterForegroundNotification object:nil]; } + + if(isBootstrapInstalled() || isSystemBootstrapped()) { + if([UIApplication.sharedApplication canOpenURL:[NSURL URLWithString:@"filza://"]] + || [LSPlugInKitProxy pluginKitProxyForIdentifier:@"com.tigisoftware.Filza.Sharing"]) + { + [AppDelegate showMesage:Localized(@"It seems that you have the Filza app installed, which may be detected as jailbroken. You can enable Tweak for it to hide it.") title:Localized(@"Warnning")]; + } + } } --(void)checkServer +-(BOOL)checkServer { static bool alerted = false; - if(alerted) return; + if(alerted) return NO; + + BOOL ret=NO; if(spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"check"], nil, nil) != 0) { + ret = NO; alerted = true; UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Server Not Running") message:Localized(@"for unknown reasons the bootstrap server is not running, the only thing we can do is to restart it now.") preferredStyle:UIAlertControllerStyleAlert]; @@ -196,9 +214,11 @@ -(void)checkServer [AppDelegate showAlert:alert]; } else { - [AppDelegate addLogText:Localized(@"bootstrap server check successful")]; [self updateOpensshStatus]; + ret = YES; } + + return ret; } -(void)updateOpensshStatus { @@ -373,6 +393,22 @@ - (IBAction)openssh:(id)sender { } - (IBAction)bootstrap:(id)sender { + + if(isSystemBootstrapped()) + { + ASSERT(checkBootstrapVersion()==false); + + UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Update") message:Localized(@"The current bootstrapped version is inconsistent with the Bootstrap app version, and you need to reboot the device to update it.") preferredStyle:UIAlertControllerStyleAlert]; + + [alert addAction:[UIAlertAction actionWithTitle:Localized(@"Cancel") style:UIAlertActionStyleDefault handler:nil]]; + [alert addAction:[UIAlertAction actionWithTitle:Localized(@"Reboot Device") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { + ASSERT(spawnRoot(NSBundle.mainBundle.executablePath, @[@"reboot"], nil, nil)==0); + }]]; + + [AppDelegate showAlert:alert]; + return; + } + if(![self checkTSVersion]) { [AppDelegate showMesage:Localized(@"Your trollstore version is too old, Bootstrap only supports trollstore>=2.0") title:Localized(@"Error")]; return; @@ -384,7 +420,7 @@ - (IBAction)bootstrap:(id)sender { } UIImpactFeedbackGenerator* generator = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleSoft]; - generator.impactOccurred; + [generator impactOccurred]; if(find_jbroot()) //make sure jbroot() function available { @@ -437,6 +473,7 @@ - (IBAction)bootstrap:(id)sender { [AppDelegate addLogText:[NSString stringWithFormat:@"openssh launch faild(%d):\n%@\n%@", status, log, err]]; } + [generator impactOccurred]; [AppDelegate addLogText:@"respring now..."]; sleep(1); status = spawnBootstrap((char*[]){"/usr/bin/sbreload", NULL}, &log, &err); diff --git a/Bootstrap/basebin/bootstrap.dylib b/Bootstrap/basebin/bootstrap.dylib index 4bed209c..9d8a011e 100755 Binary files a/Bootstrap/basebin/bootstrap.dylib and b/Bootstrap/basebin/bootstrap.dylib differ diff --git a/Bootstrap/basebin/bootstrapd b/Bootstrap/basebin/bootstrapd index e1c39be4..db3dea3f 100755 Binary files a/Bootstrap/basebin/bootstrapd and b/Bootstrap/basebin/bootstrapd differ diff --git a/Bootstrap/basebin/devtest b/Bootstrap/basebin/devtest index 743f854d..001366d2 100755 Binary files a/Bootstrap/basebin/devtest and b/Bootstrap/basebin/devtest differ diff --git a/Bootstrap/basebin/preload b/Bootstrap/basebin/preload index 8e5adbcd..df9e3bc7 100755 Binary files a/Bootstrap/basebin/preload and b/Bootstrap/basebin/preload differ diff --git a/Bootstrap/basebin/preload.dylib b/Bootstrap/basebin/preload.dylib index 5890d807..9283a10a 100755 Binary files a/Bootstrap/basebin/preload.dylib and b/Bootstrap/basebin/preload.dylib differ diff --git a/Bootstrap/basebin/rebuildapp b/Bootstrap/basebin/rebuildapp index 30c311d4..eff30a8f 100755 Binary files a/Bootstrap/basebin/rebuildapp and b/Bootstrap/basebin/rebuildapp differ diff --git a/Bootstrap/basebin/uicache b/Bootstrap/basebin/uicache index 04e848bb..524c6b52 100755 Binary files a/Bootstrap/basebin/uicache and b/Bootstrap/basebin/uicache differ diff --git a/Bootstrap/bootstrap.h b/Bootstrap/bootstrap.h index 2b3fc370..de788f8f 100644 --- a/Bootstrap/bootstrap.h +++ b/Bootstrap/bootstrap.h @@ -13,5 +13,6 @@ bool isBootstrapInstalled(); bool isSystemBootstrapped(); +bool checkBootstrapVersion(); #endif /* bootstrap_h */ diff --git a/Bootstrap/bootstrap.m b/Bootstrap/bootstrap.m index 337e98a7..5124bce0 100644 --- a/Bootstrap/bootstrap.m +++ b/Bootstrap/bootstrap.m @@ -126,7 +126,7 @@ int rebuildBasebin() return 0; } -int startBootstrapd() +int startBootstrapServer() { NSString* log=nil; NSString* err=nil; @@ -209,7 +209,7 @@ int InstallBootstrap(NSString* jbroot_path) ASSERT(rebuildBasebin() == 0); STRAPLOG("Status: Starting Bootstrapd"); - ASSERT(startBootstrapd() == 0); + ASSERT(startBootstrapServer() == 0); STRAPLOG("Status: Finalizing Bootstrap"); NSString* log=nil; @@ -252,7 +252,7 @@ int InstallBootstrap(NSString* jbroot_path) int ReRandomizeBootstrap() { - //jbroot() disabled + //jbroot() unavailable NSFileManager* fm = NSFileManager.defaultManager; @@ -292,13 +292,13 @@ int ReRandomizeBootstrap() ASSERT([fm createSymbolicLinkAtPath:[jbroot_secondary stringByAppendingPathComponent:@".jbroot"] withDestinationPath:jbroot_path error:nil]); - //jbroot() enabled + //jbroot() available now STRAPLOG("Status: Building Base Binaries"); ASSERT(rebuildBasebin() == 0); STRAPLOG("Status: Starting Bootstrapd"); - ASSERT(startBootstrapd() == 0); + ASSERT(startBootstrapServer() == 0); STRAPLOG("Status: Updating Symlinks"); ASSERT(spawnBootstrap((char*[]){"/bin/sh", "/usr/libexec/updatelinks.sh", NULL}, nil, nil) == 0); @@ -314,6 +314,12 @@ int bootstrap() NSFileManager* fm = NSFileManager.defaultManager; + struct stat st; + if(lstat("/var/jb", &st)==0) { + //remove /var/jb to avoid incorrect library loading via @rpath + ASSERT([fm removeItemAtPath:@"/var/jb" error:nil]); + } + NSString* jbroot_path = find_jbroot(); if(!jbroot_path) { @@ -355,7 +361,7 @@ int bootstrap() STRAPLOG("Status: Rebuilding Apps"); ASSERT(spawnBootstrap((char*[]){"/bin/sh", "/basebin/rebuildapps.sh", NULL}, nil, nil) == 0); - NSDictionary* bootinfo = @{@"bootsession":getBootSession()}; + NSDictionary* bootinfo = @{@"bootsession":getBootSession(), @"bootversion":NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]}; ASSERT([bootinfo writeToFile:jbroot(@"/basebin/.bootinfo.plist") atomically:YES]); STRAPLOG("Status: Bootstrap Successful"); @@ -445,3 +451,16 @@ bool isSystemBootstrapped() return [bootsession isEqualToString:getBootSession()]; } + +bool checkBootstrapVersion() +{ + if(!isBootstrapInstalled()) return false; + + NSDictionary* bootinfo = [NSDictionary dictionaryWithContentsOfFile:jbroot(@"/basebin/.bootinfo.plist")]; + if(!bootinfo) return false; + + NSString* bootversion = bootinfo[@"bootversion"]; + if(!bootversion) return false; + + return [bootversion isEqualToString:NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"]]; +} diff --git a/Bootstrap/credits.h b/Bootstrap/credits.h index af43871b..6d13fc3a 100644 --- a/Bootstrap/credits.h +++ b/Bootstrap/credits.h @@ -2,10 +2,13 @@ #define credits_h // dictionary will be sorted alphabetically NSDictionary* CREDITS = @{ +@"Nick Chan" : @"https://github.com/asdfugil", @"opa334" : @"http://github.com/opa334", @"hayden" : @"https://procursus.social/@hayden", @"CKatri" : @"https://procursus.social/@cameron", @"Alfie" : @"https://alfiecg.uk", +@"Mineek" : @"https://github.com/mineek", +@"hrtowii" : @"https://github.com/hrtowii", @"BomberFish" : @"https://twitter.com/bomberfish77", @"Évelyne" : @"http://github.com/evelyneee", @"sourcelocation" : @"http://github.com/sourcelocation", @@ -28,7 +31,6 @@ NSDictionary* CREDITS = @{ @"Nebula" : @"https://itsnebula.net", @"DuyKhanhTran" : @"https://twitter.com/TranKha50277352", @"Nathan" : @"https://github.com/verygenericname", -@"Nick Chan" : @"https://nickchan.lol", @"Muirey03" : @"https://twitter.com/Muirey03", @"absidue" : @"https://github.com/absidue", @"MasterMike" : @"https://ios.cfw.guide", @@ -55,6 +57,7 @@ NSDictionary* CREDITS = @{ @"akusio" : @"https://twitter.com/akusio_rr", @"xsf1re" : @"https://twitter.com/xsf1re", @"PoomSmart" : @"https://twitter.com/poomsmart", +@"katana" : @"https://twitter.com/nsbedtime", @"Elias Sfeir" : @"https://twitter.com/eliassfeir1", @"SquidGesture" : @"https://twitter.com/lclrc", @"yandevelop" : @"https://twitter.com/yandevelop", diff --git a/Bootstrap/main.m b/Bootstrap/main.m index ffd8c732..d4097cd8 100644 --- a/Bootstrap/main.m +++ b/Bootstrap/main.m @@ -26,6 +26,12 @@ int main(int argc, char * argv[]) { } else if(strcmp(argv[1], "rebuildiconcache")==0) { int rebuildIconCache(); exit(rebuildIconCache()); + } else if(strcmp(argv[1], "reboot")==0) { + sync(); + sleep(1); + reboot(0); + sleep(5); + exit(-1); } else if(strcmp(argv[1], "testprefs")==0) { SYSLOG("locale=%@", [NSUserDefaults.appDefaults valueForKey:@"locale"]); [NSUserDefaults.appDefaults setValue:@"CA" forKey:@"locale"]; diff --git a/Bootstrap/utils.h b/Bootstrap/utils.h index ed3d5c8a..f796c068 100644 --- a/Bootstrap/utils.h +++ b/Bootstrap/utils.h @@ -40,4 +40,10 @@ void killAllForApp(const char* bundlePath); user:(BOOL)arg3; @end +@interface LSPlugInKitProxy : NSObject ++(id)pluginKitProxyForIdentifier:(id)arg1 ; +- (NSString *)bundleIdentifier; +@property (nonatomic,readonly) NSURL *dataContainerURL; +@end + #endif /* utils_h */ diff --git a/Makefile b/Makefile index 130951f0..e0e75904 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ XCODE_SCHEME = Bootstrap XCODEPROJ_NAME = Bootstrap -Bootstrap_XCODEFLAGS = MARKETING_VERSION=$(THEOS_PACKAGE_BASE_VERSION) \ +Bootstrap_XCODEFLAGS = \ IPHONEOS_DEPLOYMENT_TARGET="$(IPHONEOS_DEPLOYMENT_TARGET)" \ CODE_SIGN_IDENTITY="" \ AD_HOC_CODE_SIGNING_ALLOWED=YES