Module: Rex::Ui::Interactive
- Includes:
- Subscriber
- Included in:
- Post::Meterpreter::Ui::Console::InteractiveChannel
- Defined in:
- lib/rex/ui/interactive.rb
Overview
This class implements the stubs that are needed to provide an interactive user interface that is backed against something arbitrary.
Instance Attribute Summary collapse
-
#completed ⇒ Object
Whether or not the session has completed interaction.
-
#interacting ⇒ Object
Whether or not the session is currently being interacted with.
-
#on_command_proc ⇒ Object
Returns the value of attribute on_command_proc.
-
#on_print_proc ⇒ Object
Returns the value of attribute on_print_proc.
Attributes included from Subscriber::Input
Attributes included from Subscriber::Output
Instance Method Summary collapse
-
#detach ⇒ Object
Stops the current interaction.
-
#interact(user_input, user_output) ⇒ Object
Starts interacting with the session at the most raw level, simply forwarding input from user_input to rstream and forwarding input from rstream to user_output.
Methods included from Subscriber
Methods included from Subscriber::Input
Methods included from Subscriber::Output
#flush, #print, #print_debug, #print_error, #print_good, #print_line, #print_status, #print_warning
Instance Attribute Details
#completed ⇒ Object
Whether or not the session has completed interaction
110 111 112 |
# File 'lib/rex/ui/interactive.rb', line 110 def completed @completed end |
#interacting ⇒ Object
Whether or not the session is currently being interacted with
105 106 107 |
# File 'lib/rex/ui/interactive.rb', line 105 def interacting @interacting end |
#on_command_proc ⇒ Object
Returns the value of attribute on_command_proc.
113 114 115 |
# File 'lib/rex/ui/interactive.rb', line 113 def on_command_proc @on_command_proc end |
#on_print_proc ⇒ Object
Returns the value of attribute on_print_proc.
112 113 114 |
# File 'lib/rex/ui/interactive.rb', line 112 def on_print_proc @on_print_proc end |
Instance Method Details
#detach ⇒ Object
Stops the current interaction
93 94 95 96 97 98 99 100 |
# File 'lib/rex/ui/interactive.rb', line 93 def detach if (self.interacting) self.interacting = false while(not self.completed) ::IO.select(nil, nil, nil, 0.25) end end end |
#interact(user_input, user_output) ⇒ Object
Starts interacting with the session at the most raw level, simply forwarding input from user_input to rstream and forwarding input from rstream to user_output.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rex/ui/interactive.rb', line 24 def interact(user_input, user_output) # Detach from any existing console if(self.interacting) detach() end init_ui(user_input, user_output) self.interacting = true self.completed = false eof = false # Start the readline stdin monitor # XXX disabled # user_input.readline_start() if user_input.supports_readline # Handle suspend notifications handle_suspend # As long as we're interacting... while (self.interacting == true) begin _interact rescue Interrupt # If we get an interrupt exception, ask the user if they want to # abort the interaction. If they do, then we return out of # the interact function and call it a day. eof = true if (_interrupt) rescue EOFError, Errno::ECONNRESET, IOError # If we reach EOF or the connection is reset... eof = true end break if eof end begin # Restore the suspend handler restore_suspend # If we've hit eof, call the interact complete handler _interact_complete if (eof == true) # Shutdown the readline thread # XXX disabled # user_input.readline_stop() if user_input.supports_readline # Detach from the input/output handles reset_ui() ensure # Mark this as completed self.completed = true end # Return whether or not EOF was reached return eof end |