ileitch-hijack 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +26 -0
- data/Rakefile +9 -0
- data/TODO +6 -0
- data/bin/hijack +14 -0
- metadata +57 -0
data/README.rdoc
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
= Hijack: Provides an irb session to an existing ruby process.
|
2
|
+
|
3
|
+
== WARNING
|
4
|
+
|
5
|
+
Hijack is new code, I'd think twice about trying it out on your critical production systems. I'd love to get some feedback though so if you have any staging systems to try it out on then please do... ;)
|
6
|
+
|
7
|
+
== Intro
|
8
|
+
|
9
|
+
Hijack allows you to connect to any ruby process and execute code as if it were a normal Irb session. Hijack does not require your target process to require any hijack code, Hijack is able to connect to any ruby process. It achieves this by using gdb to inject a payload into the process which starts up a DRb server, Hijack then detaches gdb and reconnects via DRb. Please note that gdb will halt your target process while it is attached, though the injection process is very quick and your process should only be halted for a few milliseconds.
|
10
|
+
|
11
|
+
Hijack uses DRb over a unix socket file, so you need to be on the same machine as the process you want to hijack. This is by design for security reasons. You also need to run the hijack client as the same user as the remote process.
|
12
|
+
|
13
|
+
== Using Hijack
|
14
|
+
|
15
|
+
$ ruby hijack 16451
|
16
|
+
=> Hijacking...
|
17
|
+
=> Mirroring: 100%
|
18
|
+
=> Hijacked 16451 (my_script.rb) (ruby 1.8.7 [i686-darwin9])
|
19
|
+
>>
|
20
|
+
|
21
|
+
== Process Mirroring
|
22
|
+
|
23
|
+
DRb cannot dump objects to the Hijack client for types that are not loaded in the client process. E.g if the remote process had required ActiveRecord and you tried to dump ActiveRecord::Base back to the client, DRb would instead return a DRb::Unknown object as ActiveRecord
|
24
|
+
isn't loaded in the Hijack client.
|
25
|
+
|
26
|
+
To work around this, when Hijack connects to a remote process it will inspect all the files required by the process and also attempt to require them itself. This may not work for all object types however so you may still get a warning when an object cannot be dumped.
|
data/Rakefile
ADDED
data/TODO
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
* Use thread local stdout & stderr capture.
|
2
|
+
* assigning a variable doesn't work
|
3
|
+
* Improve startup experience
|
4
|
+
* Check if attached process is in fact a ruby process
|
5
|
+
* Require actual remote script if possible so that if it defines any classes we can dump those too.
|
6
|
+
* (eval):211: [BUG] object allocation during garbage collection phase
|
data/bin/hijack
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
require 'hijack'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
ARGV.clone.options do |opts|
|
8
|
+
opts.banner = 'Usage: hijack [options] <PID>'
|
9
|
+
opts.on("--gdb-debug", "Print gdb activity to the console.") { |v| options[:gdb_debug] = v }
|
10
|
+
opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
|
11
|
+
opts.parse!
|
12
|
+
end
|
13
|
+
|
14
|
+
Hijack.start(ARGV.last, options)
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ileitch-hijack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ian Leitch
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-05-16 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Provides an irb session to an existing ruby process.
|
17
|
+
email: ian.leitch@systino.net
|
18
|
+
executables:
|
19
|
+
- hijack
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.rdoc
|
24
|
+
- TODO
|
25
|
+
files:
|
26
|
+
- README.rdoc
|
27
|
+
- Rakefile
|
28
|
+
- TODO
|
29
|
+
has_rdoc: true
|
30
|
+
homepage: http://github.com/ileitch/hijack
|
31
|
+
licenses:
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: "0"
|
42
|
+
version:
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: "0"
|
48
|
+
version:
|
49
|
+
requirements: []
|
50
|
+
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.3.5
|
53
|
+
signing_key:
|
54
|
+
specification_version: 2
|
55
|
+
summary: Provides an irb session to an existing ruby process.
|
56
|
+
test_files: []
|
57
|
+
|