Module: Msf::Post::WebRTC

Included in:
Rex::Post::Meterpreter::Extensions::Stdapi::Webcam::Webcam
Defined in:
lib/msf/core/post/webrtc.rb

Instance Method Summary collapse

Instance Method Details

#connect_video_chat(server, channel, offerer_id) ⇒ Object

Connects to a video chat session as an answerer

Parameters:

  • offerer_id (String)

    The offerer's ID in order to join the video chat

Returns:

  • void



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/msf/core/post/webrtc.rb', line 11

def connect_video_chat(server, channel, offerer_id)
  interface = load_interface('answerer.html')
  interface.gsub!(/\=SERVER\=/, server)
  interface.gsub!(/\=RHOST\=/, rhost)
  interface.gsub!(/\=CHANNEL\=/, channel)
  interface.gsub!(/\=OFFERERID\=/, offerer_id)

  tmp_interface = Tempfile.new(['answerer', '.html'])
  tmp_interface.binmode
  tmp_interface.write(interface)
  tmp_interface.close

  found_local_browser = Rex::Compat.open_webrtc_browser(tmp_interface.path)
  unless found_local_browser
    raise RuntimeError, "Unable to find a suitable browser to connect to the target"
  end
end

#load_api_codeString

Returns the webcam API

Returns:

  • (String)

    The WebRTC lib code



50
51
52
53
54
55
# File 'lib/msf/core/post/webrtc.rb', line 50

def load_api_code
  js_api_path = ::File.join(Msf::Config.data_directory, 'webcam', 'api.js')
  api = ''
  ::File.open(js_api_path) { |f| api = f.read }
  api
end

#load_interface(html_name) ⇒ String

Returns the webcam interface

Parameters:

  • html_name (String)

    The filename of the HTML interface (offerer.html or answerer.html)

Returns:

  • (String)

    The HTML interface code



36
37
38
39
40
41
42
# File 'lib/msf/core/post/webrtc.rb', line 36

def load_interface(html_name)
  interface_path = ::File.join(Msf::Config.data_directory, 'webcam', html_name)
  interface_code = ''
  ::File.open(interface_path) { |f| interface_code = f.read }
  interface_code.gsub!(/\=WEBRTCAPIJS\=/, load_api_code)
  interface_code
end