Skip to content

Commit 65c0573

Browse files
committed
Land rapid7#10848, improve play_youtube post module
2 parents db90704 + c71bbc1 commit 65c0573

File tree

2 files changed

+55
-14
lines changed

2 files changed

+55
-14
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
`play_youtube` allows you to open and start playing a YouTube video on a
2+
compromised host.
3+
4+
## Important Options
5+
6+
**EMBED**
7+
8+
Whether or not to use the `/embed` YouTube URL. The embeded version provides a
9+
clean interface and will start playing in fullscreen but is not compatible with
10+
all YouTube videos, for example Rick Astley - Never Gonna Give You Up (VID:
11+
[`dQw4w9WgXcQ`][1]) is not compatible.
12+
13+
While the non-embeded version has greater compatibility, there is a chance that
14+
an advertisement may be played before the video. It is recommended to use the
15+
embeded version when the video is compatible.
16+
17+
**VID**
18+
19+
The video's identifier on YouTube. This is the `v` parameter of the URL.
20+
21+
## See Also
22+
23+
* Meterpreter's `uictl` command in the `stdapi` extension for enabling and
24+
disabling the mouse and keyboard.
25+
26+
[1]: https://www.youtube.com/watch?v=dQw4w9WgXcQ

modules/post/multi/manage/play_youtube.rb

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,51 @@
66
class MetasploitModule < Msf::Post
77
include Msf::Post::File
88

9-
PLAY_OPTIONS = 'autoplay=1&loop=1&disablekb=1&modestbranding=1&iv_load_policy=3&controls=0&showinfo=0&rel=0'
10-
119
def initialize(info={})
1210
super( update_info( info,
1311
'Name' => 'Multi Manage YouTube Broadcast',
1412
'Description' => %q{
1513
This module will broadcast a YouTube video on specified compromised systems. It will play
16-
the video in the target machine's native browser in full screen mode. The VID datastore
17-
option is the "v" parameter in a YouTube video's URL.
14+
the video in the target machine's native browser. The VID datastore option is the "v"
15+
parameter in a YouTube video's URL.
16+
17+
Enabling the EMBED option will play the video in full screen mode through a clean interface
18+
but is not compatible with all videos.
19+
20+
This module will create a custom profile for Firefox on Linux systems in the /tmp directory.
1821
},
1922
'License' => MSF_LICENSE,
20-
'Author' => [ 'sinn3r'],
23+
'Author' => [ 'sinn3r' ],
2124
'Platform' => [ 'win', 'osx', 'linux', 'android' ],
22-
'SessionTypes' => [ 'shell', 'meterpreter' ]
25+
'SessionTypes' => [ 'shell', 'meterpreter' ],
26+
'Notes' =>
27+
{
28+
# ARTIFACTS_ON_DISK when the platform is linux
29+
'SideEffects' => [ ARTIFACTS_ON_DISK, AUDIO_EFFECTS, SCREEN_EFFECTS ]
30+
},
2331
))
2432

2533
register_options(
2634
[
35+
OptBool.new('EMBED', [true, 'Use the embed version of the YouTube URL', true]),
2736
OptString.new('VID', [true, 'The video ID to the YouTube video'])
2837
])
2938
end
3039

31-
YOUTUBE_BASE_URL = "https://youtube.com/embed/"
40+
def youtube_url
41+
if datastore['EMBED']
42+
"https://youtube.com/embed/#{datastore['VID']}?autoplay=1&loop=1&disablekb=1&modestbranding=1&iv_load_policy=3&controls=0&showinfo=0&rel=0"
43+
else
44+
"https://youtube.com/watch?v=#{datastore['VID']}"
45+
end
46+
end
3247

3348
#
3449
# The OSX version uses an apple script to do this
3550
#
3651
def osx_start_video(id)
37-
url = "#{YOUTUBE_BASE_URL}#{id}?#{PLAY_OPTIONS}"
3852
script = ''
39-
script << %Q|osascript -e 'tell application "Safari" to open location "#{url}"' |
53+
script << %Q|osascript -e 'tell application "Safari" to open location "#{youtube_url}"' |
4054
script << %Q|-e 'activate application "Safari"' |
4155
script << %Q|-e 'tell application "System Events" to key code {59, 55, 3}'|
4256

@@ -55,7 +69,7 @@ def osx_start_video(id)
5569
def win_start_video(id)
5670
iexplore_path = "C:\\Program Files\\Internet Explorer\\iexplore.exe"
5771
begin
58-
session.sys.process.execute(iexplore_path, "-k #{YOUTUBE_BASE_URL}#{id}?#{PLAY_OPTIONS}")
72+
session.sys.process.execute(iexplore_path, "-k #{youtube_url}")
5973
rescue Rex::Post::Meterpreter::RequestError
6074
return false
6175
end
@@ -72,7 +86,9 @@ def linux_start_video(id)
7286
begin
7387
# Create a profile
7488
profile_name = Rex::Text.rand_text_alpha(8)
75-
o = cmd_exec(%Q|firefox --display :0 -CreateProfile "#{profile_name} /tmp/#{profile_name}"|)
89+
display = get_env('DISPLAY') || ':0'
90+
vprint_status("Creating profile #{profile_name} using display #{display}")
91+
o = cmd_exec(%Q|firefox --display #{display} -CreateProfile "#{profile_name} /tmp/#{profile_name}"|)
7692

7793
# Add user-defined settings to profile
7894
s = %Q|
@@ -82,9 +98,8 @@ def linux_start_video(id)
8298
write_file("/tmp/#{profile_name}/prefs.js", s)
8399

84100
# Start the video
85-
url = "#{YOUTUBE_BASE_URL}#{id}?#{PLAY_OPTIONS}"
86-
data_js = %Q|"data:text/html,<script>window.open('#{url}','','width:100000px;height:100000px');</script>"|
87-
joe = "firefox --display :0 -p #{profile_name} #{data_js} &"
101+
data_js = %Q|"data:text/html,<script>window.open('#{youtube_url}','','width:100000px;height:100000px');</script>"|
102+
joe = "firefox --display #{display} -p #{profile_name} #{data_js} &"
88103
cmd_exec("/bin/sh -c #{joe.shellescape}")
89104
rescue EOFError
90105
return false

0 commit comments

Comments
 (0)