Class: Pwnlib::Tubes::Process
Overview
Launch a process.
Constant Summary collapse
- DEFAULT_OPTIONS =
Default options for #initialize.
{ env: ENV, in: :pipe, out: :pipe, raw: true, aslr: true }.freeze
Constants inherited from Tube
Instance Method Summary collapse
-
#initialize(argv, **opts) ⇒ Process
constructor
Instantiate a Process object.
-
#kill ⇒ void
(also: #close)
Kill the process.
-
#shutdown(direction = :both) ⇒ void
Close the IO.
Methods inherited from Tube
#gets, #interact, #puts, #recv, #recvall, #recvline, #recvn, #recvpred, #recvregex, #recvuntil, #send, #sendline, #unrecv
Constructor Details
#initialize(argv, **opts) ⇒ Process
Instantiate a Pwnlib::Tubes::Process object.
64 65 66 67 68 69 70 71 72 |
# File 'lib/pwnlib/tubes/process.rb', line 64 def initialize(argv, **opts) opts = DEFAULT_OPTIONS.merge(opts) super(timeout: opts[:timeout]) argv = normalize_argv(argv, opts) slave_i, slave_o = create_pipe(opts) @pid = ::Process.spawn(opts[:env], *argv, in: slave_i, out: slave_o, unsetenv_others: true) slave_i.close slave_o.close unless slave_i == slave_o end |
Instance Method Details
#kill ⇒ void Also known as: close
This method returns an undefined value.
Kill the process.
87 88 89 90 91 |
# File 'lib/pwnlib/tubes/process.rb', line 87 def kill shutdown ::Process.kill('KILL', @pid) ::Process.wait(@pid) end |
#shutdown(direction = :both) ⇒ void
This method returns an undefined value.
Close the IO.
80 81 82 |
# File 'lib/pwnlib/tubes/process.rb', line 80 def shutdown(direction = :both) close_io(normalize_direction(direction)) end |