frida 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +25 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +20 -0
- data/exe/frida +3 -0
- data/ext/c_frida/Application.c +79 -0
- data/ext/c_frida/Bus.c +91 -0
- data/ext/c_frida/Child.c +134 -0
- data/ext/c_frida/Compiler.c +208 -0
- data/ext/c_frida/Crash.c +92 -0
- data/ext/c_frida/Device.c +955 -0
- data/ext/c_frida/DeviceManager.c +260 -0
- data/ext/c_frida/EndpointParameters.c +189 -0
- data/ext/c_frida/FileMonitor.c +67 -0
- data/ext/c_frida/GObject.c +138 -0
- data/ext/c_frida/IOStream.c +228 -0
- data/ext/c_frida/PortalMembership.c +43 -0
- data/ext/c_frida/PortalService.c +413 -0
- data/ext/c_frida/Process.c +67 -0
- data/ext/c_frida/Relay.c +121 -0
- data/ext/c_frida/Script.c +221 -0
- data/ext/c_frida/Session.c +626 -0
- data/ext/c_frida/Spawn.c +53 -0
- data/ext/c_frida/c_frida.c +68 -0
- data/ext/c_frida/extconf.rb +26 -25
- data/ext/c_frida/gutils.c +498 -0
- data/ext/c_frida/gvl_bridge.c +131 -0
- data/ext/c_frida/inc/Application.h +9 -0
- data/ext/c_frida/inc/Bus.h +15 -0
- data/ext/c_frida/inc/Child.h +9 -0
- data/ext/c_frida/inc/Compiler.h +21 -0
- data/ext/c_frida/inc/Crash.h +9 -0
- data/ext/c_frida/inc/Device.h +71 -0
- data/ext/c_frida/inc/DeviceManager.h +20 -0
- data/ext/c_frida/inc/EndpointParameters.h +15 -0
- data/ext/c_frida/inc/FileMonitor.h +9 -0
- data/ext/c_frida/inc/GObject.h +10 -0
- data/ext/c_frida/inc/IOStream.h +29 -0
- data/ext/c_frida/inc/PortalMembership.h +9 -0
- data/ext/c_frida/inc/PortalService.h +47 -0
- data/ext/c_frida/inc/Process.h +9 -0
- data/ext/c_frida/inc/Relay.h +9 -0
- data/ext/c_frida/inc/Script.h +21 -0
- data/ext/c_frida/inc/Session.h +40 -0
- data/ext/c_frida/inc/Spawn.h +9 -0
- data/ext/c_frida/inc/c_frida.h +129 -0
- data/ext/c_frida/inc/gutils.h +21 -0
- data/ext/c_frida/inc/gvl_bridge.h +42 -0
- data/frida.gemspec +39 -0
- data/lib/frida/version.rb +5 -0
- data/lib/frida.rb +8 -0
- metadata +55 -3
@@ -0,0 +1,208 @@
|
|
1
|
+
#include "Compiler.h"
|
2
|
+
|
3
|
+
VALUE Compiler_from_FridaCompiler(FridaCompiler *handle)
|
4
|
+
{
|
5
|
+
VALUE self;
|
6
|
+
|
7
|
+
if (!handle)
|
8
|
+
return (Qnil);
|
9
|
+
VALUE args[1] = {Qfalse};
|
10
|
+
self = rb_class_new_instance(1, args, cCompiler);
|
11
|
+
GET_GOBJECT_DATA();
|
12
|
+
d->handle = handle;
|
13
|
+
d->destroy = frida_unref;
|
14
|
+
return (self);
|
15
|
+
}
|
16
|
+
|
17
|
+
GVL_FREE_PROXY_FUNC(build_sync, build_sync_proxy_args *args)
|
18
|
+
{
|
19
|
+
GError *gerr = NULL;
|
20
|
+
char *bundle;
|
21
|
+
|
22
|
+
bundle = frida_compiler_build_sync(args->handle, args->entrypoint, args->options, NULL, &gerr);
|
23
|
+
RETURN_GVL_FREE_RESULT(bundle);
|
24
|
+
}
|
25
|
+
|
26
|
+
/*
|
27
|
+
call-seq:
|
28
|
+
#build(entrypoint, project_root:, source_maps:, compression:) -> String
|
29
|
+
*/
|
30
|
+
static VALUE Compiler_build(int argc, VALUE *argv, VALUE self)
|
31
|
+
{
|
32
|
+
GET_GOBJECT_DATA();
|
33
|
+
REQUIRE_GOBJECT_HANDLE();
|
34
|
+
|
35
|
+
VALUE entrypoint, kws;
|
36
|
+
FridaBuildOptions *options;
|
37
|
+
FridaCompilerOptions *coptions;
|
38
|
+
|
39
|
+
rb_scan_args(argc, argv, "1:", &entrypoint, &kws);
|
40
|
+
if (!RB_TYPE_P(entrypoint, T_STRING)) {
|
41
|
+
raise_argerror("entrypoint must be a string.");
|
42
|
+
return (Qnil);
|
43
|
+
}
|
44
|
+
options = frida_build_options_new();
|
45
|
+
coptions = FRIDA_COMPILER_OPTIONS(options);
|
46
|
+
if (!NIL_P(kws)) {
|
47
|
+
VALUE project_root = rb_hash_aref(kws, ID2SYM(rb_intern("project_root")));
|
48
|
+
if (!NIL_P(project_root)) {
|
49
|
+
if (!RB_TYPE_P(project_root, T_STRING)) {
|
50
|
+
raise_argerror("project_root must be a string.");
|
51
|
+
return (Qnil);
|
52
|
+
}
|
53
|
+
frida_compiler_options_set_project_root(coptions, StringValueCStr(project_root));
|
54
|
+
}
|
55
|
+
VALUE source_maps = rb_hash_aref(kws, ID2SYM(rb_intern("source_maps")));
|
56
|
+
if (!NIL_P(source_maps)) {
|
57
|
+
if (!RB_TYPE_P(source_maps, T_STRING)) {
|
58
|
+
raise_argerror("source_maps must be a string.");
|
59
|
+
return (Qnil);
|
60
|
+
}
|
61
|
+
FridaSourceMaps gsource_maps;
|
62
|
+
if (!rbGObject_unmarshal_enum(StringValueCStr(source_maps), FRIDA_TYPE_SOURCE_MAPS, &gsource_maps)) {
|
63
|
+
raise_argerror("invalid source_maps.");
|
64
|
+
return (Qnil);
|
65
|
+
}
|
66
|
+
frida_compiler_options_set_source_maps(coptions, gsource_maps);
|
67
|
+
}
|
68
|
+
VALUE compression = rb_hash_aref(kws, ID2SYM(rb_intern("compression")));
|
69
|
+
if (!NIL_P(compression)) {
|
70
|
+
if (!RB_TYPE_P(compression, T_STRING)) {
|
71
|
+
raise_argerror("compression must be a string.");
|
72
|
+
return (Qnil);
|
73
|
+
}
|
74
|
+
FridaJsCompression gcompression;
|
75
|
+
if (!rbGObject_unmarshal_enum(StringValueCStr(compression), FRIDA_TYPE_JS_COMPRESSION, &gcompression)) {
|
76
|
+
raise_argerror("invalid compression.");
|
77
|
+
return (Qnil);
|
78
|
+
}
|
79
|
+
frida_compiler_options_set_compression(coptions, gcompression);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
build_sync_proxy_args args = {
|
83
|
+
.handle = d->handle,
|
84
|
+
.entrypoint = StringValueCStr(entrypoint),
|
85
|
+
.options = options
|
86
|
+
};
|
87
|
+
CALL_GVL_FREE_WITH_RET(char *bundle, build_sync, &args);
|
88
|
+
g_object_unref(options);
|
89
|
+
VALUE rbundle = rb_str_new_cstr(bundle);
|
90
|
+
g_free(bundle);
|
91
|
+
return (rbundle);
|
92
|
+
|
93
|
+
gerror:
|
94
|
+
g_object_unref(options);
|
95
|
+
raise_rerror(NULL, _gerr);
|
96
|
+
return (Qnil);
|
97
|
+
}
|
98
|
+
|
99
|
+
GVL_FREE_PROXY_FUNC(watch_sync, watch_sync_proxy_args *args)
|
100
|
+
{
|
101
|
+
GError *gerr = NULL;
|
102
|
+
|
103
|
+
frida_compiler_watch_sync(args->handle, args->entrypoint, args->options, NULL, &gerr);
|
104
|
+
RETURN_GVL_FREE_RESULT(NULL);
|
105
|
+
}
|
106
|
+
|
107
|
+
/*
|
108
|
+
call-seq:
|
109
|
+
#watch(entrypoint, project_root:, source_maps:, compression:) -> nil
|
110
|
+
*/
|
111
|
+
static VALUE Compiler_watch(int argc, VALUE *argv, VALUE self)
|
112
|
+
{
|
113
|
+
GET_GOBJECT_DATA();
|
114
|
+
REQUIRE_GOBJECT_HANDLE();
|
115
|
+
|
116
|
+
VALUE entrypoint, kws;
|
117
|
+
FridaWatchOptions *options;
|
118
|
+
FridaCompilerOptions *coptions;
|
119
|
+
|
120
|
+
rb_scan_args(argc, argv, "1:", &entrypoint, &kws);
|
121
|
+
if (!RB_TYPE_P(entrypoint, T_STRING)) {
|
122
|
+
raise_argerror("entrypoint must be a string.");
|
123
|
+
return (Qnil);
|
124
|
+
}
|
125
|
+
options = frida_watch_options_new();
|
126
|
+
coptions = FRIDA_COMPILER_OPTIONS(options);
|
127
|
+
if (!NIL_P(kws)) {
|
128
|
+
VALUE project_root = rb_hash_aref(kws, ID2SYM(rb_intern("project_root")));
|
129
|
+
if (!NIL_P(project_root)) {
|
130
|
+
if (!RB_TYPE_P(project_root, T_STRING)) {
|
131
|
+
raise_argerror("project_root must be a string.");
|
132
|
+
return (Qnil);
|
133
|
+
}
|
134
|
+
frida_compiler_options_set_project_root(coptions, StringValueCStr(project_root));
|
135
|
+
}
|
136
|
+
VALUE source_maps = rb_hash_aref(kws, ID2SYM(rb_intern("source_maps")));
|
137
|
+
if (!NIL_P(source_maps)) {
|
138
|
+
if (!RB_TYPE_P(source_maps, T_STRING)) {
|
139
|
+
raise_argerror("source_maps must be a string.");
|
140
|
+
return (Qnil);
|
141
|
+
}
|
142
|
+
FridaSourceMaps gsource_maps;
|
143
|
+
if (!rbGObject_unmarshal_enum(StringValueCStr(source_maps), FRIDA_TYPE_SOURCE_MAPS, &gsource_maps)) {
|
144
|
+
raise_argerror("invalid source_maps.");
|
145
|
+
return (Qnil);
|
146
|
+
}
|
147
|
+
frida_compiler_options_set_source_maps(coptions, gsource_maps);
|
148
|
+
}
|
149
|
+
VALUE compression = rb_hash_aref(kws, ID2SYM(rb_intern("compression")));
|
150
|
+
if (!NIL_P(compression)) {
|
151
|
+
if (!RB_TYPE_P(compression, T_STRING)) {
|
152
|
+
raise_argerror("compression must be a string.");
|
153
|
+
return (Qnil);
|
154
|
+
}
|
155
|
+
FridaJsCompression gcompression;
|
156
|
+
if (!rbGObject_unmarshal_enum(StringValueCStr(compression), FRIDA_TYPE_JS_COMPRESSION, &gcompression)) {
|
157
|
+
raise_argerror("invalid compression.");
|
158
|
+
return (Qnil);
|
159
|
+
}
|
160
|
+
frida_compiler_options_set_compression(coptions, gcompression);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
watch_sync_proxy_args args = {
|
164
|
+
.handle = d->handle,
|
165
|
+
.entrypoint = StringValueCStr(entrypoint),
|
166
|
+
.options = options
|
167
|
+
};
|
168
|
+
CALL_GVL_FREE_WITH_RET(char *dummy, watch_sync, &args);
|
169
|
+
goto done;
|
170
|
+
|
171
|
+
gerror:
|
172
|
+
raise_rerror(NULL, _gerr);
|
173
|
+
done:
|
174
|
+
g_object_unref(options);
|
175
|
+
return (Qnil);
|
176
|
+
}
|
177
|
+
|
178
|
+
/*
|
179
|
+
call-seq:
|
180
|
+
#new(dvmgr) -> Compiler
|
181
|
+
*/
|
182
|
+
static VALUE Compiler_initialize(VALUE self, VALUE dvmgr)
|
183
|
+
{
|
184
|
+
GET_GOBJECT_DATA();
|
185
|
+
|
186
|
+
if (dvmgr == Qfalse)
|
187
|
+
return (self);
|
188
|
+
if (!rb_obj_is_instance_of(dvmgr, cDeviceManager)) {
|
189
|
+
raise_argerror("argument should be a DeviceManager instance.");
|
190
|
+
return (Qnil);
|
191
|
+
}
|
192
|
+
VALUE dvmgr_self;
|
193
|
+
dvmgr_self = dvmgr;
|
194
|
+
GET_DATA_EX(GObject, dvmgr_self, dvmgr_d);
|
195
|
+
d->handle = frida_compiler_new(dvmgr_d->handle);
|
196
|
+
d->destroy = frida_unref;
|
197
|
+
return (self);
|
198
|
+
}
|
199
|
+
|
200
|
+
void define_Compiler()
|
201
|
+
{
|
202
|
+
cCompiler = rb_define_class_under(mCFrida, "Compiler", cGObject);
|
203
|
+
|
204
|
+
rb_define_method(cCompiler, "initialize", Compiler_initialize, 1);
|
205
|
+
|
206
|
+
rb_define_method(cCompiler, "build", Compiler_build, -1);
|
207
|
+
rb_define_method(cCompiler, "watch", Compiler_watch, -1);
|
208
|
+
}
|
data/ext/c_frida/Crash.c
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
#include "Crash.h"
|
2
|
+
|
3
|
+
VALUE Crash_from_FridaCrash(FridaCrash *handle)
|
4
|
+
{
|
5
|
+
VALUE self;
|
6
|
+
|
7
|
+
if (!handle)
|
8
|
+
return (Qnil);
|
9
|
+
self = rb_class_new_instance(0, NULL, cCrash);
|
10
|
+
GET_GOBJECT_DATA();
|
11
|
+
d->handle = handle;
|
12
|
+
d->destroy = g_object_unref;
|
13
|
+
rb_ivar_set(self, rb_intern("pid"), LL2NUM(frida_crash_get_pid(handle)));
|
14
|
+
rb_ivar_set(self, rb_intern("process_name"), rbGObject_marshal_string(frida_crash_get_process_name(handle)));
|
15
|
+
rb_ivar_set(self, rb_intern("summary"), rbGObject_marshal_string(frida_crash_get_summary(handle)));
|
16
|
+
rb_ivar_set(self, rb_intern("report"), rbGObject_marshal_string(frida_crash_get_report(handle)));
|
17
|
+
rb_ivar_set(self, rb_intern("parameters"), rbGObject_marshal_dict(frida_crash_get_parameters(handle)));
|
18
|
+
return (self);
|
19
|
+
}
|
20
|
+
|
21
|
+
VALUE Crash_inspect(VALUE self)
|
22
|
+
{
|
23
|
+
VALUE s, report;
|
24
|
+
|
25
|
+
report = rb_funcall(self, rb_intern("report"), 0, NULL);
|
26
|
+
s = rb_sprintf("#<Crash: pid=%+"PRIsVALUE", process_name=%+"PRIsVALUE", summary=%+"PRIsVALUE", report=<%+"PRIsVALUE" bytes>, parameters=%+"PRIsVALUE">", \
|
27
|
+
rb_funcall(self, rb_intern("pid"), 0, NULL),
|
28
|
+
rb_funcall(self, rb_intern("process_name"), 0, NULL),
|
29
|
+
rb_funcall(self, rb_intern("summary"), 0, NULL),
|
30
|
+
(report == Qnil) ? UINT2NUM(0) : rb_funcall(report, rb_intern("length"), 0, NULL),
|
31
|
+
rb_funcall(self, rb_intern("parameters"), 0, NULL)
|
32
|
+
);
|
33
|
+
return (s);
|
34
|
+
}
|
35
|
+
|
36
|
+
/*
|
37
|
+
call-seq:
|
38
|
+
#pid() -> Fixnum
|
39
|
+
*/
|
40
|
+
static VALUE Crash_pid(VALUE self)
|
41
|
+
{
|
42
|
+
return (rb_ivar_get(self, rb_intern("pid")));
|
43
|
+
}
|
44
|
+
|
45
|
+
/*
|
46
|
+
call-seq:
|
47
|
+
#process_name() -> String
|
48
|
+
*/
|
49
|
+
static VALUE Crash_process_name(VALUE self)
|
50
|
+
{
|
51
|
+
return (rb_ivar_get(self, rb_intern("process_name")));
|
52
|
+
}
|
53
|
+
|
54
|
+
/*
|
55
|
+
call-seq:
|
56
|
+
#summary() -> String
|
57
|
+
*/
|
58
|
+
static VALUE Crash_summary(VALUE self)
|
59
|
+
{
|
60
|
+
return (rb_ivar_get(self, rb_intern("summary")));
|
61
|
+
}
|
62
|
+
|
63
|
+
/*
|
64
|
+
call-seq:
|
65
|
+
#report() -> String
|
66
|
+
*/
|
67
|
+
static VALUE Crash_report(VALUE self)
|
68
|
+
{
|
69
|
+
return (rb_ivar_get(self, rb_intern("report")));
|
70
|
+
}
|
71
|
+
|
72
|
+
/*
|
73
|
+
call-seq:
|
74
|
+
#parameters() -> Hash
|
75
|
+
*/
|
76
|
+
static VALUE Crash_parameters(VALUE self)
|
77
|
+
{
|
78
|
+
return (rb_ivar_get(self, rb_intern("parameters")));
|
79
|
+
}
|
80
|
+
|
81
|
+
void define_Crash()
|
82
|
+
{
|
83
|
+
cCrash = rb_define_class_under(mCFrida, "Crash", cGObject);
|
84
|
+
|
85
|
+
rb_define_method(cCrash, "inspect", Crash_inspect, 0);
|
86
|
+
rb_define_alias(cCrash, "to_s", "inspect");
|
87
|
+
rb_define_method(cCrash, "pid", Crash_pid, 0);
|
88
|
+
rb_define_method(cCrash, "process_name", Crash_process_name, 0);
|
89
|
+
rb_define_method(cCrash, "summary", Crash_summary, 0);
|
90
|
+
rb_define_method(cCrash, "report", Crash_report, 0);
|
91
|
+
rb_define_method(cCrash, "parameters", Crash_parameters, 0);
|
92
|
+
}
|