CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/multi/manage/set_wallpaper.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Post
7
include Msf::Post::File
8
include Msf::Post::Windows::Registry
9
10
def initialize(info = {})
11
super(
12
update_info(
13
info,
14
'Name' => 'Multi Manage Set Wallpaper',
15
'Description' => %q{
16
This module will set the desktop wallpaper background on the specified session.
17
The method of setting the wallpaper depends on the platform type.
18
},
19
'License' => MSF_LICENSE,
20
'Author' => [ 'timwr'],
21
'Platform' => [ 'win', 'osx', 'linux', 'android' ],
22
'SessionTypes' => [ 'meterpreter' ],
23
'Compat' => {
24
'Meterpreter' => {
25
'Commands' => %w[
26
android_*
27
stdapi_railgun_api
28
]
29
}
30
}
31
)
32
)
33
34
register_options(
35
[
36
OptPath.new('WALLPAPER_FILE', [true, 'The local wallpaper file to set on the remote session'])
37
]
38
)
39
end
40
41
def upload_wallpaper(tempdir, file)
42
remote_file = "#{tempdir}#{File.basename(file)}"
43
print_status("#{peer} - Uploading to #{remote_file}")
44
45
write_file(remote_file, File.binread(file))
46
print_status("#{peer} - Uploaded to #{remote_file}")
47
remote_file
48
end
49
50
#
51
# The OS X version uses an AppleScript to do this
52
#
53
def osx_set_wallpaper(file)
54
remote_file = upload_wallpaper('/tmp/', file)
55
script = %(osascript -e 'tell application "Finder" to set desktop picture to POSIX file "#{remote_file}"')
56
begin
57
cmd_exec(script)
58
rescue EOFError
59
return false
60
end
61
true
62
end
63
64
#
65
# The Windows version uses the SystemParametersInfo call
66
#
67
def win_set_wallpaper(file)
68
remote_file = upload_wallpaper('%TEMP%\\', file)
69
client.railgun.user32.SystemParametersInfoA(0x0014, nil, remote_file, 0x2) != 0
70
end
71
72
#
73
# The Android version uses the set_wallpaper command
74
#
75
def android_set_wallpaper(file)
76
client.android.set_wallpaper(File.binread(file))
77
true
78
end
79
80
def os_set_wallpaper(file)
81
case session.platform
82
when 'osx'
83
osx_set_wallpaper(file)
84
when 'windows'
85
win_set_wallpaper(file)
86
when 'android'
87
android_set_wallpaper(file)
88
end
89
end
90
91
def run
92
file = datastore['WALLPAPER_FILE']
93
if os_set_wallpaper(file)
94
print_good("#{peer} - The wallpaper has been set")
95
else
96
print_error("#{peer} - Unable to set the wallpaper")
97
end
98
end
99
end
100
101