Path: blob/master/modules/post/multi/manage/set_wallpaper.rb
19535 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::File7include Msf::Post::Windows::Registry89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Multi Manage Set Wallpaper',14'Description' => %q{15This module will set the desktop wallpaper background on the specified session.16The method of setting the wallpaper depends on the platform type.17},18'License' => MSF_LICENSE,19'Author' => [ 'timwr'],20'Platform' => [ 'win', 'osx', 'linux', 'android' ],21'SessionTypes' => [ 'meterpreter' ],22'Compat' => {23'Meterpreter' => {24'Commands' => %w[25android_*26stdapi_railgun_api27]28}29},30'Notes' => {31'Stability' => [CRASH_SAFE],32'SideEffects' => [SCREEN_EFFECTS],33'Reliability' => []34}35)36)3738register_options(39[40OptPath.new('WALLPAPER_FILE', [true, 'The local wallpaper file to set on the remote session'])41]42)43end4445def upload_wallpaper(tempdir, file)46remote_file = "#{tempdir}#{File.basename(file)}"47print_status("#{peer} - Uploading to #{remote_file}")4849write_file(remote_file, File.binread(file))50print_status("#{peer} - Uploaded to #{remote_file}")51remote_file52end5354#55# The OS X version uses an AppleScript to do this56#57def osx_set_wallpaper(file)58remote_file = upload_wallpaper('/tmp/', file)59script = %(osascript -e 'tell application "Finder" to set desktop picture to POSIX file "#{remote_file}"')60begin61cmd_exec(script)62rescue EOFError63return false64end65true66end6768#69# The Windows version uses the SystemParametersInfo call70#71def win_set_wallpaper(file)72remote_file = upload_wallpaper('%TEMP%\\', file)73client.railgun.user32.SystemParametersInfoA(0x0014, nil, remote_file, 0x2) != 074end7576#77# The Android version uses the set_wallpaper command78#79def android_set_wallpaper(file)80client.android.set_wallpaper(File.binread(file))81true82end8384def os_set_wallpaper(file)85case session.platform86when 'osx'87osx_set_wallpaper(file)88when 'windows'89win_set_wallpaper(file)90when 'android'91android_set_wallpaper(file)92end93end9495def run96file = datastore['WALLPAPER_FILE']97if os_set_wallpaper(file)98print_good("#{peer} - The wallpaper has been set")99else100print_error("#{peer} - Unable to set the wallpaper")101end102end103end104105106