forked from vlourme/BHInsta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSideloadFix.x
60 lines (56 loc) · 1.97 KB
/
SideloadFix.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
#import <Foundation/Foundation.h>
void createDirectoryIfNotExists(NSURL *URL) {
if (![URL checkResourceIsReachableAndReturnError:nil]) {
[[NSFileManager defaultManager] createDirectoryAtURL:URL withIntermediateDirectories:YES attributes:nil error:nil];
}
}
// Make keychain accesses and application group accesses work on sideloaded Instagram
NSString *keychainAccessGroup;
NSURL *fakeGroupContainerURL;
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 NSFileManager
- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString*)groupIdentifier {
NSURL *fakeURL = [fakeGroupContainerURL URLByAppendingPathComponent:groupIdentifier];
createDirectoryIfNotExists(fakeURL);
createDirectoryIfNotExists([fakeURL URLByAppendingPathComponent:@"Library"]);
createDirectoryIfNotExists([fakeURL URLByAppendingPathComponent:@"Library/Caches"]);
return fakeURL;
}
%end
%hook FBSDKKeychainStore
- (NSString*)accessGroup{
return keychainAccessGroup;
}
%end
%hook FBKeychainItemController
- (NSString*)accessGroup {
return keychainAccessGroup;
}
%end
%hook UICKeyChainStore
- (NSString*)accessGroup {
return keychainAccessGroup;
}
%end
%ctor {
fakeGroupContainerURL = [NSURL fileURLWithPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/FakeGroupContainers"] isDirectory:YES];
loadKeychainAccessGroup();
%init;
}