Skip to content

Commit 4d5de67

Browse files
committed
add an option for "Hide All TS&JB Apps + Reboot Userspace"
1: add an option for "Hide All TS&JB Apps + Reboot Userspace" 2: remove outdated repos 3 update roothide manager and sileo app
1 parent 5d9f772 commit 4d5de67

12 files changed

Lines changed: 173 additions & 134 deletions

File tree

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@
22
packages/
33
.DS_Store
44
/layout/
5-
*.xcuserstate
6-
/Bootstrap.xcodeproj/project.xcworkspace/xcuserdata/admin.xcuserdatad/UserInterfaceState.xcuserstate
7-
*.xcuserstate
85
.vscode/
9-
6+
/Bootstrap/basebin
Binary file not shown.

Bootstrap/AppDelegate.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ + (void)showAlert:(UIAlertController*)alert {
7272
}
7373

7474
+ (void)showMesage:(NSString*)msg title:(NSString*)title {
75-
76-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert];
77-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
78-
[self showAlert:alert];
75+
dispatch_async(dispatch_get_main_queue(), ^{
76+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; //may crash if on non-main thread
77+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
78+
[self showAlert:alert];
79+
});
7980
}
8081

8182

Bootstrap/ViewController.m

Lines changed: 141 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "NSUserDefaults+appDefaults.h"
99
#import "Bootstrap-Swift.h"
1010
#import <sys/sysctl.h>
11+
#include <sys/mount.h>
1112
#include <sys/utsname.h>
1213

1314
#include <Security/SecKey.h>
@@ -51,7 +52,7 @@ BOOL updateOpensshStatus(BOOL notify)
5152
{
5253
BOOL status;
5354

54-
if(isSystemBootstrapped()) {
55+
if(isSystemBootstrapped() && spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"check"], nil, nil)==0) {
5556
status = spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"openssh",@"check"], nil, nil)==0;
5657
} else {
5758
status = [NSUserDefaults.appDefaults boolForKey:@"openssh"];
@@ -62,6 +63,32 @@ BOOL updateOpensshStatus(BOOL notify)
6263
return status;
6364
}
6465

66+
void checkAppsHidden()
67+
{
68+
if(isAllCTBugAppsHidden()) {
69+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Jailbroken Apps are Hidden") message:Localized(@"Do you want to restore them now?") preferredStyle:UIAlertControllerStyleAlert];
70+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"NO") style:UIAlertActionStyleCancel handler:nil]];
71+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"YES") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
72+
unhideAllCTBugApps();
73+
}]];
74+
[AppDelegate showAlert:alert];
75+
}
76+
}
77+
78+
void tryLoadOpenSSH()
79+
{
80+
if([NSUserDefaults.appDefaults boolForKey:@"openssh"] && [NSFileManager.defaultManager fileExistsAtPath:jbroot(@"/usr/libexec/sshd-keygen-wrapper")])
81+
{
82+
NSString* log=nil;
83+
NSString* err=nil;
84+
int status = spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"openssh",@"start"], &log, &err);
85+
if(status==0)
86+
[AppDelegate addLogText:Localized(@"openssh launch successful")];
87+
else
88+
[AppDelegate addLogText:[NSString stringWithFormat:@"openssh launch faild(%d):\n%@\n%@", status, log, err]];
89+
}
90+
}
91+
6592
BOOL checkServer()
6693
{
6794
static bool alerted = false;
@@ -83,6 +110,8 @@ BOOL checkServer()
83110
NSString* err=nil;
84111
if(spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"daemon",@"-f"], &log, &err)==0) {
85112
[AppDelegate addLogText:Localized(@"bootstrap server restart successful")];
113+
checkAppsHidden();
114+
tryLoadOpenSSH();
86115
} else {
87116
[AppDelegate showMesage:[NSString stringWithFormat:@"%@\nERR:%@"] title:Localized(@"Error")];
88117
}
@@ -143,15 +172,7 @@ void initFromSwiftUI()
143172
{
144173
if(checkServer()) {
145174
[AppDelegate addLogText:Localized(@"bootstrap server check successful")];
146-
147-
if(isAllCTBugAppsHidden()) {
148-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Jailbreak Apps is Hidden") message:Localized(@"Do you want to restore them now?") preferredStyle:UIAlertControllerStyleAlert];
149-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"NO") style:UIAlertActionStyleCancel handler:nil]];
150-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"YES") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){
151-
unhideAllCTBugApps();
152-
}]];
153-
[AppDelegate showAlert:alert];
154-
}
175+
checkAppsHidden();
155176
}
156177

