diff --git a/Application/Dopamine.xcodeproj/project.pbxproj b/Application/Dopamine.xcodeproj/project.pbxproj index bdb1239bc..b9c7ca013 100644 --- a/Application/Dopamine.xcodeproj/project.pbxproj +++ b/Application/Dopamine.xcodeproj/project.pbxproj @@ -175,6 +175,8 @@ 8C5FA96E2BDD7898008C246F /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C5FA93F2BDD5039008C246F /* IOKit.framework */; }; 8C5FA96F2BDD789C008C246F /* IOSurface.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C5FA9412BDD503D008C246F /* IOSurface.framework */; }; 8C5FA9712BDD81EF008C246F /* LICENSE_weightBufs.md in Resources */ = {isa = PBXBuildFile; fileRef = 8C5FA9702BDD81EF008C246F /* LICENSE_weightBufs.md */; }; + 8C609C9E2C19B4270023DD12 /* NSString+Version.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C609C9C2C19AECF0023DD12 /* NSString+Version.m */; }; + 8C609C9F2C19B6FA0023DD12 /* libkrw-dopamine.deb in Resources */ = {isa = PBXBuildFile; fileRef = 8C609C992C19AC250023DD12 /* libkrw-dopamine.deb */; }; 8C71981A2ABF0E82003C6658 /* DOAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C7198192ABF0E82003C6658 /* DOAppDelegate.m */; }; 8C71981D2ABF0E82003C6658 /* DOSceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C71981C2ABF0E82003C6658 /* DOSceneDelegate.m */; }; 8C7198252ABF0E84003C6658 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 8C7198242ABF0E84003C6658 /* Assets.xcassets */; }; @@ -186,7 +188,6 @@ 8CC139822B53DE6C00230143 /* NSData+Hex.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CC139812B53DE6C00230143 /* NSData+Hex.m */; }; 8CC139832B53E05300230143 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD08372B4F682500A32B61 /* IOKit.framework */; }; 8CCD2FC42B77AAA000F9C5DA /* basebin-link.deb in Resources */ = {isa = PBXBuildFile; fileRef = 8CCD2FC32B77AA9200F9C5DA /* basebin-link.deb */; }; - 8CCD8A872B6F16CC004B72B0 /* libkrw-plugin.deb in Resources */ = {isa = PBXBuildFile; fileRef = 8CCD8A852B6F1662004B72B0 /* libkrw-plugin.deb */; }; 8CDD07AA2B4F619000A32B61 /* kfd.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CDD07A92B4F619000A32B61 /* kfd.h */; settings = {ATTRIBUTES = (Public, ); }; }; 8CDD07AF2B4F619000A32B61 /* kfd.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD07A72B4F619000A32B61 /* kfd.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 8CDD08342B4F63E100A32B61 /* kfd.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CDD07B32B4F639100A32B61 /* kfd.m */; }; @@ -505,6 +506,9 @@ 8C5FA9582BDD6C0C008C246F /* kernel_rw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kernel_rw.h; sourceTree = ""; }; 8C5FA9592BDD6C0C008C246F /* exploit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = exploit.h; sourceTree = ""; }; 8C5FA9702BDD81EF008C246F /* LICENSE_weightBufs.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = LICENSE_weightBufs.md; sourceTree = ""; }; + 8C609C992C19AC250023DD12 /* libkrw-dopamine.deb */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libkrw-dopamine.deb"; path = "../../../Packages/libkrw-provider/libkrw-dopamine.deb"; sourceTree = ""; }; + 8C609C9C2C19AECF0023DD12 /* NSString+Version.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSString+Version.m"; sourceTree = ""; }; + 8C609C9D2C19AEE70023DD12 /* NSString+Version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSString+Version.h"; sourceTree = ""; }; 8C7198152ABF0E82003C6658 /* Dopamine.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Dopamine.app; sourceTree = BUILT_PRODUCTS_DIR; }; 8C7198182ABF0E82003C6658 /* DOAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOAppDelegate.h; sourceTree = ""; }; 8C7198192ABF0E82003C6658 /* DOAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DOAppDelegate.m; sourceTree = ""; }; @@ -522,7 +526,6 @@ 8CC139812B53DE6C00230143 /* NSData+Hex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+Hex.m"; sourceTree = ""; }; 8CCD2FC32B77AA9200F9C5DA /* basebin-link.deb */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "basebin-link.deb"; path = "../../../Packages/basebin-link/basebin-link.deb"; sourceTree = ""; }; 8CCD8A832B6F165A004B72B0 /* libroot.deb */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libroot.deb; path = ../../../Packages/libroot/libroot.deb; sourceTree = ""; }; - 8CCD8A852B6F1662004B72B0 /* libkrw-plugin.deb */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libkrw-plugin.deb"; path = "../../../Packages/libkrw-provider/libkrw-plugin.deb"; sourceTree = ""; }; 8CDD07A72B4F619000A32B61 /* kfd.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = kfd.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 8CDD07A92B4F619000A32B61 /* kfd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = kfd.h; sourceTree = ""; }; 8CDD07B32B4F639100A32B61 /* kfd.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = kfd.m; sourceTree = ""; }; @@ -1082,6 +1085,8 @@ 8CC139812B53DE6C00230143 /* NSData+Hex.m */, 8C9E46272ACA1C8D00B5456A /* UIImage+Blur.h */, 8C9E46282ACA1CC700B5456A /* UIImage+Blur.m */, + 8C609C9D2C19AEE70023DD12 /* NSString+Version.h */, + 8C609C9C2C19AECF0023DD12 /* NSString+Version.m */, ); path = Extensions; sourceTree = ""; @@ -1097,7 +1102,7 @@ 84F267E92BB7292C00DD3323 /* roothideapp.deb */, 8C512B8B2B5C9DE800C6F14A /* sileo.deb */, 8C512B8C2B5C9DE800C6F14A /* zebra.deb */, - 8CCD8A852B6F1662004B72B0 /* libkrw-plugin.deb */, + 8C609C992C19AC250023DD12 /* libkrw-dopamine.deb */, 8CCD8A832B6F165A004B72B0 /* libroot.deb */, 8CCD2FC32B77AA9200F9C5DA /* basebin-link.deb */, 04DD0B362B7BA6180055DE4F /* LICENSE.md */, @@ -1475,6 +1480,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8C609C9F2C19B6FA0023DD12 /* libkrw-dopamine.deb in Resources */, 04DD0B372B7BA6180055DE4F /* LICENSE.md in Resources */, 04DD0B3A2B7BF3E80055DE4F /* LICENSE_libc.md in Resources */, 8C56D4CD2B7C118B001C03D3 /* LICENSE_kfd.md in Resources */, @@ -1497,7 +1503,6 @@ 8C2875212BD850B4008B24DA /* LICENSE_libgrabkernel2.md in Resources */, 8C512B912B5C9F9100C6F14A /* sileo.deb in Resources */, 8C512B922B5C9F9400C6F14A /* zebra.deb in Resources */, - 8CCD8A872B6F16CC004B72B0 /* libkrw-plugin.deb in Resources */, 8C296BAE2BE05914007C2AD1 /* LICENSE_plooshinit.md in Resources */, 8C5FA9712BDD81EF008C246F /* LICENSE_weightBufs.md in Resources */, 8CB94F052B59E17A0098BAFD /* basebin.tar in Resources */, @@ -1659,6 +1664,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8C609C9E2C19B4270023DD12 /* NSString+Version.m in Sources */, 042479A62B66916B0082581B /* DOHeaderCell.m in Sources */, 042479A22B66916B0082581B /* DOCreditsViewController.m in Sources */, 042479B32B66916B0082581B /* DODebugLogView.m in Sources */, @@ -1798,7 +1804,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 49LJ27SG38; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1835,7 +1841,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 49LJ27SG38; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1870,7 +1876,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 49LJ27SG38; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1904,7 +1910,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 49LJ27SG38; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1938,7 +1944,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 3Z56NQJ65R; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -1974,7 +1980,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 3Z56NQJ65R; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -2010,7 +2016,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 3Z56NQJ65R; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -2046,7 +2052,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 3Z56NQJ65R; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -2214,7 +2220,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 49LJ27SG38; + DEVELOPMENT_TEAM = 333YQBLA8H; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Frameworks", @@ -2236,7 +2242,7 @@ "$(PROJECT_DIR)/Dopamine/Dependencies", "$(PROJECT_DIR)/Dopamine/Resources", ); - MARKETING_VERSION = 2.1.5; + MARKETING_VERSION = 2.1.7; PRODUCT_BUNDLE_IDENTIFIER = "com.opa334.Dopamine-roothide"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -2252,7 +2258,7 @@ ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 49LJ27SG38; + DEVELOPMENT_TEAM = 333YQBLA8H; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Frameworks", @@ -2274,7 +2280,7 @@ "$(PROJECT_DIR)/Dopamine/Dependencies", "$(PROJECT_DIR)/Dopamine/Resources", ); - MARKETING_VERSION = 2.1.5; + MARKETING_VERSION = 2.1.7; PRODUCT_BUNDLE_IDENTIFIER = "com.opa334.Dopamine-roothide"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -2288,7 +2294,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 49LJ27SG38; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -2323,7 +2329,7 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; - DEVELOPMENT_TEAM = 49LJ27SG38; + DEVELOPMENT_TEAM = 333YQBLA8H; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; diff --git a/Application/Dopamine/Exploits/weightBufs/exploit/exploit.h b/Application/Dopamine/Exploits/weightBufs/exploit/exploit.h index c7412b3ba..ac7d0a414 100644 --- a/Application/Dopamine/Exploits/weightBufs/exploit/exploit.h +++ b/Application/Dopamine/Exploits/weightBufs/exploit/exploit.h @@ -37,7 +37,7 @@ #else #define MAX_PROGRAMS 5 -#define IOSURFACE_OBJ_SIZE 0x430 +#define IOSURFACE_OBJ_SIZE 0x8 #define MAX_SHMEMS 0x2000 #endif /* TARGET_OS_OSX */ diff --git a/Application/Dopamine/Exploits/weightBufs/exploit/exploit.m b/Application/Dopamine/Exploits/weightBufs/exploit/exploit.m index ce46c3c28..ee46a96f9 100644 --- a/Application/Dopamine/Exploits/weightBufs/exploit/exploit.m +++ b/Application/Dopamine/Exploits/weightBufs/exploit/exploit.m @@ -1154,9 +1154,10 @@ bool get_target_surface(u64 *kaddr_target) printf("[+] Found a matching surface-id=0x%04x IOSurface=0x%llx ! \n", matched.surface_id, matched.IOSurface_loc); + break; } } - /* if(matched.surface_id) break; */ + if(matched.surface_id) break; } /* assert(matched.surface_id && "Unable to find a suitable IOSurface"); */ diff --git a/Application/Dopamine/Extensions/NSString+Version.h b/Application/Dopamine/Extensions/NSString+Version.h new file mode 100644 index 000000000..7e717c290 --- /dev/null +++ b/Application/Dopamine/Extensions/NSString+Version.h @@ -0,0 +1,18 @@ +// +// NSString+Version.h +// Dopamine +// +// Created by Lars Fröder on 12.06.24. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSString (Version) + +- (NSInteger)numericalVersionRepresentation; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Application/Dopamine/Extensions/NSString+Version.m b/Application/Dopamine/Extensions/NSString+Version.m new file mode 100644 index 000000000..9d5fb472d --- /dev/null +++ b/Application/Dopamine/Extensions/NSString+Version.m @@ -0,0 +1,27 @@ +// +// NSString+Version.h +// Dopamine +// +// Created by Lars Fröder on 12.06.24. +// + +#import + +@implementation NSString (Version) + +- (NSInteger)numericalVersionRepresentation +{ + NSInteger numericalRepresentation = 0; + + NSArray *components = [self componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]]; + assert(components.count <= 3); + while (components.count < 3) + components = [components arrayByAddingObject:@"0"]; + + numericalRepresentation |= [components[0] integerValue] << 16; + numericalRepresentation |= [components[1] integerValue] << 8; + numericalRepresentation |= [components[2] integerValue]; + return numericalRepresentation; +} + +@end diff --git a/Application/Dopamine/Jailbreak/DOBootstrapper.m b/Application/Dopamine/Jailbreak/DOBootstrapper.m index ca2406664..c432818e0 100644 --- a/Application/Dopamine/Jailbreak/DOBootstrapper.m +++ b/Application/Dopamine/Jailbreak/DOBootstrapper.m @@ -15,10 +15,16 @@ #import #import #import +#import "NSString+Version.h" -#define LIBKRW_DOPAMINE_BUNDLED_VERSION @"2.0.1" +#define LIBKRW_DOPAMINE_BUNDLED_VERSION @"2.0.3" #define BASEBIN_LINK_BUNDLED_VERSION @"1.0.0" +static NSDictionary *gBundledPackages = @{ + @"libkrw0-dopamine" : LIBKRW_DOPAMINE_BUNDLED_VERSION, + @"dopamine-basebin-link" : BASEBIN_LINK_BUNDLED_VERSION, +}; + struct hfs_mount_args { char *fspec; uid_t hfs_uid; /* uid that owns hfs files (standard HFS only) */ @@ -772,6 +778,17 @@ - (NSError *)installPackageManagers return nil; } +- (BOOL)shouldInstallPackage:(NSString *)identifier +{ + NSString *bundledVersion = gBundledPackages[identifier]; + if (!bundledVersion) return NO; + + NSString *installedVersion = [self installedVersionForPackageWithIdentifier:identifier]; + if (!installedVersion) return YES; + + return [installedVersion numericalVersionRepresentation] < [bundledVersion numericalVersionRepresentation]; +} + - (NSError *)finalizeBootstrap { // Initial setup on first jailbreak @@ -798,27 +815,19 @@ - (NSError *)finalizeBootstrap } } - NSString *libkrwDopamineInstalledVersion = [self installedVersionForPackageWithIdentifier:@"libkrw0-dopamine"]; - NSString *basebinLinkInstalledVersion = [self installedVersionForPackageWithIdentifier:@"dopamine-basebin-link"]; - - if ([self fileOrSymlinkExistsAtPath:NSJBRootPath(@"/usr/lib/libroot.dylib")]) { - [[NSFileManager defaultManager] removeItemAtPath:NSJBRootPath(@"/usr/lib/libroot.dylib") error:nil]; - } - [[NSFileManager defaultManager] createSymbolicLinkAtPath:NSJBRootPath(@"/usr/lib/libroot.dylib") withDestinationPath:NSJBRootPath(@"/basebin/libroot.dylib") error:nil]; + BOOL shouldInstallLibkrw = [self shouldInstallPackage:@"libkrw0-dopamine"]; + BOOL shouldInstallBasebinLink = [self shouldInstallPackage:@"dopamine-basebin-link"]; - if ( - !libkrwDopamineInstalledVersion || ![libkrwDopamineInstalledVersion isEqualToString:LIBKRW_DOPAMINE_BUNDLED_VERSION] || - !basebinLinkInstalledVersion || ![basebinLinkInstalledVersion isEqualToString:BASEBIN_LINK_BUNDLED_VERSION]) { + if (shouldInstallLibkrw || shouldInstallBasebinLink) { [[DOUIManager sharedInstance] sendLog:@"Updating Bundled Packages" debug:NO]; - - - if (!libkrwDopamineInstalledVersion || ![libkrwDopamineInstalledVersion isEqualToString:LIBKRW_DOPAMINE_BUNDLED_VERSION]) { - NSString *libkrwPath = [[NSBundle mainBundle].bundlePath stringByAppendingPathComponent:@"libkrw-plugin.deb"]; + + if (shouldInstallLibkrw) { + NSString *libkrwPath = [[NSBundle mainBundle].bundlePath stringByAppendingPathComponent:@"libkrw-dopamine.deb"]; int r = [self installPackage:libkrwPath]; if (r != 0) return [NSError errorWithDomain:bootstrapErrorDomain code:BootstrapErrorCodeFailedFinalising userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Failed to install the libkrw plugin: %d\n", r]}]; } - - if (!basebinLinkInstalledVersion || ![basebinLinkInstalledVersion isEqualToString:BASEBIN_LINK_BUNDLED_VERSION]) { + + if (shouldInstallBasebinLink) { // Clean symlinks from earlier Dopamine versions if (![self fileOrSymlinkExistsAtPath:NSJBRootPath(@"/usr/bin/opainject")]) { [[NSFileManager defaultManager] removeItemAtPath:NSJBRootPath(@"/usr/bin/opainject") error:nil]; @@ -839,6 +848,11 @@ - (NSError *)finalizeBootstrap if (r != 0) return [NSError errorWithDomain:bootstrapErrorDomain code:BootstrapErrorCodeFailedFinalising userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Failed to install basebin link: %d\n", r]}]; } } + + if ([self fileOrSymlinkExistsAtPath:NSJBRootPath(@"/usr/lib/libroot.dylib")]) { + [[NSFileManager defaultManager] removeItemAtPath:NSJBRootPath(@"/usr/lib/libroot.dylib") error:nil]; + } + [[NSFileManager defaultManager] createSymbolicLinkAtPath:NSJBRootPath(@"/usr/lib/libroot.dylib") withDestinationPath:NSJBRootPath(@"/basebin/libroot.dylib") error:nil]; [[NSString stringWithFormat:@"%d",DOPAMINE_INSTALL_VERSION] writeToFile:NSJBRootPath(@"/.installed_dopamine") atomically:YES encoding:NSUTF8StringEncoding error:nil]; diff --git a/Application/Dopamine/Jailbreak/DOJailbreaker.m b/Application/Dopamine/Jailbreak/DOJailbreaker.m index 964263e5f..12b1ba14f 100644 --- a/Application/Dopamine/Jailbreak/DOJailbreaker.m +++ b/Application/Dopamine/Jailbreak/DOJailbreaker.m @@ -83,6 +83,7 @@ - (NSError *)gatherSystemInformation NULL, NULL, NULL, + NULL, }; uint32_t idx = 8; @@ -285,17 +286,8 @@ - (NSError *)showNonDefaultSystemApps - (NSError *)ensureDevModeEnabled { if (@available(iOS 16.0, *)) { - uint64_t developer_mode_state = kread64(ksymbol(developer_mode_enabled)); - if ((developer_mode_state & 0xff) == 0 || (developer_mode_state & 0xff) == 1) { - // On iOS 16.0 - 16.3, developer_mode_state is a bool - if (developer_mode_state == 0) { - kwrite8(ksymbol(developer_mode_enabled), 1); - } - } - else if (kread8(developer_mode_state) == 0) { - // On iOS 16.4+, developer_mode_state is a pointer to a bool - kwrite8(developer_mode_state, 1); - } + uint64_t developer_mode_storage = kread64(ksymbol(developer_mode_enabled)); + kwrite8(developer_mode_storage, 1); } return nil; } @@ -391,39 +383,48 @@ - (NSError *)injectLaunchdHook return nil; } -//- (NSError *)createFakeLib -//{ -// int r = exec_cmd(JBRootPath("/basebin/jbctl"), "internal", "fakelib_init", NULL); -// if (r != 0) { -// return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Creating fakelib failed with error: %d", r]}]; -// } -// -// cdhash_t *cdhashes; -// uint32_t cdhashesCount; -// macho_collect_untrusted_cdhashes(JBRootPath("/basebin/.fakelib/dyld"), NULL, NULL, &cdhashes, &cdhashesCount); -// if (cdhashesCount != 1) return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Got unexpected number of cdhashes for dyld???: %d", cdhashesCount]}]; -// -// trustcache_file_v1 *dyldTCFile = NULL; -// r = trustcache_file_build_from_cdhashes(cdhashes, cdhashesCount, &dyldTCFile); -// free(cdhashes); -// if (r == 0) { -// int r = trustcache_file_upload_with_uuid(dyldTCFile, DYLD_TRUSTCACHE_UUID); -// if (r != 0) return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Failed to upload dyld trustcache: %d", r]}]; -// free(dyldTCFile); -// } -// else { -// return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : @"Failed to build dyld trustcache"}]; -// } -// -// r = exec_cmd(JBRootPath("/basebin/jbctl"), "internal", "fakelib_mount", NULL); -// if (r != 0) { -// return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Mounting fakelib failed with error: %d", r]}]; -// } -// -// // Now that fakelib is up, we want to make systemhook inject into any binary we spawn -// setenv("DYLD_INSERT_LIBRARIES", "/usr/lib/systemhook.dylib", 1); -// return nil; -//} +// - (NSError *)applyProtection +// { +// int r = exec_cmd(JBRootPath("/basebin/jbctl"), "internal", "protection_init", NULL); +// if (r != 0) { +// return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitProtection userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Failed initializing protection with error: %d", r]}]; +// } +// return nil; +// } + +// - (NSError *)createFakeLib +// { +// int r = exec_cmd(JBRootPath("/basebin/jbctl"), "internal", "fakelib_init", NULL); +// if (r != 0) { +// return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Creating fakelib failed with error: %d", r]}]; +// } + +// cdhash_t *cdhashes = NULL; +// uint32_t cdhashesCount = 0; +// macho_collect_untrusted_cdhashes(JBRootPath("/basebin/.fakelib/dyld"), NULL, NULL, NULL, NULL, 0, &cdhashes, &cdhashesCount); +// if (cdhashesCount != 1) return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Got unexpected number of cdhashes for dyld???: %d", cdhashesCount]}]; + +// trustcache_file_v1 *dyldTCFile = NULL; +// r = trustcache_file_build_from_cdhashes(cdhashes, cdhashesCount, &dyldTCFile); +// free(cdhashes); +// if (r == 0) { +// int r = trustcache_file_upload_with_uuid(dyldTCFile, DYLD_TRUSTCACHE_UUID); +// if (r != 0) return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Failed to upload dyld trustcache: %d", r]}]; +// free(dyldTCFile); +// } +// else { +// return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : @"Failed to build dyld trustcache"}]; +// } + +// r = exec_cmd(JBRootPath("/basebin/jbctl"), "internal", "fakelib_mount", NULL); +// if (r != 0) { +// return [NSError errorWithDomain:JBErrorDomain code:JBErrorCodeFailedInitFakeLib userInfo:@{NSLocalizedDescriptionKey : [NSString stringWithFormat:@"Mounting fakelib failed with error: %d", r]}]; +// } + +// // Now that fakelib is up, we want to make systemhook inject into any binary we spawn +// setenv("DYLD_INSERT_LIBRARIES", "/usr/lib/systemhook.dylib", 1); +// return nil; +// } - (NSError *)ensureNoDuplicateApps { @@ -553,9 +554,16 @@ - (void)runWithError:(NSError **)errOut didRemoveJailbreak:(BOOL*)didRemove show *errOut = [self injectLaunchdHook]; if (*errOut) return; -// [[DOUIManager sharedInstance] sendLog:DOLocalizedString(@"Applying Bind Mount") debug:NO]; -// *errOut = [self createFakeLib]; -// if (*errOut) return; + // // Now that we can, protect important system files by bind mounting on top of them + // // This will be always be done during the userspace reboot + // // We also do it now though in case there is a failure between the now step and the userspace reboot + // [[DOUIManager sharedInstance] sendLog:DOLocalizedString(@"Initializing Protection") debug:NO]; + // *errOut = [self applyProtection]; + // if (*errOut) return; + + // [[DOUIManager sharedInstance] sendLog:DOLocalizedString(@"Applying Bind Mount") debug:NO]; + // *errOut = [self createFakeLib]; + // if (*errOut) return; setenv("DYLD_INSERT_LIBRARIES", JBRootPath("/basebin/systemhook.dylib"), 1); diff --git a/Application/Dopamine/UI/DOUIManager.m b/Application/Dopamine/UI/DOUIManager.m index 8372543e8..61c1036de 100644 --- a/Application/Dopamine/UI/DOUIManager.m +++ b/Application/Dopamine/UI/DOUIManager.m @@ -7,6 +7,7 @@ #import "DOUIManager.h" #import "DOEnvironmentManager.h" +#import "NSString+Version.h" #import @implementation DOUIManager @@ -35,20 +36,7 @@ - (BOOL)isUpdateAvailable { NSString *latestVersion = [self getLatestReleaseTag]; NSString *currentVersion = [self getLaunchedReleaseTag]; - return [self numericalRepresentationForVersion:latestVersion] > [self numericalRepresentationForVersion:currentVersion]; -} - -- (long long)numericalRepresentationForVersion:(NSString*)version { - long long numericalRepresentation = 0; - - NSArray *components = [version componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]]; - while (components.count < 3) - components = [components arrayByAddingObject:@"0"]; - - numericalRepresentation |= [components[0] integerValue] << 16; - numericalRepresentation |= [components[1] integerValue] << 8; - numericalRepresentation |= [components[2] integerValue]; - return numericalRepresentation; + return [latestVersion numericalVersionRepresentation] > [currentVersion numericalVersionRepresentation]; } - (NSArray *)getUpdatesInRange:(NSString *)start end:(NSString *)end @@ -57,8 +45,8 @@ - (NSArray *)getUpdatesInRange:(NSString *)start end:(NSString *)end if (releases.count == 0) return @[]; - long long startVersion = [self numericalRepresentationForVersion:start]; - long long endVersion = [self numericalRepresentationForVersion:end]; + long long startVersion = [start numericalVersionRepresentation]; + long long endVersion = [end numericalVersionRepresentation]; NSMutableArray *updates = [NSMutableArray new]; for (NSDictionary *release in releases) { NSString *version = release[@"tag_name"]; @@ -67,7 +55,7 @@ - (NSArray *)getUpdatesInRange:(NSString *)start end:(NSString *)end // Skip prereleases continue; } - long long numericalVersion = [self numericalRepresentationForVersion:version]; + long long numericalVersion = [version numericalVersionRepresentation]; if (numericalVersion > startVersion && numericalVersion <= endVersion) { [updates addObject:release]; } @@ -132,9 +120,11 @@ - (BOOL)environmentUpdateAvailable { if (![[DOEnvironmentManager sharedManager] jailbrokenVersion]) return NO; - long long jailbrokenVersion = [self numericalRepresentationForVersion:[[DOEnvironmentManager sharedManager] jailbrokenVersion]]; - long long launchedVersion = [self numericalRepresentationForVersion:[self getLaunchedReleaseTag]]; - return launchedVersion > jailbrokenVersion; + + NSString *jailbrokenVersion = [[DOEnvironmentManager sharedManager] jailbrokenVersion]; + NSString *launchedVersion = [self getLaunchedReleaseTag]; + + return [launchedVersion numericalVersionRepresentation] > [jailbrokenVersion numericalVersionRepresentation]; } - (bool)launchedReleaseNeedsManualUpdate @@ -247,7 +237,7 @@ - (BOOL)enableTweaks - (void)sendLog:(NSString*)log debug:(BOOL)debug update:(BOOL)update { - NSLog(@"sendLog: %@", log); + // NSLog(@"sendLog: %@", log); if (!self.logView || !log) return; @@ -299,7 +289,7 @@ - (void)completeJailbreak [self.logView didComplete]; } -- (void)startLogCapture +- (void)observeFileDescriptor:(int)fd withCallback:(void (^)(char *line))callbackBlock { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ int stdout_pipe[2]; @@ -308,33 +298,28 @@ - (void)startLogCapture return; } - dup2(STDOUT_FILENO, stdout_orig[1]); + dup2(fd, stdout_orig[1]); close(stdout_orig[0]); - dup2(stdout_pipe[1], STDOUT_FILENO); + dup2(stdout_pipe[1], fd); close(stdout_pipe[1]); - char buffer[1024]; + char cur = 0; char line[1024]; int line_index = 0; ssize_t bytes_read; - while ((bytes_read = read(stdout_pipe[0], buffer, sizeof(buffer) - 1)) > 0) { + while ((bytes_read = read(stdout_pipe[0], &cur, sizeof(cur))) > 0) { @autoreleasepool { - // Tee: Write back to the original standard output - write(stdout_orig[1], buffer, bytes_read); - - buffer[bytes_read] = '\0'; // Null terminate to handle as string - for (int i = 0; i < bytes_read; ++i) { - if (buffer[i] == '\n') { - line[line_index] = '\0'; - NSString *str = [NSString stringWithUTF8String:line]; - [self sendLog:str debug:YES]; - line_index = 0; - } else { - if (line_index < sizeof(line) - 1) { - line[line_index++] = buffer[i]; - } + write(stdout_orig[1], &cur, bytes_read); + + if (cur == '\n') { + line[line_index] = '\0'; + callbackBlock(line); + line_index = 0; + } else { + if (line_index < sizeof(line) - 1) { + line[line_index++] = cur; } } } @@ -343,6 +328,19 @@ - (void)startLogCapture }); } +- (void)startLogCapture +{ + [self observeFileDescriptor:STDOUT_FILENO withCallback:^(char *line) { + NSString *str = [NSString stringWithUTF8String:line]; + [self sendLog:str debug:YES]; + }]; + + [self observeFileDescriptor:STDERR_FILENO withCallback:^(char *line) { + NSString *str = [NSString stringWithUTF8String:line]; + [self sendLog:str debug:YES]; + }]; +} + - (NSString *)localizedStringForKey:(NSString*)key { NSString *candidate = NSLocalizedString(key, nil); diff --git a/Application/Dopamine/UI/Update/DOUpdateViewController.m b/Application/Dopamine/UI/Update/DOUpdateViewController.m index 0aa00b0de..9290b31c8 100644 --- a/Application/Dopamine/UI/Update/DOUpdateViewController.m +++ b/Application/Dopamine/UI/Update/DOUpdateViewController.m @@ -12,6 +12,7 @@ #import "DODownloadViewController.h" #import "DOUIManager.h" #import "DOEnvironmentManager.h" +#import @interface DOUpdateViewController () @@ -150,7 +151,19 @@ - (void)updateChangelog NSString *name = release[@"name"]; NSString *body = release[@"body"]; [changelogText appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"Version %@\n", name] attributes:@{NSFontAttributeName: [UIFont boldSystemFontOfSize:18], NSForegroundColorAttributeName : [UIColor whiteColor], NSParagraphStyleAttributeName:paragraphStyle}]]; - [changelogText appendAttributedString:[[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"\n%@\n\n\n", body] attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16], NSForegroundColorAttributeName : [UIColor whiteColor], NSParagraphStyleAttributeName:paragraphStyle}]]; + [changelogText appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]]; + + NSAttributedStringMarkdownParsingOptions *parsingOptions = [[NSAttributedStringMarkdownParsingOptions alloc] init]; + parsingOptions.allowsExtendedAttributes = YES; + parsingOptions.interpretedSyntax = NSAttributedStringMarkdownInterpretedSyntaxInlineOnlyPreservingWhitespace; + + NSMutableAttributedString *markdownStringMut = [[NSAttributedString alloc] initWithMarkdownString:body options:parsingOptions baseURL:nil error:nil].mutableCopy; + + [markdownStringMut addAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:16], NSForegroundColorAttributeName : [UIColor whiteColor], NSParagraphStyleAttributeName:paragraphStyle} range:NSMakeRange(0, markdownStringMut.length)]; + + [changelogText appendAttributedString:markdownStringMut]; + + [changelogText appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n\n\n"]]; if (idx == 0) { NSArray *assets = release[@"assets"]; diff --git a/Application/Dopamine/ko.lproj/Localizable.strings b/Application/Dopamine/ko.lproj/Localizable.strings index 27766e79e..f1236a608 100644 --- a/Application/Dopamine/ko.lproj/Localizable.strings +++ b/Application/Dopamine/ko.lproj/Localizable.strings @@ -41,7 +41,7 @@ "Settings_Tweak_Injection" = "트윅 주입"; "Settings_iDownload" = "iDownload (개발자 터미널)"; "Settings_Verbose_Logs" = "로그"; -/*Settings_Apps_JIT*/ +"Settings_Apps_JIT" = "앱에서 JIT 사용 허용"; // Settings Buttons "Button_Remove_Jailbreak" = "탈옥 제거"; @@ -49,13 +49,13 @@ "Button_Unhide_Jailbreak" = "탈옥 숨기기 취소"; "Button_Refresh_Jailbreak_Apps" = "탈옥 앱 새로고침"; "Button_Reinstall_Package_Managers" = "패키지 매니저 재설치"; -/*Button_Change_Mobile_Password*/ +"Button_Change_Mobile_Password" = "\"mobile\" 비밀번호 변경"; // Settings Hints "Hint_Hide_Jailbreak" = "\"탈옥 숨기기\"는 다음 탈옥까지 일시적으로 탈옥 관련 파일을 제거합니다."; "Hint_Hide_Jailbreak_Jailbroken" = "\"탈옥 숨기기\"는 탈옥기능을 부분적으로 비활성화해 탐지를 더 어렵게 만드는 것을 목표로 합니다. 그러나, 모두 우회가 되는건 아니며 모든 것을 숨기는 것은 아닙니다."; "Section_Jailbreak_Settings" = "탈옥 설정"; -"Section_Actions" = "동작"; +"Section_Actions" = "작업"; "Section_Customization" = "커스텀"; "Section_Exploits" = "익스플로잇"; @@ -67,10 +67,10 @@ "Alert_Remove_Jailbreak_Title" = "탈옥 제거"; "Alert_Remove_Jailbreak_Pressed_Body" = "탈옥을 제거하면 탈옥 관련 파일은 모두 삭제되지만 일반 앱, 파일 및 데이터는 모두 유지됩니다. 계속하시겠습니까? 이 작업은 돌이킬 수 없습니다."; "Alert_Remove_Jailbreak_Enabled_Body" = "\"탈옥 제거\"를 활성화하면 다음 탈옥 시 모든 탈옥 관련 파일이 삭제되지만, 모든 일반 앱, 파일 및 데이터는 유지됩니다. 계속하시겠습니까? 이 작업은 돌이킬 수 없습니다."; -/*Alert_Change_Mobile_Password_Body*/ -/*Password_Placeholder*/ -/*Repeat_Password_Placeholder*/ -/*Button_Change*/ +"Alert_Change_Mobile_Password_Body" = "기기의 \"mobile\" 사용자의 비밀번호를 설정하세요. 이 비밀번호를 sudo에 사용하여 루트 권한에 접근할 수 있습니다. 루트 비밀번호를 설정하고 싶다면 모바일 셸(터미널)에서 \"sudo passwd root\" 명령어를 사용해 설정할 수 있습니다."; +"Password_Placeholder" = "비밀번호"; +"Repeat_Password_Placeholder" = "비밀번호 확인"; +"Button_Change" = "변경"; "Button_Cancel" = "취소"; "Button_Continue" = "계속"; @@ -84,8 +84,8 @@ "Kernel Exploit" = "커널 익스플로잇"; "PPL Bypass" = "PPL 우회"; "PAC Bypass" = "PAC 우회"; -/*None*/ -/*Recommended*/ +"None" = "없음"; +"Recommended" = "권장됨"; // Credits "Credits_Button_Discord" = "Discord"; @@ -93,8 +93,8 @@ "Credits_Button_Source_Code" = "소스코드"; // Logs -"Initializing Environment" = "환경 초기화 중"; -/*Initializing Protection*/ +"Initializing Environment" = "환경 초기화"; +"Initializing Protection" = "보안 초기화"; "Loading BaseBin TrustCache" = "배이스 바이너리 신뢰 캐시 불러오기"; "Applying Bind Mount" = "바인드 마운트 적용"; "Removing Jailbreak" = "탈옥 제거"; @@ -109,6 +109,5 @@ // Package Manager selection "Status_Title_Select_Package_Managers" = "패키지 매니저 선택"; -"Select_Package_Managers_Install_Message" = "어떤 것을 선택할지 확실하지 않은 경우 Sileo를 선택하세요."; +"Select_Package_Managers_Install_Message" = "어떤 것을 선택할지 모르겠다면 Sileo를 선택하세요."; "Continue" = "계속"; - diff --git a/BaseBin/ChOma b/BaseBin/ChOma index 4ad4a014e..96000d80c 160000 --- a/BaseBin/ChOma +++ b/BaseBin/ChOma @@ -1 +1 @@ -Subproject commit 4ad4a014e0e4315d20e2cedc6afe3ad08620c467 +Subproject commit 96000d80c62f407ef7e103dc3bcb29133a3b990d diff --git a/BaseBin/XPF b/BaseBin/XPF index d9217bb71..cb71150f5 160000 --- a/BaseBin/XPF +++ b/BaseBin/XPF @@ -1 +1 @@ -Subproject commit d9217bb7186f21d11564c837bf2a18a7cd59b566 +Subproject commit cb71150f59fb4ee217baf77947d8986eafe682ca diff --git a/BaseBin/_external/basebin/.version b/BaseBin/_external/basebin/.version index cd57a8b95..04b10b4f1 100644 --- a/BaseBin/_external/basebin/.version +++ b/BaseBin/_external/basebin/.version @@ -1 +1 @@ -2.1.5 +2.1.7 diff --git a/BaseBin/_external/include/CoreServices/LSApplicationProxy.h b/BaseBin/_external/include/CoreServices/LSApplicationProxy.h index d8c0faa14..809ed166c 100644 --- a/BaseBin/_external/include/CoreServices/LSApplicationProxy.h +++ b/BaseBin/_external/include/CoreServices/LSApplicationProxy.h @@ -2,4 +2,5 @@ @interface LSApplicationProxy : LSBundleProxy @property (getter=isInstalled,nonatomic,readonly) BOOL installed; + (instancetype)applicationProxyForIdentifier:(NSString *)identifier; +@property (nonatomic,readonly) NSSet * claimedURLSchemes; @end \ No newline at end of file diff --git a/BaseBin/launchdhook/src/jbserver/jbdomain_platform.c b/BaseBin/launchdhook/src/jbserver/jbdomain_platform.c index 46383856a..a6cd5fed3 100644 --- a/BaseBin/launchdhook/src/jbserver/jbdomain_platform.c +++ b/BaseBin/launchdhook/src/jbserver/jbdomain_platform.c @@ -35,19 +35,8 @@ static int platform_jbsettings_get(const char *key, xpc_object_t *valueOut) return 0; } else if(strcmp(key, "DevMode")==0) { - int state = 1; - uint64_t developer_mode_state = kread64(ksymbol(developer_mode_enabled)); - if ((developer_mode_state & 0xff) == 0 || (developer_mode_state & 0xff) == 1) { - // On iOS 16.0 - 16.3, developer_mode_state is a bool - state = (uint8_t)developer_mode_state; - } - else { - // On iOS 16.4+, developer_mode_state is a pointer to a bool - uint8_t devmode = kread8(developer_mode_state); - if(devmode==0 || devmode==1) { - state = devmode; - } - } + uint64_t developer_mode_storage = kread64(ksymbol(developer_mode_enabled)); + int state = kread8(developer_mode_storage); *valueOut = xpc_bool_create(state); return 0; } @@ -62,17 +51,8 @@ static int platform_jbsettings_set(const char *key, xpc_object_t value) } else if(strcmp(key, "DevMode")==0 && xpc_get_type(value) == XPC_TYPE_BOOL) { int state = xpc_bool_get_value(value); - uint64_t developer_mode_state = kread64(ksymbol(developer_mode_enabled)); - if ((developer_mode_state & 0xff) == 0 || (developer_mode_state & 0xff) == 1) { - // On iOS 16.0 - 16.3, developer_mode_state is a bool - if (developer_mode_state != state) { - kwrite8(ksymbol(developer_mode_enabled), state); - } - } - else if (kread8(developer_mode_state) != state) { - // On iOS 16.4+, developer_mode_state is a pointer to a bool - kwrite8(developer_mode_state, state); - } + uint64_t developer_mode_storage = kread64(ksymbol(developer_mode_enabled)); + kwrite8(developer_mode_storage, state); return 0; } return -1; diff --git a/BaseBin/launchdhook/src/main.m b/BaseBin/launchdhook/src/main.m index b2b15a2e3..1c6b0f9c5 100644 --- a/BaseBin/launchdhook/src/main.m +++ b/BaseBin/launchdhook/src/main.m @@ -24,9 +24,107 @@ void abort_with_reason(uint32_t reason_namespace, uint64_t reason_code, const char *reason_string, uint64_t reason_flags); +/*struct dyld_cache_header +{ + char magic[16]; // e.g. "dyld_v0 i386" + uint32_t mappingOffset; // file offset to first dyld_cache_mapping_info + uint32_t mappingCount; // number of dyld_cache_mapping_info entries + uint32_t imagesOffset; // file offset to first dyld_cache_image_info + uint32_t imagesCount; // number of dyld_cache_image_info entries + uint64_t dyldBaseAddress; // base address of dyld when cache was built + uint64_t codeSignatureOffset; // file offset of code signature blob + uint64_t codeSignatureSize; // size of code signature blob (zero means to end of file) + uint64_t slideInfoOffsetUnused; // unused. Used to be file offset of kernel slid info + uint64_t slideInfoSizeUnused; // unused. Used to be size of kernel slid info + uint64_t localSymbolsOffset; // file offset of where local symbols are stored + uint64_t localSymbolsSize; // size of local symbols information + uint8_t uuid[16]; // unique value for each shared cache file + uint64_t cacheType; // 0 for development, 1 for production + uint32_t branchPoolsOffset; // file offset to table of uint64_t pool addresses + uint32_t branchPoolsCount; // number of uint64_t entries + uint64_t accelerateInfoAddr; // (unslid) address of optimization info + uint64_t accelerateInfoSize; // size of optimization info + uint64_t imagesTextOffset; // file offset to first dyld_cache_image_text_info + uint64_t imagesTextCount; // number of dyld_cache_image_text_info entries + uint64_t patchInfoAddr; // (unslid) address of dyld_cache_patch_info + uint64_t patchInfoSize; // Size of all of the patch information pointed to via the dyld_cache_patch_info + uint64_t otherImageGroupAddrUnused; // unused + uint64_t otherImageGroupSizeUnused; // unused + uint64_t progClosuresAddr; // (unslid) address of list of program launch closures + uint64_t progClosuresSize; // size of list of program launch closures + uint64_t progClosuresTrieAddr; // (unslid) address of trie of indexes into program launch closures + uint64_t progClosuresTrieSize; // size of trie of indexes into program launch closures + uint32_t platform; // platform number (macOS=1, etc) + uint32_t formatVersion : 8, // dyld3::closure::kFormatVersion + dylibsExpectedOnDisk : 1, // dyld should expect the dylib exists on disk and to compare inode/mtime to see if cache is valid + simulator : 1, // for simulator of specified platform + locallyBuiltCache : 1, // 0 for B&I built cache, 1 for locally built cache + builtFromChainedFixups : 1, // some dylib in cache was built using chained fixups, so patch tables must be used for overrides + padding : 20; // TBD + uint64_t sharedRegionStart; // base load address of cache if not slid + uint64_t sharedRegionSize; // overall size of region cache can be mapped into + uint64_t maxSlide; // runtime slide of cache can be between zero and this value + uint64_t dylibsImageArrayAddr; // (unslid) address of ImageArray for dylibs in this cache + uint64_t dylibsImageArraySize; // size of ImageArray for dylibs in this cache + uint64_t dylibsTrieAddr; // (unslid) address of trie of indexes of all cached dylibs + uint64_t dylibsTrieSize; // size of trie of cached dylib paths + uint64_t otherImageArrayAddr; // (unslid) address of ImageArray for dylibs and bundles with dlopen closures + uint64_t otherImageArraySize; // size of ImageArray for dylibs and bundles with dlopen closures + uint64_t otherTrieAddr; // (unslid) address of trie of indexes of all dylibs and bundles with dlopen closures + uint64_t otherTrieSize; // size of trie of dylibs and bundles with dlopen closures + uint32_t mappingWithSlideOffset; // file offset to first dyld_cache_mapping_and_slide_info + uint32_t mappingWithSlideCount; // number of dyld_cache_mapping_and_slide_info entries +}; + +struct dyld_cache_mapping_info { + uint64_t address; + uint64_t size; + uint64_t fileOffset; + uint32_t maxProt; + uint32_t initProt; +}; + +void lockDSCText(const char *dscPath) +{ + int fd = open(dscPath, O_RDONLY); + if (fd >= 0) { + struct stat sb; + if (fstat(fd, &sb) == 0) { + void *localMap = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); + struct dyld_cache_header *header = (struct dyld_cache_header *)localMap; + for (uint32_t i = 0; i < header->mappingCount; i++) { + uint32_t curMappingOff = header->mappingOffset + (i * sizeof(struct dyld_cache_mapping_info)); + struct dyld_cache_mapping_info *curMapping = (struct dyld_cache_mapping_info *)(((uint64_t)localMap) + curMappingOff); + + //printf("fileOffset: %llx, address: %llx, size: %llx, initProt: %c%c%c, maxProt: %c%c%c\n", curMapping->fileOffset, curMapping->address, curMapping->size, curMapping->initProt & PROT_READ ? 'r' : '-', curMapping->initProt & PROT_WRITE ? 'w' : '-', curMapping->initProt & PROT_EXEC ? 'x' : '-', curMapping->maxProt & PROT_READ ? 'r' : '-', curMapping->maxProt & PROT_WRITE ? 'w' : '-', curMapping->maxProt & PROT_EXEC ? 'x' : '-'); + + if (curMapping->initProt & PROT_EXEC) { + printf("%s locking down %llx -> %llx\n", dscPath, curMapping->fileOffset, curMapping->fileOffset + curMapping->size); + int r = mlock(((void *)(uint64_t)localMap + curMapping->fileOffset), curMapping->size); + printf("mlock => %d\n", r); + } + } + } + close(fd); + } +} + +void lockAllDSCText(void) +{ + @autoreleasepool { + NSURL *dscURL = [NSURL fileURLWithPath:@"/System/Library/Caches/com.apple.dyld" isDirectory:YES]; + for (NSURL *partURL in [[NSFileManager defaultManager] contentsOfDirectoryAtURL:dscURL includingPropertiesForKeys:nil options:0 error:nil]) { + if (![partURL.pathExtension isEqualToString:@"symbols"]) { + lockDSCText(partURL.fileSystemRepresentation); + } + } + } +}*/ + __attribute__((constructor)) static void initializer(void) { crashreporter_start(); + //lockAllDSCText(); // If we performed a jbupdate before the userspace reboot, these vars will be set // In that case, we want to run finalizers diff --git a/BaseBin/launchdhook/src/spawn_hook.c b/BaseBin/launchdhook/src/spawn_hook.c index 4d3203ee5..858c4e579 100644 --- a/BaseBin/launchdhook/src/spawn_hook.c +++ b/BaseBin/launchdhook/src/spawn_hook.c @@ -6,7 +6,6 @@ #include "boomerang.h" #include "crashreporter.h" #include "update.h" -#include #include #include #include diff --git a/BaseBin/libjailbreak/src/info.h b/BaseBin/libjailbreak/src/info.h index eca4a2aae..d72939307 100644 --- a/BaseBin/libjailbreak/src/info.h +++ b/BaseBin/libjailbreak/src/info.h @@ -293,9 +293,6 @@ extern struct system_info gSystemInfo; #define JAILBREAK_SETTINGS_ITERATE(ctx, iterator) \ iterator(ctx, jailbreakSettings.markAppsAsDebugged); -#define JAILBREAK_SETTINGS_ITERATE(ctx, iterator) \ - iterator(ctx, jailbreakSettings.markAppsAsDebugged); - #define KERNEL_SYMBOLS_ITERATE(ctx, iterator) \ iterator(ctx, kernelSymbol.perfmon_dev_open); \ iterator(ctx, kernelSymbol.vn_kqfilter); \ diff --git a/BaseBin/libjailbreak/src/primitives_IOSurface.m b/BaseBin/libjailbreak/src/primitives_IOSurface.m index 842ce78b1..4fcb7841d 100644 --- a/BaseBin/libjailbreak/src/primitives_IOSurface.m +++ b/BaseBin/libjailbreak/src/primitives_IOSurface.m @@ -6,6 +6,7 @@ #import #import #import +#import uint64_t IOSurfaceRootUserClient_get_surfaceClientById(uint64_t rootUserClient, uint32_t surfaceId) { @@ -202,7 +203,10 @@ void libjailbreak_IOSurface_primitives_init(void) (__bridge NSString *)kIOSurfaceBytesPerElement : @4, }); if (!surfaceRef) { - printf("Failed to initialize IOSurface primitives, add \"IOSurfaceRootUserClient\" to the \"com.apple.security.exception.iokit-user-client-class\" dictionary of the binaries entitlements to fix this.\n"); + char execPath[PATH_MAX]; + uint32_t execPathSize = PATH_MAX; + _NSGetExecutablePath(execPath, &execPathSize); + printf("Failed to initialize IOSurface primitives, add \"IOSurfaceRootUserClient\" to the \"com.apple.security.exception.iokit-user-client-class\" dictionary of the entitlements from \"%s\" to fix this. Due to this, the kalloc, kmap and kcall primitives will not work.\n", execPath); return; } CFRelease(surfaceRef); diff --git a/BaseBin/rootlesshooks/cfprefsd.x b/BaseBin/rootlesshooks/cfprefsd.x index 388b2fab2..0042191b6 100644 --- a/BaseBin/rootlesshooks/cfprefsd.x +++ b/BaseBin/rootlesshooks/cfprefsd.x @@ -45,7 +45,6 @@ BOOL preferencePlistNeedsRedirection(NSString *plistPath) return ![additionalSystemPlistNames containsObject:plistName]; } - BOOL (*orig_CFPrefsGetPathForTriplet)(CFStringRef, CFStringRef, BOOL, CFStringRef, UInt8*); BOOL new_CFPrefsGetPathForTriplet(CFStringRef bundleIdentifier, CFStringRef user, BOOL byHost, CFStringRef path, UInt8 *buffer) { diff --git a/BaseBin/rootlesshooks/main.x b/BaseBin/rootlesshooks/main.x index a7f24a05c..c4b47493c 100644 --- a/BaseBin/rootlesshooks/main.x +++ b/BaseBin/rootlesshooks/main.x @@ -18,11 +18,11 @@ NSString* getProcessName() { NSLog(@"rootlesshooks coming... %@", safe_getExecutablePath()); NSString *processName = getProcessName(); - if ([processName isEqualToString:@"installd"]) { + /*if ([processName isEqualToString:@"installd"]) { extern void installdInit(void); - //installdInit(); + installdInit(); } - else if ([processName isEqualToString:@"cfprefsd"]) { + else*/ if ([processName isEqualToString:@"cfprefsd"]) { extern void cfprefsdInit(void); cfprefsdInit(); } diff --git a/BaseBin/systemhook/src/common.h b/BaseBin/systemhook/src/common.h index 184ce1578..8802865fa 100644 --- a/BaseBin/systemhook/src/common.h +++ b/BaseBin/systemhook/src/common.h @@ -10,13 +10,6 @@ extern char HOOK_DYLIB_PATH[]; extern char *JB_BootUUID; extern char *JB_RootPath; -#define JBRootPath(path) ({ \ - char *outPath = alloca(PATH_MAX); \ - strlcpy(outPath, JB_RootPath, PATH_MAX); \ - strlcat(outPath, path, PATH_MAX); \ - (outPath); \ -}) - bool stringStartsWith(const char *str, const char* prefix); bool stringEndsWith(const char* str, const char* suffix); diff --git a/BaseBin/systemhook/src/main.c b/BaseBin/systemhook/src/main.c index de3d9e13b..993d09051 100644 --- a/BaseBin/systemhook/src/main.c +++ b/BaseBin/systemhook/src/main.c @@ -25,6 +25,13 @@ int necp_session_action(int necp_fd, uint32_t action, uint8_t *in_buffer, size_t #define SYSCALL_NECP_SESSION_OPEN 0x20A #define SYSCALL_NECP_SESSION_ACTION 0x20B +#define JBRootPath(path) ({ \ + char *outPath = alloca(PATH_MAX); \ + strlcpy(outPath, JB_RootPath, PATH_MAX); \ + strlcat(outPath, path, PATH_MAX); \ + (outPath); \ +}) + extern char **environ; bool gShouldFixFork = false; bool gFullyDebugged = false; diff --git a/LICENSE.md b/LICENSE.md index 375556325..3e876146d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/Packages/.gitignore b/Packages/.gitignore index 4eec8f301..0dcd0fd04 100644 --- a/Packages/.gitignore +++ b/Packages/.gitignore @@ -1,3 +1,3 @@ -libkrw-provider/libkrw-plugin.* +libkrw-provider/libkrw-dopamine.* libroot/libroot.* basebin-link/basebin-link.* \ No newline at end of file diff --git a/Packages/libkrw-provider/Makefile b/Packages/libkrw-provider/Makefile index 3d7a78683..80d3e6c4e 100644 --- a/Packages/libkrw-provider/Makefile +++ b/Packages/libkrw-provider/Makefile @@ -1,4 +1,4 @@ -TARGET = libkrw-plugin.dylib +TARGET = libkrw-dopamine.dylib CC = clang CFLAGS = -I../../BaseBin/.include -Isrc -isysroot $(shell xcrun --sdk iphoneos --show-sdk-path) -arch arm64 -arch arm64e -miphoneos-version-min=15.0 -fobjc-arc -O2 @@ -15,12 +15,12 @@ $(TARGET): $(wildcard src/*.c) clean: @rm -f $(TARGET) - @rm -f libkrw-plugin.deb + @rm -f libkrw-dopamine.deb package: all @mkdir -p .package/DEBIAN @mkdir -p .package/usr/lib/libkrw @cp control .package/DEBIAN/control - @cp libkrw-plugin.dylib .package/usr/lib/libkrw/libkrw-plugin.dylib - @dpkg-deb --root-owner-group -Zzstd -b .package ./libkrw-plugin.deb + @cp libkrw-dopamine.dylib .package/usr/lib/libkrw/libkrw-dopamine.dylib + @dpkg-deb --root-owner-group -Zzstd -b .package ./libkrw-dopamine.deb @rm -rf .package diff --git a/Packages/libkrw-provider/control b/Packages/libkrw-provider/control index 87aa4f6ec..f91cbd860 100644 --- a/Packages/libkrw-provider/control +++ b/Packages/libkrw-provider/control @@ -5,7 +5,7 @@ Maintainer: opa334 Architecture: iphoneos-arm64e Version: 2.0.1 Provides: libkrw0-plugin -Depends: libiosexec1 (>= 1.3.1), libkrw0 +Depends: libiosexec1 (>= 1.3.1) Section: Libraries Priority: standard Homepage: https://github.com/opa334/Dopamine/tree/main/Packages/libkrw-provider diff --git a/Packages/libkrw-provider/src/main.c b/Packages/libkrw-provider/src/main.c index a57583c7c..8b93261d1 100644 --- a/Packages/libkrw-provider/src/main.c +++ b/Packages/libkrw-provider/src/main.c @@ -1,8 +1,9 @@ #include #include #include +#include -void load_primitives_once(void) +static void load_primitives_once(void) { static dispatch_once_t onceToken; dispatch_once (&onceToken, ^{ @@ -10,33 +11,36 @@ void load_primitives_once(void) }); } -int kwritebuf_wrapper(void *from, uint64_t to, size_t len) +static int kwritebuf_wrapper(void *from, uint64_t to, size_t len) { return kwritebuf(to, from, len); } -int kcall_wrapper(uint64_t func, size_t argc, const uint64_t *argv, uint64_t *ret) +static int kcall_wrapper(uint64_t func, size_t argc, const uint64_t *argv, uint64_t *ret) { - return kcall(ret, func, argc, argv); + if (jbinfo(usesPACBypass)) { + return kcall(ret, func, argc, argv); + } + return ENOTSUP; } -int physreadbuf_wrapper(uint64_t from, void *to, size_t len, uint8_t granule) +static int physreadbuf_wrapper(uint64_t from, void *to, size_t len, uint8_t granule) { return physreadbuf(from, to, len); } -int physwritebuf_wrapper(void *from, uint64_t to, size_t len, uint8_t granule) +static int physwritebuf_wrapper(void *from, uint64_t to, size_t len, uint8_t granule) { return physwritebuf(to, from, len); } -int kbase_wrapper(uint64_t *kbase) +static int kbase_wrapper(uint64_t *kbase) { *kbase = kconstant(base); return 0; } -__attribute__((used)) krw_plugin_initializer_t krw_initializer(krw_handlers_t handlers) +__attribute__((used)) int krw_initializer(krw_handlers_t handlers) { load_primitives_once(); @@ -48,14 +52,11 @@ __attribute__((used)) krw_plugin_initializer_t krw_initializer(krw_handlers_t ha return 0; } -__attribute__((used)) krw_plugin_initializer_t kcall_initializer(krw_handlers_t handlers) +__attribute__((used)) int kcall_initializer(krw_handlers_t handlers) { load_primitives_once(); - if (jbinfo(usesPACBypass)) { - handlers->kcall = kcall_wrapper; - } - + handlers->kcall = kcall_wrapper; handlers->physread = physreadbuf_wrapper; handlers->physwrite = physwritebuf_wrapper; return 0;