-
Notifications
You must be signed in to change notification settings - Fork 22
/
hijack
executable file
·27 lines (23 loc) · 888 Bytes
/
hijack
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
#!/usr/bin/env ruby
require 'optparse'
require File.dirname(__FILE__) + '/../lib/hijack'
require 'hijack'
options = {}
usage = 'Usage: hijack [options] <PID>'
pid = ARGV.find {|o| o =~ /\d/}
new_argv = ARGV.clone
new_argv.delete(pid)
new_argv.options do |opts|
opts.banner = usage
opts.on("--debug", "Enable debugging.") { |v| options[:debug] = true }
opts.on("--mute", "Ignore stdout/stderr writes from the remote process.") { |v| options[:mute] = true }
opts.on("-e", "--execute=FILE", String, "Execute the specified file in the remote process and then disconnect.") { |v| options[:execute] = v }
opts.on("--version", "Display this version of Hijack.") { |v| puts "Hijack #{Hijack.version}"; exit }
opts.on("-h", "--help", "Show this help message.") { puts opts; exit }
opts.parse!
end
if pid.nil? || pid.to_s == ''
puts usage
exit 1
end
Hijack.start(pid, options)