Skip to content

Commit

Permalink
Merge branch 'opa334:2.1' into 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
m1337v authored Apr 23, 2024
2 parents 928ec07 + 16663ae commit bcc3354
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 44 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ xcshareddata/
DerivedData/
.swiftpm/xcode/
/Package.resolved
/Server/orig.ipa
/Server/serverCert/fullchain.cer
/Server/serverCert/server.key
Dopamine/Dopamine/bootstrap/tmp/
Application/Payload
.idea
Tools/fastPathSign/.build_*
Exploits/kfd/kfd.framework/kfd
24 changes: 12 additions & 12 deletions Application/Dopamine.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
04DD0B442B7CBE2E0055DE4F /* DOThemeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 04DD0B432B7CBE2E0055DE4F /* DOThemeManager.m */; };
04DD0B472B7CBEEA0055DE4F /* DOTheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 04DD0B462B7CBEEA0055DE4F /* DOTheme.m */; };
04DD0B592B7D19E60055DE4F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 04DD0B5B2B7D19E60055DE4F /* Localizable.strings */; };
51F19D052BBF456200896361 /* libpartial.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 51AB98D92BBF44390042EA7B /* libpartial.a */; };
8C029F432B4DFD5D0071DE58 /* DOExploitManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C029F422B4DFD5D0071DE58 /* DOExploitManager.m */; };
8C029F462B4DFD910071DE58 /* DOBootstrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C029F452B4DFD910071DE58 /* DOBootstrapper.m */; };
8C029F4E2B4E1FF30071DE58 /* DOExploit.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C029F4D2B4E1FF30071DE58 /* DOExploit.m */; };
Expand Down Expand Up @@ -80,6 +81,7 @@
8C2131A12B50CA4B008E682C /* perf.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C21318E2B50CA4B008E682C /* perf.h */; };
8C2131A22B50CA4B008E682C /* info.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C21318F2B50CA4B008E682C /* info.h */; };
8C2131A32B50CA4B008E682C /* libkfd.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C2131902B50CA4B008E682C /* libkfd.h */; };
8C2875212BD850B4008B24DA /* LICENSE_libgrabkernel2.md in Resources */ = {isa = PBXBuildFile; fileRef = 8C2875202BD850B4008B24DA /* LICENSE_libgrabkernel2.md */; };
8C2B1FEA2B53238D009BA166 /* libjailbreak.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD08422B4F6DD800A32B61 /* libjailbreak.dylib */; platformFilter = ios; };
8C2B1FF02B5324DE009BA166 /* dmaFail.h in Headers */ = {isa = PBXBuildFile; fileRef = 8C2B1FEF2B5324DE009BA166 /* dmaFail.h */; };
8C2B1FF42B53492B009BA166 /* dmaFail.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8C2B1FDF2B532374009BA166 /* dmaFail.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -120,9 +122,7 @@
8CDD08342B4F63E100A32B61 /* kfd.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CDD07B32B4F639100A32B61 /* kfd.m */; };
8CDD08362B4F682000A32B61 /* IOSurface.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD08352B4F682000A32B61 /* IOSurface.framework */; };
8CDD08382B4F682500A32B61 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD08372B4F682500A32B61 /* IOKit.framework */; };
8CDD083F2B4F6D8700A32B61 /* libcurl.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD08392B4F6D8200A32B61 /* libcurl.a */; };
8CDD08402B4F6D8700A32B61 /* libfragmentzip.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD083A2B4F6D8200A32B61 /* libfragmentzip.a */; };
8CDD08412B4F6D8700A32B61 /* libgrabkernel.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD083B2B4F6D8200A32B61 /* libgrabkernel.a */; };
8CDD08412B4F6D8700A32B61 /* libgrabkernel2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD083B2B4F6D8200A32B61 /* libgrabkernel2.a */; };
8CDD08462B4F6DD800A32B61 /* libchoma.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD08432B4F6DD800A32B61 /* libchoma.dylib */; };
8CDD08472B4F6DD800A32B61 /* libxpf.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CDD08442B4F6DD800A32B61 /* libxpf.dylib */; };
8CDD08482B4F6DF100A32B61 /* libxpf.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 8CDD08442B4F6DD800A32B61 /* libxpf.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
Expand Down Expand Up @@ -285,6 +285,7 @@
04DD0B5A2B7D19E60055DE4F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
04DD0B5C2B7D1A210055DE4F /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Localizable.strings; sourceTree = "<group>"; };
04DD0B5D2B7D1A210055DE4F /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
51AB98D92BBF44390042EA7B /* libpartial.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libpartial.a; path = Dopamine/Dependencies/libpartial.a; sourceTree = "<group>"; };
8C029F412B4DFD5D0071DE58 /* DOExploitManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOExploitManager.h; sourceTree = "<group>"; };
8C029F422B4DFD5D0071DE58 /* DOExploitManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DOExploitManager.m; sourceTree = "<group>"; };
8C029F442B4DFD910071DE58 /* DOBootstrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOBootstrapper.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -323,6 +324,7 @@
8C21318E2B50CA4B008E682C /* perf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = perf.h; sourceTree = "<group>"; };
8C21318F2B50CA4B008E682C /* info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = info.h; sourceTree = "<group>"; };
8C2131902B50CA4B008E682C /* libkfd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libkfd.h; sourceTree = "<group>"; };
8C2875202BD850B4008B24DA /* LICENSE_libgrabkernel2.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = LICENSE_libgrabkernel2.md; sourceTree = "<group>"; };
8C2B1FC72B52FB56009BA166 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8C2B1FDF2B532374009BA166 /* dmaFail.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = dmaFail.framework; sourceTree = BUILT_PRODUCTS_DIR; };
8C2B1FEF2B5324DE009BA166 /* dmaFail.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dmaFail.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -370,9 +372,7 @@
8CDD07B32B4F639100A32B61 /* kfd.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = kfd.m; sourceTree = "<group>"; };
8CDD08352B4F682000A32B61 /* IOSurface.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOSurface.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/IOSurface.framework; sourceTree = DEVELOPER_DIR; };
8CDD08372B4F682500A32B61 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/IOKit.framework; sourceTree = DEVELOPER_DIR; };
8CDD08392B4F6D8200A32B61 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = Dopamine/Dependencies/libcurl.a; sourceTree = "<group>"; };
8CDD083A2B4F6D8200A32B61 /* libfragmentzip.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfragmentzip.a; path = Dopamine/Dependencies/libfragmentzip.a; sourceTree = "<group>"; };
8CDD083B2B4F6D8200A32B61 /* libgrabkernel.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgrabkernel.a; path = Dopamine/Dependencies/libgrabkernel.a; sourceTree = "<group>"; };
8CDD083B2B4F6D8200A32B61 /* libgrabkernel2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgrabkernel2.a; path = Dopamine/Dependencies/libgrabkernel2.a; sourceTree = "<group>"; };
8CDD08422B4F6DD800A32B61 /* libjailbreak.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libjailbreak.dylib; path = ../BaseBin/.build/libjailbreak.dylib; sourceTree = "<group>"; };
8CDD08432B4F6DD800A32B61 /* libchoma.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libchoma.dylib; path = ../BaseBin/.build/libchoma.dylib; sourceTree = "<group>"; };
8CDD08442B4F6DD800A32B61 /* libxpf.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxpf.dylib; path = ../BaseBin/.build/libxpf.dylib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -406,11 +406,10 @@
8CC139832B53E05300230143 /* IOKit.framework in Frameworks */,
8C029F682B4E31D50071DE58 /* libMobileGestalt.tbd in Frameworks */,
8C46D7252B588973002899DB /* libzstd in Frameworks */,
8CDD08412B4F6D8700A32B61 /* libgrabkernel.a in Frameworks */,
8CDD08412B4F6D8700A32B61 /* libgrabkernel2.a in Frameworks */,
51F19D052BBF456200896361 /* libpartial.a in Frameworks */,
042479E52B66B0DD0082581B /* Preferences.framework in Frameworks */,
8CDD08402B4F6D8700A32B61 /* libfragmentzip.a in Frameworks */,
8C029F662B4E2E970071DE58 /* libcompression.tbd in Frameworks */,
8CDD083F2B4F6D8700A32B61 /* libcurl.a in Frameworks */,
8C58E5592B7EAF8000E3ADAA /* CoreServices.framework in Frameworks */,
8C4ABEB62B52094100B43C9B /* libjailbreak.dylib in Frameworks */,
);
Expand Down Expand Up @@ -612,6 +611,7 @@
8C029F642B4E2E7D0071DE58 /* Frameworks */ = {
isa = PBXGroup;
children = (
51AB98D92BBF44390042EA7B /* libpartial.a */,
8C58E5582B7EAF8000E3ADAA /* CoreServices.framework */,
042479E42B66B0DD0082581B /* Preferences.framework */,
8CDD08372B4F682500A32B61 /* IOKit.framework */,
Expand All @@ -621,9 +621,7 @@
8CDD08442B4F6DD800A32B61 /* libxpf.dylib */,
8C029F672B4E31D50071DE58 /* libMobileGestalt.tbd */,
8C029F652B4E2E7D0071DE58 /* libcompression.tbd */,
8CDD08392B4F6D8200A32B61 /* libcurl.a */,
8CDD083A2B4F6D8200A32B61 /* libfragmentzip.a */,
8CDD083B2B4F6D8200A32B61 /* libgrabkernel.a */,
8CDD083B2B4F6D8200A32B61 /* libgrabkernel2.a */,
8C029F6A2B4E320E0071DE58 /* libz.tbd */,
);
name = Frameworks;
Expand Down Expand Up @@ -822,6 +820,7 @@
8C56D4B82B7C0DF2001C03D3 /* LICENSE_ChOma.md */,
8C56D4BA2B7C0DF2001C03D3 /* LICENSE_dimentio.md */,
8C56D4BC2B7C0DF2001C03D3 /* LICENSE_ElleKit.md */,
8C2875202BD850B4008B24DA /* LICENSE_libgrabkernel2.md */,
8C56D4B92B7C0DF2001C03D3 /* LICENSE_Fugu15_Rootful.md */,
8C56D4BB2B7C0DF2001C03D3 /* LICENSE_Fugu15.md */,
8C56D4BE2B7C0DF2001C03D3 /* LICENSE_opainject.md */,
Expand Down Expand Up @@ -1089,6 +1088,7 @@
8C05C5A02B75A17A0097A931 /* bootstrap_1900.tar.zst in Resources */,
8C05C59F2B75A1770097A931 /* bootstrap_1800.tar.zst in Resources */,
042479A42B66916B0082581B /* Credits.plist in Resources */,
8C2875212BD850B4008B24DA /* LICENSE_libgrabkernel2.md in Resources */,
8C512B912B5C9F9100C6F14A /* sileo.deb in Resources */,
8C512B922B5C9F9400C6F14A /* zebra.deb in Resources */,
8CCD8A872B6F16CC004B72B0 /* libkrw-plugin.deb in Resources */,
Expand Down
Binary file removed Application/Dopamine/Dependencies/libcurl.a
Binary file not shown.
Binary file removed Application/Dopamine/Dependencies/libfragmentzip.a
Binary file not shown.
Binary file removed Application/Dopamine/Dependencies/libgrabkernel.a
Binary file not shown.
Binary file not shown.
Binary file added Application/Dopamine/Dependencies/libpartial.a
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void smith_free(struct kfd* kfd)
*/
void smith_helper_init(struct kfd* kfd)
{
const u64 target_hole_size = pages(0);
const u64 target_hole_size = pages(10000);
bool found_target_hole = false;

struct smith_data* smith = (struct smith_data*)(kfd->puaf.puaf_method_data);
Expand Down
21 changes: 16 additions & 5 deletions Application/Dopamine/Exploits/kfd/kfd.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ int exploit_init(const char *flavor)

uint64_t vm_map__pmap = koffsetof(vm_map, pmap);

uint64_t pmap_to_hint = 0; // offset between vm_map->pmap and vm_map->hint
if (@available(iOS 16.0, *)) {
pmap_to_hint = 0x58;
}
else if(@available(iOS 15.4, *)) {
pmap_to_hint = 0x38;
}
else {
pmap_to_hint = 0xB8;
}

dynamic_system_info = (struct dynamic_info){
.kread_kqueue_workloop_ctl_supported = true,
.krkw_iosurface_supported = (kread_method == kread_IOSurface),
Expand All @@ -171,11 +182,11 @@ int exploit_init(const char *flavor)
.vm_map__hdr_nentries_u64 = koffsetof(vm_map, hdr) + koffsetof(vm_map_header, links) + koffsetof(vm_map_links, max) + 0x8,
.vm_map__hdr_rb_head_store_rbh_root = koffsetof(vm_map, hdr) + koffsetof(vm_map_header, links) + koffsetof(vm_map_links, max) + 0x18,

.vm_map__pmap = vm_map__pmap, // 0x48 or 0x40
.vm_map__hint = vm_map__pmap + 0x58, // 0xa0 or 0x98
.vm_map__hole_hint = vm_map__pmap + 0x60, // 0xa8 or 0xa0
.vm_map__holes_list = vm_map__pmap + 0x68, // 0xb0 or 0xa8
.vm_map__object_size = vm_map__pmap + 0x80, // 0xc8 or 0xc0
.vm_map__pmap = vm_map__pmap,
.vm_map__hint = vm_map__pmap + pmap_to_hint,
.vm_map__hole_hint = vm_map__pmap + pmap_to_hint + 0x8,
.vm_map__holes_list = vm_map__pmap + pmap_to_hint + 0x10,
.vm_map__object_size = vm_map__pmap + pmap_to_hint + 0x28,

.IOSurface__isa = 0x0,
.IOSurface__pixelFormat = 0xa4,
Expand Down
4 changes: 2 additions & 2 deletions Application/Dopamine/Jailbreak/DOEnvironmentManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#import <sys/sysctl.h>
#import <mach-o/dyld.h>
#import <libgrabkernel/libgrabkernel.h>
#import <libgrabkernel2/libgrabkernel2.h>
#import <libjailbreak/info.h>
#import <libjailbreak/codesign.h>
#import <libjailbreak/util.h>
Expand Down Expand Up @@ -539,7 +539,7 @@ - (NSString *)accessibleKernelPath
[[DOUIManager sharedInstance] sendLog:@"Downloading Kernel" debug:NO];
NSString *kernelcachePath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/kernelcache"];
if (![[NSFileManager defaultManager] fileExistsAtPath:kernelcachePath]) {
if (grabkernel((char *)kernelcachePath.fileSystemRepresentation, 0) != 0) return nil;
if (grab_kernelcache(kernelcachePath) == false) return nil;
}
return kernelcachePath;
}
Expand Down
2 changes: 0 additions & 2 deletions Application/Dopamine/Jailbreak/DOExploitManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#import "DOEnvironmentManager.h"
#import "DOPreferenceManager.h"

#import <libgrabkernel/libgrabkernel.h>

#define FORCE_PAC_BYPASS 0

@implementation DOExploitManager
Expand Down
7 changes: 7 additions & 0 deletions Application/Dopamine/Resources/LICENSE_libgrabkernel2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2024 Alfie CG

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 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.
4 changes: 4 additions & 0 deletions Application/Dopamine/UI/Settings/DOLicenseViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ + (NSArray*)licenses
@"name": @"kfd",
@"file": @"LICENSE_kfd"
},
@{
@"name": @"libgrabkernel2",
@"file": @"LICENSE_libgrabkernel2"
},
@{
@"name": @"ElleKit",
@"file": @"LICENSE_ElleKit"
Expand Down
18 changes: 0 additions & 18 deletions BaseBin/_external/include/libgrabkernel/libgrabkernel.h

This file was deleted.

20 changes: 20 additions & 0 deletions BaseBin/_external/include/libgrabkernel2/libgrabkernel2.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// grabkernel.h
// libgrabkernel2
//
// Created by Alfie on 14/02/2024.
//

#ifndef grabkernel_h
#define grabkernel_h

#include <Foundation/Foundation.h>

bool download_kernelcache(NSString *zipURL, bool isOTA, NSString *outPath);
bool grab_kernelcache(NSString *outPath);

// libgrabkernel compatibility shim
// Note that research kernel grabbing is not currently supported
int grabkernel(char *downloadPath, int isResearchKernel);

#endif /* grabkernel_h */
2 changes: 1 addition & 1 deletion BaseBin/libjailbreak/src/primitives_IOSurface.m
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ void libjailbreak_IOSurface_primitives_init(void)
}
CFRelease(surfaceRef);

gPrimitives.kmap = IOSurface_map;
gPrimitives.kmap = IOSurface_map;
if (@available(iOS 16.0, *)) {}
else {
gPrimitives.kalloc_global = IOSurface_kalloc_global;
Expand Down

0 comments on commit bcc3354

Please sign in to comment.