Module: Rex::Post::HWBridge::Ui::Console::InteractiveChannel
- Includes:
- Ui::Interactive
- Defined in:
- lib/rex/post/hwbridge/ui/console/interactive_channel.rb
Overview
Mixin that is meant to extend the base channel class from hwbridge in a manner that adds interactive capabilities.
Instance Attribute Summary collapse
-
#on_log_proc ⇒ Object
Returns the value of attribute on_log_proc.
Attributes included from Ui::Interactive
#completed, #interacting, #next_session, #on_command_proc, #on_print_proc, #on_run_command_error_proc, #orig_suspend, #orig_usr1, #orig_winch
Attributes included from Ui::Subscriber::Input
Attributes included from Ui::Subscriber::Output
Instance Method Summary collapse
-
#_interact ⇒ Object
Interacts with self.
-
#_interact_complete ⇒ Object
Closes the channel like it aint no thang.
-
#_interrupt ⇒ Object
Called when an interrupt is sent.
-
#_remote_fd(stream) ⇒ Object
Returns the remote file descriptor to select on.
-
#_stream_read_local_write_remote(channel) ⇒ Object
Reads data from local input and writes it remotely.
-
#_stream_read_remote_write_local(channel) ⇒ Object
Reads from the channel and writes locally.
-
#_suspend ⇒ Object
Suspends interaction with the channel.
Methods included from Ui::Interactive
#_local_fd, #_winch, #detach, #handle_suspend, #handle_usr1, #handle_winch, #interact, #interact_stream, #prompt, #prompt_yesno, #restore_suspend, #restore_usr1, #restore_winch
Methods included from Ui::Subscriber
Methods included from Ui::Subscriber::Input
Methods included from Ui::Subscriber::Output
#flush, #print, #print_blank_line, #print_error, #print_good, #print_line, #print_status, #print_warning
Instance Attribute Details
#on_log_proc ⇒ Object
Returns the value of attribute on_log_proc.
95 96 97 |
# File 'lib/rex/post/hwbridge/ui/console/interactive_channel.rb', line 95 def on_log_proc @on_log_proc end |
Instance Method Details
#_interact ⇒ Object
Interacts with self.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rex/post/hwbridge/ui/console/interactive_channel.rb', line 20 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 ⇒ Object
Closes the channel like it aint no thang.
57 58 59 60 61 62 63 64 |
# File 'lib/rex/post/hwbridge/ui/console/interactive_channel.rb', line 57 def _interact_complete begin self.interactive(false) self.close rescue IOError end end |
#_interrupt ⇒ Object
Called when an interrupt is sent.
38 39 40 |
# File 'lib/rex/post/hwbridge/ui/console/interactive_channel.rb', line 38 def _interrupt prompt_yesno("Terminate channel #{self.cid}?") end |
#_remote_fd(stream) ⇒ Object
Returns the remote file descriptor to select on
91 92 93 |
# File 'lib/rex/post/hwbridge/ui/console/interactive_channel.rb', line 91 def _remote_fd(stream) self.lsock end |
#_stream_read_local_write_remote(channel) ⇒ Object
Reads data from local input and writes it remotely.
69 70 71 72 73 74 75 |
# File 'lib/rex/post/hwbridge/ui/console/interactive_channel.rb', line 69 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) ⇒ Object
Reads from the channel and writes locally.
80 81 82 83 84 85 86 |
# File 'lib/rex/post/hwbridge/ui/console/interactive_channel.rb', line 80 def _stream_read_remote_write_local(channel) data = self.lsock.sysread(16384) self.on_print_proc.call(data.strip) if self.on_print_proc self.on_log_proc.call(data.strip) if self.on_log_proc user_output.print(data) end |
#_suspend ⇒ Object
Suspends interaction with the channel.
45 46 47 48 49 50 51 52 |
# File 'lib/rex/post/hwbridge/ui/console/interactive_channel.rb', line 45 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 |