This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 106
/
iSpy.msgSend.whitelist.xm
181 lines (160 loc) · 5.48 KB
/
iSpy.msgSend.whitelist.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#include "iSpy.common.h"
#include "iSpy.class.h"
#include "iSpy.msgSend.whitelist.h"
#include <iostream>
#include <string>
#include <vector>
#include <memory>
struct interestingCall interestingCalls[] = {
/*
{
// Field meanings:
"Classification of interesting call",
"Name of class to trigger on",
"Name of method to trigger on",
"Provide a description that will be sent to the iSpy UI",
"Provide a risk rating",
one of: INTERESTING_CALL or INTERESTING_BREAKPOINT
}
*/
// Data Storage
{
"Data Storage",
"NSManagedObjectContext",
"save",
"Core Data uses unencrypted SQLite databases. Sensitive information should not be stored here.",
"Medium",
INTERESTING_CALL
},
{
"Data Storage",
"NSDictionary",
"writeToFile",
"Sensitive data should not be saved in this manner.",
"Medium",
INTERESTING_CALL
},
{
"Data Storage",
"NSUserDefaults",
"init",
"Sensitive data should not be saved using NSUserDefaults.",
"Medium",
INTERESTING_CALL
},
{
"Data Storage",
"NSURLCache",
"initWithMemoryCapacity:diskCapacity:diskPath:",
"Sensitive SSL-encrypted data may be stored in the clear using NSURLCache.",
"Medium",
INTERESTING_CALL
},
{
"Data Storage",
"NSURLCache",
"storeCachedResponse:forRequest:",
"Sensitive SSL-encrypted data may be stored in the clear using NSURLCache.",
"Medium",
INTERESTING_CALL
},
{
"Data Storage",
"NSURLCache",
"setDiskCapacity:",
"Sensitive SSL-encrypted data may be stored in the clear using NSURLCache.",
"Medium",
INTERESTING_CALL
},
// Breakpoints
/*
{
"TEST", // must be present, value unimportant
"RealTimeDataViewController", // class
"showLoadingView", // method
"",
"",
INTERESTING_BREAKPOINT // must be present
},
*/
{ NULL }
};
extern void whitelist_add_method(std::string *className, std::string *methodName, unsigned int type) {
ispy_log_debug(LOG_GENERAL, "[Whitelist] add [%s %s]", className->c_str(), methodName->c_str());
ClassMap_t *ClassMap = [[iSpy sharedInstance] classWhitelist];
(*ClassMap)[*className][*methodName] = type;
}
extern void whitelist_remove_method(std::string *className, std::string *methodName) {
ClassMap_t *ClassMap = [[iSpy sharedInstance] classWhitelist];
(*ClassMap)[*className].erase(*methodName);
}
extern void whitelist_startup() {
// use a static buffer because for some odd reason this is the only way to stick a hash map on the BSS without a crash. LAME.
static std::tr1::unordered_map<std::string, std::tr1::unordered_map<std::string, unsigned int> > WhitelistClassMap;
static BreakpointMap_t Breakpoints;
ispy_log_debug(LOG_GENERAL, "[Whitelist] initializing the pointers and whatnot.");
// Set the singleton pointers to the hashmaps.
[[iSpy sharedInstance] setClassWhitelist:&WhitelistClassMap];
[iSpy sharedInstance]->breakpoints = &Breakpoints;
}
extern void whitelist_add_hardcoded_interesting_calls() {
ispy_log_debug(LOG_GENERAL, "[Whitelist] Initializing the interesting functions");
struct interestingCall *call = interestingCalls;
while(call->classification) {
ispy_log_debug(LOG_GENERAL, "call = %p", call);
whitelist_add_method(&std::string(call->className), &std::string(call->methodName), (unsigned int)call);
call++;
}
}
extern void whitelist_clear_whitelist() {
ClassMap_t *whitelist = [[iSpy sharedInstance] classWhitelist];
whitelist->clear();
}
void whitelist_add_app_classes() {
int i, numClasses, m, numMethods;
// Get a list of all the classes in the app
NSArray *classes = [[iSpy sharedInstance] classes];
numClasses = [classes count];
ispy_log_debug(LOG_GENERAL, "[Whitelist] adding %d classes...", numClasses);
// Iterate through all the class names, adding each one to our lookup table
for(i = 0; i < numClasses; i++) {
NSString *name = [classes objectAtIndex:i];
if(!name) {
continue;
}
NSArray *methods = [[iSpy sharedInstance] methodListForClass:name];
if(!methods) {
continue;
}
numMethods = [methods count];
if(!numMethods) {
[methods release];
[name release];
continue;
}
for(m = 0; m < numMethods; m++) {
NSString *methodName = [methods objectAtIndex:m];
if(!methodName) {
continue;
}
std::string *classNameString = new std::string([name UTF8String]);
std::string *methodNameString = new std::string([methodName UTF8String]);
if(!classNameString || !methodNameString) {
if(methodNameString)
delete methodNameString;
if(classNameString)
delete classNameString;
continue;
}
//ispy_log_debug(LOG_GENERAL, "[Whitelist adding [%s %s]", classNameString->c_str(), methodNameString->c_str());
whitelist_add_method(classNameString, methodNameString, WHITELIST_PRESENT);
[methodName release];
delete methodNameString;
delete classNameString;
}
[name release];
[methods release];
}
[classes release];
ispy_log_debug(LOG_GENERAL, "[whitelist] Added %d of %d classes to the whitelist.", i, numClasses);
}