Class: Msf::Exploit::Remote::HTTP::Beyondtrust::RemoteSupport::WebSocketStream

Inherits:
Object
  • Object
show all
Defined in:
lib/msf/core/exploit/remote/http/beyondtrust/remote_support.rb

Overview

Uses the framework's RFC 6455 framing; MRS is a byte stream across frames. https://www.rfc-editor.org/rfc/rfc6455.html#section-5.2

Instance Method Summary collapse

Constructor Details

#initialize(socket) ⇒ WebSocketStream

Returns a new instance of WebSocketStream.

Parameters:



85
86
87
88
# File 'lib/msf/core/exploit/remote/http/beyondtrust/remote_support.rb', line 85

def initialize(socket)
  @socket = socket
  @buffer = String.new(encoding: Encoding::BINARY)
end

Instance Method Details

#close ⇒ void

This method returns an undefined value.



114
115
116
# File 'lib/msf/core/exploit/remote/http/beyondtrust/remote_support.rb', line 114

def close
  @socket.close unless @socket.closed?
end

#line ⇒ String

Returns line without LF.

Returns:

  • (String) —

    line without LF



104
105
106
107
108
109
110
111
# File 'lib/msf/core/exploit/remote/http/beyondtrust/remote_support.rb', line 104

def line
  until (offset = @buffer.index("\n"))
    raise ProtocolError, 'Oversized WebSocket handshake line' if @buffer.bytesize > MAX_MESSAGE

    @buffer << frame
  end
  @buffer.slice!(0, offset + 1).delete_suffix("\n")
end

#read(size) ⇒ String

Returns received bytes.

Parameters:

  • size (Integer) —

    exact byte count

Returns:

  • (String) —

    received bytes



98
99
100
101
# File 'lib/msf/core/exploit/remote/http/beyondtrust/remote_support.rb', line 98

def read(size)
  @buffer << frame while @buffer.bytesize < size
  @buffer.slice!(0, size)
end

#write(data) ⇒ void

This method returns an undefined value.

Parameters:

  • data (String) —

    bytes to send



92
93
94
# File 'lib/msf/core/exploit/remote/http/beyondtrust/remote_support.rb', line 92

def write(data)
  @socket.put_wsbinary(data.b)
end