Path: blob/master/modules/auxiliary/admin/chromecast/chromecast_youtube.rb
19535 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Chromecast YouTube Remote Control',13'Description' => %q{14This module acts as a simple remote control for Chromecast YouTube.1516Only the deprecated DIAL protocol is supported by this module.17Casting via the newer CASTV2 protocol is unsupported at this time.18},19'Author' => ['wvu'],20'References' => [21['URL', 'http://www.google.com/intl/en/chrome/devices/chromecast/index.html'] # vendor website22],23'License' => MSF_LICENSE,24'Actions' => [25['Play', { 'Description' => 'Play video' }],26['Stop', { 'Description' => 'Stop video' }]27],28'DefaultAction' => 'Play',29'Notes' => {30'Stability' => [CRASH_SAFE],31'SideEffects' => [IOC_IN_LOGS, SCREEN_EFFECTS],32'Reliability' => []33}34)35)3637register_options([38Opt::RPORT(8008),39OptString.new('VID', [true, 'Video ID', 'kxopViU98Xo'])40])41end4243def run44vid = datastore['VID']4546case action.name47when 'Play'48res = play(vid)49when 'Stop'50res = stop51end5253return unless res5455case res.code56when 20157print_good("Playing https://www.youtube.com/watch?v=#{vid}")58when 20059print_status('Stopping video')60when 40461print_error('Target no longer supports casting via the DIAL protocol. ' \62'CASTV2 is not supported by this module at this time.')63end64end6566def play(vid)67send_request_cgi(68'method' => 'POST',69'uri' => '/apps/YouTube',70'agent' => Rex::Text.rand_text_english(rand(1..42)),71'vars_post' => {72'v' => vid73}74)75rescue Rex::ConnectionRefused, Rex::ConnectionTimeout,76Rex::HostUnreachable => e77fail_with(Failure::Unreachable, e)78ensure79disconnect80end8182def stop83send_request_raw(84'method' => 'DELETE',85'uri' => '/apps/YouTube',86'agent' => Rex::Text.rand_text_english(rand(1..42))87)88rescue Rex::ConnectionRefused, Rex::ConnectionTimeout,89Rex::HostUnreachable => e90fail_with(Failure::Unreachable, e)91ensure92disconnect93end94end959697