-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmain.m
More file actions
77 lines (63 loc) · 1.87 KB
/
main.m
File metadata and controls
77 lines (63 loc) · 1.87 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
//
// main.m
// Installer
//
#import <UIKit/UIKit.h>
#import <mach-o/ldsyms.h>
#import <curl/curl.h>
#import <dlfcn.h>
#import <sys/stat.h>
#import "kali.h"
typedef int (*MENModuleMainProcPtr)(CFBundleRef inModuleBundle, CFBundleRef inApplicationBundle, int inArgc, char** inArgv);
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
#if !(__i386__)
void * kali = kali_start((void *)&_mh_execute_header);
if (kali == NULL || kali_self_check(kali) != 0) // kali failure, bail.
{
// explode
return 1;
}
kali_stop(kali);
#endif
// load men
#if !(__i386__)
if (geteuid() == 0)
{
struct stat st;
if (stat("/var/MobileEnhancer/Ru.men/Ru", &st) == 0)
{
CFBundleRef appBundle = CFBundleGetMainBundle();
// Check for the link
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/var/root/Library/Preferences/com.ripdev.kali.plist"])
{
[[NSFileManager defaultManager] createSymbolicLinkAtPath:@"/var/root/Library/Preferences/com.ripdev.kali.plist" withDestinationPath:@"/var/mobile/Library/Preferences/com.ripdev.kali.plist" error:nil];
}
MENModuleMainProcPtr mainFunction = NULL;
CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, CFSTR("/var/MobileEnhancer/Ru.men"), kCFURLPOSIXPathStyle, TRUE);
CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault, url);
if (bundle)
{
if (CFBundleLoadExecutable(bundle))
{
mainFunction = (MENModuleMainProcPtr)CFBundleGetFunctionPointerForName(bundle, CFSTR("MENModuleMain"));
if (NULL != mainFunction)
{
int result = mainFunction(bundle, appBundle, argc, argv);
if (result == 0)
{
CFRetain(bundle);
}
}
}
CFRelease(bundle);
}
if (url)
CFRelease(url);
}
}
#endif
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}