157178
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
@@ -511,16 +532,7 @@ void bootstrapAction()
511532
NSString* log=nil;
512533
NSString* err=nil;
513534

514-
if([NSUserDefaults.appDefaults boolForKey:@"openssh"] && [NSFileManager.defaultManager fileExistsAtPath:jbroot(@"/usr/libexec/sshd-keygen-wrapper")])
515-
{
516-
NSString* log=nil;
517-
NSString* err=nil;
518-
status = spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"openssh",@"start"], &log, &err);
519-
if(status==0)
520-
[AppDelegate addLogText:Localized(@"openssh launch successful")];
521-
else
522-
[AppDelegate addLogText:[NSString stringWithFormat:@"openssh launch faild(%d):\n%@\n%@", status, log, err]];
523-
}
535+
tryLoadOpenSSH();
524536

525537
if(gTweakEnabled && ![NSFileManager.defaultManager fileExistsAtPath:jbroot(@"/var/mobile/.tweakenabled")]) {
526538
ASSERT([[NSString new] writeToFile:jbroot(@"/var/mobile/.tweakenabled") atomically:YES encoding:NSUTF8StringEncoding error:nil]);
@@ -609,101 +621,120 @@ void resetMobilePassword()
609621
[AppDelegate showAlert:alert];
610622
}
611623

612-
void hideAllCTBugApps()
624+
int hideBootstrapApp(BOOL usreboot)
613625
{
614-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Warning") message:Localized(@"This operation will make all apps installed via TrollStore/Bootstrap disappear from the Home Screen. You can restore them later via TrollStore Helper->[Refresh App Registrations] and Bootstrap->Settings->[Unhide Jailbreak Apps]") preferredStyle:UIAlertControllerStyleAlert];
615-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"Cancel") style:UIAlertActionStyleDefault handler:nil]];
616-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"Hide") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action){
626+
if(![LSApplicationWorkspace.defaultWorkspace unregisterApplication:NSBundle.mainBundle.bundleURL]) {
627+
return -1;
628+
}
629+
630+
if(usreboot)
631+
{
632+
sleep(2);
633+
634+
int status = spawnRoot(jbroot(@"/basebin/bootstrapd"), @[@"usreboot"], nil, nil);
635+
if(status != 0) {
636+
return -2;
637+
}
638+
}
639+
640+
return 0;
641+
}
617642

