123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- #import <objc/runtime.h>
- #import <notify.h>
- #import <dlfcn.h>
- #import <substrate.h>
- #import <sys/utsname.h>
- #import <UIKit/UIKit.h>
- extern const char *__progname;
- #define NSLog(...)
- #define PLIST_PATH_Settings "/var/mobile/Library/Preferences/com.julioverne.lowerinstall.plist"
- static BOOL Enabled;
- static __strong NSString* kCurrentiOSVersion = nil;
- static __strong NSString* kCurrentDeviceType = nil;
- const char * kCurrentiOSVersionSpoof;
- const char * kCurrentDeviceTypeSpoof;
- static __strong NSString* kUserAgent = @"User-Agent";
- static __strong NSString* kFormatHeader = @"/%@ ";
- %group itunesstoredHooks
- %hook NSMutableURLRequest
- - (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field
- {
- %log;
- if(Enabled && field && value && kUserAgent && [field isEqualToString:kUserAgent] && kCurrentiOSVersion && kCurrentiOSVersionSpoof) {
- HBLogInfo(@"currentiOSVaersion: %@ value: %@", kCurrentiOSVersion, value);
- if([value rangeOfString:kCurrentiOSVersion].location != NSNotFound) {
- HBLogInfo(@"### are we inside here???");
- value = [value stringByReplacingOccurrencesOfString:[NSString stringWithFormat:kFormatHeader, kCurrentiOSVersion] withString:[NSString stringWithFormat:kFormatHeader, [NSString stringWithUTF8String:kCurrentiOSVersionSpoof]]];
- value = [value stringByReplacingOccurrencesOfString:[NSString stringWithFormat:kFormatHeader, kCurrentDeviceType] withString:[NSString stringWithFormat:kFormatHeader, [NSString stringWithUTF8String:kCurrentDeviceTypeSpoof]]];
- } else {
-
- HBLogInfo(@"#### value: %@ not found in %@", value, kCurrentiOSVersion);
-
-
- }
- }
- %orig(value, field);
- }
- %end
- %end
- %group installdHooks
- %hook MIBundle
- /*
- - (BOOL)isApplicableToCurrentOSVersionWithError:(NSError *)error {
-
- %log;
- return YES;
- }
- */
- - (NSString*)minimumOSVersion
- {
- %log;
- NSString* ret = %orig;
- ret = @"2.0";
- return ret;
- }
- /*
- - (_Bool)isApplicableToCurrentDeviceCapabilitiesWithError:(id *)arg1
- {
- %log;
- BOOL orig = %orig;
- return YES;
- }
- - (_Bool)isApplicableToOSVersion:(id)arg1 error:(id *)arg2{
- %log;
- BOOL orig = %orig;
- return YES;
- }
- - (_Bool)isApplicableToCurrentOSVersionWithError:(id *)arg1{
- %log;
- BOOL orig = %orig;
- return YES;
- }
- - (_Bool)isApplicableToCurrentDeviceFamilyWithError:(id *)arg1{
- %log;
- BOOL orig = %orig;
- return YES;
- }
- - (_Bool)isCompatibleWithDeviceFamily:(int)arg1{
- %log;
- BOOL orig = %orig;
- return YES;
- }
- */
- - (NSArray *)supportedDevices
- {
- NSArray* ret = %orig?:@[];
- if(kCurrentDeviceType && ![ret containsObject:kCurrentDeviceType]) {
- NSMutableArray* retMut = [ret mutableCopy];
- [retMut addObject:[kCurrentDeviceType copy]];
- ret = [retMut copy];
- }
- return ret;
- }
- %end
- %end
- /* Set platform binary flag */
- #define FLAG_PLATFORMIZE (1 << 1)
- void platformize_me() {
- void* handle = dlopen("/usr/lib/libjailbreak.dylib", RTLD_LAZY);
- if (!handle) return;
-
- // Reset errors
- dlerror();
- typedef void (*fix_entitle_prt_t)(pid_t pid, uint32_t what);
- fix_entitle_prt_t ptr = (fix_entitle_prt_t)dlsym(handle, "jb_oneshot_entitle_now");
-
- const char *dlsym_error = dlerror();
- if (dlsym_error) return;
-
- ptr(getpid(), FLAG_PLATFORMIZE);
- }
- static void settingsChangedLowerInstall()
- {
- @autoreleasepool {
- NSDictionary *LowerInstallPrefs = [[[NSDictionary alloc] initWithContentsOfFile:@PLIST_PATH_Settings]?:[NSDictionary dictionary] copy];
- Enabled = (BOOL)[[LowerInstallPrefs objectForKey:@"Enabled"]?:@YES boolValue];
- NSString* CurrentiOSVersionSpoof = [LowerInstallPrefs objectForKey:@"SpoofVersion"]?:@"11.1";
- kCurrentiOSVersionSpoof = (const char*)(malloc([CurrentiOSVersionSpoof length]));
- memcpy((void*)kCurrentiOSVersionSpoof,(const void*)CurrentiOSVersionSpoof.UTF8String, [CurrentiOSVersionSpoof length]);
- ((char*)kCurrentiOSVersionSpoof)[[CurrentiOSVersionSpoof length]] = '\0';
- NSString* CurrentDeviceTypeSpoof = [LowerInstallPrefs objectForKey:@"SpoofDevice"]?:@"AppleTV5,3";
- kCurrentDeviceTypeSpoof = (const char*)(malloc([CurrentDeviceTypeSpoof length]));
- memcpy((void*)kCurrentDeviceTypeSpoof,(const void*)CurrentDeviceTypeSpoof.UTF8String, [CurrentDeviceTypeSpoof length]);
- ((char*)kCurrentDeviceTypeSpoof)[[CurrentDeviceTypeSpoof length]] = '\0';
- }
- }
- %ctor
- {
- HBLogInfo(@"### DalesDeadBug reporting for duty!");
- //platformize_me();
-
- //HBDebugLog(@"Dales Dead Bug reporting for duty!");
- CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)settingsChangedLowerInstall, CFSTR("com.julioverne.lowerinstall/SettingsChanged"), NULL, CFNotificationSuspensionBehaviorCoalesce);
- settingsChangedLowerInstall();
- struct utsname systemInfo;
- uname(&systemInfo);
- kCurrentDeviceType = [NSString stringWithFormat:@"%s", systemInfo.machine];
- kCurrentiOSVersion = [NSString stringWithFormat:@"%@", [[UIDevice currentDevice] systemVersion]];
- if(strcmp(__progname, "itunesstored") == 0) {
- HBLogInfo(@"### DalesDeadBug: itunesstored");
- %init(itunesstoredHooks);
- } else {
- HBLogInfo(@"### DalesDeadBug: installd");
- %init(installdHooks);
- }
- }
|