forked from donato-fiore/TrollDecrypt
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathTweakHook.xm
More file actions
87 lines (67 loc) · 2.9 KB
/
TweakHook.xm
File metadata and controls
87 lines (67 loc) · 2.9 KB
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
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <rootless.h>
@interface MIBundle : NSObject
- (BOOL)isWatchApp;
@end
static NSString *iosVersion = nil;
static BOOL updatesEnabled = NO;
%group appstoredHooks
%hook NSMutableURLRequest
- (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field
{
if (iosVersion != nil) {
if (updatesEnabled == YES) {
if ([field isEqualToString:@"User-Agent"]) {
// NSLog(@"[TrollDecrypt] Spoofing iOS version: iOS/%@", iosVersion);
value = [value stringByReplacingOccurrencesOfString:@"iOS/.*? " withString:[NSString stringWithFormat:@"iOS/%@ ", iosVersion] options:NSRegularExpressionSearch range:NSMakeRange(0, [value length])];
}
} else {
if ([[self.URL absoluteString] containsString:@"WebObjects/MZBuy.woa/wa/buyProduct"]) {
if ([field isEqualToString:@"User-Agent"]) {
// NSLog(@"[TrollDecrypt] Spoofing iOS version for buyProduct: iOS/%@", iosVersion);
value = [value stringByReplacingOccurrencesOfString:@"iOS/.*? " withString:[NSString stringWithFormat:@"iOS/%@ ", iosVersion] options:NSRegularExpressionSearch range:NSMakeRange(0, [value length])];
}
}
}
}
%orig(value, field);
}
%end
%end
%group installdHooks
%hook MIBundle
-(BOOL)_isMinimumOSVersion:(id)arg1 applicableToOSVersion:(id)arg2 requiredOS:(unsigned long long)arg3 error:(id*)arg4
{
if ([self isWatchApp]) {
return %orig(arg1, arg2, arg3, arg4);
}
// NSLog(@"[TrollDecrypt] installd: arg1: %@ arg2: %@ arg3: %llu", arg1, arg2, arg3);
if (iosVersion != nil) {
return %orig(arg1, iosVersion, arg3, arg4);
} else {
return %orig(arg1, arg2, arg3, arg4);
}
}
%end
%end
%ctor {
// Use our preference file path
[[NSFileManager defaultManager] setAttributes:@{NSFilePosixPermissions: @(0644)} ofItemAtPath:ROOT_PATH_NS(@"/var/mobile/Library/Preferences/com.trolldecrypt.hook.plist") error:nil];
NSDictionary *prefs = [NSDictionary dictionaryWithContentsOfFile:ROOT_PATH_NS(@"/var/mobile/Library/Preferences/com.trolldecrypt.hook.plist")];
// Check if hook is enabled (default: disabled)
if (![prefs objectForKey:@"hookEnabled"] || ![[prefs objectForKey:@"hookEnabled"] boolValue]) {
// NSLog(@"[TrollDecrypt] Hook not enabled");
return;
}
// Get custom iOS version (default: 99.0.0 if not set)
iosVersion = [prefs objectForKey:@"iOSVersion"];
if (iosVersion == nil || [iosVersion length] == 0) {
iosVersion = @"99.0.0";
}
// Get updates enabled flag (default: NO)
updatesEnabled = [[prefs objectForKey:@"updatesEnabled"] boolValue];
NSLog(@"[TrollDecrypt] Hook enabled - iOS version: %@, updatesEnabled: %d", iosVersion, updatesEnabled);
%init(appstoredHooks);
%init(installdHooks);
}