|
| 1 | +#import <UIKit/UIKit.h> |
| 2 | +#import <Foundation/Foundation.h> |
| 3 | +#import <dlfcn.h> |
| 4 | + |
| 5 | +#define YT_BUNDLE_ID @"com.google.ios.youtube" |
| 6 | +#define YT_NAME @"YouTube" |
| 7 | + |
| 8 | +@interface SSOConfiguration : NSObject |
| 9 | +@end |
| 10 | + |
| 11 | +%group gSideloading |
| 12 | +// Keychain patching |
| 13 | +static NSString *accessGroupID() { |
| 14 | + NSDictionary *query = [NSDictionary dictionaryWithObjectsAndKeys: |
| 15 | + (__bridge NSString *)kSecClassGenericPassword, (__bridge NSString *)kSecClass, |
| 16 | + @"bundleSeedID", kSecAttrAccount, |
| 17 | + @"", kSecAttrService, |
| 18 | + (id)kCFBooleanTrue, kSecReturnAttributes, |
| 19 | + nil]; |
| 20 | + CFDictionaryRef result = nil; |
| 21 | + OSStatus status = SecItemCopyMatching((__bridge CFDictionaryRef)query, (CFTypeRef *)&result); |
| 22 | + if (status == errSecItemNotFound) |
| 23 | + status = SecItemAdd((__bridge CFDictionaryRef)query, (CFTypeRef *)&result); |
| 24 | + if (status != errSecSuccess) |
| 25 | + return nil; |
| 26 | + NSString *accessGroup = [(__bridge NSDictionary *)result objectForKey:(__bridge NSString *)kSecAttrAccessGroup]; |
| 27 | + |
| 28 | + return accessGroup; |
| 29 | +} |
| 30 | + |
| 31 | +// IAmYouTube (https://github.com/PoomSmart/IAmYouTube/) |
| 32 | +%hook YTVersionUtils |
| 33 | ++ (NSString *)appName { return YT_NAME; } |
| 34 | ++ (NSString *)appID { return YT_BUNDLE_ID; } |
| 35 | +%end |
| 36 | + |
| 37 | +%hook GCKBUtils |
| 38 | ++ (NSString *)appIdentifier { return YT_BUNDLE_ID; } |
| 39 | +%end |
| 40 | + |
| 41 | +%hook GPCDeviceInfo |
| 42 | ++ (NSString *)bundleId { return YT_BUNDLE_ID; } |
| 43 | +%end |
| 44 | + |
| 45 | +%hook OGLBundle |
| 46 | ++ (NSString *)shortAppName { return YT_NAME; } |
| 47 | +%end |
| 48 | + |
| 49 | +%hook GVROverlayView |
| 50 | ++ (NSString *)appName { return YT_NAME; } |
| 51 | +%end |
| 52 | + |
| 53 | +%hook OGLPhenotypeFlagServiceImpl |
| 54 | +- (NSString *)bundleId { return YT_BUNDLE_ID; } |
| 55 | +%end |
| 56 | + |
| 57 | +%hook APMAEU |
| 58 | ++ (BOOL)isFAS { return YES; } |
| 59 | +%end |
| 60 | + |
| 61 | +%hook GULAppEnvironmentUtil |
| 62 | ++ (BOOL)isFromAppStore { return YES; } |
| 63 | +%end |
| 64 | + |
| 65 | +%hook SSOConfiguration |
| 66 | +- (id)initWithClientID:(id)clientID supportedAccountServices:(id)supportedAccountServices { |
| 67 | + self = %orig; |
| 68 | + [self setValue:YT_NAME forKey:@"_shortAppName"]; |
| 69 | + [self setValue:YT_BUNDLE_ID forKey:@"_applicationIdentifier"]; |
| 70 | + return self; |
| 71 | +} |
| 72 | +%end |
| 73 | + |
| 74 | +%hook NSBundle |
| 75 | +- (NSString *)bundleIdentifier { |
| 76 | + NSArray *address = [NSThread callStackReturnAddresses]; |
| 77 | + Dl_info info = {0}; |
| 78 | + if (dladdr((void *)[address[2] longLongValue], &info) == 0) |
| 79 | + return %orig; |
| 80 | + NSString *path = [NSString stringWithUTF8String:info.dli_fname]; |
| 81 | + if ([path hasPrefix:NSBundle.mainBundle.bundlePath]) |
| 82 | + return YT_BUNDLE_ID; |
| 83 | + return %orig; |
| 84 | +} |
| 85 | +- (id)objectForInfoDictionaryKey:(NSString *)key { |
| 86 | + if ([key isEqualToString:@"CFBundleIdentifier"]) |
| 87 | + return YT_BUNDLE_ID; |
| 88 | + if ([key isEqualToString:@"CFBundleDisplayName"] || [key isEqualToString:@"CFBundleName"]) |
| 89 | + return YT_NAME; |
| 90 | + return %orig; |
| 91 | +} |
| 92 | +// Fix Google Sign in by @PoomSmart and @level3tjg (qnblackcat/uYouPlus#684) |
| 93 | +- (NSDictionary *)infoDictionary { |
| 94 | + NSMutableDictionary *info = %orig.mutableCopy; |
| 95 | + NSString *altBundleIdentifier = info[@"ALTBundleIdentifier"]; |
| 96 | + if (altBundleIdentifier) info[@"CFBundleIdentifier"] = altBundleIdentifier; |
| 97 | + return info; |
| 98 | +} |
| 99 | +%end |
| 100 | + |
| 101 | +// Fix login for YouTube 18.13.2 and higher |
| 102 | +%hook SSOKeychainHelper |
| 103 | ++ (NSString *)accessGroup { |
| 104 | + return accessGroupID(); |
| 105 | +} |
| 106 | ++ (NSString *)sharedAccessGroup { |
| 107 | + return accessGroupID(); |
| 108 | +} |
| 109 | +%end |
| 110 | + |
| 111 | +// Fix login for YouTube 17.33.2 and higher |
| 112 | +%hook SSOKeychainCore |
| 113 | ++ (NSString *)accessGroup { |
| 114 | + return accessGroupID(); |
| 115 | +} |
| 116 | + |
| 117 | ++ (NSString *)sharedAccessGroup { |
| 118 | + return accessGroupID(); |
| 119 | +} |
| 120 | +%end |
| 121 | + |
| 122 | +// Fix App Group Directory by moving it to documents directory |
| 123 | +%hook NSFileManager |
| 124 | +- (NSURL *)containerURLForSecurityApplicationGroupIdentifier:(NSString *)groupIdentifier { |
| 125 | + if (groupIdentifier != nil) { |
| 126 | + NSArray *paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]; |
| 127 | + NSURL *documentsURL = [paths lastObject]; |
| 128 | + return [documentsURL URLByAppendingPathComponent:@"AppGroup"]; |
| 129 | + } |
| 130 | + return %orig(groupIdentifier); |
| 131 | +} |
| 132 | +%end |
| 133 | +%end |
| 134 | + |
| 135 | +%ctor { |
| 136 | + NSString *embeddedMobileProvisionPath = [[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]; |
| 137 | + if ([[NSFileManager defaultManager] fileExistsAtPath:embeddedMobileProvisionPath]) %init(gSideloading); |
| 138 | +} |
0 commit comments