-
Notifications
You must be signed in to change notification settings - Fork 8
/
SideloadedFixes.x
91 lines (69 loc) · 2.05 KB
/
SideloadedFixes.x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#import <mach-o/dyld.h>
#import <Foundation/Foundation.h>
// Credit goes to opa334 and his code: https://github.com/opa334/IGSideloadFix
NSString* keychainAccessGroup;
NSURL* fakeGroupContainerURL;
void createDirectoryIfNotExists(NSURL* URL)
{
if(![URL checkResourceIsReachableAndReturnError:nil])
{
[[NSFileManager defaultManager] createDirectoryAtURL:URL withIntermediateDirectories:YES attributes:nil error:nil];
}
}
%group SideloadedFixes
%hook NSFileManager
- (NSURL*)containerURLForSecurityApplicationGroupIdentifier:(NSString*)groupIdentifier
{
NSURL* fakeURL = [fakeGroupContainerURL URLByAppendingPathComponent:groupIdentifier];
createDirectoryIfNotExists(fakeURL);
createDirectoryIfNotExists([fakeURL URLByAppendingPathComponent:@"Library"]);
createDirectoryIfNotExists([fakeURL URLByAppendingPathComponent:@"Library/Caches"]);
return fakeURL;
}
%end
void loadKeychainAccessGroup()
{
NSDictionary* dummyItem = @{
(__bridge id)kSecClass : (__bridge id)kSecClassGenericPassword,
(__bridge id)kSecAttrAccount : @"dummyItem",
(__bridge id)kSecAttrService : @"dummyService",
(__bridge id)kSecReturnAttributes : @YES,
};
CFTypeRef result;
OSStatus ret = SecItemCopyMatching((__bridge CFDictionaryRef)dummyItem, &result);
if(ret == -25300)
{
ret = SecItemAdd((__bridge CFDictionaryRef)dummyItem, &result);
}
if(ret == 0 && result)
{
NSDictionary* resultDict = (__bridge id)result;
keychainAccessGroup = resultDict[(__bridge id)kSecAttrAccessGroup];
NSLog(@"loaded keychainAccessGroup: %@", keychainAccessGroup);
}
}
%hook FBSDKKeychainStore
- (NSString*)accessGroup
{
return keychainAccessGroup;
}
%end
%hook FBKeychainItemController
- (NSString*)accessGroup
{
return keychainAccessGroup;
}
%end
%hook UICKeyChainStore
- (NSString*)accessGroup
{
return keychainAccessGroup;
}
%end
%end
void initSideloadedFixes()
{
fakeGroupContainerURL = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/FakeGroupContainers"] isDirectory:YES];
loadKeychainAccessGroup();
%init(SideloadedFixes);
}