618-
dispatch_async(dispatch_get_global_queue(0, 0), ^{
619-
[AppDelegate showHudMsg:Localized(@"Hiding All Jailbreak/TrollStore Apps...")];
620-
621-
NSArray* allInstalledApplications = [LSApplicationWorkspace.defaultWorkspace allInstalledApplications];
622-
623-
BOOL TSHelperFound = NO;
624-
for(LSApplicationProxy* proxy in allInstalledApplications) {
625-
NSString* TSHelperMarker = [proxy.bundleURL.path stringByAppendingPathComponent:@".TrollStorePersistenceHelper"];
626-
if([NSFileManager.defaultManager fileExistsAtPath:TSHelperMarker]) {
627-
TSHelperFound = YES;
628-
break;
629-
}
630-
}
631-
632-
if(!TSHelperFound) {
633-
[AppDelegate dismissHud];
634-
635-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Error") message:Localized(@"You haven't installed TrollStore Helper yet, please install it in TrollStore->Settings first.") preferredStyle:UIAlertControllerStyleAlert];
636-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
637-
[AppDelegate showAlert:alert];
638-
639-
return;
640-
}
641-
642-
for(LSApplicationProxy* proxy in allInstalledApplications)
643-
{
644-
if([NSFileManager.defaultManager fileExistsAtPath:[proxy.bundleURL.path stringByAppendingString:@"/../_TrollStore"]])
645-
{
646-
if([proxy.bundleIdentifier isEqualToString:NSBundle.mainBundle.bundleIdentifier]) {
647-
continue;
648-
}
649-
650-
NSString* log=nil;
651-
NSString* err=nil;
652-
int status = spawnBootstrap((char*[]){"/usr/bin/uicache","-u",rootfsPrefix(proxy.bundleURL.path).fileSystemRepresentation,NULL}, &log, &err);
653-
if(status != 0) {
654-
[AppDelegate dismissHud];
655-
656-
NSString* msg = [NSString stringWithFormat:@"code(%d)\n%@\n\nstderr:\n%@",status,log,err];
657-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:msg preferredStyle:UIAlertControllerStyleAlert];
658-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
659-
[AppDelegate showAlert:alert];
660-
661-
return;
662-
}
663-
}
643+
void hideAllCTBugAppsAction(BOOL usreboot)
644+
{
645+
[AppDelegate showHudMsg:Localized(@"Hiding All Jailbreak/TrollStore Apps...")];
646+
647+
NSArray* allInstalledApplications = [LSApplicationWorkspace.defaultWorkspace allInstalledApplications];
648+
649+
BOOL TSHelperFound = NO;
650+
for(LSApplicationProxy* proxy in allInstalledApplications) {
651+
NSString* TSHelperMarker = [proxy.bundleURL.path stringByAppendingPathComponent:@".TrollStorePersistenceHelper"];
652+
if([NSFileManager.defaultManager fileExistsAtPath:TSHelperMarker]) {
653+
TSHelperFound = YES;
654+
break;
655+
}
656+
}
657+
658+
if(!TSHelperFound) {
659+
[AppDelegate dismissHud];
660+
661+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Error") message:Localized(@"You haven't installed TrollStore Helper yet, please install it in TrollStore->Settings first.") preferredStyle:UIAlertControllerStyleAlert];
662+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
663+
[AppDelegate showAlert:alert];
664+
665+
return;
666+
}
667+
668+
for(LSApplicationProxy* proxy in allInstalledApplications)
669+
{
670+
NSString* appPath = proxy.bundleURL.path;
671+
672+
if([proxy.bundleIdentifier isEqualToString:NSBundle.mainBundle.bundleIdentifier]) {
673+
continue;
674+
}
675+
676+
struct statfs fsb={0};
677+
statfs(appPath.fileSystemRepresentation, &fsb);
678+
if(strcmp(fsb.f_mntonname, "/") == 0) {
679+
continue;
680+
}
681+
682+
if(isDefaultInstallationPath(appPath))
683+
{
684+
if(![NSFileManager.defaultManager fileExistsAtPath:[appPath stringByAppendingString:@"/../_TrollStore"]]
685+
&& ![NSFileManager.defaultManager fileExistsAtPath:[appPath stringByAppendingString:@"/../_TrollStoreLite"]]) {
686+
continue;
664687
}
688+
}
689+
690+
if([proxy.bundleIdentifier hasPrefix:@"com.apple."] && [NSFileManager.defaultManager fileExistsAtPath:[@"/Applications" stringByAppendingPathComponent:appPath.lastPathComponent]]) {
691+
continue;
692+
}
665693

666-
for(NSString* bundle in [NSFileManager.defaultManager directoryContentsAtPath:jbroot(@"/Applications")])
667-
{
668-
NSString* bundlePath = [@"/Applications" stringByAppendingPathComponent:bundle];
669-
NSDictionary* appInfo = [NSDictionary dictionaryWithContentsOfFile:[bundlePath stringByAppendingPathComponent:@"Info.plist"]];
670-
671-
if([appInfo[@"CFBundleIdentifier"] hasPrefix:@"com.apple."] && [NSFileManager.defaultManager fileExistsAtPath:bundlePath]) {
672-
continue;
673-
}
674-
675-
NSString* log=nil;
676-
NSString* err=nil;
677-
int status = spawnBootstrap((char*[]){"/usr/bin/uicache","-u",bundlePath.fileSystemRepresentation,NULL}, &log, &err);
678-
if(status != 0) {
679-
[AppDelegate dismissHud];
680-
681-
NSString* msg = [NSString stringWithFormat:@"code(%d)\n%@\n\nstderr:\n%@",status,log,err];
682-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:msg preferredStyle:UIAlertControllerStyleAlert];
683-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
684-
[AppDelegate showAlert:alert];
685-
686-
return;
687-
}
688-
}
689694

695+
if(![LSApplicationWorkspace.defaultWorkspace unregisterApplication:proxy.bundleURL]) {
690696
[AppDelegate dismissHud];
691-
692-
[[NSString stringWithFormat:@"%llX",jbrand()] writeToFile:jbroot(@"/var/mobile/.allctbugappshidden") atomically:YES encoding:NSUTF8StringEncoding error:nil];
693-
694-
NSString* log=nil;
695-
NSString* err=nil;
696-
int status = spawnBootstrap((char*[]){"/usr/bin/uicache","-u",rootfsPrefix(NSBundle.mainBundle.bundlePath).fileSystemRepresentation,NULL}, &log, &err);
697-
if(status != 0) {
698-
NSString* msg = [NSString stringWithFormat:@"code(%d)\n%@\n\nstderr:\n%@",status,log,err];
699-
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:msg preferredStyle:UIAlertControllerStyleAlert];
700-
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
701-
[AppDelegate showAlert:alert];
702-
} else {
703-
exit(0);
704-
}
705-
});
706697

698+
NSString* msg = [NSString stringWithFormat:Localized(@"Failed to Hide %@ : %@"),proxy.bundleIdentifier,proxy.bundleURL.path];
699+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:msg preferredStyle:UIAlertControllerStyleAlert];
700+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
701+
[AppDelegate showAlert:alert];
702+
703+
return;
704+
}
705+
}
706+
707+
[[NSString stringWithFormat:@"%llX",jbrand()] writeToFile:jbroot(@"/var/mobile/.allctbugappshidden") atomically:YES encoding:NSUTF8StringEncoding error:nil];
708+
709+
sleep(1);
710+
711+
NSString* log=nil;
712+
NSString* err=nil;
713+
int status = spawnRoot(NSBundle.mainBundle.executablePath, @[@"hidebootstrapapp",usreboot?@"usreboot":@""], &log, &err);
714+
if(status != 0) {
715+
NSString* msg = [NSString stringWithFormat:@"code(%d)\n%@\n\nstderr:\n%@",status,log,err];
716+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:msg preferredStyle:UIAlertControllerStyleAlert];
717+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"OK") style:UIAlertActionStyleDefault handler:nil]];
718+
[AppDelegate showAlert:alert];
719+
720+
return;
721+
}
722+
723+
}
724+
725+
void hideAllCTBugApps()
726+
{
727+
UIAlertController *alert = [UIAlertController alertControllerWithTitle:Localized(@"Warning") message:Localized(@"This operation will make all apps installed via TrollStore/Bootstrap disappear from the Home Screen. You can restore them later via TrollStore Helper->[Refresh App Registrations] and Bootstrap->Settings->[Unhide Jailbreak Apps]") preferredStyle:UIAlertControllerStyleAlert];
728+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"Cancel") style:UIAlertActionStyleCancel handler:nil]];
729+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"Hide") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action){
730+
dispatch_async(dispatch_get_global_queue(0, 0), ^{
731+
hideAllCTBugAppsAction(NO);
732+
});
733+
}]];
734+
[alert addAction:[UIAlertAction actionWithTitle:Localized(@"Hide & Reboot Userspace") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action){
735+
dispatch_async(dispatch_get_global_queue(0, 0), ^{
736+
hideAllCTBugAppsAction(YES);
737+
});
707738
}]];
708739
[AppDelegate showAlert:alert];
709740
}
@@ -725,6 +756,8 @@ void unhideAllCTBugApps()
725756
[AppDelegate showAlert:alert];
726757

