Method: Rex::Ui::Interactive#interact

Defined in:
lib/rex/ui/interactive.rb

#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