Path: blob/master/modules/auxiliary/admin/appletv/appletv_display_image.rb
19813 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' => 'Apple TV Image Remote Control',13'Description' => %q{14This module will show an image on an AppleTV device for a period of time.15Some AppleTV devices are actually password-protected, in that case please16set the PASSWORD datastore option. For password brute forcing, please see17the module auxiliary/scanner/http/appletv_login.18},19'Author' => [20'0a29406d9794e4f9b30b3c5d6702c708', # Original work21'sinn3r' # You can blame me for mistakes22],23'References' => [24['URL', 'http://nto.github.io/AirPlay.html']25],26'DefaultOptions' => { 'HttpUsername' => 'AirPlay' },27'License' => MSF_LICENSE,28'Notes' => {29'Stability' => [CRASH_SAFE],30'SideEffects' => [IOC_IN_LOGS, SCREEN_EFFECTS],31'Reliability' => []32}33)34)3536# Make the PASSWORD option more visible and hope the user is more aware of this option37register_options([38Opt::RPORT(7000),39OptInt.new('TIME', [true, 'Time in seconds to show the image', 10]),40OptPath.new('FILE', [true, 'Image to upload and show']),41OptString.new('HttpPassword', [false, 'The password for AppleTV AirPlay'])42])4344# We're not actually using any of these against AppleTV in our Rex HTTP client init,45# so deregister them so we don't overwhelm the user with fake options.46deregister_options(47'HTTP::uri_encode_mode', 'HTTP::uri_full_url', 'HTTP::pad_method_uri_count',48'HTTP::pad_uri_version_count', 'HTTP::pad_method_uri_type', 'HTTP::pad_uri_version_type',49'HTTP::method_random_valid', 'HTTP::method_random_invalid', 'HTTP::method_random_case',50'HTTP::uri_dir_self_reference', 'HTTP::uri_dir_fake_relative', 'HTTP::uri_use_backslashes',51'HTTP::pad_fake_headers', 'HTTP::pad_fake_headers_count', 'HTTP::pad_get_params',52'HTTP::pad_get_params_count', 'HTTP::pad_post_params', 'HTTP::pad_post_params_count',53'HTTP::uri_fake_end', 'HTTP::uri_fake_params_start', 'HTTP::header_folding',54'NTLM::UseNTLM2_session', 'NTLM::UseNTLMv2', 'NTLM::SendLM', 'NTLM::SendNTLM',55'NTLM::SendSPN', 'NTLM::UseLMKey', 'DOMAIN', 'DigestAuthIIS', 'VHOST'56)57end5859#60# Sends an image request to AppleTV. HttpClient isn't used because we actually need to keep61# the connection alive so that the video can keep playing.62#63def send_image_request(opts)64http = Rex::Proto::Http::Client.new(65rhost,66rport.to_i,67{68'Msf' => framework,69'MsfExploit' => self70},71ssl,72ssl_version,73proxies,74datastore['HttpUsername'],75datastore['HttpPassword']76)77add_socket(http)7879http.set_config('agent' => datastore['UserAgent'])8081req = http.request_raw(opts)82res = http.send_recv(req)8384Rex.sleep(datastore['TIME']) if res.code == 20085http.close8687res88end8990def get_image_data91File.open(datastore['FILE'], 'rb') { |f| f.read(f.stat.size) }92end9394def show_image95image = get_image_data9697opts = {98'method' => 'PUT',99'uri' => '/photo',100'data' => image101}102103res = send_image_request(opts)104105if !res106print_status('The connection timed out')107elsif res.code == 200108print_status('Received HTTP 200')109else110print_error('The request failed due to an unknown reason')111end112end113114def run115print_status("Image request sent. Duration set: #{datastore['TIME']} seconds")116show_image117end118end119120121