forked from wdmchaft/iSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iSpy.common.h
151 lines (126 loc) · 5.51 KB
/
iSpy.common.h
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
#ifndef __ISPY_H__
#define __ISPY_H__
#include "objc_type.h" // taken from the class-dump-z source
#include <objc/runtime.h>
#include <objc/message.h>
// Helper macros
#define SL_SETUP_HOOK(func, returnType, args...) static returnType (*orig_##func)(args);returnType sl_##func(args)
#define SL_HOOK_FUNCTION(func) (MSHookFunction((void *)func, (void *)sl_##func, (void **)&orig_##func))
#define SL_UNHOOK_FUNCTION(func) MSHookFunction((void *)func, (void *)orig_##func, (void **)&orig_##func)
// Do not fuck with this, it will only break shit.
#define USED __attribute__((used))
#define FOUND 0
#define NOT_FOUND 0xff
#define MAX_HOOKS 256 // ok, you might need to mess with this
#define CTLIOCGINFO _IOWR('N', 3, struct ctl_info)
#define EXPORT extern "C" __attribute__((visibility("default")))
// Cribbed from http://www.opensource.apple.com/source/xnu/xnu-792.13.8/bsd/sys/sys_domain.h
/* Kernel Events Protocol */
#define SYSPROTO_EVENT 1 /* kernel events protocol */
/* Kernel Control Protocol */
#define SYSPROTO_CONTROL 2 /* kernel control protocol */
#define AF_SYS_CONTROL 2 /* corresponding sub address type */
/*
This where the all the preferences end up, from the 'Settings' app
The dictionary keys, and ui are defined in layout/Library/PreferenceLoader/Preferences/iSpy.plist
Format for keys is roughly "namespace_attrib"
*/
#define PREFERENCEFILE "/private/var/mobile/Library/Preferences/com.bishopfox.iSpy.Settings.plist"
#define APP_PREFERENCEFILE "/private/var/mobile/Library/Preferences/com.bishopfox.iSpy.Targets.plist"
/* System family socket address */
struct sockaddr_sys {
u_char ss_len; /* sizeof(struct sockaddr_sys) */
u_char ss_family; /* AF_SYSTEM */
u_int16_t ss_sysaddr; /* protocol address in AF_SYSTEM */
u_int32_t ss_reserved[7]; /* reserved to the protocol use */
};
struct sockaddr_ctl {
u_char sc_len; /* depends on size of bundle ID string */
u_char sc_family; /* AF_SYSTEM */
u_int16_t ss_sysaddr; /* AF_SYS_KERNCONTROL */
u_int32_t sc_id; /* Controller unique identifier */
u_int32_t sc_unit; /* Developer private unit number */
u_int32_t sc_reserved[5];
};
struct ctl_info {
u_int32_t ctl_id; /* Kernel Controller ID */
char ctl_name[96]; /* Kernel Controller Name (a C string) */
};
/* iSpy Logging Stuffs */
static const unsigned int LOG_STRACE = 0;
static const unsigned int LOG_MSGSEND = 1;
static const unsigned int LOG_GENERAL = 2;
static const unsigned int LOG_HTTP = 3;
static const unsigned int LOG_TCPIP = 4;
static const unsigned int LOG_GLOBAL = 5;
static const unsigned int LOG_REPORT = 6;
static const unsigned int MAX_LOG = LOG_REPORT; // this must be equal to the last number in the list of LOG_* numbers, above.
EXPORT void ispy_init_logwriter(NSString *documents);
EXPORT void ispy_log_debug(unsigned int facility, const char *msg, ...);
EXPORT void ispy_log_info(unsigned int facility, const char *msg, ...);
EXPORT void ispy_log_warning(unsigned int facility, const char *msg, ...);
EXPORT void ispy_log_error(unsigned int facility, const char *msg, ...);
EXPORT void ispy_log_wtf(unsigned int facility, const char *msg, ...);
/* Other */
EXPORT OSStatus new_SecTrustEvaluate(SecTrustRef trust, SecTrustResultType *result);
EXPORT void bf_hook_msgSend();
EXPORT void bf_hook_msgSend_stret();
EXPORT void bf_enable_msgSend_stret();
EXPORT void bf_disable_msgSend_stret();
//EXPORT void bf_set_msgSend_log_filename_stret(const char *fname);
EXPORT void bf_enable_msgSend();
EXPORT void bf_disable_msgSend();
//EXPORT void bf_set_msgSend_log_filename(const char *fname);
EXPORT int bf_get_msgSend_state();
EXPORT void bf_init_substrate_replacement();
EXPORT int return_false();
EXPORT int return_true();
EXPORT id (*orig_objc_msgSend)(id theReceiver, SEL theSelector, ...);
EXPORT bool bf_get_instance_tracking_state();
EXPORT void bf_disable_instance_tracker();
EXPORT void bf_enable_instance_tracker();
EXPORT bool bf_msgSend_should_we_log_this_call(id Cls, SEL selector);
EXPORT bool startWebServices();
EXPORT NSDictionary *getNetworkInfo(void);
EXPORT void update_msgSend_checklists(id *whiteListPtr, id *blackListPtr);
EXPORT void update_msgSend_checklists_stret(id *whiteListPtr, id *blackListPtr);
EXPORT void bf_logwrite_msgSend(int facility, const char *msg, ...);
EXPORT NSString *base64forData(NSData *theData);
// These funcrions are a hacked-up way of using pure C code to send data down Web Sockets.
// This is useful in the obj_msgSend logging code where we cannot use Objective-C.
extern "C" void bf_websocket_write(const char *msg);
// These are implemented in Tweak.xm
void bf_init_msgSend_logging();
void bf_enable_msgSend_logging();
void bf_disable_msgSend_logging();
void hijack_on();
BOOL shouldBlockPath(const char *fpath);
BOOL activelyBlock(void);
// for the objc_msgSend logging code.
struct lr_node {
intptr_t lr;
id self;
int should_filter;
int regs[6];
};
/*
UI interaction logging.
If you want to log most interactions with UI elements, enable this.
It'll dump an entry to NSLog every time you press a button, slide a slider,
hit "back" or "login" or whatever. You'll get these items in your Xcode console:
class name
method name
parameter names and values
a pointer to the controller receiving the UI event
a pony
It generates very little logging unless you're going crazy in the UI pressing shit.
NOTE: This isn't complete. Needs more work to encorporate all UI elements.
Enabled by default. Comment out to disable.
*/
#define LOG_UI_INTERACTION 1
@interface xxxLoggingAssertionHandler :NSObject {
}
@end
@interface GCKPB_PBGeneratedMessage : NSObject
@end
#endif