Module: Msf::Session::Interactive

Includes:
Rex::Ui::Interactive
Included in:
Basic, Msf::Sessions::Meterpreter
Defined in:
lib/msf/core/session/interactive.rb

Overview

This class implements the stubs that are needed to provide an interactive session.

Instance Attribute Summary collapse

Attributes included from Rex::Ui::Interactive

#completed, #interacting, #on_command_proc, #on_print_proc

Attributes included from Rex::Ui::Subscriber::Input

#user_input

Attributes included from Rex::Ui::Subscriber::Output

#user_output

Instance Method Summary collapse

Methods included from Rex::Ui::Interactive

#detach, #interact

Methods included from Rex::Ui::Subscriber

#copy_ui, #init_ui, #reset_ui

Methods included from Rex::Ui::Subscriber::Input

#gets

Methods included from Rex::Ui::Subscriber::Output

#flush, #print, #print_debug, #print_error, #print_good, #print_line, #print_status, #print_warning

Instance Attribute Details

#ringObject

The RingBuffer object used to allow concurrent access to this session


103
104
105
# File 'lib/msf/core/session/interactive.rb', line 103

def ring
  @ring
end

#rstreamObject

The remote stream handle. Must inherit from Rex::IO::Stream.


98
99
100
# File 'lib/msf/core/session/interactive.rb', line 98

def rstream
  @rstream
end

Instance Method Details

#cleanupObject

Closes rstream.


84
85
86
87
88
89
90
91
92
93
# File 'lib/msf/core/session/interactive.rb', line 84

def cleanup
  begin
    self.interacting = false if self.interactive?
    rstream.close if (rstream)
  rescue ::Exception
  end

  rstream = nil
  super
end

#initialize(rstream, opts = {}) ⇒ Object

Initializes the session.


25
26
27
28
29
30
31
32
# File 'lib/msf/core/session/interactive.rb', line 25

def initialize(rstream, opts={})
  # A nil is passed in the case of non-stream interactive sessions (Meterpreter)
  if rstream
    self.rstream = rstream
    self.ring    = Rex::IO::RingBuffer.new(rstream, {:size => opts[:ring_size] || 100 })
  end
  super()
end

#interactive?Boolean

Returns that, yes, indeed, this session supports going interactive with the user.


38
39
40
# File 'lib/msf/core/session/interactive.rb', line 38

def interactive?
  true
end

#killObject

Terminate the session


75
76
77
78
79
# File 'lib/msf/core/session/interactive.rb', line 75

def kill
  self.reset_ui
  self.cleanup
  super()
end

#run_cmd(cmd) ⇒ Object

Run an arbitrary command as if it came from user input.


69
70
# File 'lib/msf/core/session/interactive.rb', line 69

def run_cmd(cmd)
end

#tunnel_localObject

Returns the local information.


45
46
47
48
49
50
51
52
# File 'lib/msf/core/session/interactive.rb', line 45

def tunnel_local
  return @local_info if @local_info
  begin
    @local_info = rstream.localinfo
  rescue ::Exception
    @local_info = '127.0.0.1'
  end
end

#tunnel_peerObject

Returns the remote peer information.


57
58
59
60
61
62
63
64
# File 'lib/msf/core/session/interactive.rb', line 57

def tunnel_peer
  return @peer_info if @peer_info
  begin
    @peer_info = rstream.peerinfo
  rescue ::Exception
    @peer_info = '127.0.0.1'
  end
end