Method: Msf::Sessions::Meterpreter#initialize

Defined in:
lib/msf/base/sessions/meterpreter.rb

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

Initializes a meterpreter session instance using the supplied rstream that is to be used as the client’s connection to the server.


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
89
90
91
92
93
94
95
96
# File 'lib/msf/base/sessions/meterpreter.rb', line 54

def initialize(rstream, opts={})
  super

  opts[:capabilities] = {
    :ssl => supports_ssl?,
    :zlib => supports_zlib?
  }

  # The caller didn't request to skip ssl, so make sure we support it
  if not opts[:skip_ssl]
    opts.merge!(:skip_ssl => (not supports_ssl?))
  end

  #
  # Parse options passed in via the datastore
  #

  # Extract the HandlerSSLCert option if specified by the user
  if opts[:datastore] and opts[:datastore]['HandlerSSLCert']
    opts[:ssl_cert] = opts[:datastore]['HandlerSSLCert']
  end

  # Extract the MeterpreterDebugBuild option if specified by the user
  if opts[:datastore]
    opts[:debug_build] = opts[:datastore]['MeterpreterDebugBuild']
  end

  # Don't pass the datastore into the init_meterpreter method
  opts.delete(:datastore)

  # Assume by default that 10 threads is a safe number for this session
  self.max_threads ||= 10

  #
  # Initialize the meterpreter client
  #
  self.init_meterpreter(rstream, opts)

  #
  # Create the console instance
  #
  self.console = Rex::Post::Meterpreter::Ui::Console.new(self)
end