Skip to content

Commit

Permalink
Land #11933, add default VID and cmd/unix support to post/multi/manag…
Browse files Browse the repository at this point in the history
…e/play_youtube
  • Loading branch information
timwr committed Jun 2, 2019
2 parents d335415 + 42082f0 commit b5bdc06
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions modules/post/multi/manage/play_youtube.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def initialize(info={})
}, },
'License' => MSF_LICENSE, 'License' => MSF_LICENSE,
'Author' => [ 'sinn3r' ], 'Author' => [ 'sinn3r' ],
'Platform' => [ 'win', 'osx', 'linux', 'android' ], 'Platform' => [ 'win', 'osx', 'linux', 'android', 'unix' ],
'SessionTypes' => [ 'shell', 'meterpreter' ], 'SessionTypes' => [ 'shell', 'meterpreter' ],
'Notes' => 'Notes' =>
{ {
Expand All @@ -33,7 +33,7 @@ def initialize(info={})
register_options( register_options(
[ [
OptBool.new('EMBED', [true, 'Use the embed version of the YouTube URL', true]), OptBool.new('EMBED', [true, 'Use the embed version of the YouTube URL', true]),
OptString.new('VID', [true, 'The video ID to the YouTube video']) OptString.new('VID', [true, 'The video ID to the YouTube video', 'kxopViU98Xo'])
]) ])
end end


Expand All @@ -48,7 +48,7 @@ def youtube_url
# #
# The OSX version uses an apple script to do this # The OSX version uses an apple script to do this
# #
def osx_start_video(id) def osx_start_video(_id)
script = '' script = ''
script << %Q|osascript -e 'tell application "Safari" to open location "#{youtube_url}"' | script << %Q|osascript -e 'tell application "Safari" to open location "#{youtube_url}"' |
script << %Q|-e 'activate application "Safari"' | script << %Q|-e 'activate application "Safari"' |
Expand All @@ -66,7 +66,7 @@ def osx_start_video(id)
# #
# The Windows version uses the "embed" player to make sure IE won't download the SWF as an object # The Windows version uses the "embed" player to make sure IE won't download the SWF as an object
# #
def win_start_video(id) def win_start_video(_id)
iexplore_path = "C:\\Program Files\\Internet Explorer\\iexplore.exe" iexplore_path = "C:\\Program Files\\Internet Explorer\\iexplore.exe"
begin begin
session.sys.process.execute(iexplore_path, "-k #{youtube_url}") session.sys.process.execute(iexplore_path, "-k #{youtube_url}")
Expand All @@ -82,7 +82,7 @@ def win_start_video(id)
# The Linux version uses Firefox # The Linux version uses Firefox
# TODO: Try xdg-open? # TODO: Try xdg-open?
# #
def linux_start_video(id) def linux_start_video(_id)
begin begin
# Create a profile # Create a profile
profile_name = Rex::Text.rand_text_alpha(8) profile_name = Rex::Text.rand_text_alpha(8)
Expand Down Expand Up @@ -121,6 +121,14 @@ def android_start_video(id)
true true
end end


# The generic Unix version calls xdg-open(1) or open(1)
def unix_start_video(_id)
cmd_exec("xdg-open '#{youtube_url}' || open '#{youtube_url}'")
true
rescue EOFError
false
end

def start_video(id) def start_video(id)
case session.platform case session.platform
when 'osx' when 'osx'
Expand All @@ -131,6 +139,8 @@ def start_video(id)
linux_start_video(id) linux_start_video(id)
when 'android' when 'android'
android_start_video(id) android_start_video(id)
when 'unix'
unix_start_video(id)
end end
end end


Expand Down

0 comments on commit b5bdc06

Please sign in to comment.