727758
[NSFileManager.defaultManager removeItemAtPath:jbroot(@"/var/mobile/.allctbugappshidden") error:nil];
759+
760+
[NSNotificationCenter.defaultCenter postNotificationName:@"unhideAllCTBugAppsNotification" object:nil];
728761
});
729762
}
730763

Bootstrap/Views/OptionsView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ struct OptionsView: View {
185185
} else {
186186
hideAllCTBugApps()
187187
}
188-
allCTBugAppsHidden.state = isAllCTBugAppsHidden()
189188
} label: {
190189
Label(
191190
title: { Text( allCTBugAppsHidden.state && isAllCTBugAppsHidden() ? "Unhide Jailbreak Apps" : "Hide All JB/TS Apps") },
@@ -195,6 +194,11 @@ struct OptionsView: View {
195194
.padding(.vertical, 10)
196195
.foregroundColor((!isSystemBootstrapped() || !checkBootstrapVersion()) ? Color.accentColor : Color.init(uiColor: UIColor.label))
197196
}
197+
.onReceive(NotificationCenter.default.publisher(for: Notification.Name("unhideAllCTBugAppsNotification"))) { obj in
198+
DispatchQueue.main.async {
199+
allCTBugAppsHidden.state = isAllCTBugAppsHidden()
200+
}
201+
}
198202
.frame(width: 250)
199203
.background(Color.clear)
200204
.overlay(

Bootstrap/bootstrap.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ int buildPackageSources()
9292

9393
ASSERT([[NSString stringWithFormat:@(DEFAULT_SOURCES), getCFMajorVersion()] writeToFile:jbroot(@"/etc/apt/sources.list.d/default.sources") atomically:YES encoding:NSUTF8StringEncoding error:nil]);
9494

95-
//Users in some regions seem to be unable to access github.io
96-
SYSLOG("locale=%@", [NSUserDefaults.appDefaults valueForKey:@"locale"]);
97-
if([[NSUserDefaults.appDefaults valueForKey:@"locale"] isEqualToString:@"CN"]) {
98-
ASSERT([[NSString stringWithFormat:@(ALT_SOURCES), getCFMajorVersion()] writeToFile:jbroot(@"/etc/apt/sources.list.d/sileo.sources") atomically:YES encoding:NSUTF8StringEncoding error:nil]);
99-
}
95+
// //Users in some regions seem to be unable to access github.io
96+
// SYSLOG("locale=%@", [NSUserDefaults.appDefaults valueForKey:@"locale"]);
97+
// if([[NSUserDefaults.appDefaults valueForKey:@"locale"] isEqualToString:@"CN"]) {
98+
// ASSERT([[NSString stringWithFormat:@(ALT_SOURCES), getCFMajorVersion()] writeToFile:jbroot(@"/etc/apt/sources.list.d/sileo.sources") atomically:YES encoding:NSUTF8StringEncoding error:nil]);
99+
// }
100100

101101
if(![fm fileExistsAtPath:jbroot(@"/var/mobile/Library/Application Support/xyz.willy.Zebra")])
102102
{

Bootstrap/main.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ int main(int argc, char * argv[]) {
2626
} else if(strcmp(argv[1], "rebuildiconcache")==0) {
2727
int rebuildIconCache();
2828
exit(rebuildIconCache());
29+
} else if(strcmp(argv[1], "hidebootstrapapp")==0) {
30+
int hideBootstrapApp(BOOL usreboot);
31+
exit(hideBootstrapApp(argc==3 && strcmp(argv[2],"usreboot")==0));
2932
} else if(strcmp(argv[1], "reboot")==0) {
3033
sync();
3134
sleep(1);

0 commit comments

Comments
 (0)