-
Notifications
You must be signed in to change notification settings - Fork 36
/
Utils.m
185 lines (163 loc) · 5.92 KB
/
Utils.m
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#import "Utils.h"
#import <dlfcn.h>
#import "substrate.h"
uint64_t bh_memmem(const uint8_t* haystack, size_t hlen, const uint8_t* needle, size_t nlen) {
size_t last, scan = 0;
size_t bad_char_skip[UCHAR_MAX + 1];
if (nlen <= 0 || !haystack || !needle) return 0;
for (scan = 0; scan <= UCHAR_MAX; scan = scan + 1) bad_char_skip[scan] = nlen;
last = nlen - 1;
for (scan = 0; scan < last; scan = scan + 1)
bad_char_skip[needle[scan]] = last - scan;
while (hlen >= nlen) {
for (scan = last; haystack[scan] == needle[scan]; scan = scan - 1) {
if (scan == 0) return (uint64_t)haystack;
if (*(uint32_t *)haystack == 0xd65f03c0) return 0; // reached ret
if (*(uint32_t *)haystack == 0xd65f0fff) return 0; // reached retab
}
hlen -= bad_char_skip[haystack[last]];
haystack += bad_char_skip[haystack[last]];
}
return 0;
}
int (*__LHPatchMemory)(const struct LHMemoryPatch *patches, int count);
int PatchMemory(const struct LHMemoryPatch *patches, int count) {
static dispatch_once_t onceToken;
dispatch_once (&onceToken, ^{
void* lhImage = dlopen((ROOT_PATH("/usr/lib/libhooker.dylib")), RTLD_NOW);
if(lhImage) {
__LHPatchMemory = (void*)dlsym(lhImage, "LHPatchMemory");
}
});
if(__LHPatchMemory) {
return __LHPatchMemory(patches, count);
} else {
for(int i = 0; i < count; i++)
{
struct LHMemoryPatch patch = patches[i];
MSHookMemory(patch.destination, patch.data, patch.size);
}
return 0;
}
}
void HookMemory(Class class, SEL selector, uint64_t offset, uint32_t data) {
void *final_offset = (void *)[class instanceMethodForSelector:selector] + offset;
struct LHMemoryPatch patch;
patch.destination = final_offset;
patch.data = &data;
patch.size = sizeof(data);
patch.options = NULL;
PatchMemory(&patch, 1);
}
void alert(UIView* object, NSString *title, NSString *message) {
UIViewController *vc = object.window.rootViewController;
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:ok];
[vc presentViewController:alert animated:YES completion:nil];
}
NSDictionary *getPreferences() {
static NSDictionary *preferences;
if (!preferences) {
CFArrayRef keyList = CFPreferencesCopyKeyList(CFSTR("com.fiore.gameseagull.prefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if (keyList) {
preferences = (__bridge NSDictionary *)CFPreferencesCopyMultiple(keyList, CFSTR("com.fiore.gameseagull.prefs"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
CFRelease(keyList);
}
if (!preferences) {
preferences = [[NSDictionary alloc] initWithContentsOfFile:ROOT_PATH_NS(@"/var/mobile/Library/Preferences/com.fiore.gameseagull.prefs.plist")];
}
}
return preferences;
}
bool boolForKey(NSString *key) {
if (!getPreferences()) return false;
id val = getPreferences()[key];
return val ? [val boolValue] : false;
}
UIButton *makeButton(NSString *title, CGRect frame, id target, SEL selector) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:frame];
[button setBackgroundColor:[UIColor colorWithRed:(255/255.0) green:(255/255.0) blue:(255/255.0) alpha:.85]];
[button setTitle:title forState:UIControlStateNormal];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
button.layer.cornerRadius = 14;
return button;
}
SCNVector3 getAimbotPos(int multiplier, int number) {
if (multiplier == 1 && number == 25) {
return SCNVector3Make(0.0, 0.325, 0.0);
} else if (multiplier == 1 && number == 50) {
return SCNVector3Make(0.0, 0.35, 0.0);
}
NSArray *points = @[
@[
@[@0.05, @0.5, @0.0],
@[@0.2, @0.0, @0.0],
@[@0.0, @0.0, @0.0],
@[@0.2, @0.5, @0.0],
@[@-0.05, @0.5, @0.0],
@[@0.2, @0.35, @0.0],
@[@-0.2, @0.0, @0.0],
@[@-0.2, @0.3, @0.0],
@[@-0.2, @0.5, @0.0],
@[@0.2, @0.3, @0.0],
@[@-0.2, @0.35, @0.0],
@[@-0.1, @0.5, @0.0],
@[@0.2, @0.4, @0.0],
@[@-0.2, @0.4, @0.0],
@[@0.2, @0.2, @0.0],
@[@-0.2, @0.2, @0.0],
@[@0.1, @0.0, @0.0],
@[@0.1, @0.5, @0.0],
@[@-0.1, @0.0, @0.0],
@[@0.0, @0.5, @0.0]
], @[
@[@0.15, @0.815, @0.0],
@[@0.26, @-0.05, @0.0],
@[@0.0, @-0.145, @0.0],
@[@0.4, @0.625, @0.0],
@[@-0.15, @0.815, @0.0],
@[@0.49, @0.35, @0.0],
@[@-0.26, @-0.05, @0.0],
@[@-0.47, @0.175, @0.0],
@[@-0.4, @0.625, @0.0],
@[@0.47, @0.175, @0.0],
@[@-0.49, @0.35, @0.0],
@[@-0.26, @0.75, @0.0],
@[@0.47, @0.46, @0.0],
@[@-0.47, @0.46, @0.0],
@[@0.4, @0.05, @0.0],
@[@-0.4, @0.05, @0.0],
@[@0.15, @-0.125, @0.0],
@[@0.26, @0.75, @0.0],
@[@-0.15, @-0.125, @0.0],
@[@0.0, @0.835, @0.0],
],
@[
@[@0.1, @0.63, @0.0],
@[@0.175, @0.1, @0.0],
@[@0.0, @0.035, @0.0],
@[@0.25, @0.53, @0.0],
@[@-0.1, @0.63, @0.0],
@[@0.3, @0.35, @0.0],
@[@-0.175, @0.1, @0.0],
@[@-0.28, @0.25, @0.0],
@[@-0.25, @0.53, @0.0],
@[@0.28, @0.25, @0.0],
@[@-0.3, @0.35, @0.0],
@[@-0.175, @0.59, @0.0],
@[@0.28, @0.45, @0.0],
@[@-0.28, @0.45, @0.0],
@[@0.25, @0.16, @0.0],
@[@-0.25, @0.16, @0.0],
@[@0.1, @0.05, @0.0],
@[@0.175, @0.59, @0.0],
@[@-0.1, @0.05, @0.0],
@[@0.0, @0.65, @0.0]
]
];
NSArray *coords = points[multiplier - 1][number - 1];
return SCNVector3Make([coords[0] floatValue], [coords[1] floatValue], [coords[2] floatValue]);
}