Class: Ronin::PostEx::RemoteProcess

Inherits:
Resource
  • Object
show all
Includes:
Enumerable, FakeIO
Defined in:
lib/ronin/post_ex/remote_process.rb

Overview

The RemoteProcess class represents a command being executed on a remote system. The RemoteProcess class wraps around the process_popen and process_read, process_write, and process_close methods defined in the API object.

Instance Attribute Summary collapse

Attributes inherited from Resource

#session

Instance Method Summary collapse

Methods inherited from Resource

#interact, #supports, #supports?

Constructor Details

#initialize(session, command) ⇒ RemoteProcess

Creates a new remote process.

Parameters:

  • session (Sessions::Session)

    The object controlling command execution.

  • command (String)

    The command to run.

Raises:

  • (NotImplementedError)

    The session object does not define process_popen.



55
56
57
58
59
60
61
62
63
64
# File 'lib/ronin/post_ex/remote_process.rb', line 55

def initialize(session,command)
  unless session.respond_to?(:process_popen)
    raise(NotImplementedError,"#{session.inspect} must define #process_popen for #{self.class}")
  end

  @session = session
  @command = command

  super()
end

Instance Attribute Details

#commandString (readonly)

The command string.

Returns:

  • (String)


41
42
43
# File 'lib/ronin/post_ex/remote_process.rb', line 41

def command
  @command
end

Instance Method Details

#inspectString

Inspects the command.

Returns:

  • (String)

    The inspected command listing the program name and arguments.



100
101
102
# File 'lib/ronin/post_ex/remote_process.rb', line 100

def inspect
  "#<#{self.class}: #{self}>"
end

#reopen(command) ⇒ RemoteProcess

Reopens the command.

Parameters:

  • command (String)

    The new command to run.

Returns:



75
76
77
78
79
80
81
# File 'lib/ronin/post_ex/remote_process.rb', line 75

def reopen(command)
  close

  @command = command

  return open
end

#to_sString

Converts the command to a String.

Returns:

  • (String)

    The process'es command.



90
91
92
# File 'lib/ronin/post_ex/remote_process.rb', line 90

def to_s
  @command
end