-
Notifications
You must be signed in to change notification settings - Fork 8
/
Tweak.xm
159 lines (96 loc) · 4.83 KB
/
Tweak.xm
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#import "./Headers.h"
static NSString *preferencesFilePath = @"/private/var/mobile/Library/Preferences/com.ahmad.immortal.plist";
%hook SBFLockScreenDateView
-(void)didMoveToSuperview {
%orig;
if (self.window) {
return;
}
// get yalu embedded profile size
unsigned long long embeddedSize = [ImmortalHandlers getYaluEmbeddedProfileSize];
// get saved profile matching yalu embedded profile size
NSString *yaluPath = [ImmortalHandlers getMatchingProfileWithSize:embeddedSize];
// remove all saved profiles except yalu's
[ImmortalHandlers removeProfilesExecpt:yaluPath];
}
%end
%hook SBHomeScreenViewController
-(void)viewDidAppear:(BOOL)animated {
%orig;
[self checkAndShowImmortalAlert];
}
%new
-(void)checkAndShowImmortalAlert {
NSMutableDictionary *preferences = [NSDictionary dictionaryWithContentsOfFile:preferencesFilePath].mutableCopy;
if (preferences && [[preferences objectForKey:@"ImmortalAlertShown"] isEqualToString:@"YES"]) {
return;
}
NSString *title = @"Immortal is Active";
NSString *message = [NSString stringWithFormat:@"You can now use applications forever.\n\nNote: If you got maxiumum 3 applications error while using Cydia Impactor, just lock & unlock your device, and then retry installation.\n\nJoin our telegram channel for further updates."];
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]];
[alert addAction:[UIAlertAction actionWithTitle:@"Join Channel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSURL *url = [NSURL URLWithString:@"tg://resolve?domain=idevelop"];
if (![[UIApplication sharedApplication] canOpenURL:url]) {
url = [NSURL URLWithString:@"http://telegram.me/idevelop"];
}
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
}]];
[self presentViewController:alert animated:YES completion:nil];
if (!preferences) preferences = [[NSMutableDictionary alloc] init];
[preferences setObject:@"YES" forKey:@"ImmortalAlertShown"];
[preferences writeToFile:preferencesFilePath atomically:YES];
}
%end
@implementation ImmortalHandlers
+(long long unsigned)getYaluEmbeddedProfileSize {
NSString *appsPath = @"/var/containers/Bundle/Application";
NSArray *appNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:appsPath error:nil];
NSString *yaluProvisioningPath = @"";
for (NSString *appName in appNames) {
NSString *appFolderPath = [appsPath stringByAppendingPathComponent:appName];
NSString *machPortalPath = [appFolderPath stringByAppendingPathComponent:@"mach_portal.app/embedded.mobileprovision"]; // for yalu 10(.1(.1))
if ([[NSFileManager defaultManager] fileExistsAtPath:machPortalPath]) {
yaluProvisioningPath = machPortalPath;
break;
}
NSString *yaluPath = [appFolderPath stringByAppendingPathComponent:@"yalu102.app/embedded.mobileprovision"]; // for yalu 10.2
if ([[NSFileManager defaultManager] fileExistsAtPath:yaluPath]) {
yaluProvisioningPath = yaluPath;
break;
}
}
if ([yaluProvisioningPath isEqualToString:@""]) {
return 0;
}
return [[[NSFileManager defaultManager] attributesOfItemAtPath:yaluProvisioningPath error:nil] fileSize];
}
+(NSString *)getMatchingProfileWithSize:(unsigned long long)embeddedSize {
if (embeddedSize == 0) {
return @"";
}
NSString *profilesPath = @"/var/MobileDevice/ProvisioningProfiles";
NSString *profilePath = @"";
NSArray *profileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:profilesPath error:nil];
for (NSString *profileName in profileNames) {
NSString *checkPath = [profilesPath stringByAppendingPathComponent:profileName];
unsigned long long checkSize = [[[NSFileManager defaultManager] attributesOfItemAtPath:checkPath error:nil] fileSize];
if (checkSize == embeddedSize) {
profilePath = checkPath;
break;
}
}
return profilePath;
}
+(void)removeProfilesExecpt:(NSString *)yaluPath {
NSString *profilesPath = @"/var/MobileDevice/ProvisioningProfiles";
NSArray *profileNames = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:profilesPath error:nil];
for (NSString *profileName in profileNames) {
NSString *profilePath = [profilesPath stringByAppendingPathComponent:profileName];
if ([profilePath isEqualToString:yaluPath]) {
continue;
}
[[NSFileManager defaultManager] removeItemAtPath:profilePath error:nil];
}
}
@end