CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/modules/post/multi/manage/screensaver.rb
Views: 1904
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6def initialize(info = {})7super(8update_info(9info,10'Name' => 'Multi Manage the screensaver of the target computer',11'Description' => %q{12This module allows you to turn on or off the screensaver of the target computer and also13lock the current session.14},15'License' => MSF_LICENSE,16'Author' => [ 'Eliott Teissonniere'],17'Platform' => [ 'linux', 'osx', 'win' ],18'SessionTypes' => [ 'shell', 'meterpreter' ],19'Actions' => [20[ 'LOCK', { 'Description' => 'Lock the current session' } ],21[ 'START', { 'Description' => 'Start the screensaver, may lock the current session' } ],22[ 'STOP', { 'Description' => 'Stop the screensaver, user may be prompted for its password' }]23]24)25)26end2728#29# cmd_exec but with some controls and verbosity30#31def cmd_vexec(cmd)32print_status("Executing '#{cmd}'")3334begin35cmd_exec(cmd)36rescue EOFError37print_error('Command failed')38return false39end4041true42end4344def lock_session45case session.platform46when 'linux'47cmd_vexec('xdg-screensaver lock')48when 'osx'49cmd_vexec('pmset displaysleepnow')50when 'windows'51cmd_vexec('rundll32 user32.dll,LockWorkStation')52end5354true55end5657def start_screensaver58case session.platform59when 'linux'60cmd_vexec('xdg-screensaver activate')61when 'osx'62cmd_vexec('open -a ScreenSaverEngine')63when 'windows'64cmd_vexec('powershell -w hidden -nop -c "Start-Process C:\\Windows\\System32\\scrnsave.scr"')65end6667true68end6970def stop_screensaver71case session.platform72when 'linux'73cmd_vexec('xdg-screensaver reset')74when 'osx'75print_error('Not supported on Mac OSX, you can still lock the screen or start the screensaver')76return false77when 'windows'78print_error('Not supported on Windows, you can still lock the screen or start the screensaver')79return false80end8182true83end8485def run86if action.nil?87print_error('Please specify an action')88end8990case action.name91when 'LOCK'92return lock_session93when 'START'94return start_screensaver95when 'STOP'96return stop_screensaver97end98end99end100101102