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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec8f3e43fcf993f4fe7f22c780ea2c265c77f9c1f342fe20365401e7569e8c27
|
4
|
+
data.tar.gz: 44bd17ab08b8999210c2adb3f27f27c89e7529a54ca50b359a9b63f29af3337b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c294d04d835eae8b2a81fecf1cdd434caf313dc6e3a12ae55891e817fee08b6518c02bd0b923becd7ae8f8e031edf08873f70989e00c62b09e391341c87f67ee
|
7
|
+
data.tar.gz: d8d166c37b5dcd7c9fc8631470d479c6dee8c28c5b84f5221a9c1bfa57bb4c546d2ffa1d2e000e48d0c601df7c83b117cea19da8f43665b3baa72540e0def840
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 67718634+hakivvi@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
frida (0.1.0)
|
5
|
+
rake-compiler (~> 1.2.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
minitest (5.21.2)
|
11
|
+
rake (13.1.0)
|
12
|
+
rake-compiler (1.2.7)
|
13
|
+
rake
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
x86_64-linux
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
frida!
|
20
|
+
minitest (~> 5.0)
|
21
|
+
rake (~> 13.0)
|
22
|
+
rake-compiler
|
23
|
+
|
24
|
+
BUNDLED WITH
|
25
|
+
2.3.7
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 hakivvi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Frida
|
2
|
+
|
3
|
+
Frida Ruby bindings.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
First install frida-core from frida releases depending on your system, for instance [frida-core-devkit-16.1.11-linux-x86_64](https://github.com/frida/frida/releases/download/16.1.11/frida-core-devkit-16.1.11-linux-x86_64.tar.xz) or [frida-core-devkit-16.1.11-macos-x86_64.tar.xz](https://github.com/frida/frida/releases/download/16.1.11/frida-core-devkit-16.1.11-macos-x86_64.tar.xz):
|
8
|
+
|
9
|
+
$ wget https://github.com/frida/frida/releases/download/16.1.11/frida-core-devkit-16.1.11-linux-x86_64.tar.xz
|
10
|
+
|
11
|
+
then extract the library and the header file and set `FRIDA_CORE_DEVKIT` env variable to the directory:
|
12
|
+
|
13
|
+
$ tar -xf frida-core-devkit-16.1.11-linux-x86_64.tar.xz
|
14
|
+
$ export FRIDA_CORE_DEVKIT=`pwd`
|
15
|
+
|
16
|
+
Install the gem and add to the application's Gemfile by executing:
|
17
|
+
|
18
|
+
$ bundle add frida
|
19
|
+
|
20
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
21
|
+
|
22
|
+
$ gem install frida
|
23
|
+
|
24
|
+
## OS Support
|
25
|
+
|
26
|
+
Currently frida-ruby does not work on Windows because frida-core is built with Visual Studio, and Ruby native extensions by default build with MinGW, and these two do not link together, i'm not sure yet if i can get the native gem to build with VS.
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
the class names, function names and parameters names are same as [frida-python](https://github.com/frida/frida-python) for ease of migration (note: the whole gem is based on frida-python), every method has a documentation on how to call it, for instance:
|
31
|
+
```C
|
32
|
+
/*
|
33
|
+
call-seq:
|
34
|
+
#create_script(source, name:, snapshot:, runtime:) -> Script
|
35
|
+
*/
|
36
|
+
static VALUE Session_create_script(int argc, VALUE *argv, VALUE self)
|
37
|
+
{
|
38
|
+
}
|
39
|
+
```
|
40
|
+
|
41
|
+
`Session.create_script` takes one positional argument `source` and three optional keyword arguments (keyword arguments are always optional) and returns a `Script` object.
|
42
|
+
`test/` directory has some example scripts to try.
|
43
|
+
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
48
|
+
|
49
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hakivvi/frida-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/frida/blob/master/CODE_OF_CONDUCT.md).
|
54
|
+
|
55
|
+
things to improve:
|
56
|
+
* GVL bridge: this is a workaround i made for acquiring the GVL, frida has lot of callbacks and those callbacks fire from its own threads, CRuby does not support setting up non Ruby created threads to call its APIs. check [gvl_bridge.c](ext/c_frida/gvl_bridge.c) for more informations.
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
61
|
+
|
62
|
+
## Code of Conduct
|
63
|
+
|
64
|
+
Everyone interacting in the Frida project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/frida/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/test_*.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "rake/extensiontask"
|
13
|
+
|
14
|
+
task build: :compile
|
15
|
+
|
16
|
+
Rake::ExtensionTask.new("c_frida") do |ext|
|
17
|
+
ext.lib_dir = "lib"
|
18
|
+
end
|
19
|
+
|
20
|
+
task default: %i[clobber compile test]
|
data/exe/frida
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#include "Application.h"
|
2
|
+
|
3
|
+
VALUE Application_from_FridaApplication(FridaApplication *handle)
|
4
|
+
{
|
5
|
+
VALUE self;
|
6
|
+
|
7
|
+
if (!handle)
|
8
|
+
return (Qnil);
|
9
|
+
self = rb_class_new_instance(0, NULL, cApplication);
|
10
|
+
GET_GOBJECT_DATA();
|
11
|
+
d->handle = handle;
|
12
|
+
d->destroy = g_object_unref;
|
13
|
+
rb_ivar_set(self, rb_intern("identifier"), rb_str_new_cstr(frida_application_get_identifier(d->handle)));
|
14
|
+
rb_ivar_set(self, rb_intern("name"), rb_str_new_cstr(frida_application_get_name(d->handle)));
|
15
|
+
rb_ivar_set(self, rb_intern("pid"), LL2NUM(frida_application_get_pid(d->handle)));
|
16
|
+
rb_ivar_set(self, rb_intern("parameters"), rbApplication_marshal_parameters_dict(frida_application_get_parameters(d->handle)));
|
17
|
+
return (self);
|
18
|
+
}
|
19
|
+
|
20
|
+
static VALUE Application_inspect(VALUE self)
|
21
|
+
{
|
22
|
+
VALUE s;
|
23
|
+
|
24
|
+
s = rb_sprintf("#<Application: identifier=%+"PRIsVALUE", name=%+"PRIsVALUE", pid=%+"PRIsVALUE", parameters=%+"PRIsVALUE">", \
|
25
|
+
rb_funcall(self, rb_intern("identifier"), 0, NULL),
|
26
|
+
rb_funcall(self, rb_intern("name"), 0, NULL),
|
27
|
+
rb_funcall(self, rb_intern("pid"), 0, NULL),
|
28
|
+
rb_funcall(self, rb_intern("parameters"), 0, NULL)
|
29
|
+
);
|
30
|
+
return (s);
|
31
|
+
}
|
32
|
+
|
33
|
+
/*
|
34
|
+
call-seq:
|
35
|
+
#identifier() -> String
|
36
|
+
*/
|
37
|
+
static VALUE Application_identifier(VALUE self)
|
38
|
+
{
|
39
|
+
return (rb_ivar_get(self, rb_intern("identifier")));
|
40
|
+
}
|
41
|
+
|
42
|
+
/*
|
43
|
+
call-seq:
|
44
|
+
#name() -> String
|
45
|
+
*/
|
46
|
+
static VALUE Application_name(VALUE self)
|
47
|
+
{
|
48
|
+
return (rb_ivar_get(self, rb_intern("name")));
|
49
|
+
}
|
50
|
+
|
51
|
+
/*
|
52
|
+
call-seq:
|
53
|
+
#pid() -> Fixnum
|
54
|
+
*/
|
55
|
+
static VALUE Application_pid(VALUE self)
|
56
|
+
{
|
57
|
+
return (rb_ivar_get(self, rb_intern("pid")));
|
58
|
+
}
|
59
|
+
|
60
|
+
/*
|
61
|
+
call-seq:
|
62
|
+
#parameters() -> Hash
|
63
|
+
*/
|
64
|
+
static VALUE Application_parameters(VALUE self)
|
65
|
+
{
|
66
|
+
return (rb_ivar_get(self, rb_intern("parameters")));
|
67
|
+
}
|
68
|
+
|
69
|
+
void define_Application()
|
70
|
+
{
|
71
|
+
cApplication = rb_define_class_under(mCFrida, "Application", cGObject);
|
72
|
+
|
73
|
+
rb_define_method(cApplication, "inspect", Application_inspect, 0);
|
74
|
+
rb_define_alias(cApplication, "to_s", "inspect");
|
75
|
+
rb_define_method(cApplication, "identifier", Application_identifier, 0);
|
76
|
+
rb_define_method(cApplication, "name", Application_name, 0);
|
77
|
+
rb_define_method(cApplication, "pid", Application_pid, 0);
|
78
|
+
rb_define_method(cApplication, "parameters", Application_parameters, 0);
|
79
|
+
}
|
data/ext/c_frida/Bus.c
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
#include "Bus.h"
|
2
|
+
|
3
|
+
VALUE Bus_from_FridaBus(FridaBus *fridabus)
|
4
|
+
{
|
5
|
+
VALUE self;
|
6
|
+
|
7
|
+
self = rb_class_new_instance(0, NULL, cBus);
|
8
|
+
GET_GOBJECT_DATA();
|
9
|
+
d->handle = fridabus;
|
10
|
+
d->destroy = g_object_unref;
|
11
|
+
return (self);
|
12
|
+
}
|
13
|
+
|
14
|
+
GVL_FREE_PROXY_FUNC(attach_sync, void *handle)
|
15
|
+
{
|
16
|
+
GError *gerr = NULL;
|
17
|
+
|
18
|
+
frida_bus_attach_sync(handle, NULL, &gerr);
|
19
|
+
RETURN_GVL_FREE_RESULT(NULL);
|
20
|
+
}
|
21
|
+
|
22
|
+
/*
|
23
|
+
call-seq:
|
24
|
+
#attach() -> nil
|
25
|
+
*/
|
26
|
+
static VALUE Bus_attach(VALUE self)
|
27
|
+
{
|
28
|
+
GET_GOBJECT_DATA();
|
29
|
+
REQUIRE_GOBJECT_HANDLE();
|
30
|
+
|
31
|
+
CALL_GVL_FREE_WITH_RET(void *dummy, attach_sync, d->handle);
|
32
|
+
return (Qnil);
|
33
|
+
|
34
|
+
GERROR_BLOCK
|
35
|
+
}
|
36
|
+
|
37
|
+
GVL_FREE_PROXY_FUNC(post, bus_post_proxy_args *args)
|
38
|
+
{
|
39
|
+
GError *gerr = NULL;
|
40
|
+
|
41
|
+
frida_bus_post(args->handle, args->message, args->data);
|
42
|
+
RETURN_GVL_FREE_RESULT(NULL);
|
43
|
+
}
|
44
|
+
|
45
|
+
/*
|
46
|
+
call-seq:
|
47
|
+
#post(message, data:) -> nil
|
48
|
+
*/
|
49
|
+
static VALUE Bus_post(int argc, VALUE *argv, VALUE self)
|
50
|
+
{
|
51
|
+
GET_GOBJECT_DATA();
|
52
|
+
REQUIRE_GOBJECT_HANDLE();
|
53
|
+
VALUE message, kws, data;
|
54
|
+
GBytes *gdata = NULL;
|
55
|
+
|
56
|
+
rb_scan_args(argc, argv, "1:", &message, &kws);
|
57
|
+
if (!RB_TYPE_P(message, T_STRING)) {
|
58
|
+
raise_argerror("message should be a string.");
|
59
|
+
return (Qnil);
|
60
|
+
}
|
61
|
+
if (!NIL_P(kws)) {
|
62
|
+
data = rb_hash_aref(kws, ID2SYM(rb_intern("data")));
|
63
|
+
if (!NIL_P(data)) {
|
64
|
+
if (!RB_TYPE_P(data, T_STRING)) {
|
65
|
+
raise_argerror("scope must be a string.");
|
66
|
+
return (Qnil);
|
67
|
+
}
|
68
|
+
gdata = g_bytes_new(RSTRING_PTR(data), RSTRING_LEN(data));
|
69
|
+
}
|
70
|
+
}
|
71
|
+
bus_post_proxy_args args = {
|
72
|
+
.handle = d->handle,
|
73
|
+
.message = StringValueCStr(message),
|
74
|
+
.data = gdata
|
75
|
+
};
|
76
|
+
CALL_GVL_FREE_WITH_RET(void *dummy, post, &args);
|
77
|
+
g_bytes_unref(gdata);
|
78
|
+
return (Qnil);
|
79
|
+
|
80
|
+
gerror:
|
81
|
+
g_bytes_unref(gdata);
|
82
|
+
raise_rerror(NULL, _gerr);
|
83
|
+
return (Qnil);
|
84
|
+
}
|
85
|
+
|
86
|
+
void define_Bus()
|
87
|
+
{
|
88
|
+
cBus = rb_define_class_under(mCFrida, "Bus", cGObject);
|
89
|
+
rb_define_method(cBus, "attach", Bus_attach, 0);
|
90
|
+
rb_define_method(cBus, "post", Bus_post, -1);
|
91
|
+
}
|
data/ext/c_frida/Child.c
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
#include "Child.h"
|
2
|
+
|
3
|
+
VALUE Child_from_FridaChild(FridaChild *handle)
|
4
|
+
{
|
5
|
+
VALUE self;
|
6
|
+
|
7
|
+
if (!handle)
|
8
|
+
return (Qnil);
|
9
|
+
self = rb_class_new_instance(0, NULL, cChild);
|
10
|
+
GET_GOBJECT_DATA();
|
11
|
+
d->handle = handle;
|
12
|
+
d->destroy = g_object_unref;
|
13
|
+
rb_ivar_set(self, rb_intern("pid"), UINT2NUM(frida_child_get_pid(d->handle)));
|
14
|
+
rb_ivar_set(self, rb_intern("parent_pid"), UINT2NUM(frida_child_get_parent_pid(d->handle)));
|
15
|
+
rb_ivar_set(self, rb_intern("identifier"), rbGObject_marshal_string(frida_child_get_identifier(d->handle)));
|
16
|
+
rb_ivar_set(self, rb_intern("path"), rbGObject_marshal_string(frida_child_get_path(d->handle)));
|
17
|
+
rb_ivar_set(self, rb_intern("origin"), rbGObject_marshal_enum(frida_child_get_origin(d->handle), FRIDA_TYPE_CHILD_ORIGIN));
|
18
|
+
gint len;
|
19
|
+
rb_ivar_set(self, rb_intern("argv"), rbGObject_marshal_strv((gchar **)frida_child_get_argv(d->handle, &len), len));
|
20
|
+
rb_ivar_set(self, rb_intern("envp"), rbGObject_marshal_envp((const gchar **)frida_child_get_envp(d->handle, &len), len));
|
21
|
+
return (self);
|
22
|
+
}
|
23
|
+
|
24
|
+
static VALUE Child_inspect(VALUE self)
|
25
|
+
{
|
26
|
+
GET_GOBJECT_DATA();
|
27
|
+
|
28
|
+
VALUE s;
|
29
|
+
FridaChildOrigin origin;
|
30
|
+
GString *inspect_s;
|
31
|
+
|
32
|
+
inspect_s = g_string_new("#<Child: ");
|
33
|
+
g_string_append(inspect_s, "pid=%+"PRIsVALUE", parent_pid=%+"PRIsVALUE);
|
34
|
+
g_string_append(inspect_s, ", origin=%+"PRIsVALUE", identifier=%+"PRIsVALUE);
|
35
|
+
|
36
|
+
if (d->handle)
|
37
|
+
origin = frida_child_get_origin(d->handle);
|
38
|
+
else
|
39
|
+
origin = FRIDA_CHILD_ORIGIN_FORK;
|
40
|
+
if (origin != FRIDA_CHILD_ORIGIN_FORK) {
|
41
|
+
g_string_append(inspect_s, ", path=%+"PRIsVALUE", argv=%+"PRIsVALUE", envp=%+"PRIsVALUE);
|
42
|
+
g_string_append(inspect_s, ">");
|
43
|
+
s = rb_sprintf(inspect_s->str, \
|
44
|
+
rb_funcall(self, rb_intern("pid"), 0, NULL), rb_funcall(self, rb_intern("parent_pid"), 0, NULL), \
|
45
|
+
rb_funcall(self, rb_intern("origin"), 0, NULL), rb_funcall(self, rb_intern("identifier"), 0, NULL), \
|
46
|
+
rb_funcall(self, rb_intern("path"), 0, NULL), rb_funcall(self, rb_intern("argv"), 0, NULL), \
|
47
|
+
rb_funcall(self, rb_intern("envp"), 0, NULL));
|
48
|
+
} else {
|
49
|
+
g_string_append(inspect_s, ">");
|
50
|
+
s = rb_sprintf(inspect_s->str, \
|
51
|
+
rb_funcall(self, rb_intern("pid"), 0, NULL), rb_funcall(self, rb_intern("parent_pid"), 0, NULL), \
|
52
|
+
rb_funcall(self, rb_intern("origin"), 0, NULL), rb_funcall(self, rb_intern("identifier"), 0, NULL));
|
53
|
+
}
|
54
|
+
g_string_free(inspect_s, TRUE);
|
55
|
+
return (s);
|
56
|
+
}
|
57
|
+
|
58
|
+
/*
|
59
|
+
call-seq:
|
60
|
+
#pid() -> Fixnum
|
61
|
+
*/
|
62
|
+
static VALUE Child_pid(VALUE self)
|
63
|
+
{
|
64
|
+
return (rb_ivar_get(self, rb_intern("pid")));
|
65
|
+
}
|
66
|
+
|
67
|
+
/*
|
68
|
+
call-seq:
|
69
|
+
#identifier() -> String
|
70
|
+
*/
|
71
|
+
static VALUE Child_identifier(VALUE self)
|
72
|
+
{
|
73
|
+
return (rb_ivar_get(self, rb_intern("identifier")));
|
74
|
+
}
|
75
|
+
|
76
|
+
/*
|
77
|
+
call-seq:
|
78
|
+
#parent_pid() -> Fixnum
|
79
|
+
*/
|
80
|
+
static VALUE Child_parent_pid(VALUE self)
|
81
|
+
{
|
82
|
+
return (rb_ivar_get(self, rb_intern("parent_pid")));
|
83
|
+
}
|
84
|
+
|
85
|
+
/*
|
86
|
+
call-seq:
|
87
|
+
#path() -> String
|
88
|
+
*/
|
89
|
+
static VALUE Child_path(VALUE self)
|
90
|
+
{
|
91
|
+
return (rb_ivar_get(self, rb_intern("path")));
|
92
|
+
}
|
93
|
+
|
94
|
+
/*
|
95
|
+
call-seq:
|
96
|
+
#argv() -> Array
|
97
|
+
*/
|
98
|
+
static VALUE Child_argv(VALUE self)
|
99
|
+
{
|
100
|
+
return (rb_ivar_get(self, rb_intern("argv")));
|
101
|
+
}
|
102
|
+
|
103
|
+
/*
|
104
|
+
call-seq:
|
105
|
+
#envp() -> Array
|
106
|
+
*/
|
107
|
+
static VALUE Child_envp(VALUE self)
|
108
|
+
{
|
109
|
+
return (rb_ivar_get(self, rb_intern("envp")));
|
110
|
+
}
|
111
|
+
|
112
|
+
/*
|
113
|
+
call-seq:
|
114
|
+
#origin() -> String
|
115
|
+
*/
|
116
|
+
static VALUE Child_origin(VALUE self)
|
117
|
+
{
|
118
|
+
return (rb_ivar_get(self, rb_intern("origin")));
|
119
|
+
}
|
120
|
+
|
121
|
+
void define_Child()
|
122
|
+
{
|
123
|
+
cChild = rb_define_class_under(mCFrida, "Child", cGObject);
|
124
|
+
|
125
|
+
rb_define_method(cChild, "inspect", Child_inspect, 0);
|
126
|
+
rb_define_alias(cChild, "to_s", "inspect");
|
127
|
+
rb_define_method(cChild, "pid", Child_pid, 0);
|
128
|
+
rb_define_method(cChild, "parent_pid", Child_parent_pid, 0);
|
129
|
+
rb_define_method(cChild, "identifier", Child_identifier, 0);
|
130
|
+
rb_define_method(cChild, "origin", Child_origin, 0);
|
131
|
+
rb_define_method(cChild, "path", Child_path, 0);
|
132
|
+
rb_define_method(cChild, "argv", Child_argv, 0);
|
133
|
+
rb_define_method(cChild, "envp", Child_envp, 0);
|
134
|
+
}
|