module Rex::Post::Meterpreter::Ui::Console::InteractiveChannel

Mixin that is meant to extend the base channel class from meterpreter in a manner that adds interactive capabilities.

Public Instance Methods

_interact() click to toggle source

Interacts with self.

# File lib/rex/post/meterpreter/ui/console/interactive_channel.rb, line 19
def _interact
  # If the channel has a left-side socket, then we can interact with it.
  if (self.lsock)
    self.interactive(true)

    interact_stream(self)

    self.interactive(false)
  else
    print_error("Channel #{self.cid} does not support interaction.")

    self.interacting = false
  end
end
_interact_complete() click to toggle source

Closes the channel like it aint no thang.

# File lib/rex/post/meterpreter/ui/console/interactive_channel.rb, line 56
def _interact_complete
  begin
    self.interactive(false)

    self.close
  rescue IOError
  end
end
_interrupt() click to toggle source

Called when an interrupt is sent.

# File lib/rex/post/meterpreter/ui/console/interactive_channel.rb, line 37
def _interrupt
  prompt_yesno("Terminate channel #{self.cid}?")
end
_remote_fd(stream) click to toggle source

Returns the remote file descriptor to select on

# File lib/rex/post/meterpreter/ui/console/interactive_channel.rb, line 89
def _remote_fd(stream)
  self.lsock
end
_stream_read_local_write_remote(channel) click to toggle source

Reads data from local input and writes it remotely.

# File lib/rex/post/meterpreter/ui/console/interactive_channel.rb, line 68
def _stream_read_local_write_remote(channel)
  data = user_input.gets
  return if not data

  self.on_command_proc.call(data.strip) if self.on_command_proc
  self.write(data)
end
_stream_read_remote_write_local(channel) click to toggle source

Reads from the channel and writes locally.

# File lib/rex/post/meterpreter/ui/console/interactive_channel.rb, line 79
def _stream_read_remote_write_local(channel)
  data = self.lsock.sysread(16384)

  self.on_print_proc.call(data.strip) if self.on_print_proc
  user_output.print(data)
end
_suspend() click to toggle source

Suspends interaction with the channel.

# File lib/rex/post/meterpreter/ui/console/interactive_channel.rb, line 44
def _suspend
  # Ask the user if they would like to background the session
  if (prompt_yesno("Background channel #{self.cid}?") == true)
    self.interactive(false)

    self.interacting = false
  end
end