-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathTweak.xmi
108 lines (84 loc) · 2.95 KB
/
Tweak.xmi
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
#import "hooks/CustomURLProtocol.h"
#import "hooks/SocketClass.h"
#import "hooks/DelegateProxies.h"
//Hooks for C functions
#import "hooks/CCCryptHook.h"
#import "hooks/SSLWriteHook.h"
#import "hooks/KeychainHooks.h"
SocketClass *gsocket ;
//Hooks for OC functions
%group MITM
#include "hooks/NSUIWebViewHook.xm"
#include "hooks/NSURLSessionHook.xm"
%end // end group
%group Traffic
#include "hooks/TrafficHook.xm"
%end
%group URL
#include "hooks/URLHook.xm"
%end
%group keyboardHook
#include "hooks/KeyboardHook.xm"
%end
%group PlistHooks
#include "hooks/PlistHooks.xm"
%end
%group NSUserDefaultsHooks
#include "hooks/NSUserDefaultsHooks.xm"
%end
static NSString *applistPreferenceFilePath = @"/private/var/mobile/Library/Preferences/com.softsec.iosdefect.app.plist";
static NSString *settingsPreferenceFilePath = @"/private/var/mobile/Library/Preferences/com.softsec.iosdefect.settings.plist";
static BOOL getBoolFromPreferences(NSMutableDictionary *preferences, NSString *preferenceValue) {
id value = [preferences objectForKey:preferenceValue];
if (value == nil) {
return NO; // default to NO
}
return [value boolValue];
}
%ctor{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
gsocket = [[SocketClass alloc] init];
NSString *appId = [[NSBundle mainBundle] bundleIdentifier];
// Load applist preferences
NSMutableDictionary *appPreferences = [[NSMutableDictionary alloc] initWithContentsOfFile:applistPreferenceFilePath];
if (! getBoolFromPreferences(appPreferences,appId) ) {
NSLog(@"yujianbo: the app [%@] is not in list",appId);
[appPreferences release];
[pool drain];
return;
}
//load settings preferences
NSMutableDictionary *settingsPreferences = [[NSMutableDictionary alloc] initWithContentsOfFile:settingsPreferenceFilePath];
NSLog(@"yujianbo: the app [%@] is in list",appId);
//init default tweak
%init(URL);
%init(keyboardHook);
if (getBoolFromPreferences(settingsPreferences, @"MITM")) {
NSLog(@"yujianbo: start MITM");
%init(MITM);
[SSLWriteHook enableHook];
}
if (getBoolFromPreferences(settingsPreferences, @"Traffic")) {
NSLog(@"yujianbo: start Traffic");
%init(Traffic);
}
if (getBoolFromPreferences(settingsPreferences, @"CCCrypt")) {
NSLog(@"yujianbo: start CCCrypt");
[CCCryptHook enableHook];
}
if (getBoolFromPreferences(settingsPreferences, @"KeyChain")) {
NSLog(@"yujianbo: start KeyChain");
[KeychainHooks enableHooks];
}
if (getBoolFromPreferences(settingsPreferences, @"Plist")) {
NSLog(@"yujianbo: start Plist");
%init(PlistHooks);
}
if (getBoolFromPreferences(settingsPreferences, @"NSUserDefaults")) {
NSLog(@"yujianbo: start NSUserDefaultHook");
%init(NSUserDefaultsHooks);
}
[appPreferences release];
[settingsPreferences release];
[pool drain];
}