Permalink
Browse files

Catch SIGINT whilst injecting payload to stop the remote process gett…

…ing killed. Process may still seg fault though... humpf. Probably not possible to avoid while using popen.. rb-libgdb anyone?
  • Loading branch information...
1 parent 1020eb4 commit c93c51c5459d9576fa4d504ca39d82de1850fd82 Ian Leitch committed Sep 21, 2009
Showing with 8 additions and 0 deletions.
  1. +2 −0 lib/hijack/gdb.rb
  2. +6 −0 lib/hijack/payload.rb
View
@@ -31,10 +31,12 @@ def eval(cmd)
end
def detach
+ return unless @gdb
exec('detach')
exec('quit')
@backtrace = nil
@gdb.close
+ @gdb = nil
end
protected
View
@@ -1,9 +1,15 @@
module Hijack
class Payload
def self.inject(pid)
+ gdb = nil
+ trap('SIGINT') do
+ puts
+ @received_sigint = true
+ end
gdb = GDB.new(pid)
gdb.eval(payload(pid))
gdb.detach
+ exit if @received_sigint
end
def self.payload(pid)

0 comments on commit c93c51c

Please sign in to comment.