Skip to content

Commit

Permalink
fix 16.2-3 maybe? kpf not my respons
Browse files Browse the repository at this point in the history
  • Loading branch information
hrtowii committed Jan 12, 2024
1 parent 281599b commit 99effed
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 27 deletions.
2 changes: 1 addition & 1 deletion RootHelperSample/launchdshim/SpringBoardShim/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TARGET := iphone:clang:latest
TARGET := iphone:clang:16.4
ARCHS = arm64

include $(THEOS)/makefiles/common.mk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,6 @@ int spawnRoot(NSString* path, NSArray* args, NSString** stdOut, NSString** stdEr
return WEXITSTATUS(status);
}

%hook CSStatusTextView
- (void)setInternalLegalText:(NSString *)string {
%orig(@":troll:");
}
%end

bool isarm64e(void) {
int ptrAuthVal = 0;
size_t len = sizeof(ptrAuthVal);
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion RootHelperSample/launchdshim/launchdhook/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ int hooked_posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_acti
return orig_posix_spawn(pid, path, file_actions, attrp, argv, envp);
}

#define JETSAM_MULTIPLIER 3
#define JETSAM_MULTIPLIER 6

int hooked_posix_spawnp(pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *restrict file_actions, posix_spawnattr_t *attrp, char *const argv[restrict], char *const envp[restrict]) {
change_launchtype(attrp, path);
Expand Down
87 changes: 72 additions & 15 deletions RootHelperSample/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ int runLdid(NSArray* args, NSString** output, NSString** errorOutput)

if(spawnError != 0)
{
NSLog(@"posix_spawn error %d\n", spawnError);
// NSLog(@"posix_spawn error %d\n", spawnError);
return spawnError;
}

Expand Down Expand Up @@ -216,14 +216,14 @@ int signAdhoc(NSString *filePath, NSString *entitlements) // lets just assume ld
// [[NSFileManager defaultManager] removeItemAtPath:entitlementsPath error:nil];
// }

NSLog(@"roothelper: ldid exited with status %d", ldidRet);

NSLog(@"roothelper: - ldid error output start -");

printMultilineNSString(signArg);
printMultilineNSString(errorOutput);

NSLog(@"roothelper: - ldid error output end -");
// NSLog(@"roothelper: ldid exited with status %d", ldidRet);
//
// NSLog(@"roothelper: - ldid error output start -");
//
// printMultilineNSString(signArg);
// printMultilineNSString(errorOutput);
//
// NSLog(@"roothelper: - ldid error output end -");

if(ldidRet == 0)
{
Expand Down Expand Up @@ -273,6 +273,62 @@ void replaceByte(NSString *filePath, int offset, const char *replacement) {
fclose(file);
}

//void removeItemAtPathRecursively(NSString *path) {
// NSFileManager *fileManager = [NSFileManager defaultManager];
// [fileManager removeItemAtPath:directoryPath error:nil];
// if ([fileManager fileExistsAtPath:directoryPath]) {
// NSDirectoryEnumerator *dirEnum = [fileManager enumeratorAtPath:directoryPath];
// NSString *documentsName;
// while (documentsName = [dirEnum nextObject]) {
// NSString *filePath = [directoryPath stringByAppendingString:documentsName];
// BOOL isFileDeleted = [fileManager removeItemAtPath:filePath error:nil];
// if(isFileDeleted == NO) {
// NSLog(@"All Contents not removed");
// break;
// }
// }
// printf("All Contents Removed");
// }
//}

void removeItemAtPathRecursively(NSString *path) {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
if (![fileManager fileExistsAtPath:path]) {
NSLog(@"Item does not exist at path: %@", path);
return;
}
NSArray *contents = [fileManager contentsOfDirectoryAtPath:path error:&error];

if (error == nil) {
for (NSString *item in contents) {
if ([item isEqualToString:@".jbroot"]) {
NSLog(@"Skipping deletion of %@ in %@", item, path);
continue;
}
NSString *itemPath = [path stringByAppendingPathComponent:item];
BOOL isDirectory = NO;
if ([fileManager fileExistsAtPath:itemPath isDirectory:&isDirectory]) {
if (isDirectory) {
removeItemAtPathRecursively(itemPath);
} else {
[fileManager removeItemAtPath:itemPath error:&error];
if (error != nil) {
NSLog(@"Error removing item at path %@: %@", itemPath, error);
}
}
}
}
[fileManager removeItemAtPath:path error:&error];
if (error != nil) {
NSLog(@"Error removing item at path %@: %@", path, error);
}
} else {
NSLog(@"Error reading contents of directory %@: %@", path, error);
}
}


int main(int argc, char *argv[], char *envp[]) {
@autoreleasepool {
// NSLog(@"Hello from the other side! our uid is %u and our pid is %d", getuid(), getpid());
Expand Down Expand Up @@ -347,14 +403,15 @@ int main(int argc, char *argv[], char *envp[]) {
if (!jbroot(@"/")) {
NSLog(@"jbroot not found...");
} else {
// if (!jbroot(@"lunchd")) {
if (!jbroot(@"lunchd")) {
NSLog(@"not continuing, lunchd wasn't found to remove");
return -1;
} else {
removeItemAtPathRecursively(jbroot(@"/System/Library/CoreServices/SpringBoard.app/"));
[[NSFileManager defaultManager] removeItemAtPath:@"/var/mobile/Serotonin.jp2" error:nil];
[[NSFileManager defaultManager] removeItemAtPath:jbroot(@"lunchd") error:nil];
[[NSFileManager defaultManager] removeItemAtPath:jbroot(@"launchdhook.dylib") error:nil];
[[NSFileManager defaultManager] removeItemAtPath:jbroot(@"/System/Library/CoreServices/SpringBoard.app/") error:nil];
[[NSFileManager defaultManager] removeItemAtPath:@"/var/mobile/Serotonin.jp2" error:nil];
// } else {
// NSLog(@"lunchd was found, you've already installed");
// }
}
}
} else if ([action isEqual: @"reinstall"]) {
spawnRoot(rootHelperPath(), @[@"uninstall", source, @""], nil, nil);
Expand Down
5 changes: 2 additions & 3 deletions usprebooter/TheCoolerContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -287,24 +287,23 @@ struct CoolerContentView: View {
VStack {

Toggle("Reinstall jailbreak", isOn: $reinstall)
// .disabled(true)
.onChange(of: reinstall) { _ in
if reinstall {
withAnimation(fancyAnimation) {
resetfs = false
}
}
}
.disabled(resetfs);
Divider()
Toggle("Remove jailbreak", isOn: $resetfs)
// .disabled(true)
.onChange(of: resetfs) { _ in
if resetfs {
withAnimation(fancyAnimation) {
reinstall = false
}
}
}
}.disabled(reinstall);
Divider()
Button("More Settings", systemImage: "gear") {
UIImpactFeedbackGenerator(style: .medium).impactOccurred(intensity: 200)
Expand Down
2 changes: 2 additions & 0 deletions usprebooter/fun/offsets.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ void _offsets_init(void) {

//https://github.com/apple-oss-distributions/xnu/blob/xnu-8792.41.9/bsd/sys/vnode_internal.h#L158
off_vnode_v_ncchildren_tqh_first = 0x30;
// hmm..
off_vnode_v_nclinks_lh_first = 0x40;
off_vnode_v_iocount = 0x64;
off_vnode_v_usecount = 0x60;
off_vnode_v_flag = 0x54;
Expand Down
2 changes: 1 addition & 1 deletion usprebooter/overwriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bool overwrite_patchedlaunchd_kfd(void) {
// ayo whats this – bomberfish
// SwitchSysBin(getVnodeAtPathByChdir("/System/Library/CoreServices/SpringBoard.app"), "SpringBoard", "/var/jb/SprangBoard");
printf("[i] performing launchd hax\n");
if (SYSTEM_VERSION_LOWER_THAN(@"16.2")) {
if (SYSTEM_VERSION_LOWER_THAN(@"16.3.1")) {
uint64_t orig_nc_vp = 0;
uint64_t orig_to_vnode = 0;
SwitchSysBin160("/sbin/launchd", getLunchd().UTF8String, &orig_to_vnode, &orig_nc_vp);
Expand Down

0 comments on commit 99effed

Please sign in to comment.